[program-l] Re: the code--with my idea

  • From: "Jamal Mazrui" <Jamal.Mazrui@xxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Wed, 4 Jan 2006 14:08:07 -0500

Tyler,
I am also learning AutoIt, so am personally interested in the issue of
placing controls.  In reviewing the draft of code you posted, it seems
that you are assuming that position coordinates are relative to the
screen, whereas for controls, they are relative to the parent window
instead--at least as I understand the documentation I have excerpted
below.  That documentation also suggests an easier way to place controls
by initially calling
Opt("GUISetCoordMode", 2)

Jamal

[Relevant documentation follows]

AutoItSetOption

Changes the operation of various AutoIt functions/parameters.

AutoItSetOption ( "option" [, param] )


Parameters
option  The option to change.  See Remarks.
param   [optional] The value to assign to the option.  The type and
meaning vary
by option.  See remarks below.  If the param is not provided, then the
function just returns the value already assigned to the option.  The
keyword
Default can be used for the parameter to reset the option to its default
value.


Return Value Returns the value of the previous setting for the option.


Remarks You may use Opt() as an alternative to AutoItSetOption().

AutoIt will halt with an error message if the requested option is
unknown.
Options are as follows:


Option  Param
...
GUICoordMode    Alters the position of a control defined by
GUICtrlSetPos.
1 = absolute coordinates (default) still relative to the dialog box.
0 = relative position to the start of the last control (upper left
corner).
2 = cell positionining relative to current cell. A -1 for left or top
parameter don't increment the start.
So next line is -1,offset; next cell is offset,-1; current cell is
-1,-1.

Obviously "offset" cannot be -1 which reserved to indicate the no
increment.
But if you can use a multiple of the width you choose to skip or go
back.

GUISetCoord

Sets absolute coordinates for next control.

GUISetCoord ( left, top [, width [, height [, winhandle]]] )


Parameters
left    The left side of the control.
top     The top of the control.
width   [optional] The width of the control (default is the previously
used
width).
height  [optional] The height of the control (default is the previously
used
height).
winhandle       [optional] Windows handle as returned by GUICreate
(default is the
previously used).


Return Value
Success:        Returns 1.
Failure:        Returns 0.


Remarks To be used specially in Opt ("GUICoordMode", 2). It allows you
to set
the current position to a precise point and from that position to create
controls by row (x_offset,-1) or by columns (-1, y_offset).


Related GUICtrlCreate...


Example

#include <GUIConstants.au3>

Opt ("GUICoordMode", 2) ; relative to cell mode

GUICreate ("My GUI Set Coord", 200, 100)
GUICtrlCreateCheckbox ("Check #1", 20, 10, 75)
GUICtrlCreateCheckbox ("Notify #2", 10, -1) ; next cell in the line

GUISetCoord(20,60)

GUICtrlCreateButton ("OK #3", -1,-1)
GUICtrlCreateButton ("Cancel #4", 10, -1)
GUICtrlSetState( -1, $GUI_FOCUS)

GUISetState ()       ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: