Jump to content

[Preview included] Need help with my window manager


E1M1
 Share

Recommended Posts

Hello.

I am trying to make window manager that would allow me to use third party themes. But I found some bugs that i cant find fix for. Could anyone be so nice and tell me how I could fix my bugs?

Bugs

1)All created windows gets minimized.

How do I edit my script so that only window received minimize click gets minimized?

2)$GUI_WS_EX_PARENTDRAG Doesnt work at all

Who Can I make $GUI_WS_EX_PARENTDRAG work again

3) when only last styled window looks nice, all other looks ugly. When nice looking window looses focus it turns ugly.

With ugly I meant that orange title bar gets replaced with random picture which is usually image of inactive title bar. Any fix for this?

Preview:

Posted Image

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

$var = WinList()
OnAutoItExitRegister("Release")
Dim $captured[1][7]
$TitleHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
$TitleHeight += _WinAPI_GetSystemMetrics($SM_CXFRAME)
$BorderWidht = _WinAPI_GetSystemMetrics($SM_CYFRAME)
For $i = 1 To $var[0][0]
    If $var[$i][0] <> "" And HasState($var[$i][1], 2) Then
        If $var[$i][0] <> "Program Manager" Then
            $size = WinGetPos($var[$i][0])
            ReDim $captured[UBound($captured) + 1][7]
            $hGUI = GUICreate($var[$i][0], $size[2]-(2*$BorderWidht), $size[3]-(2*$BorderWidht), $size[0], $size[1], BitOR($WS_POPUP, $WS_CLIPCHILDREN))
            TitlebarCreate($hGUI, $var[$i][0], 23, 3, 24, 18)
            GUISetState(@SW_SHOW)
            $captured[UBound($captured) - 1][6] = $hGUI
            $captured[UBound($captured) - 1][0] = $var[$i][1]
            $captured[UBound($captured) - 1][1] = _WinAPI_GetWindowLong($captured[UBound($captured) - 1][0], $GWL_STYLE)
            $captured[UBound($captured) - 1][2] = _WinAPI_GetWindowLong($captured[UBound($captured) - 1][0], $GWL_EXSTYLE)
            _WinAPI_SetWindowLong($captured[UBound($captured) - 1][0], $GWL_EXSTYLE, $WS_EX_MDICHILD)
            _WinAPI_SetWindowLong($captured[UBound($captured) - 1][0], $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
            _WinAPI_SetParent($captured[UBound($captured) - 1][0], $hGUI)
            WinMove($captured[UBound($captured) - 1][0], "", -$BorderWidht, -$TitleHeight +23)
            ConsoleWrite("Title: " & $var[$i][0] & " Handle: " & $captured[UBound($captured) - 1][0] & @CRLF)
        EndIf
    EndIf
Next

While 1
    $nmsg = GUIGetMsg()
    If $nmsg  = -3 Then Exit
    for $i = 0 To UBound($captured) -1
        If $captured[$i][3] = $nmsg Then WinSetState($captured[$i][6],"",@SW_MINIMIZE)
    Next
WEnd

Func HasState($handle, $iState)
    If BitAND(WinGetState($handle), $iState) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc   ;==>HasState

Func Release()
    For $i = 0 To UBound($captured) - 1
        _WinAPI_SetParent($captured[$i][0], 0)
        _WinAPI_SetWindowLong($captured[$i][0], $GWL_STYLE, $captured[$i][1])
        _WinAPI_SetWindowLong($captured[$i][0], $GWL_EXSTYLE, $captured[$i][2])
        WinActivate($captured[$i][0])
        WinMove($captured[$i][0], "", 0, 0)
    Next
EndFunc   ;==>Release

Func TitlebarCreate($hWnd, $Text, $height, $fromtop, $buttonW, $ButtonH)
    $pos = WinGetPos($hWnd)
    GUICtrlCreatePic(@ScriptDir & "\TitleBar.bmp", 0, 0, $pos[2], $height, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS),$GUI_WS_EX_PARENTDRAG)
    $captured[UBound($captured) - 1][3] = GUICtrlCreatePic(@ScriptDir & "\minimize.bmp", $pos[2] - 20 - ($buttonW * 3), $fromtop, $buttonW, $ButtonH)
    GUICtrlSetState(-1, $GUI_ONTOP)
    $captured[UBound($captured) - 1][4] = GUICtrlCreatePic(@ScriptDir & "\maximize.bmp", $pos[2] - 17 - ($buttonW * 2), $fromtop, $buttonW, $ButtonH)
    GUICtrlSetState(-1, $GUI_ONTOP)
    $captured[UBound($captured) - 1][5] = GUICtrlCreatePic(@ScriptDir & "\close.bmp", $pos[2] - 13 - ($buttonW), $fromtop, $buttonW, $ButtonH)
    GUICtrlSetState(-1, $GUI_ONTOP)
    GUICtrlCreateLabel($Text, 7, $fromtop,StringLen($Text)*11,Default,Default,$GUI_WS_EX_PARENTDRAG)
    GUICtrlSetBkColor(-1, -2)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
EndFunc   ;==>TitlebarCreate

Image files

autoit.pri.ee/downloads/manager.zip

Edited by E1M1

edited

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...