Sign in to follow this  
Followers 0
troglo

Button over a progress bar

9 posts in this topic

I put a button over a progress bar.

But when I click on the button I get a reaction only when I click on that area with no progress bar below it!

Is this normal?

What should I do in order to be able to click on the whole area of the button?

Thank you for your help

Troglo

CODE
#include <GUIConstantsEx.au3>

#include <ProgressConstants.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("TEST", 279, 130)

GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")

$percentMax = 50

$pbLeft = 8

$pbTop = 20

$pbWidth = 257

$pbHeigth = 30

Global $pb = GUICtrlCreateProgress($pbLeft, $pbTop, $pbWidth, $pbHeigth, $PBS_SMOOTH)

$btnLimit = GUICtrlCreateButton("", $pbLeft + ($pbWidth * $percentMax / 100), $pbTop, 15, $pbHeigth * 2)

GUICtrlSetOnEvent(-1, "Limit")

GUICtrlSetBkColor($btnLimit, 0xff0000) ;red

GUISetState(@SW_SHOW)

While 1

For $i = 0 To 100 Step 5

GUICtrlSetData($pb, $i)

GUICtrlSetPos($btnLimit, $pbLeft + ($pbWidth * $percentMax / 100), $pbTop)

Sleep(100)

Next

WEnd

;=======================================================

Func AForm1Close()

Exit

EndFunc ;==>AForm1Close

;=======================================================

Func Limit()

MsgBox(0, "", "button pressed", 1)

EndFunc ;==>Limit

;=======================================================

Share this post


Link to post
Share on other sites



$btnLimit = GUICtrlCreateButton("", $pbLeft + ($pbWidth * $percentMax / 100), $pbTop, 15, $pbHeigth * 2)
Global $pb = GUICtrlCreateProgress($pbLeft, $pbTop, $pbWidth, $pbHeigth, $PBS_SMOOTH)

GUICtrlSetOnEvent($btnLimit, "Limit")

Create it first.

Thank you very much!

Although it is not intuitive: I thought that the last created control will stay on top of all others and catch all clicks!

Or if I delete the 2 instructions:

GUICtrlSetBkColor($btnLimit, 0xff0000) ;red

GUICtrlSetPos($btnLimit, $pbLeft + ($pbWidth * $percentMax / 100), $pbTop)

I get a button hidden by the progress bar but nevertheless fully active!

Troglo

Share this post


Link to post
Share on other sites

Thank you very much!

Although it is not intuitive: I thought that the last created control will stay on top of all others and catch all clicks!

Or if I delete the 2 instructions:

GUICtrlSetBkColor($btnLimit, 0xff0000) ;red

GUICtrlSetPos($btnLimit, $pbLeft + ($pbWidth * $percentMax / 100), $pbTop)

I get a button hidden by the progress bar but nevertheless fully active!

Troglo

Maybe this would make more sense

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <windowsconstants.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("TEST", 279, 130)
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")

$percentMax = 50
$pbLeft = 8
$pbTop = 20
$pbWidth = 257
$pbHeigth = 30

$btnLimit = GUICtrlCreateButton("", $pbLeft + ($pbWidth * $percentMax / 100), $pbTop, 15, $pbHeigth * 2)
GUICtrlSetOnEvent(-1, "Limit")
Global $pb = GUICtrlCreateProgress($pbLeft, $pbTop, $pbWidth, $pbHeigth, BitOR($WS_CLIPSIBLINGS, $PBS_SMOOTH))

;GUICtrlSetBkColor($btnLimit, 0xff0000);red <- line can be in or not, makes no difference

GUISetState(@SW_SHOW)

While 1
    For $i = 0 To 100 Step 5
        GUICtrlSetData($pb, $i)
        Sleep(100)
    Next
WEnd
;=======================================================
Func AForm1Close()
    Exit
EndFunc  ;==>AForm1Close
;=======================================================
Func Limit()
    MsgBox(0, "", "button pressed", 1)
EndFunc  ;==>Limit
;=======================================================

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

Just great!

I thought that $WS_CLIPSIBLINGS would work with windows only and not with controls.

In any case honestly I don't understand what this style really does.

My mother tongue is not english and the description of this style is not clear at all to me.

May be you could explain it in a simpler way?

Troglo

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I am not sure, but look at this: [link removed]

Edited by SmOke_N

Share this post


Link to post
Share on other sites

Just great!

I thought that $WS_CLIPSIBLINGS would work with windows only and not with controls.

In any case honestly I don't understand what this style really does.

My mother tongue is not english and the description of this style is not clear at all to me.

May be you could explain it in a simpler way?

Troglo

Well first of all controls are windows.

What the style $WS_CLIPSIBLINGS does is to prevent the control or window being drawn over an area occupied by another, previously created, control or window which has the same parent window.


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

#8 ·  Posted (edited)

All this fails to [link snipped] !

Edited by SmOke_N

Share this post


Link to post
Share on other sites

Well first of all controls are windows.

What the style $WS_CLIPSIBLINGS does is to prevent the control or window being drawn over an area occupied by another, previously created, control or window which has the same parent window.

Thank you: now everything is clear!

Troglo

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