qwert Posted July 29, 2009 Share Posted July 29, 2009 I have a button on a GUI that isn't working, so I prepared the following greatly simplified test case. Button1 works. Button2 doesn't. Why not? #include <GUIConstants.au3> $GUI = GUICreate("Text Position Test", 300, 200, -1, -1) $Label = GUICtrlCreateLabel("Long strings of displayed text need to start at the beginning ... but so do short strings.", 20, 120, 200, 60) $Entry = GUICtrlCreateInput("", 100, 40, 100, 20) $Button_1 = GUICtrlCreateButton ("Run Notepad", 40, 80, 80,20) $Button_2 = GUICtrlCreateButton ("Button Test", 40, 160, 80,20) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 GUICtrlSetData($Entry, "This is an example of long text that exceeds the viewable area") Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_2 MsgBox(0, "Testing", "Button 2 was pressed") ; Will demonstrate Button 2 being pressed GUICtrlSetData($Entry, "This is short text") EndSelect Wend Obviously, it's something basic -- but I can't see it. Somehow the placing of text in the entry field interferes with Button2 only. Thanks for any help. Link to comment Share on other sites More sharing options...
enaiman Posted July 29, 2009 Share Posted July 29, 2009 Your Button2 is "under" the label that's why you can't press it. This works: (moved the button further down) #include <GUIConstants.au3> $GUI = GUICreate("Text Position Test", 300, 250, -1, -1) $Label = GUICtrlCreateLabel("Long strings of displayed text need to start at the beginning ... but so do short strings.", 20, 120, 200, 60) $Entry = GUICtrlCreateInput("", 100, 40, 100, 20) $Button_1 = GUICtrlCreateButton ("Run Notepad", 40, 80, 80,20) $Button_2 = GUICtrlCreateButton ("Button Test", 40, 200, 80,20) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 GUICtrlSetData($Entry, "This is an example of long text that exceeds the viewable area") ;Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_2 MsgBox(0, "Testing", "Button 2 was pressed") ; Will demonstrate Button 2 being pressed GUICtrlSetData($Entry, "This is short text") EndSelect Wend SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
CodyBarrett Posted July 29, 2009 Share Posted July 29, 2009 its a very simple and very common problem if its under a alabel or a pic control... [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
qwert Posted July 30, 2009 Author Share Posted July 30, 2009 Your Button2 is "under" the label that's why you can't press it.That explains why it worked every time I took out the label statement -- but I didn't make the connection about field overlap.Thank you very much. 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