Announcement

Collapse
No announcement yet.

How to get message from MENU when a top level item is clicked?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get message from MENU when a top level item is clicked?

    Click image for larger version

Name:	Snap71.jpg
Views:	74
Size:	23.8 KB
ID:	785543

    See the "Settings" and "Hide" in the menu... How to catch the message when one is pressed and there is no drop down menu choices.

    The only message that I can find so far is 293. wParam and lParam are always the same regardless of which menu item I press.

    Think Sub Classing the menu would work?

  • #2
    Did you use BYCMD?

    Better than twenty questions would be some source code that demos the problem.

    Cheers,
    Dale

    Comment


    • #3
      BTW, 293 is -
      https://docs.microsoft.com/en-us/win...ninitmenupopup

      Does not seem useful.

      "
      See the "Settings" and "Hide" in the menu...", where?

      Cheers,
      Dale

      Comment


      • #4
        Some sample code would be useful to see where things are going wrong.
        Normally notification is sent via WM_Command..
        Code:
        ' %WM_Command..
        ' Message Source : wParam (high word) : wParam (low word)       : lParam
        ' Menu             0                    Menu identifier (IDM_*)   0
        
        #Compile Exe
        #Dim All
        #Include "Win32api.inc"
        
        %IDM_Menu = 500
        '------------------/
        
        Sub AddMenu(ByVal hWin As Dword)
          Local hMenu As Dword
           Menu New Bar  To  hMenu
            Menu Add String, hMenu, "Settings", %IDM_Menu,   %MF_Enabled
            Menu Add String, hMenu, "Hide",     %IDM_Menu+1, %MF_Enabled
           Menu Attach hMenu, hWin
        End Sub
        '------------------/AddMenu
        
        CallBack Function DlgProc() As Long
           Select Case Cb.Msg
              Case %WM_Command
                 Select Case Cb.Ctl
                     Case %IDM_Menu   : MsgBox "Settings"
                     Case %IDM_Menu+1 : MsgBox "Hide"
                 End Select
           End Select
        End Function
        '------------------/DlgProc
        
        Function PBMain()
         Local hDlg As Dword
           Dialog New 0, "SnapMessage Lite",,,400,120, %WS_Caption Or %WS_SysMenu To hDlg
             AddMenu hDlg
           Dialog Show Modal hDlg Call DlgProc()
        End Function
        '------------------/PBMain
        Rgds, Dave

        Comment


        • #5
          Google WM_MENUSELECT for additional info on wParam/lParam
          Code:
            CASE %WM_MENUSELECT
                DIALOG SET TEXT CB.HNDL, "%WM_MENUSELECT" + STR$(LO(WORD, CB.WPARAM))  ' loword wParam indicates item

          Comment


          • #6
            >>> Also <<<

            Comment

            Working...
            X