When i display other top-level windows in an AHK-GUI,
severe displaying/redrawing problems occur on the contained windows.
The happen randomly
when either the contained or the containing windows are resized, minimized or restored.
i tried several workarounds (e.g
Winset, Redraw or adding the
WS_CHILD-style to the contained windows) but nothing solved this problem completely.
this script "adds" other windows to it´s own GUI,
when you Ctrl-Click on the windows TitleBar.
It "releases" them when close the AHK-GUI.
Pressing Ctrl+1 will start some of the fixes i tried:
Code:
;Gui, 1: +E0x00010000L
Gui, 1: Show, x0 y0 w800 h600
Gui, 1: +LastFound
GUI_id := WinExist()
return
~^LButton:: ;add the window under the mouse to the ahk-GUI
hk_result =
CoordMode, Mouse, Screen
MouseGetPos, hk_x, hk_y, hk_id, hk_control
if IsOverTitleBar(hk_x, hk_y, hk_id)
{
hk_result := Set_Parent(hk_id, GUI_id)
if (hk_result = "")
return
else
{
; WinSet, Style, +0x40000000, ahk_id %hk_id%
capturelist .= hk_id . "-" . hk_result . "`n`r"
Gui, 1: Show
}
}
return
^1:: ; try to fix the redrawing problem
Winset, Redraw, , ahk_id %GUI_id%
tmp_cl_1 =
tmp_cl_2 =
loop, parse, capturelist, `n, `r
{
StringSplit, tmp_cl_, A_LoopField, -,
Winset, Redraw, , ahk_id %tmp_cl_1%
; WinHide, ahk_id %tmp_cl_1%
; WinShow, ahk_id %tmp_cl_1%
}
return
Set_Parent(Child_Handle, Parent_Handle)
{
Return DllCall( "SetParent", "uint", Child_Handle, "uint", Parent_Handle ) ; success = handle to previous parent, failure =null
}
IsOverTitleBar(x, y, hWnd)
{
SendMessage, 0x84,, (x & 0xFFFF) | (y & 0xFFFF) << 16,, ahk_id %hWnd%
if ErrorLevel in 2,3,8,9,20,21
return true
else
return false
}
GuiClose:
tmp_cl_1 =
tmp_cl_2 =
loop, parse, capturelist, `n, `r
{
StringSplit, tmp_cl_, A_LoopField, -,
; WinSet, Style, -0x40000000, ahk_id %tmp_cl_1%
Set_Parent(tmp_cl_1, tmp_cl_2)
}
ExitApp
return
Does anybody know, why it happens or how it can be solved?
(i´m running on Win2K here, not tested on other versions)