Closed hoppfrosch closed 12 years ago
This happens because the window isn't sized yet at that place since Gui, Show wasn't used yet. I've committed some changes that work around this by calling Gui, Show, Autosize every time a control is added before the GUI is first shown or a manual size gets set. Please test it and see if this behaves like you think it should.
Height and MaxSize not behaving properly was caused by invalid spaces in if ... in ... commands. I've also spotted a few others that I fixed, good that you noticed this!
Margin isn't added yet. Might do this later on, but I'll need to check the AHK source to find the correct values.
... fast response!
Will test it on monday.
First good news:
Mostly everything works as expected now (at least as I expected) ....
One thing I noticed yet:
;Example 1: MinSize not set
this.width :=400
this.height := 300
MsgBox % this.Width " - " this.Height
; Results in "400 - 300" <-- Correct values
;Example 2: Using Minsize ... (I want to display my GUI with MinSize on the beginning ...)
this.MinSize := "400x300"
this.width :=400
this.height := 300
MsgBox % this.Width " - " this.Height
; Results in "406 - 328" <-- These are obviously wrong values
;Example 3
this.MinSize := "400x300"
this.width :=500
this.height := 400
MsgBox % this.Width " - " this.Height
; Results in "500 - 400" <-- Correct!
I think there's a bug/inconsitency when calculating x and y under consideration of MinSize.x and Minsize.y - or do I get something wrong?
Further testing going on ...
Obviously there are still some errors when calculating the geometric properties.
Have a look at the following example: I want to center a progressbar within a fixed size window
SetBatchlines, -1
MyWindow := new CBasicWindow("ProgBar-Demo") ;Create an instance of this window class
Loop 1000
{
MyWindow.progBar.Value := A_Index
sleep 10
}
ExitApp
return
#include %A_ScriptDir%\lib
#include CGUI.ahk
Class CBasicWindow Extends CGUI
{
progBar := this.AddControl("Progress", "progBar", "", "Progress")
__New(Title)
{
this.Title := Title
this.width := 400
this.height := 300
this.CloseOnEscape := true
this.DestroyOnClose := true
this.Bordersize := 10
this.progBar.Min := 0
this.progBar.Max := 1000
this.progBar.Value := 0
this.progBar.x := this.Bordersize
this.progBar.y := this.Bordersize
this.progbar.Width := this.Width - 2 * this.Bordersize
this.progbar.Height := this.Height - 2 * this.Bordersize
MsgBox % this.progBar.x "-" this.progBar.y "-" this.progbar.Width "-" this.Height - 2 * this.Bordersize
; Results in "10-10-380-280" as expected
this.progBar.Style := 0x800000
;Show the window
this.Show("")
}
}
"Show"ing this window should result in a window with a centered progressbar (with a border of 10 pixels around progressbar). But ... all borders - except the upper border - are shown correctly. The progressbar is drawn "to high": the upper part of the progressbar is overdrawn with caption bar - the calculated y-coordinate is not applied correctly (as the progressbar is hidden in its upper part by caption bar of window) and the calculated height is also not applied correctly (as the distance of lower border of progressbar to windows border is correct - but the upper border of progressbar is hidden by caption bar) ...
It sounds like an issue with window/client coordinates.
I looked into it an this was indeed the issue. I've uploaded fixed files of CGUI and CControl that should consistently use client coordinates now.
Bug seems to be fixed now - though it needs some more intensive testing.
Thanks anyway ...
The geometry of the GUI (x,y,width,height) does not seem to be handled correctly. I tested with width and height (not with x and y yet) and do have following observations/remarks/bugs ...
Base Code from your CSharpGuiConverter.ahk:
1.) Initialization (Line 024) TestResult: MsgBox shows " 0 - 0 - 0 - "
2.) What are/should be the impacts of setting this.width (or height or x or y)? 2.a.) If width is not set by user (Omitting line 025): As the GUI contains already some controls (Line 002 ... Line 011) the GUI does have some default width (which seems to be correct - as the GUI is drawn to show all added controls). In this case this.width should be set to the "default value" (I would call it "calculated width") ... 2.b.) What should be the behaviour if this.width is set explictly? Should the size of the drawn GUI be "setted.width" - or "calculated width"? I think it has to be "setted.width" - which isn't the case yet. (Change line 027 to "this.Width := 801" and run the example - the drawn GUI has the same size as before, "this.Width" is unconsidered .... -> this seems to be a bug)
Coming back to 1.) this.Width should not show up as "0" in line 024 - better it should show up as "calculated width"
3.) this.width should always have a valid value. I would like to do something like this: (Nonsense example in context of example above - but demonstrates what I mean (for example: Placing a button in the lower left corner of GUI, width over the whole GUI)
BTW: as the GUI uses some default margin, it would be nice to have a Getter() for this value ... ;-) ( a Setter() would also be nice)
=> Summary: