Sign in to follow this  
Followers 0
E1M1

Why doesnt my window manager display minimize, maximize and close button on titlebar?

3 posts in this topic

#1 ·  Posted (edited)

I am trying to write my own window manager, but I can not find out why minimize, maximize and close aren't visible until I move window out of screen and then drag back.

Could anyone tell me what should I do differently.

Zip file contains images and source below.

http://autoit.net.ee/downloads/windowmanager.zip

#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) + 26, $size[0], $size[1], $WS_POPUP)
            GUISetState(@SW_SHOW)
            $gui2 = GUICreate("", $size[2] - (2 * $BorderWidht), $size[3] - (2 * $BorderWidht), 0, 26, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
            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], $gui2)
            WinMove($captured[UBound($captured) - 1][0], "", -$BorderWidht, -$TitleHeight)
;~          WinActivate($captured[UBound($captured) - 1][0])
            ConsoleWrite("Title: " & $var[$i][0] & " Handle: " & $captured[UBound($captured) - 1][0] & @CRLF)
            TitlebarCreate($hGUI, $var[$i][0], 23, 3, 24, 18)
;~          WinSetTrans($gui2,"",128)
            WinSetTrans($hGUI,"",128)
        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)
    GUISwitch($hWnd)
    $pos = WinGetPos($hWnd)
    GUICtrlCreatePic(@ScriptDir & "\TitleBar.bmp", 0, 0, $pos[2], $height, BitOR($SS_NOTIFY, $WS_GROUP,$WS_CLIPSIBLINGS), $GUI_WS_EX_PARENTDRAG)
;~  GuiCtrlSetState(-1,$GUI_DISABLE)
    $captured[UBound($captured) - 1][3] = GUICtrlCreatePic(@ScriptDir & "\minimize.bmp", $pos[2] - 20 - ($buttonW * 3), $fromtop, $buttonW, $ButtonH,$WS_VISIBLE)
    $captured[UBound($captured) - 1][4] = GUICtrlCreatePic(@ScriptDir & "\maximize.bmp", $pos[2] - 17 - ($buttonW * 2), $fromtop, $buttonW, $ButtonH,$WS_VISIBLE)
    $captured[UBound($captured) - 1][5] = GUICtrlCreatePic(@ScriptDir & "\close.bmp", $pos[2] - 13 - ($buttonW), $fromtop, $buttonW, $ButtonH,$WS_VISIBLE)
    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
Edited by E1M1

edited

Share this post


Link to post
Share on other sites



E1M1,

There appears to be no relationship betwen the code you posted and the contents of the zip file you say has the source. Where, for example, is the raconfedit.eng.lng file? :)

If you want help, try and make it a bit easier, please. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Oh sorry. For some reason I copied wrong source. Thank you for notifying me. Post updated


edited

Share this post


Link to post
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
Sign in to follow this  
Followers 0