Sign in to follow this  
Followers 0
merriman

Trap menu item events

2 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0