Hi Titan,
I'll give it a try.
I tried all of your former PM'ed solutions for my problem. But none of them worked for me. So I made a dirty little workaround. I wonder if you already have seen it.
I changed back to v. 3.4.2 and added this little passage
Code:
Anchor(In_CtrlVar, In_Anchor, Draw = false)
{
; Thanks to Titan for this function (v3.4.2)
; Details under http://www.autohotkey.com/forum/topic4348.html
; In_CtrlVar : Controls associated variable (e.g. "MyEdit")
; In_Anchor : Anchors (x, y, w, h)
; Draw : true/1 to use MoveDraw otherwise leave blank for a normal Move
; store control positions and sizes in an internally parsable table-like format
static DataTbl
global ResetAnchor, DataTblCtrlList
If ResetAnchor
{
DataTbl =
StringSplit, CtrlListArray, DataTblCtrlList, `n
; Loop 12 times because of twelve controls in GuiSize label
Loop, %CtrlListArray0%
{
StringSplit, CtrlEntryArray, CtrlListArray%A_Index%, `,
GuiControlGet, CtrlPS, Pos, %CtrlEntryArray1%
Signtre = `n%A_Gui%:%CtrlEntryArray1%
PrsHlp = x.w.y.h./.7.%A_GuiWidth%.%A_GuiHeight%
StringSplit, PrsHlp, PrsHlp, .
Loop, 4
RelFact%A_Index% += !RegExMatch(CtrlEntryArray2, PrsHlp%A_Index% . "(?P<" . A_Index . ">[\d.]+)", RelFact)
If !InStr(DataTbl, Signtre)
DataTbl := DataTbl . Signtre . CtrlPSX - PrsHlp7 * RelFact1 . PrsHlp5 . CtrlPSW - PrsHlp7 * RelFact2
. PrsHlp5 . CtrlPSY - PrsHlp8 * RelFact3 . PrsHlp5 . CtrlPSH - PrsHlp8 * RelFact4 . PrsHlp5
}
ResetAnchor := false
}
; Retrieve control's size and position
GuiControlGet, CtrlPS, Pos, %In_CtrlVar%
; If control doesn't exist or this thread isn't called by a GUI event...
If !A_Gui or ErrorLevel
Return
; Create identifier for the control in the current window
Signtre = `n%A_Gui%:%In_CtrlVar%
; Period-delimited variable for parsing support
PrsHlp = x.w.y.h./.7.%A_GuiWidth%.%A_GuiHeight%
StringSplit, PrsHlp, PrsHlp, .
; Retrieve relative factors by RegEx and store them into "RelFact" array
Loop, 4
RelFact%A_Index% += !RegExMatch(In_Anchor, PrsHlp%A_Index% . "(?P<" . A_Index . ">[\d.]+)", RelFact)
; If current signature is not found in the data table, concatenate each value
; subtracted by the gui width for x/w or height for y/h and multiplied by it's factor.
If !InStr(DataTbl, Signtre)
DataTbl := DataTbl . Signtre . CtrlPSX - PrsHlp7 * RelFact1 . PrsHlp5 . CtrlPSW - PrsHlp7 * RelFact2
. PrsHlp5 . CtrlPSY - PrsHlp8 * RelFact3 . PrsHlp5 . CtrlPSH - PrsHlp8 * RelFact4 . PrsHlp5
; For each of the four possible anchors (again):
Loop, 4
If InStr(In_Anchor, PrsHlp%A_Index%)
{
; Alias for the Loop index
LoopIdx = %A_Index%
; For x/w, PrsHlp6 equals to the GUI width, otherwise height
PrsHlp6 += !cx AND (cx := LoopIdx > 2)
; This regular expression assigns the variable CtrlPS1 to the absolute dimension
; stored in the data table:
RegExMatch(DataTbl, Signtre . "(?:(-?[\d.]+)/){" . LoopIdx . "}", CtrlPS)
; Concatenate the new value and it's anchor to the variable 'NewVal':
NewVal := NewVal . PrsHlp%LoopIdx% . CtrlPS1 + PrsHlp%PrsHlp6% * RelFact%LoopIdx%
}
; If Draw is true use GuiControl, MoveDraw instead of normal GuiControl, Move
If Draw
GCtrlMv = Draw
; Update the positions of the control
GuiControl, Move%GCtrlMv%, %In_CtrlVar%, %NewVal%
}
CtrlListArray is listed in BBCodeEditor.ahk and contains:
Code:
; List of Gui controls of MainGUI to rebuild DataTbl within Anchor function -> functions.ahk
DataTblCtrlList =
(Ltrim
EdtComment,wh
GrpMenuBorder,w
GrpCstmBorder,w
BtnCustomize,x
ChkSig,y
DDLSig,y
BtnEditSig,y
BtnDelSig,y
BtnSend,xy
BtnPreview,xy
BtnReset,xy
BtnPinned,x
)
When I want to reset positions I switch the 'ResetAnchor' variable to 'true' and Anchor rereads the complete 'DataTbl' variable. I wonder what you think about it.
______________________
Cheers AGU