Results 1 to 8 of 8

Thread: RESOLVED Get menu disabled status

Threaded View

  1. #1

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    RESOLVED Get menu disabled status

    I'm trying to verify that a program is still running, by getting the enabled status of a menu item. If it's disabled, the app is running, if it's enabled, then the app has stopped. Simple enough right?

    Please help! This is what I have tried:


    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    
    Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Integer) As Integer
    
    Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
    
    Private Declare Function IsWindowEnabled Lib "user32" (ByVal hwnd As Integer) As Integer
    
    If FindWindow(vbNullString, "AppTitle") <> 0 Then
       Dim hMenu, hSubMenu As Integer
    
       hMenu = GetMenu(FindWindow(vbNullString, "AppTitle"))
       hSubMenu = GetSubMenu(hMenu, 0)
    
       If IsWindowEnabled(hSubMenu) Then
          MessageBox.Show("App not running")
       Else
          MessageBox.Show("App running")
       End If
    Else
       MessageBox.Show("App, is closed")
    End If
    Or should I try to use the MF_DISABLED constant with something?
    Last edited by TTn; Sep 1st, 2006 at 07:55 AM. Reason: Resolved

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