Jump to content

Size information of controls?


Recommended Posts

Hi again,

I feel like I am missing something obvious.

Maybe I'm just getting worse at searching.

All I need is a udf that when sent a controlID will return an array holding left, Top, height and width.

This seemed simple when I started and now I've been searching forever.

Normally I just want a pointer to get me going.

Here I think I would learn more by studying the func if someone would be kind enough.

As always, thank you for your time and eternal patience.

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

Thank you.

That could have been better named.

For once though I am happy to have overlooked the obvious as this exactly what I need.

I have two other problems but I want to search and nibble for a couple more days.

Thank you for your time and patience.

[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

This is the first time I am writing something to an array.

Based on examples it seems like this should work.

Why does it error?

#include <array.au3>
#Include <GuiSlider.au3>

$Width  = 550
$Height = 600
$WinX   = 480
$WinY   = 400
$GUIid  = GUICreate("DropBeep", $Width, $Height, $WinX,  $WinY)
$slider = GUICtrlCreateSlider(333,114, 128, 20, $TBS_BOTH)
$ret    = Center($slider, 72)

$slider1FreqLabel = GUICtrlCreateInput("Testing", $ret[0], $ret[1], 128, 72)
GUICtrlSetBkColor($slider1FreqLabel, 0xffffff)

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func Center($Cid, $Width)
    $Pos = ControlGetPoS("","",$Cid)
    $X = $Pos[0]
    $XW= $Pos[2]
    $Y = $Pos[1]
    $YH= $Pos[3]
    $PosX = (($XW/2)+$X - ($Width/2))
    $PosY = ($Y - 20)
    $array[0] = $PosX
    $array[1] = $PosY
    return $array
EndFunc
[size="2"]The second mouse gets the cheese[/size]
Link to comment
Share on other sites

  • Moderators

JAFN,

Two problems:

- 1. You need to specify the GUI when you use ControlGetPos. You have not yet allowed the GUI to show, so AutoIt is not sure exactly what GUI to use. Just add the GUI handle to make it explicit. :)

- 2. You need to declare arrays before you assign values to the elements otherwise AutoIt does not know what how much meory to allocate - it cannot read your mind! :P

This works for me (look for the <<<<<< lines as usual):

#include <GUIConstantsEx.au3> ; <<<<<<<<<<<<<<<<<<
#include <array.au3>
#Include <GuiSlider.au3>

$Width  = 550
$Height = 600
$WinX   = 480
$WinY   = 400
$GUIid  = GUICreate("DropBeep", $Width, $Height, $WinX,  $WinY)
$slider = GUICtrlCreateSlider(333,114, 128, 20, $TBS_BOTH)
$ret    = Center($slider, 72)

$slider1FreqLabel = GUICtrlCreateInput("Testing", $ret[0], $ret[1], 128, 72)
GUICtrlSetBkColor($slider1FreqLabel, 0xffffff)

GUISetState() ; <<<<<<<<<<<<<<<<<<

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func Center($Cid, $Width)
    Local $array[2] ; <<<<<<<<<<<<<<<<<<
    $Pos = ControlGetPoS($GUIid,"",$Cid) ; <<<<<<<<<<<<<<<<<<
    $X = $Pos[0]
    $XW= $Pos[2]
    $Y = $Pos[1]
    $YH= $Pos[3]
    $PosX = (($XW/2)+$X - ($Width/2))
    $PosY = ($Y - 20)
    $array[0] = $PosX
    $array[1] = $PosY
    return $array
EndFunc

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

JAFN,

Thank you all for putting up with my questions. And answering so quickly.

My pleasure - it is what I am here for! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...