Re: gui message problems
"valery_vi" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
damien,
This is not hard to make layout of control in GUI, I think.
I make it manually by the following empirical "method"
1. Height of control is about 30 pixels.
2. Width of control is the length of textual content. So for example
to make label "This is an example" I would set width - 250 or 300
pixels.
3. Left margin - 10 pixels
4. Y coordinate - Y coordinate of control above + maybe 10 pixels.
Thus we can make layout ie of two controls:
1. Label "This is an example":
10, 10, 250, 30
These give us:
$Label = GUICtrlCreateLabel("What Note Is This?", 10, 10, 250, 30)
2. Radio "Music Machine":
Left margin - 10
Y coordinate = 10 (previous Y) + 30 = 40
Width - 200
Height - 30
So we will get:
10, 40, 200, 30
These give us:
$Radio1 = GUICtrlCreateRadio("Music Machine", 10, 40, 200, 30)
2. Radio "My Music":
Left margin - 10
Y coordinate = 40 (previous Y) + 30 = 70
Width - 200
Height - 30
So we will get:
10, 40, 200, 30
These give us:
$Radio2 = GUICtrlCreateRadio("My Music", 10, 70, 200, 30)
The second radio is the same as previous apart from it's Y position.
And so on...
I should add about GUI window. Width of window should be greater
than longest control + it's left margin. We have here Label - "What
Note Is This?". Length - 250 pixels. So I would create GUI with
width 270 = Length + 20 (two left margins of longest control) and
for example with 400 pixels in Height
I should insert builded GUI constants by
#include <GUIConstants.au3>
Thus we will have the following:
#include <GUIConstants.au3>
$hWnd = GUICreate ("Easy GUI", 270, 400)
$Label = GUICtrlCreateLabel("What Note Is This?", 10, 10, 100, 30)
$Radio1 = GUICtrlCreateRadio("Music Machine", 10, 40, 200, 30)
$Radio2 = GUICtrlCreateRadio("My Music", 10, 70, 200, 30)
The last thing which we need is to add magic "command" to show this
GUI and main loop to get messages from Windows System:
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Thus we have written this Easy GUI.
#include <GUIConstants.au3>
$hWnd = GUICreate ("Easy GUI", 270, 400)
$Label = GUICtrlCreateLabel("What Note Is This?", 10, 10, 100, 30)
$Radio1 = GUICtrlCreateRadio("Music Machine", 10, 40, 200, 30)
$Radio2 = GUICtrlCreateRadio("My Music", 10, 70, 200, 30)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Best wishes from Russia,
Valery
--- In [email protected], "damien c. sadler" <necdet@...>
wrote:
>
> this is almost the same as what i use, but because i'm visually
impaired i find it hard to know what positions to put the gui on the
screen, and this lbc.au3 library does it for me, so i'm using that,
which is very similar to what you just did. i can't understand why
it's stating that there's no wend statement when there is.
>
> but as you can do gui positioning ok i'll try this method.
>
> thanks.
>
> regards,
>
> damien
>
>
> ----- Original Message -----
> From: valery_vi
> To: [email protected]
> Sent: Monday, December 04, 2006 6:11 AM
> Subject: [AutoIt] Re: gui message problems
>
>
> This one works fine for me:
>
> #include <GUIConstants.au3>
> $hGUI = GUICreate("Test", 400, 300)
>
> $mm=GUICtrlCreateRadio("Music Machine", 10, 0, 100, 30)
> $wnit=GUICtrlCreateRadio("What Note Is This?", 10, 30, 100, 30)
> $simon=GUICtrlCreateRadio("Simon", 10, 60, 100, 30)
> $fkey=GUICtrlCreateRadio("fire key", 10, 90, 100, 30)
> $mbi=GUICtrlCreateRadio("musical bop it", 10, 120, 100, 30)
> $mbox=GUICtrlCreateRadio("music box", 10, 150, 100, 30)
> $ok=GUICtrlCreateButton("&ok", 10, 180, 100, 30)
> $ccl=GUICtrlCreateButton("e&xit", 10, 210, 100, 30)
> GUISetState()
> while 1
> $msg=guigetmsg()
> if $msg=$ccl or $msg=$gui_event_close then exit
> if $msg=$ok then read_choice()
> wend
>
> func read_choice()
> if guictrlread($mm)=$gui_checked then music_machine()
> if guictrlread($wnit)=$gui_checked then what_note_is_this()
> if guictrlread($simon)=$gui_checked then simon()
> if guictrlread($fkey)=$gui_checked then firekey()
> if guictrlread($mbi)=$gui_checked then musical_bop()
> if guictrlread($mbox)=$gui_checked then music_box()
> endfunc
>
> Valery
>
> --- In [email protected], "damien c. sadler" <necdet@>
> wrote:
> >
> > hi guys,
> >
> > could you look at this code and tell me what the problem is? i
> keep getting an error telling me that there's no wend statement
when
> i know there is:
> > btw i'm using jamal mazrui's layout by code library to help
with
> gui placement.
> >
> >
> > func prompt()
> > _LBCCreate("choose activity:")
> > $mm=_LBCCtrlCreateRadio("Music Machine")
> > $wnit=_LBCCtrlCreateRadio("What Note Is This?")
> > $simon=_LBCCtrlCreateRadio("Simon")
> > $fkey=_LBCCtrlCreateRadio("fire key")
> > $mbi=_LBCCtrlCreateRadio("musical bop it")
> > $mbox=_LBCCtrlCreateRadio("music box")
> > $ok=_LBCCtrlCreateButton("&ok")
> > $ccl=_LBCCtrlCreateButton("e&xit")
> > _LBCShow()
> > while 1
> > $msg=guigetmsg()
> > if $msg=$ccl or $msg=$gui_event_close then exit
> > if $msg=$ok then read_choice()
> > wend
> > endfunc
> > func read_choice()
> > if guictrlread($mm)=$gui_checked then music_machine()
> > if guictrlread($wnit)=$gui_checked then what_note_is_this()
> > if guictrlread($simon)=$gui_checked then simon()
> > if guictrlread($fkey)=$gui_checked then firekey()
> > if guictrlread($mbi)=$gui_checked then musical_bop()
> > if guictrlread($mbox)=$gui_checked then music_box()
> > endfunc
> >
> >
> >
> > thanks.
> >
> > regards,
> >
> > damien
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>