JAFN Posted April 2, 2011 Share Posted April 2, 2011 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 More sharing options...
Rogue5099 Posted April 3, 2011 Share Posted April 3, 2011 Check out ControlGetPos. My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
JAFN Posted April 3, 2011 Author Share Posted April 3, 2011 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 More sharing options...
JAFN Posted April 3, 2011 Author Share Posted April 3, 2011 Could *not* have been better named [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
JAFN Posted April 3, 2011 Author Share Posted April 3, 2011 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 More sharing options...
somdcomputerguy Posted April 3, 2011 Share Posted April 3, 2011 So what is the error? A lot of times, an error message will point you in the right direction to start. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2011 Moderators Share Posted April 3, 2011 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! 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 EndFuncAll clear? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JAFN Posted April 3, 2011 Author Share Posted April 3, 2011 Thank you. I see exactly how I twisted myself up. Thank you all for putting up with my questions. And answering so quickly. [size="2"]The second mouse gets the cheese[/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2011 Moderators Share Posted April 3, 2011 JAFN,Thank you all for putting up with my questions. And answering so quickly.My pleasure - it is what I am here for! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now