I was trying to make a cutrom titlebar with some extra features but I got stuck with a problem,
every time I use "Gui, titlebar%hwnd%: Show, AutoSize" it changes the location for gui, is there a bug or I'm doing it wrong?
Commenting "DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd)" fixes the problem but then gui wouldn't move or minimize with parent window.
Also small question about DllCall( "GetParent", "uint", hwnd) it's not supposed to work for ahk gui attached to another application?
Code: Select all
#SingleInstance force
Win_Hwnd := WinExist("ahk_exe Notepad.exe")
WinGetTitle, TitleToShow, ahk_id %Win_Hwnd%
WinGetPos,,,Win_W, Win_H
Gui, titlebar%Win_Hwnd%: New, +LastFound +AlwaysOnTop -Caption -Border +ToolWindow HWNDGui_Hwnd
Gui, Font, s7 c000060, Bold Verdana
Gui, Color, 808080
Gui, Margin, 1, 1
Gui, Add, Text, gGuiMove w84 r1, %TitleToShow%
Gui, Add, Text, gClose x+5, [X]
DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd)
;Gui, Add, Text, % "x+1 h0 w0 vP"
;GuiControlGet, P, Pos
; H := PY + PH
Gui, Show, % "x" Win_W/2 "y" Win_H/2
return
f12::
MouseGetPos,,, hwnd
Loop, 5
{
Gui, titlebar%hwnd%: Add, Text, x1 y+1 r1 W50, 1234567
}
Gui, titlebar%hwnd%: Show, AutoSize
Gui, titlebar%hwnd%: +hwndtitlebarshwnd
;WinSet, Redraw,, ahk_id %titlebarshwnd%
WinGetPos,win_x,win_y,Win_W, Win_H, ahk_id %titlebarshwnd%
MsgBox, % "win_x=" win_x " win_y=" win_y " win_W=" win_W " win_H=" win_H " titlebarshwnd=" titlebarshwnd
return
GuiMove:
PostMessage, 0xA1, 2,,, ahk_id %Gui_Hwnd%
return
Close:
StringTrimLeft, ParentHwnd, A_GUI, 8
WinClose, ahk_id %ParentHwnd%
ExitApp
return