Skip to content

Commit

Permalink
Fixes #1, causes #4
Browse files Browse the repository at this point in the history
Fixes window resize affecting child windows.
Commit is for the best, but stops scrollbars showing on load until
resized.
  • Loading branch information
Clive Galway committed Feb 16, 2015
1 parent f2da6d2 commit 9ee4a91
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
21 changes: 19 additions & 2 deletions CGui.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,18 @@ class _CScrollGui extends _CGui {
OnMessage(WM_SIZE, fn, 999)
}

AdjustToParent(){
; AKA Window resized.
AdjustToParent(WParam:= 0, lParam := 0, Msg := 0, hwnd := 0){
Static SB_HORZ := 0, SB_VERT = 1
static SIF_PAGE := 0x2

if (hwnd = 0){
hwnd := this._hwnd
} else if (this._hwnd != hwnd){
; message not for this window
return
}
tooltip % this._hwnd
WindowRECT := this._GetClientRect()
CanvasRECT := this._GetClientSize()
Width := WindowRECT.Right
Expand Down Expand Up @@ -117,10 +125,18 @@ class _CScrollGui extends _CGui {
}
}

AdjustToChild(){
; AKA Child contents changed size
AdjustToChild(WParam := 0, lParam := 0, msg := 0, hwnd := 0){
Static SB_HORZ := 0, SB_VERT = 1
static SIF_ALL := 0x17

if (hwnd = 0){
hwnd := this._hwnd
} else if (this._hwnd != hwnd){
;MsgBox % "hwnd " this._hwnd " Rejecting HWND " Format("{:x}",hwnd)
return
}

WindowRECT := this._GetClientRect()
this._width := WindowRECT.Right
this._height := WindowRECT.Bottom
Expand Down Expand Up @@ -549,6 +565,7 @@ Class _CGui {
if (max != -1){
value := Substr(value, 1, percent-1)
value := round(( max / 100 ) * value)
ret.flags._haspercent := 1
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions demo - multiple scrollbars.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,30 @@ Class MyClass extends CWindow {
this.GUI_MAX_WIDTH := 500
this.GUI_COLUMN_2 := 300
this.Gui("Margin",5,5)

this.Gui("Show", "w500 h150","Scroll Demo")

this.Gui("Add", "Text", "Center xm ym w" this.GUI_MAX_WIDTH, "HWND: " this._hwnd)
;this.Gui("Add", "Text", "Center xm ym w" this.GUI_MAX_WIDTH, "HWND: " this._hwnd)
this.Gui("Add", "Text", "Center xm ym w100% ", "HWND: " this._hwnd)

this.ChildWindow1 := new CWindow(this, "-Border").GuiOption("+Parent", this)
this.Gui("Add", "Text", "Center xm y30 w" this.GUI_WIDTH, "HWND: " this.ChildWindow1._hwnd)
this.Gui("Add", "Text", "Center x0 y30 w45%", "HWND: " this.ChildWindow1._hwnd)
Loop 20 {
;this.ChildWindow1.Gui("Add", "Text", "Center xm w" this.GUI_WIDTH, "Text " A_Index)
;this.ChildWindow1.Gui("Add", "Text", "Center xm w50%", "Text " A_Index)
this.ChildWindow1.Gui("Add", "Text", "Center xm", "Text " A_Index)
}
this.ChildWindow1.Gui("Show", "x0 y50 w" this.GUI_WIDTH " h200")
this.ChildWindow1.AdjustToChild()

this.ChildWindow2 := new CWindow(this, "-Border").GuiOption("+Parent", this)
this.Gui("Add", "Text", "Center x" this.GUI_COLUMN_2 " y30 w" this.GUI_WIDTH, "HWND: " this.ChildWindow2._hwnd)
this.Gui("Add", "Text", "Center x50% y30 w50%", "HWND: " this.ChildWindow2._hwnd)
Loop 30 {
this.ChildWindow2.Gui("Add", "Text", "Center xm w" this.GUI_WIDTH, "Text " A_Index)
this.ChildWindow2.Gui("Add", "Text", "Center x0 w100%", "Text " A_Index)
}
this.ChildWindow2.Gui("Show", "x" this.GUI_COLUMN_2 " y50 w" this.GUI_WIDTH " h200")
this.ChildWindow2.AdjustToChild()
this.ChildWindow1.Gui("Show", "x0 y50 w45% h200")
this.ChildWindow1.AdjustToChild()

this.ChildWindow2.Gui("Show", "x55% y50 w45% h200")
this.ChildWindow2.AdjustToChild()

this.Gui("Show", "w500 h150","Scroll Demo")
}

SendMyString(){
Expand Down

0 comments on commit 9ee4a91

Please sign in to comment.