Sunaj Posted September 19, 2006 Share Posted September 19, 2006 How to detect tab change in OnEventMode? Code below should show a msgbox when TabSheet2 is activated, really hope someone can help with this #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) $dlgTabbed = GUICreate("Tabs", 412, 280, 302, 218) $PageControl1 = GUICtrlCreateTab(8, 8, 396, 256) $TabSheet1 = GUICtrlCreateTabItem("3") GUICtrlCreateLabel("Tab 1", 168, 104, 61, 17) $TabSheet2 = GUICtrlCreateTabItem("different") GUICtrlSetOnEvent($TabSheet2, "tabchangedetected") ; I know this doesn't work.. what does though? GUICtrlCreateLabel("Tab 2", 176, 136, 61, 17) $TabSheet3 = GUICtrlCreateTabItem("Tabs") GUICtrlCreateLabel("Tab 3", 184, 128, 61, 17) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW,$dlgTabbed) GUISetOnEvent($GUI_EVENT_CLOSE, "closeclicked") While 1 Sleep(100) Wend Func closeclicked() Exit EndFunc Func tabchangedetected() MsgBox(4096, "Result", "Tab active") EndFunc [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 19, 2006 Moderators Share Posted September 19, 2006 This is a quick and VERY dirty way of doing it... I would seriously say look at GUIRegisterMsg()expandcollapse popup#include <guitab.au3> #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) $dlgTabbed = GUICreate("Tabs", 412, 280, 302, 218) $PageControl1 = GUICtrlCreateTab(8, 8, 396, 256) $TabSheet1 = GUICtrlCreateTabItem("3") GUICtrlCreateLabel("Tab 1", 168, 104, 61, 17) $TabSheet2 = GUICtrlCreateTabItem("different") GUICtrlSetOnEvent($TabSheet2, "tabchangedetected") ; I know this doesn't work.. what does though? GUICtrlCreateLabel("Tab 2", 176, 136, 61, 17) $TabSheet3 = GUICtrlCreateTabItem("Tabs") GUICtrlCreateLabel("Tab 3", 184, 128, 61, 17) GUICtrlCreateTabItem("") GUISetOnEvent($GUI_EVENT_CLOSE, "closeclicked") GUISetState(@SW_SHOW,$dlgTabbed) Global $iCurrentTab = _GUICtrlTabGetCurFocus($PageControl1) AdlibEnable('tabchangedetected', 10) While 1 Sleep(1000) Wend Func closeclicked() Exit EndFunc Func tabchangedetected() If _GUICtrlTabGetCurFocus($PageControl1) <> $iCurrentTab Then $iCurrentTab = _GUICtrlTabGetCurFocus($PageControl1) MsgBox(4096, "Result", "Tab active") EndIf EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Sunaj Posted September 19, 2006 Author Share Posted September 19, 2006 This is a quick and VERY dirty way of doing it... I would seriously say look at GUIRegisterMsg()It may be dirty but it is completely functional from my perspective - I'll have a look at GUIRegisterMsg() later when my app is at a stage where it feels more right to polish the details! Thanks a lot for your quick reply SmOke_N. Since I've searched the forum thin without finding reference to this particular issue I'm sure it'll be of help to many other AutoItters [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Sunaj Posted September 19, 2006 Author Share Posted September 19, 2006 Hmm, looked a bit at the code and got around to thinking that it might be better to do the following (this way AdlibEnable is avoided and I still avoid going into GUIRegisterMsg, which, after I looked at it, scare me quite a bit), I don't know whether it is better or worse from a technical standpoint.. but it works! #include <guitab.au3> #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) $dlgTabbed = GUICreate("Tabs", 412, 280, 302, 218) $PageControl1 = GUICtrlCreateTab(8, 8, 396, 256) $TabSheet1 = GUICtrlCreateTabItem("3") GUICtrlCreateLabel("Tab 1", 168, 104, 61, 17) $TabSheet2 = GUICtrlCreateTabItem("different") GUICtrlCreateLabel("Tab 2", 176, 136, 61, 17) $TabSheet3 = GUICtrlCreateTabItem("Tabs") GUICtrlCreateLabel("Tab 3", 184, 128, 61, 17) GUICtrlCreateTabItem("") GUISetOnEvent($GUI_EVENT_CLOSE, "closeclicked") GUISetState(@SW_SHOW,$dlgTabbed) Global $iCurrentTab = _GUICtrlTabGetCurFocus($PageControl1) While 1 Sleep(100) If _GUICtrlTabGetCurFocus($PageControl1) <> $iCurrentTab Then $iCurrentTab = _GUICtrlTabGetCurFocus($PageControl1) MsgBox(4096, "Result", "New Tab active") EndIf Wend Func closeclicked() Exit EndFunc [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/list] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 19, 2006 Moderators Share Posted September 19, 2006 Whatever floats your boat... Typically people use OnEventMode to save on CPU usage so I'm told, so I didn't think you wanted to play with the While/WEnd loop. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GaryFrost Posted September 19, 2006 Share Posted September 19, 2006 You don't need adlib and you don't need it in the while loop, just put the event on the tab itself: expandcollapse popup#include <guitab.au3> #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) $dlgTabbed = GUICreate("Tabs", 412, 280, 302, 218) $PageControl1 = GUICtrlCreateTab(8, 8, 396, 256) GUICtrlSetOnEvent($PageControl1, "tabchangedetected") $TabSheet1 = GUICtrlCreateTabItem("3") GUICtrlCreateLabel("Tab 1", 168, 104, 61, 17) $TabSheet2 = GUICtrlCreateTabItem("different") GUICtrlCreateLabel("Tab 2", 176, 136, 61, 17) $TabSheet3 = GUICtrlCreateTabItem("Tabs") GUICtrlCreateLabel("Tab 3", 184, 128, 61, 17) GUICtrlCreateTabItem("") GUISetOnEvent($GUI_EVENT_CLOSE, "closeclicked") GUISetState(@SW_SHOW, $dlgTabbed) Global $iCurrentTab = _GUICtrlTabGetCurFocus($PageControl1) While 1 Sleep(200 WEnd Func closeclicked() Exit EndFunc ;==>closeclicked Func tabchangedetected() If _GUICtrlTabGetCurFocus($PageControl1) <> $iCurrentTab Then $iCurrentTab = _GUICtrlTabGetCurFocus($PageControl1) MsgBox(4096, "Result", "Tab active:" & $iCurrentTab) EndIf EndFunc ;==>tabchangedetected 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...
Sunaj Posted September 19, 2006 Author Share Posted September 19, 2006 You don't need adlib and you don't need it in the while loop, just put the event on the tab itself:Brilliant.. problem was I kept messing about with trying to get nfo from GUICtrlCreateTabItem instead of GUICtrlCreateTab. This was the exact solution I was looking for, thanks [list=1][*]Generic way to detect full path to default browser, List/ListView Events Using GuiRegisterMsg (detect doubleclick and much more)[*]Using dllcall for full control over fileopendialog, Make DirMove act somewhat normally (by circumventing it...)[*]Avoid problems with "&" (chr(38)) in code, Change desktop maximized area/workspace (fx to make deskbar type app)[*]Change focus behavior when buttons are clicked to work closer to 'standard windows' app[*](Context) Menus With Timed Tooltips, Fast Loops & Operators in AU3[*]Clipboard UDF, A clipboard change notification udf[/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