Results 1 to 6 of 6

Thread: Form on top but let the rest go on in the back

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574

    Form on top but let the rest go on in the back

    Alright this is complicated. I made my own msgbox form cause the standard isn't good enough cause it freezes the whole program. Now I want this form on top so the user can't klik elsewhere in the program, but it must let all the other forms go on. Cause it's a chat program and else the winsock isn't working good cause i check each x seconds if the other users are still online. Any suggestions??

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Try making the msgbox form modal

    VB Code:
    1. Form1.Show vbModal
    That will prevent them from clicking elsewhere in the app and it should allow the app to continue working underneath

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Posts
    574
    That just do'n't work, cause the mainform winsock will get the data (in a buffer I think) but only goes on handling them when the modal form is away, so showing modal isn't the good solution

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Modal form would cause the execution in anyother part of program to stop..

    You can use SetWindowPos with SWP_TOPMOST and disable any other window of the program

  5. #5
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    I couldn't remember if modal stopped execution or not...apparently it does

    Oh well, c'est la vie

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    a sample on how to use SetWindowPos

    VB Code:
    1. Private Const HWND_TOPMOST = -1
    2. Private Const HWND_NOTOPMOST = -2
    3. Private Const SWP_NOMOVE = &H2
    4. Private Const SWP_NOSIZE = &H1
    5. Private Const SWP_NOACTIVATE = &H10
    6. Private Const SWP_SHOWWINDOW = &H40
    7. Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    8.  
    9. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    10.  
    11. Public Sub MakeNormal(Handle As Long)
    12.     'Replaces the window in the ZOrder
    13.     SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    14. End Sub
    15.  
    16. Public Sub MakeTopMost(Handle As Long)
    17.     'Sets the window in the ZOrder
    18.     SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    19. End Sub
    20.  
    21. 'usage
    22. Private Sub Form_Load()
    23.     MakeTopMost Me.hwnd
    24. End Sub
    -= a peet post =-

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