 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Zed Gecko
Joined: 23 Sep 2006 Posts: 149
|
Posted: Sat Jun 20, 2009 12:13 pm Post subject: [Solved]DLLCall(SetParent) problems with displaying windows |
|
|
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) _________________ code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795
Last edited by Zed Gecko on Tue Jun 23, 2009 3:39 pm; edited 1 time in total |
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Sat Jun 20, 2009 5:26 pm Post subject: |
|
|
i also tried:
assign the WS_CLIPCHILDREN style to the ahk_GUI
sending the WM_PAINT Message to the contained windows
assign the WM_CHILD style to the contained windows
all without success.
I´m out of options now and still got no clue. |
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Sun Jun 21, 2009 1:28 pm Post subject: |
|
|
| impatient *BUMP* |
|
| Back to top |
|
 |
YMP
Joined: 23 Dec 2006 Posts: 418 Location: Russia
|
Posted: Sun Jun 21, 2009 2:28 pm Post subject: |
|
|
| Z_Gecko wrote: | i also tried:
assign the WS_CLIPCHILDREN style to the ahk_GUI |
For me on XP SP2, WS_CLIPCHILDREN seems to solve the problem. Without that, the child is apparently painted over.
| Code: |
;Gui, 1: +E0x00010000L
Gui, +0x2000000 ; +WS_CLIPCHILDREN
Gui, 1:Show, x0 y0 w800 h600
Gui, 1:+LastFound
GUI_id := WinExist()
return
|
|
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Mon Jun 22, 2009 12:35 am Post subject: |
|
|
| Quote: | | For me on XP SP2, WS_CLIPCHILDREN seems to solve the problem. | thanks, that is interesting.
I will try to find me a XP-machine myself to try this out.
Does someone know why or how this happens.
And could someone test the script on other windows versions, please. |
|
| Back to top |
|
 |
Zed Gecko
Joined: 23 Sep 2006 Posts: 149
|
Posted: Tue Jun 23, 2009 3:39 pm Post subject: |
|
|
i finally got it to work properly:
| Code: | ; http://support.microsoft.com/kb/112181/en-us/
Gui, 1: +0x16000000 +Resize
;Gui, 1: +0x02000000L +Resize
Gui, 1: Show, x0 y0 w800 h600
Gui, 1: +LastFound
GUI_id := WinExist()
return
~^LButton::
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::
Winset, Redraw, , ahk_id %GUI_id%
tmp_cl_1 =
tmp_cl_2 =
loop, parse, capturelist, `n, `r
{
if (A_LoopField = "")
break
StringSplit, tmp_cl_, A_LoopField, -,
SendMessage, 0x0F, , , , ahk_id %tmp_cl_1% ; send WM_PAINT
Winset, Redraw, , ahk_id %tmp_cl_1%
; WinHide, ahk_id %tmp_cl_1%
; WinShow, ahk_id %tmp_cl_1%
}
;Winset, Redraw, , ahk_id %GUI_id%
Gui, 1: Restore
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
{
if (A_LoopField = "")
break
StringSplit, tmp_cl_, A_LoopField, -,
; WinSet, Style, -0x40000000, ahk_id %tmp_cl_1%
Set_Parent(tmp_cl_1, tmp_cl_2)
}
ExitApp
return |
googling for WS_CLIPCHILDREN i found this page: http://support.microsoft.com/kb/112181/en-us/
it says: | Quote: | | NOTE: Microsoft recommends that you always include the WS_VISIBLE, WS_CLIPSIBLINGS, and WS_CLIPCHILDREN styles in the new value. This means the value of nVal would always be at least 0x16000000. |
And exactly this did the trick. _________________ code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|