Results 1 to 37 of 37

Thread: [RESOLVED] How Can I show Form2 Without Show all Project Forms !?

Threaded View

  1. #33
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: How Can I show Form2 Without Show all Project Forms !?

    Quote Originally Posted by Bonnie West View Post
    Because when you activate any of the Forms in your app, VB automatically brings to the foreground all the other visible Forms as well.
    There is a workaround for that, but IIRC it involves setting the windows GWL_HWNDPARENT , something like...
    Code:
    Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Const GWL_HWNDPARENT As Long = -8
    
    Dim oFrm As Form2
    Set oFrm = New Form2
    oFrm.Show
    SetWindowLong oFrm.hWnd, GWL_HWNDPARENT, 0&
    Though its been years since I used that so may be incorrect,
    I got a couple tricks like that from this old thread here.

    EDIT some code I was using in my app...
    Code:
    Public Sub SetWinSelf(f As Form)
    ' this makes a form not activate other forms open on desktop when it gets the focus. 
    ' FOR COMPILED EXE.
            f.Show
            SetWindowLong f.hwnd, GWL_HWNDPARENT, CreateWindowEx( _
             &H80, "ThunderRT6Main", vbNullString, &H94000000, _
             0&, 0&, 0&, 0&, 0&, 0&, GetWindowLong(f.hwnd, GWL_HINSTANCE), 0&)
    For testing in IDE, .
    Code:
        ' **** CODE TO TEST IN IDE ONLY *******
        'SetWindowLong Chld.hWnd, _
                  GWL_HWNDPARENT, _
                  CreateWindowEx( _
                                 &H80, "ThunderMain", _
                                 vbNullString, &H94000000, _
                                 0&, 0&, 0&, 0&, 0&, 0&, _
                                 GetWindowLong(Chld.hWnd, GWL_HINSTANCE), _
                                 0&)

    I don't have VB6 installed on any PCs anymore so can't test, but I believe the above hides the form from taskbar also, don't really remember , see URL above.

    HTH.
    Last edited by Edgemeal; Apr 7th, 2014 at 12:43 PM.

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