Page 2 of 2 FirstFirst 12
Results 41 to 52 of 52

Thread: [RESOLVED] Getting hWnd from VBIDE.Window

  1. #41

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Made this to show a friend what I was working on. Posting here just to show you guys...



    https://www.youtube.com/watch?v=yzTSLRKz8l0
    Last edited by ColinE66; Jan 25th, 2021 at 11:10 AM.
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  2. #42
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    EspaƱa
    Posts
    506

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    looks great could you share the add-ins

    a greeting

  3. #43

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Quote Originally Posted by yokesee View Post
    looks great could you share the add-ins
    Yes, that's the plan....
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  4. #44
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    I started to develop an addin, and I had to stop because of exactly this ...

    Getting hWnd from VBIDE.Window

    When I can I will come back again ... with this addin that I will develop there will be more space on the code screen ... and design.

  5. #45

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Quote Originally Posted by Episcopal View Post
    I started to develop an addin, and I had to stop because of exactly this ...

    Getting hWnd from VBIDE.Window

    When I can I will come back again ... with this addin that I will develop there will be more space on the code screen ... and design.
    Be aware that Trick's technique will only work in Design mode, in case that makes a difference to your usage of it. If you attempt it during Run or Break mode, you will get a 'permission denied' error.

    Also, this may be useful information for you: If you attempt to enumerate the VBWindows collection, there is no way of knowing what component each window relates to. The way around that is to take the following 'backwards' approach:

    Code:
    Private Sub ListWindowInfo()
    Dim CP As CodePane, VBComp As VBComponent, VBProj As VBProject
    
       For Each CP In gVBInstance.CodePanes
          Set VBComp = CP.CodeModule.Parent
          Set VBProj = VBComp.Collection.Parent
          Debug.Print VBProj.Name & " - " & VBComp.Name & "(" & CP.Window.Type & ")"
       Next CP
       
       For Each VBProj In gVBInstance.VBProjects
          For Each VBComp In VBProj.VBComponents
             If VBComp.HasOpenDesigner Then
                Debug.Print VBProj.Name & " - " & VBComp.Name & "(" & VBComp.DesignerWindow.Type & ")"
             End If
          Next VBComp
       Next VBProj
       
    End Sub
    That may seem convoluted, but other approaches, where you 'touch' a window that doesn't exist, will force that window to be created. And that's why there's two loops in the above code; the second one will pick up open designer windows where the code pane isn't also open.

    Somebody may find this useful...
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  6. #46
    Junior Member
    Join Date
    Oct 2013
    Posts
    30

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Hi,

    I'm ***very*** interested in the addin and looking at the complete code.

    I also would like to go the other way and if there is a listbox "window" get the listbox so I can look at the contents. This is from using spy++ on the stck window when debugging. If that works I'd like to query the watch and locals windows as well!!!

    TIA
    Lisa

  7. #47

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  8. #48
    Junior Member
    Join Date
    Oct 2013
    Posts
    30

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Quote Originally Posted by ColinE66 View Post
    Thank you ColinE!!!!!

    Unzipping it now!!!

    Regards
    Lisa

  9. #49
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Quote Originally Posted by wqweto View Post
    The idea of xiaoyao's code is that if Caption property is writable then you can temporaty change the Caption to a unique string (a GUID) then use FindWindow API to locate the hWnd before restoring the original Caption.

    Super hacky but can be used as a last resort until anything better comes up.

    cheers,
    </wqw.
    Yep, the caption can be temporarily changed:
    Code:
    Private Function GetDesignerHwnd(nComponent As VBComponent) As Long
        Dim w As Window
        Dim iCaptionPrev As String
        Dim h As Long
        Const cTmpCaption As String = "! tmp_caption ^_^"
        
        iCaptionPrev = nComponent.Properties("Caption")
        On Error GoTo ErrNext
        nComponent.Properties("Caption") = cTmpCaption
        For Each w In VBInstance.Windows
            If w.Caption = cTmpCaption Then
                CopyMemory h, ByVal ObjPtr(w) + &H1C, 4
                GetDesignerHwnd = h
                Exit For
            End If
        Next
    ErrNext:
        nComponent.Properties("Caption") = iCaptionPrev
    End Function

  10. #50
    Junior Member
    Join Date
    Oct 2013
    Posts
    30

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Um.... please excuse me if I'm being dense but.. which caption/window?

    Lisa

  11. #51
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Quote Originally Posted by lisagreen View Post
    Um.... please excuse me if I'm being dense but.. which caption/window?

    Lisa
    It is the caption of the form at design time, and its hWnd.

  12. #52
    Junior Member
    Join Date
    Oct 2013
    Posts
    30

    Re: [RESOLVED] Getting hWnd from VBIDE.Window

    Thank you.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width