Sign in to follow this  
Followers 0
Lope

Clickable button ontop of label?

4 posts in this topic

#1 ·  Posted (edited)

How do you get GUIGetMsg() for a button ontop of a label?

If I create the button after the label it displays the button ontop of the label as you'd expect.

Problem is I can't click it unless I disable the label.

But if I disable the label, the label text goes grey. (setting the color doesn't work.

Any ideas?

Example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Label1 = GUICtrlCreateLabel("The dog (Canis lupus familiaris[3] and Canis lupus dingo[1][2]) is a domesticated form of the gray wolf, a member of the Canidae family of the order Carnivora. The term is used for both feral and pet varieties. The dog was the first animal to be domesticated, and has been the most widely kept working, hunting, and companion animal in human history. The word 'dog' may also mean the male of a canine species,[4] as opposed to the word 'bitch' for the female of the species.", 104, 216, 464, 153)
$Button1 = GUICtrlCreateButton("Button1", 288, 224, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            msgbox(0,"","clicked")
    EndSwitch
WEnd
Edited by Lope

Share this post


Link to post
Share on other sites



How do you get GUIGetMsg() for a button ontop of a label?

If I create the button after the label it displays the button ontop of the label as you'd expect.

Problem is I can't click it unless I disable the label.

But if I disable the label, the label text goes grey. (setting the color doesn't work.

Any ideas?

Example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Label1 = GUICtrlCreateLabel("The dog (Canis lupus familiaris[3] and Canis lupus dingo[1][2]) is a domesticated form of the gray wolf, a member of the Canidae family of the order Carnivora. The term is used for both feral and pet varieties. The dog was the first animal to be domesticated, and has been the most widely kept working, hunting, and companion animal in human history. The word 'dog' may also mean the male of a canine species,[4] as opposed to the word 'bitch' for the female of the species.", 104, 216, 464, 153)
$Button1 = GUICtrlCreateButton("Button1", 288, 224, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            msgbox(0,"","clicked")
    EndSwitch
WEnd

Hi,

GUICtrlSetState($Button1, $gui_ontop)

cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Lope,

Or you can remove the forced $SS_NOTIFY style from the label so that it no longer is a clickable control - it the overlapping active controls that confuse AutoIt. :unsure:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Label1 = GUICtrlCreateLabel("The dog (Canis lupus familiaris[3] and Canis lupus dingo[1][2]) is a domesticated form of the gray wolf, a member of the Canidae family of the order Carnivora. The term is used for both feral and pet varieties. The dog was the first animal to be domesticated, and has been the most widely kept working, hunting, and companion animal in human history. The word 'dog' may also mean the male of a canine species,[4] as opposed to the word 'bitch' for the female of the species.", 104, 216, 464, 153)
GUICtrlSetStyle(-1, $SS_LEFT)
$Button1 = GUICtrlCreateButton("Button1", 288, 224, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            msgbox(0,"","clicked")
    EndSwitch
WEnd

By explicitly setting the $SS_LEFT style we overwrite the default setting of $SS_LEFT and $SS_NOTIFY styles - read the Setting Styles tutorial in the Wiki for about this. :>

M23

Edit: Added explanation.

Edited by Melba23
1 person likes this

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

YOU GUYS ARE THE ULTIMATE!!!!!!!

+KARMA!

November: I was simplifying when I gave the example with the button. My actual implementation

It probably should have been one thread. I just wanted to keep the question simple and to the point.

Thanks!!

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