Results 1 to 2 of 2

Thread: Always on top

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Posts
    21
    Hi...
    I was implenting the "Always on Top" feature using the API in a VB program I've written ... but I then releazed that, whenever the user clicks on the "About" form in the program... the program craches, due to this Always on Top thing. So I added some code to disable Always on Top when the user clicks About, then set it back on... when the user clicks Ok in About.

    1. Is this the right way to do it... ?
    2. How come msgboxes do not get affected by this problem and they continue to function well... Are they coded in a way that would also disabel Always on Top when they're displayed.. ?

    Thanks a lot...

  2. #2
    Guest
    Make your About Form an "always on top" form as well.

    Code for Form1 (with a CommandButton)
    Code:
    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 Command1_Click()
        Form2.Show 1
    End Sub
    
    Private Sub Form_Load()
        SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
    End Sub
    code for Form2.
    Code:
    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()
        SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
    End Sub

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