Jump to content

Trap menu item events


Recommended Posts

I am using the following code (courtesy of gaFrost) to trap edit control events. I would like to use the same technique to trap menu item events. I would appreciate it if some one (possibly gaFrost) would show me how.

Global Const $EN_CHANGE = 0x300
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    Switch $nID
        Case $edit
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Edit_Changed() 
        Case $EN_MAXTEXT
            _GuiCtrlStatusBarSetIcon($StatusBar, 0, "shell32.dll", 109)
            _GuiCtrlStatusBarSetText ($StatusBar, " Maximum text reached", 0)
            SoundPlay(@WindowsDir & "\media\Windows XP Critical Stop.wav",1)
         EndSwitch
        EndSwitch
EndFunc

Best Regards Merriman

Link to comment
Share on other sites

I am using the following code (courtesy of gaFrost) to trap edit control events. I would like to use the same technique to trap menu item events. I would appreciate it if some one (possibly gaFrost) would show me how.

Global Const $EN_CHANGE = 0x300
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    Switch $nID
        Case $edit
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Edit_Changed() 
        Case $EN_MAXTEXT
            _GuiCtrlStatusBarSetIcon($StatusBar, 0, "shell32.dll", 109)
            _GuiCtrlStatusBarSetText ($StatusBar, " Maximum text reached", 0)
            SoundPlay(@WindowsDir & "\media\Windows XP Critical Stop.wav",1)
         EndSwitch
        EndSwitch
EndFunc
Whatever you're trying to do zoomed right over my head, but I noticed one thing about your function. The indentation implies Case $EN_MAXTEXT is associated with Switch $nID, but it's not (maybe that's what you intended and it's just a format error):

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    Switch $nID
        Case $edit
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Edit_Changed() 
                Case $EN_MAXTEXT
                    _GuiCtrlStatusBarSetIcon($StatusBar, 0, "shell32.dll", 109)
                    _GuiCtrlStatusBarSetText ($StatusBar, " Maximum text reached", 0)
                    SoundPlay(@WindowsDir & "\media\Windows XP Critical Stop.wav",1)
            EndSwitch
    EndSwitch
EndFunc

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...