Jump to content

GUIRegisterMessage and Tab controls


mark2004
 Share

Recommended Posts

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
Link to comment
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!!!!

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...