Gozzgug Posted September 28, 2007 Share Posted September 28, 2007 I have gui with numerous tabs. I would like to do a validation check on the currently selected tab when you click to exit to the next tab. Are there any events to handle this? Sorry for the double post. I posted this originally in the general help area and I think it needs to be here. Link to comment Share on other sites More sharing options...
GaryFrost Posted September 28, 2007 Share Posted September 28, 2007 Deleted original topic SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Achilles Posted October 20, 2007 Share Posted October 20, 2007 (edited) I don't know if there has been a solution to this that I missed somewhere, but if not can someone think of a solution to it now? EDIT: Using GuiRegisterMsg() with $WM_NOTIFY does something but I haven't figured how to make it recognize the tab click. EDIT2: I've already looked through what AutoItLib has to offer but it doesn't seem to have what I'm looking for, unless I missed it. Edited October 20, 2007 by Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
GaryFrost Posted October 20, 2007 Share Posted October 20, 2007 Pay attention to $TCN_SELCHANGING expandcollapse popup#include <GuiConstants.au3> #include <GuiTab.au3> Opt('MustDeclareVars', 1) $Debug_TAB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work Global $hTab _Main() Func _Main() Local $hGUI ; Create GUI $hGUI = GUICreate("Tab Control Create", 400, 300) $hTab = _GUICtrlTab_Create ($hGUI, 2, 2, 396, 296) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Add tabs _GUICtrlTab_InsertItem ($hTab, 0, "Tab 1") _GUICtrlTab_InsertItem ($hTab, 1, "Tab 2") _GUICtrlTab_InsertItem ($hTab, 2, "Tab 3") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab, $fValid $hWndTab = $hTab If Not IsHWnd($hTab) Then $hWndTab = GUICtrlGetHandle($hTab) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTab Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom: " & @TAB & $iIDFrom & @LF & _ "-->Code: " & @TAB & $iCode) ; The return value is ignored by the tab control Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RCLICK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RDBLCLK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RELEASEDCAPTURE ; control is releasing mouse capture _DebugPrint("$NM_RELEASEDCAPTURE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; No return value Case $TCN_SELCHANGING _DebugPrint("$TCN_SELCHANGING" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode & @LF & _ "-->Item: " & @TAB & _GUICtrlTab_GetCurSel($hTab)) ; could do validation here and determine return $fValid = False If Not $fValid Then Return True ; prevent the selection from changing Else Return False ; FALSE to allow the selection to change EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
smashly Posted October 20, 2007 Share Posted October 20, 2007 .....EDIT2: I've already looked through what AutoItLib has to offer but it doesn't seem to have what I'm looking for, unless I missed it.If your looking to find out if a tab has been hit on then you missed it... Maybe look in the A3LTabControl.au3 then look at _Tab_HitTest($hWnd, $iX, iY) use tab hittest to find the tab you've hit on.Works pretty sweet for many things as it reports what's been hit, eg: the tab index and or on the tab text and or on tab icon.Not sure exactly what your after but a crude example of what I mean, but you could do it a lot better to suite your needs maybe.. hereCheers Link to comment Share on other sites More sharing options...
GaryFrost Posted October 20, 2007 Share Posted October 20, 2007 (edited) If your looking to find out if a tab has been hit on then you missed it... Maybe look in the A3LTabControl.au3 then look at _Tab_HitTest($hWnd, $iX, iY) use tab hittest to find the tab you've hit on.Works pretty sweet for many things as it reports what's been hit, eg: the tab index and or on the tab text and or on tab icon.Not sure exactly what your after but a crude example of what I mean, but you could do it a lot better to suite your needs maybe.. hereCheersNo need to go through all that as I pointed out $TCN_SELCHANGING you can either allow the tab selection to change or not, put validation code there to make the decision.Not much missing from the Beta help in the tab department that is in the A3L libraries, most have been combined with the libraries that were already there.Edit: Must be getting tired, _GUICtrlTab_HitTest is in the help Edited October 20, 2007 by GaryFrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
smashly Posted October 20, 2007 Share Posted October 20, 2007 I really should move onto that beta.. Link to comment Share on other sites More sharing options...
Achilles Posted October 20, 2007 Share Posted October 20, 2007 Thanks GaryFrost... that's exactly what I was hoping for. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now