Sign in to follow this  
Followers 0
redndahead

Using a Button on top of a label

21 posts in this topic

Maybe this is not possible but here is my problem. I tried to create a button that sits on top of a label. If you try to click on the button it doesn't work. As soon as you move the button off of the label it can click. I first created the label then the button so the button sits on top.

If i create the button first and then the label the label hides the button as expected but when you click on the label it clicks the button. Any way to change this behavior?

red

Share this post


Link to post
Share on other sites



Wouldn't it be better/easier to toggle if the button is present?

i.e

GUISetControlEx($MyButton, 32)

or

GUISetControlEx($MyButton, 16)

I have one set of buttons on a tab that are shown based on if a checkbox is checked or not.

Share this post


Link to post
Share on other sites

He wants the zorder of the button to over lap part of the label.


Who else would I be?

Share this post


Link to post
Share on other sites

Oh you want it to be visible but unclickable.... or am I still missing the point? If I am not then you can toggle the "disabled" style?

Share this post


Link to post
Share on other sites

Who cares if it clicks the button... just ignore the message?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

|----------------------------------|
|                                  |
|                                  |
|            button                |
|                                  |----------------------|
|                                  |                      |
|----------------------------------|                      |
                      |                   label           |
                      |                                   |
                      |-----------------------------------|

I think that is what he wants.

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

I'm not sure if this is what you want, but see my post here

Here's the relevant excerpt:

GuiCreate($title, 200, 100, 10, 10, 0x80000000)

;;; CREATE ALL CONTROLS BEFORE THE BACKGROUND
$hello = GuiSetControl("button","Hello", 10, 10, 30, 20)
$close = GuiSetControl("button","Close", 140, 60, 30, 20)

$background = GuiSetControl("label","", 0, 0, 200, 100)
GuiShow()
WinSetOnTop($title, "", 1)

;;; SET CONTROL STATES TO SHOW... IN ORDER FOR THE WINDOW TO REPAINT (MAKE BUTTONS APPEAR ON TOP)

GUISetControlEx($hello, 16);show
GUISetControlEx($close, 16);show

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Just like the Windows Z-Order, though, the last thing with focus will be at the top. In the case of controls, the last control that was clicked will be the one on top. So with the example this-is-me posted, you could click on either control to bring that particular one to the top (I guess that's provided the label is a tab-stop, which labels aren't by default).

Unless you really really know what you're doing, overlapping controls is not a good idea.

Edited by Valik

Share this post


Link to post
Share on other sites

If you code the same overlap in visual basic, it doesn't do that... Is there something that could be changed in the gui functions to allow that to work? I can see a few reasons that this would be needed.


Who else would I be?

Share this post


Link to post
Share on other sites

Is this a problem when you only disable this label like this?:

$title = "test"
GuiCreate($title, 200, 100, 10, 10, 0x80000000)

;;; CREATE ALL CONTROLS BEFORE THE BACKGROUND
$hello = GuiSetControl("button","Hello", 10, 10, 30, 20)
$close = GuiSetControl("button","Close", 140, 60, 30, 20)

$background = GuiSetControl("label","", 0, 0, 200, 100)
GUISetControlEx(-1, 128);disable lable;-)
GuiShow()

WinSetOnTop($title, "", 1)

;;; SET CONTROL STATES TO SHOW... IN ORDER FOR THE WINDOW TO REPAINT (MAKE BUTTONS APPEAR ON TOP)

GUISetControlEx($hello, 16);show
GUISetControlEx($close, 16);show
GUIWaitClose()

Or do I have still an understanding problem? :ph34r:

Share this post


Link to post
Share on other sites

CS is attempting to detect clicks inside the window by making a label the size of the window. Label's return from GuiMsg() when clicked. Disabling the label means it won't return a message, so the existence of the label becomes pointless.

Share this post


Link to post
Share on other sites

@Valik:ahhh, yeah...now I understand it.

Hmmm...I think like you too, overlapping isn't very well.

But I don't know if it is easy to change/code in the GUI-functions.

It would be good for me to see what the real meaning/target should be.

And what is with:

$background = GuiSetControl("label","", 0, 0, 200, 100)
GUISetControlNotify(-1,1)

So with CyberSlug's code it should be no problem :ph34r::(

Share this post


Link to post
Share on other sites

Alright since I've been gone there has been a full conversation about it. =)

Here is what I mean. I have a gui that is a pop up window. So no title bar at the top. I created my own title bar using a label then I wanted to place my own buttons at the top. I wanted spacing in between the buttons so I want the label color to show through. But if I do this I am completely unable to click on the buttons. Here is a screenshot of my window. What I ended up doing is putting the buttons right next to each other and have the label bump up against that.

Posted Image

red

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Avoid overlapping controls :ph34r: Here's one attempt that does use overlapping....

Why don't you just create another colored label where you want the gap between the buttons???

Global $GUI_SHOW = 16

Opt("WinTitleMatchMode", 4)
Opt("GUINotifyMode", 1)
$window = GuiCreate("MyGUI", 392,273,(@DesktopWidth-392)/2, (@DesktopHeight-273)/2 ,  0x80000000)

$button_1 = GUISetControl("button", "0", 300, 0, 30, 30)
   GUISetControlFont($button_1, 24, 400, "Webdings")
$button_2 = GUISetControl("button", "x", 360, 0, 30, 30)
   GUISetControlFont($button_2, 24, 400, "Wingdings")

$titlebar = GUISetControl("label", "Label 1", 0, 0, 400, 30)
   GUISetControlEx ($titlebar, 0, 0, "", 0x0, 0x00FF00)

GuiShow()

While 1
    showButtonsOnTop();needed if window is every not activate and is reactivated
    sleep(100)
    $msg = GuiMsg(0)
    Select
    Case $msg = $button_1
        WinSetState("handle=" & $window, "", @SW_MINIMIZE)
    Case $msg = $button_2
        Exit
    EndSelect
WEnd
Exit

Func showButtonsOnTop()
   GUISetControlEx($button_1, $GUI_SHOW)
   GUISetControlEx($button_2, $GUI_SHOW)
EndFunc

Note: The "webdings" font contains icons for the minimize,restore,maximize buttons found on the Windows 9x/2000 style titlebar.

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Avoid overlapping controls smile.gif Here's one attempt that does use overlapping....

Why don't you just create another colored label where you want the gap between the buttons???

Well I could create another label but I just thought that the topmost control should be able to receive the action no matter what. Anywho, I'm getting it to work as is. Thanks for the clue on the font. Is this installed on all computers?

red

Share this post


Link to post
Share on other sites

Cause I have to go to bed ( to much thinking today :( ) you could use:

WS_CLIPSIBLINGS on the overlapping (label)-control like this:

$WS_CLIPSIBLINGS = 0x04000000

GuiCreate("test", 200, 100, 10, 10, 0x80000000)

;;; CREATE ALL CONTROLS BEFORE THE BACKGROUND
$hello = GuiSetControl("button","Hello", 10, 10, 30, 20)
$close = GuiSetControl("button","Close", 140, 60, 30, 20)

$background = GuiSetControl("label","", 0, 0, 200, 100, $WS_CLIPSIBLINGS)
GUISetControlNotify(-1,1)

GuiShow()

GUIWaitClose()

Msgbox(0,"",GUIRead())
GUIDelete()
Exit

Hope that helps :lol:

Good night... :ph34r:

Share this post


Link to post
Share on other sites

Holger, can you please explain to me what does this WS_CLIPSIBLINGS settings? I've had the same problem with an overlapping panel and button and I'd like to understand how to avoid this, a part than not overlapping them! :">

Angel

Cause I have to go to bed ( to much thinking today :) ) you could use:

WS_CLIPSIBLINGS on the overlapping (label)-control like this:

$WS_CLIPSIBLINGS = 0x04000000

GuiCreate("test", 200, 100, 10, 10, 0x80000000)

;;; CREATE ALL CONTROLS BEFORE THE BACKGROUND
$hello = GuiSetControl("button","Hello", 10, 10, 30, 20)
$close = GuiSetControl("button","Close", 140, 60, 30, 20)

$background = GuiSetControl("label","", 0, 0, 200, 100, $WS_CLIPSIBLINGS)
GUISetControlNotify(-1,1)

GuiShow()

GUIWaitClose()

Msgbox(0,"",GUIRead())
GUIDelete()
Exit

Hope that helps ;)

Good night... :)

<{POST_SNAPBACK}>

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