Results 1 to 12 of 12

Thread: Prevent Form2 show when i click on Form1...

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2015
    Posts
    72

    Prevent Form2 show when i click on Form1...

    It's hard to say in few line so this example is the best way to describe:

    Step to reproduce the behavior :

    Create a new vb6 project, create two form named form1 and form2. Double click on form1 and paste this code :

    Code:
    Const HWND_TOP = 0
    Const HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2
    Const SWP_NOMOVE = &H2
    Const SWP_NOSIZE = &H1
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    
    Private Sub Form_Load()
    Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
    Form2.Show
    End Sub
    Now press F5 to run the application, you will see both form show up.
    Click on Form2 to make it have focus, then click on the vb6 ide to make the IDE have focus and form2 will disappear. Form1 still appear because it's have HWND_TOPMOST, now click on Form1 to make Form1 have focus. But when you click on Form1, Form2 suddenly show up, that is very annoy. This behavior not occur if you're using vb.net with the same code. So how to prevent form2 show up when i click back to form1 in this case?
    Last edited by vietnamvodich; Apr 19th, 2015 at 11:10 AM.

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