#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("_WinSetStyle Demo", 260, 100) $nSetStyle_Button = GUICtrlCreateButton("Set Style", 45, 50, 150, 20) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $nSetStyle_Button If BitAND(_WinGetStyle($hGUI), $WS_CAPTION) = $WS_CAPTION Then _WinSetStyle($hGUI, BitOR($WS_POPUP, $WS_BORDER)) GUICtrlSetData($nSetStyle_Button, 'Undo Style') Else _WinSetStyle($hGUI, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) GUICtrlSetData($nSetStyle_Button, 'Set Style') EndIf EndSwitch WEnd Func _WinSetStyle($hWnd, $nStyle = -1, $nExStyle = 0) Local Const $GWL_STYLE = -16, $GWL_EXSTYLE = -20 Local Const $SWP_NOMOVE = 0x2, $SWP_NOSIZE = 0x1, $SWP_SHOWWINDOW = 0x40, $SWP_NOZORDER = 0x4 Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) If $nStyle = -1 Then $nStyle = BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) EndIf DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $nStyle) DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $nExStyle) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", $iFlags) EndFunc Func _WinGetStyle($hWnd, $iIndex=0) Local Const $GWL_STYLE = -16, $GWL_EXSTYLE = -20 Local $iGWL_Index = $GWL_STYLE If $iIndex > 0 Then $iGWL_Index = $GWL_EXSTYLE EndIf Local $aStyles = DllCall('User32.dll', 'long', 'GetWindowLong', 'hwnd', $hWnd, 'int', $iGWL_Index) Return $aStyles[0] EndFunc |