Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1449

Hide IDEOwner Class Window when loading IDE

$
0
0
I'm not sure if this just happens when running SDI (which is the only way I run) for the VB6 IDE, or if it happens for everyone.

But, when I load the IDE, ever since about the beginning of Windows 10, I get this little window on the center of my screen, If I minimize and then re-normalize the IDE, it goes away. But that's annoying. For years, I've just been ignoring it, but I finally decided to do something about it.

This little add-in attempts to hide it when the IDE loads. Its class is named "IDEOwner", and it seems to be the only window that's part of the IDE with that class name. So, that's how I found it (programmatically).

Here's code in the add-ins DSR module:
Code:


Option Explicit
'
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
'

Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
    Dim hWnds() As Long
    hWnds = hWndOfAllTopLevelWindows ' Only ones belonging to our PID.
    '
    ' Find the IDEOwner Class
    Dim i As Long
    Dim hWndIdeOwner As Long
    For i = LBound(hWnds) To UBound(hWnds)
        If WindowClass(hWnds(i)) = "IDEOwner" Then
            hWndIdeOwner = hWnds(i)
            Erase hWnds
            Exit For
        End If
    Next
    '
    ' Now hide it.
    Const SW_HIDE As Long = 0&
    If hWndIdeOwner Then
        ShowWindow hWndIdeOwner, SW_HIDE
    End If
End Sub

Private Function WindowClass(hWndOfInterest As Long) As String
    WindowClass = String$(1024&, 0&)
    WindowClass = Left$(WindowClass, GetClassName(hWndOfInterest, WindowClass, 1024&))
End Function



And here's some code that needed to be in a BAS module (so AddressOf could be used):
Code:


Option Explicit
'
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
'
Dim hWnds() As Long
Dim hWndCount As Long
'

Public Function hWndOfAllTopLevelWindows() As Long()
    hWndCount = 0&
    ReDim hWnds(99&)
    EnumWindows AddressOf EnumWindowsCallBack, &H0& ' Doesn't return until done.
    If hWndCount > 0& Then
        ReDim Preserve hWnds(hWndCount - 1&)
    Else
        ReDim hWnds(0&)
    End If
    hWndOfAllTopLevelWindows = hWnds
    Erase hWnds
End Function

Private Function EnumWindowsCallBack(ByVal hWnd As Long, ByVal lpData As Long) As Long
    EnumWindowsCallBack = 1&
    If ProcessID(hWnd) = GetCurrentProcessId Then
        hWndCount = hWndCount + 1&
        If UBound(hWnds) < hWndCount Then ReDim Preserve hWnds(UBound(hWnds) + 100&)
        hWnds(hWndCount) = hWnd
    End If
End Function

Private Function ProcessID(hWndOfInterest As Long) As Long
    Call GetWindowThreadProcessId(hWndOfInterest, ProcessID)
End Function


And the whole project is attached (minus the actual add-in's DLL).

I also included some little DLLReg and DLLUnreg scripts for registering/unregistering this in case you needed to. However, just compiling it will register it, so long as you save your DLL in a reasonable place. I save my add-in DLLs in the following folder: C:\Program Files (x86)\Microsoft Visual Studio\VB6_Addins

Enjoy.
Attached Files

Viewing all articles
Browse latest Browse all 1449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>