Jump to content
Sign in to follow this  
qwert

Button on top of drag area?

Recommended Posts

qwert

I have a GUI with a drag area defined per the following:

The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that don't have a titlebar

Now I find I need a button in that same area. Can a button be created on top of another button?

So far, the one(s) I've created don't work. After reading some posts, I thought I might just be able to add the style $WS_CLIPSIBLINGS to the create for the drag area -- but that didn't work either.

Thanks for any help.

Share this post


Link to post
Share on other sites
martin

I have a GUI with a drag area defined per the following:

Now I find I need a button in that same area. Can a button be created on top of another button?

So far, the one(s) I've created don't work. After reading some posts, I thought I might just be able to add the style $WS_CLIPSIBLINGS to the create for the drag area -- but that didn't work either.

Thanks for any help.

I'm not clear whay you want a button on top of another button. Do yu mean you have used a button to drag the window? I didn't know you could do that butI wouldn't have thought it was worth trying. You can use a label with the extended style $GUI_WS_EX_PARENTDRAG, and you can set its style to $WS_CLIPSIBLINGS to ensure the butons show.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
qwert

You can use a label with the extended style $GUI_WS_EX_PARENTDRAG, and you can set its style to $WS_CLIPSIBLINGS to ensure the butons show.

That's exactly what I tried, but the drag area was still active on top of the defined button. BTW, the new button is defined after the drag area "button" is defined -- if that matters.

Any suggestions?

Share this post


Link to post
Share on other sites
Valuater

Any suggestions?

show your code

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Siao

BTW, the new button is defined after the drag area "button" is defined -- if that matters.

Yes, it does.

Another approach would be to enable dragging on entire window. There are several methods, all evolve around generating non-client click event when user presses mouse button. Search forum for HTCAPTION


"be smart, drink your wine"

Share this post


Link to post
Share on other sites
martin

Yes, it does.

Another approach would be to enable dragging on entire window. There are several methods, all evolve around generating non-client click event when user presses mouse button. Search forum for HTCAPTION

Or you could do something like this

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("exit button won't work until you press 'change'",-1,-1,-1,-1);,$WS_POPUP)
$Labelb = MakeLabel()
$b = GUICtrlCreateButton("exit",10,10,80,22)
$b2 = GUICtrlCreateButton("change",10,200,80,22)
GUISetState()
While 1
$msg = GUIGetMsg()  
If $msg = $b Then ExitLoop
If $msg = $b2 Then
    GUICtrlDelete($Labelb)
    MakeLabel()
    EndIf
WEnd


Func MakeLabel()
    Local $lab = GUICtrlCreateLabel("", 0, 0,200, 100, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1,0xff3322)
Return $lab
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
qwert

Or you could do something like this

Thanks, Martin.

I simplified what you suggested to the minimum and got this result:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Button works from the start",-1,-1,-1,-1);,$WS_POPUP)
$button = GUICtrlCreateButton("exit",45,35,80,22)
GUICtrlCreateLabel("", 0, 0, 200, 100, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1,0xff3322)
GUISetState()

While 1
$msg = GUIGetMsg()  
If $msg = $button Then ExitLoop
WEnd

It works (because of the creation order, I suppose) in this controlled example -- but will it hold up for a more complicated GUI with 20 buttons and fields? I'll test that tomorrow -- unless someone can offer the answer.

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  

×