Results 1 to 3 of 3

Thread: [RESOLVED] Find out if Form is shown modally

  1. #1

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Resolved [RESOLVED] Find out if Form is shown modally

    I have 2 Forms.

    "Form1" has a menu. "Form2" is shown modally. I also have a tray icon representing the application.

    Here is my problem.

    Since "Form2" is shown modally - whenever i try to popup the menu from "Form1" via tray icon i get error. That's normal.

    Until now i have been putting some String into "Form2" Tag property so i knew it was shown modally. This works fine.

    However, i am interested if there's some other, more "official" way to find out if some Form is shown modally?

    Thanks

    -gav

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Find out if Form is shown modally

    A google search returned the Answer
    http://support.microsoft.com/kb/77316

  3. #3

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Find out if Form is shown modally

    Thank you

    Here's the "complete" solution:
    VB Code:
    1. 'declarations
    2. Option Explicit
    3.     Public Const WS_DISABLED = &H8000000
    4.     Public Const GWL_STYLE As Long = (-16)
    5.  
    6.     Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    7.  
    8. 'syntax
    9. Sub Test()
    10.     If (GetWindowLong(Form1.hWnd, GWL_STYLE) And WS_DISABLED) <> 0 Then
    11.         'Form1 is Modal...
    12.     End If
    13. 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