Sign in to follow this  
Followers 0
packrat

Problem with clicking a button

3 posts in this topic

The dialog box below has a button which the user can click to close the dialog box or where the user can press the ENTER key as a substitute for the mouseclick. Pressing ENTER works fine, but I can't seem to get the button to react to a mouseclick. I've got to be overlooking something obvious, but I just can't seem to see it. Can anyone help?

CODE

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#include <StaticConstants.au3>

#include <ButtonConstants.au3>

#include <Date.au3>

#include <File.au3>

;------------------------------------------------------------

Func ShowStopDialog( $txt1, $txt2 )

Local $WinHandle2

Local $OkButton

Local $msg

;

$WinHandle2 = GUICreate( "" , 665, 115, 75, 200, BitOR($WS_POPUP, $WS_BORDER) )

GUISetBkColor(0xFFFFCC)

;

GUICtrlCreateLabel( $txt1, 5, 10, 650, 45, $SS_CENTER )

GUICtrlSetFont(-1, 30, 800, 0, "Arial" )

GUICtrlSetColor(-1,0xFF1C3C)

GUICtrlCreateLabel( $txt2, 15, 70, 650, 36, $SS_CENTER )

GUICtrlSetFont(-1, 18, 800, 0, "Arial" )

GUICtrlSetColor(-1,0x0000FF)

;

$OkButton = GUICtrlCreateButton ("OK", 580, 85, 75, 22, $BS_FLAT )

GUICtrlSetState( $OkButton, $GUI_ENABLE )

GUICtrlSetFont( -1, 8, 1200, 0, "Arial")

GUICtrlSetBkColor( -1, 0xFFFFAA )

;

GUICtrlSetState( $OkButton, $GUI_FOCUS )

GUICtrlSetState( $OkButton, $GUI_DEFBUTTON )

GUISetState(@SW_SHOW,$WinHandle2)

;

WinSetOnTop("[ACTIVE]", "", 1)

;

$msg = 0

While True

$msg = GUIGetMsg()

Select

Case $msg = $OkButton

ExitLoop

EndSelect

Wend

GUIDelete($WinHandle2)

EndFunc

;------------------------------------------------------------

$txt = "BARCODE PROBLEM"

ShowStopDialog( $txt, "P U T A S I D E" )

Thanks in advance!

Harvey

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

packrat,

Your labels are too big and the button is overlapping them. AutoIt does not accept 2 active controls in the same space - I assume it looks for mouse click coordinates and then cannot decide which control has been activated.

I suggest either disabling the labels (but that makes the text go grey) or making them smaller so the button is in "clear" space. Hint - use GUICtrlSetBkColor to colour the labels and so clearly see their extent.

M23

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

packrat,

Your labels are too big and the button is overlapping them. AutoIt does not accept 2 active controls in the same space - I assume it looks for mouse click coordinates and then cannot decide which control has been activated.

I suggest aither disabling the labels (but that makes the text go grey) or making them smaller so the button is in "clear" space. Hint - use GUICtrlSetBkColor to colour the labels and so clearly see their extent.

M23

Boy, you'd think I'd learn from my mistakes! This happened once before, and someone here noted the same solution: shorten the label so it doesn't overlap. Thanks for your helpful response, and maybe this time it'll stick in my mind! :)

Harvey

Share this post


Link to post
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
Sign in to follow this  
Followers 0