taurus905 Posted July 9, 2006 Share Posted July 9, 2006 I am trying to simulate a transparent button by using a graphic control. (Thanks to Valik for the idea.) I was very pleased with the initial results, but have found two problems. The first issue pertains to ControlGetFocus(). I am unable to get the graphic control to report its focus or change its focus using the tab key or arrow keys. The second issue deals with GUICtrlSetTip(). The tooltip quits working when it timesout while hovering, or if you right- or left-click on the control. The following two example scripts illustrate this behavior. Thank you to anyone who can help me clear things up. taurus905 expandcollapse popup; Button Example.au3 ; Show how tab and arrow keys change button focus. #include <GUIConstants.au3> GUICreate("Button Example", 200, 77, -1, 150, $WS_SIZEBOX + $WS_SYSMENU) GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg", -1, -1, 200, 50) GUICtrlSetState(-1, $GUI_DISABLE) $Button1 = GUICtrlCreateButton("", 33, 14, 40, 30) GUICtrlSetTip(-1, "First Button") $ctxt_Button1 = GUICtrlCreateContextMenu($Button1) $ctxt_Button1_Focus = GUICtrlCreateMenuitem("Which button has focus?", $ctxt_Button1) $Button2 = GUICtrlCreateButton("", 74, 14, 48, 30) GUICtrlSetTip(-1, "Second Button") $ctxt_Button2 = GUICtrlCreateContextMenu($Button2) $ctxt_Button2_Focus = GUICtrlCreateMenuitem("Focus?", $ctxt_Button2) GUISetState() While 1 Switch GUIGetMsg() Case $Button1 MsgBox(0, "Which was clicked on?", "Button over Win") Case $Button2 MsgBox(0, "Which was clicked on?", "Button over dows") Case $ctxt_Button1_Focus $Focus = ControlGetFocus("Button Example") MsgBox(0, "$Focus", $Focus) Case $ctxt_Button2_Focus $Focus = ControlGetFocus("Button Example") MsgBox(0, "$Focus", $Focus) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd expandcollapse popup; Graphic Example.au3 ; Make a graphic act like a button. #include <GUIConstants.au3> GUICreate("Graphic Example", 200, 77, -1, 240, $WS_SIZEBOX + $WS_SYSMENU) GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg", -1, -1, 200, 50) GUICtrlSetState(-1, $GUI_DISABLE) $Graphic1 = GUICtrlCreateGraphic(33, 14, 40, 30, $SS_NOTIFY + $SS_WHITEFRAME) GUICtrlSetTip(-1, "First Graphic") $ctxt_Graphic1 = GUICtrlCreateContextMenu($Graphic1) $ctxt_Graphic1_Focus = GUICtrlCreateMenuitem("Focus?", $ctxt_Graphic1) $Graphic2 = GUICtrlCreateGraphic(74, 14, 48, 30, $SS_NOTIFY + $SS_WHITEFRAME) GUICtrlSetTip(-1, "Second Graphic") $ctxt_Graphic2 = GUICtrlCreateContextMenu($Graphic2) $ctxt_Graphic2_Focus = GUICtrlCreateMenuitem("Which graphic has focus?", $ctxt_Graphic2) GUISetState() While 1 Switch GUIGetMsg() Case $Graphic1 MsgBox(0, "Which was clicked on?", "Graphic around Win") Case $Graphic2 MsgBox(0, "Which was clicked on?", "Graphic around dows") Case $ctxt_Graphic1_Focus $Focus = ControlGetFocus("Graphic Example") MsgBox(0, "$Focus", $Focus) Case $ctxt_Graphic2_Focus $Focus = ControlGetFocus("Graphic Example") MsgBox(0, "$Focus", $Focus) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
marfdaman Posted July 9, 2006 Share Posted July 9, 2006 As for the tab-issue, I believe $WS_TABSTOP will do the trick. And again, if no one comes with a more practical solution for your other issues, look at my funcs! Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Link to comment Share on other sites More sharing options...
taurus905 Posted July 9, 2006 Author Share Posted July 9, 2006 As for the tab-issue, I believe $WS_TABSTOP will do the trick. And again, if no one comes with a more practical solution for your other issues, look at my funcs!marfdaman, Thank you for the quick response. You were right. I was hoping that one was something simple I had just overlooked. In the 'Graphic Example' script, I replaced these two lines: $Graphic1 = GUICtrlCreateGraphic(33, 14, 40, 30, $SS_NOTIFY + $SS_WHITEFRAME) $Graphic2 = GUICtrlCreateGraphic(74, 14, 48, 30, $SS_NOTIFY + $SS_WHITEFRAME) With these two lines: $Graphic1 = GUICtrlCreateGraphic(33, 14, 40, 30, $SS_NOTIFY + $SS_WHITEFRAME + $WS_TABSTOP) $Graphic2 = GUICtrlCreateGraphic(74, 14, 48, 30, $SS_NOTIFY + $SS_WHITEFRAME + $WS_TABSTOP) I do have plans on using your UDF's. I will let you know how later. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 9, 2006 Moderators Share Posted July 9, 2006 Just a FYI:$SS_NOTIFY + $SS_WHITEFRAME + $WS_TABSTOPShould be:BitOr($SS_NOTIFY, $SS_WHITEFRAME, $WS_TABSTOP) 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...
taurus905 Posted July 10, 2006 Author Share Posted July 10, 2006 Just a FYI:$SS_NOTIFY + $SS_WHITEFRAME + $WS_TABSTOPShould be:BitOr($SS_NOTIFY, $SS_WHITEFRAME, $WS_TABSTOP)SmOke_N, Thanks for the input. I usually use something like this in my finished script: $Graphic1 = GUICtrlCreateGraphic(33, 14, 40, 30, 0x00010109); BitOr($SS_NOTIFY, $SS_WHITEFRAME, $WS_TABSTOP)) Do you think the second issue I mentioned above is an AutoIt bug? The second issue deals with GUICtrlSetTip(). The tooltip quits working when it timesout while hovering, or if you right- or left-click on the control. I think I will try a work-around of reassigning it after each button click. But if I am overlooking something, as I often do, please tell me. Thanks, taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs 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