Sign in to follow this  
Followers 0
kiboost

button name with variable, and rollover

6 posts in this topic

Hi,

I'm creating a script that check and list a few things, and for each thing, create some buttons and label.

So, is there a way to put a variable in a button name, for example like this :

$Bt_&$k = GUICtrlCreateButton("", $left, $top, 40, 20)

So I can then, knowing k number, change its state by calling it $Bt_20 (if k=20) ?

Secondly, is there a way to have a button that show a text when mouse is over it ? Not changing its state, but showing a little text beside the mouse cursor, just like "title" balise in html ?

cheers,

Kib


Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites



kiboost,

The easiest way to do what you want is to use an array to hold the button ControlIds. You can set "little texts" by using GUICtrlSetTip. ;)

Take a look at this to see what I mean:

#include <GUIConstantsEx.au3>

; Declare the array
Global $hButtonID[3]

$hGUI = GUICreate("Test", 500, 500)

; Create buttons and store ControlIDs in the array
$hButtonID[0] = GUICtrlCreateButton("Button 0", 10, 10, 80, 30)
$hButtonID[1] = GUICtrlCreateButton("Button 1", 10, 50, 80, 30)
$hButtonID[2] = GUICtrlCreateButton("Button 2", 10, 90, 80, 30)

; Set tooltips
For $i = 0 To 2
    GUICtrlSetTip($hButtonID[$i], "Button " & $i)
Next

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButtonID[0]
            ; Disable Buton 2
            GUICtrlSetState($hButtonID[2], $GUI_DISABLE)
        Case $hButtonID[1]
            ; Enable Buton 2
            GUICtrlSetState($hButtonID[2], $GUI_ENABLE)
    EndSwitch

WEnd

Please ask if you have any questions. :)

M23


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

#3 ·  Posted (edited)

many thanks, I had indeed to declare the array before.

$hButtonID[$k] = GUICtrlCreateButton("Button 0", 10, 10, 80, 30)

it works !

Now, how can I get the position (specially top position) of a button ? Doesn't seems to be GUICtrlGetPos ! I could register them into another array anyway ... I need to change the button when I click on it, and remap the function it will call then.

Edited by kiboost

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

ok, ControlGetPos !!

Thanks again ;-)

Any thought about the rollover ?


Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

kiboost,

If by "rollover" you mean showing a small text window when you put the mouse over a control then I already showed you how to use GUICtrlSetTip in the code I posted. :)

If not, then what do you mean by "rollover"? ;)

M23


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

GOSH, I missed this one ! Works exactly like I need, you just made my day !!

Many thanks, again !

Cheers :-)

Kib


Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

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