CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: form vbmodal

  1. #1
    Join Date
    May 2001
    Posts
    9

    form vbmodal

    if my application is running minimized, I want to pop up a form with a message. I've tried with form1.show vbmodal
    but it shows behind other running applications (for example: internet explorer), does anyone know how can i show it infront of all other applications?


  2. #2
    Join Date
    Apr 2001
    Posts
    95

    Re: form vbmodal


    Place this in General Declarations or Module (if in module change "Private" to "Public"):


    Const HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2
    private Declare Sub 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)




    then place this where you want to show your form:


    frmMessage.Show vbModal
    Form2.Show vbModal

    SetWindowPos frmMessage.hWnd, HWND_TOPMOST, frmMessage.Left, frmMessage.Top, frmMessage.Width, frmMessage.Height, 0





    HTH


  3. #3
    Join Date
    Apr 2001
    Posts
    95

    Re: form vbmodal

    The code I gave you before did not work consistantly but this should. Place it in your message form's code:


    Const HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2
    Const SWP_NOSIZE = &H1
    Const SWP_NOMOVE = &H2
    Const SWP_NOACTIVATE = &H10
    Const SWP_SHOWWINDOW = &H40
    private Declare Sub 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)

    private Sub Form_Activate()
    SetWindowPos frmMessage.hWnd, HWND_TOPMOST, frmMessage.Left, frmMessage.Top, frmMessage.Width, frmMessage.Height, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    End Sub





    Hope that works a little better. :-)


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

Featured