Jump to content

Modify Window Style of Foreign Window - add minimize button


Knight
 Share

Recommended Posts

You can't add buttons to an external program GUI, however you could possibly make a separate tool window with buttons to minimize and maximize the GUI. It may even be possible to somehow float an image over the top right hand corner of the original window and click on that. That's a bit too complicated for me though.

Edited by czardas
Link to comment
Share on other sites

This.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Constants.au3>

Global $Check = False

$hGui = GuiCreate("Change/UnChange WS_MAXIMIZEBOX",250,30)
$iAction = GuiCtrlCreateButton("Remove WS_MAXIMIZEBOX to Calc",0,0,250,30)
GuiSetState()

Run("Calc.exe")
WinWait("[CLASS:CalcFrame]")
$hWinHandle = WingetHandle("[CLASS:CalcFrame]")
$dwStyle = _WinApi_getwindowlong($hWinHandle, $GWL_STYLE)

While True
    $iMsg = GuiGetMsg()
    Switch $iMsg
        case - 3
            WinClose($hWinHandle)
            Exit
        case $iAction
            If $check = false Then
            _WinAPI_SetWindowLong($hWinHandle, $GWL_STYLE, BitAND($dwStyle, $WS_MAXIMIZEBOX))
            $check = Not $check
        Else
            _WinAPI_SetWindowLong($hWinHandle, $GWL_STYLE, $dwStyle)
            $check = Not $check
        EndIf
    EndSwitch
WEnd

The Bug is because the style changing is a little more complicated, but not too much.

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...