Code: Select all
; Create a Testwindow ...
Run, notepad.exe
WinWait, ahk_class Notepad, , 2
WinMove, ahk_class Notepad,, 10, 10, 300, 300
OutputDebug % "*********************** WINDOW CREATED *******************"
hWnd := WinExist("ahk_class Notepad")
tw := new TestIt(hwnd)
sleep 1000
OutputDebug % "*********************** CAPTION OFF **********************"
tw.style := "-0x00C00000" ; Remove the active window's title bar (WS_CAPTION).
sleep 1000
OutputDebug % "*********************** CAPTION ON ***********************"
tw.style := "+0x00C00000" ; Re-Add the active window's title bar (WS_CAPTION).
sleep 1000
OutputDebug % "*********************** DONE *****************************"
ExitApp
class TestIt {
style[] {
get {
hWnd := this._hwnd
WinGet, st, Style, ahk_id %hwnd%
OutputDebug % "|[" A_ThisFunc "([" this._hwnd "])] -> (" st ")"
return st
}
set {
hwnd := this._hwnd
WinGet, st, Style, ahk_id %hwnd%
OutputDebug % "...[" A_ThisFunc "([" this._hwnd "], style=" value ")] -> style BEFORE: " st
WinSet, Style, value, ahk_id %hwnd%
sleep 500
WinGet, st2, Style, ahk_id %hwnd%
OutputDebug % "...[" A_ThisFunc "([" this._hwnd "], style=" value ")] -> style AFTER: " st2
return value
}
}
__New(_hWnd) {
this._hWnd := _hWnd
return this
}
}
I try to remove and re-add the caption bar via property implementation unsing WinSet/WinGet.001 [9924] *********************** WINDOW CREATED *******************
002 [9924] *********************** CAPTION OFF **********************
003 [9924] ...[TestIt.style.set([0x1290d82], style=-0x00C00000)] -> style BEFORE: 0x14CF0000
004 [9924] ...[TestIt.style.set([0x1290d82], style=-0x00C00000)] -> style AFTER:
005 [9924] *********************** CAPTION ON ***********************
006 [9924] ...[TestIt.style.set([0x1290d82], style=+0x00C00000)] -> style BEFORE:
007 [9924] ...[TestIt.style.set([0x1290d82], style=+0x00C00000)] -> style AFTER:
008 [9924] *********************** DONE *****************************
Removing the caption bar works - but it isn't re-added again. Looking at the debug output (line 004) shows, that getting the window-style via WinGet after WinSet fails within my implementation ... and the style cannot retrieved via WinGet anymore (lines 006-007)
What's going wrong?