Sign in to follow this  
Followers 0
mark2004

GUIRegisterMessage and Tab controls

3 posts in this topic

I would like my code to detect when a tab control is about to change its tab item selection. According to MSDN, the notification

message TCN_SELCHANGING is sent when this happens. I am using the WM_Notify_Events function below to handle my WM_NOTIFY messages. It works great for my Listview ($opencase in the code below). However, I can't get it to work for my Tab control ($MainTab in the

code below). $MainTab is the control ID of the Tab, although I have also tried subbing the control IDs of the individual tab items. Nothing seems to do the trick. I can't even get the code to detect a mouse click with NM_CLICK.

This WM_Notify_Events function was originally intended for use with a listview (thanks gaFrost) so I was assuming I could extend it to other controls that communicate via WM_NOTIFY messages........

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    ;#forceref $hWndGUI, $MsgID
    Local $tagNMHDR, $event
    Local Const $NM_FIRST = 0
    Local Const $NM_CLICK = -2
    Local Const $NM_DBLCLK = -3
    Local Const $NM_RETURN = $NM_FIRST - 4
    Local Const $NM_RCLICK = -5
    Local Const $TCN_FIRST = -550
    Local Const $TCN_SELCHANGING = $TCN_FIRST-2

    Switch $wParam
        Case $Opencaselist
            $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
            If @error Then Return
            $event = DllStructGetData($tagNMHDR, 3)
            Switch $event
                Case $NM_CLICK
                    $Event_Code = $event
                    If $DebugIt Then ConsoleWrite("-->$NM_CLICK" & @LF)
                Case $NM_DBLCLK
                    $Event_Code = $event
                    If $DebugIt Then ConsoleWrite("-->$NM_DBLCLK" & @LF)
                Case $NM_RETURN
                    $Event_Code = $event
                    If $DebugIt Then ConsoleWrite("-->$NM_RETURN" & @LF)
        Case $MainTab           
            $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
            If @error Then Return
            $event = DllStructGetData($tagNMHDR, 3)
            Switch $event
                Case $TCN_SELCHANGING
                    $Event_Code = $event
                    If $DebugIt Then ConsoleWrite("-->$TCN_SELCHANGING" & @LF)
                Case $NM_CLICK
                    $Event_Code = $event
                    If $DebugIt Then ConsoleWrite("-->$NM_CLICK" & @LF)
            EndSwitch
        EndSwitch   
    EndSwitch
$tagNMHDR = 0
EndFunc ;==>WM_Notify_Events

Share this post


Link to post
Share on other sites



Well, I figured it out. It was a syntax error in the Switch/Case conditional statement. It wasn't picked up by the compiler......ahhh yes good old copy and paste gets you into trouble sometimes.

I'm happy to discover that the WM_NOTIFY message handling applies to more than my original listview. Wow, what a powerful tool working with the API!!!!

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