Jump to content

Disable Minimize Button?


Recommended Posts

How do I disable the minimize button on a gui?

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Perhaps....

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$iStyle1 = BitOr($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU); Style with minimize box
$iStyle2 = BitOr($WS_MAXIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU); Style without minimize box

$gui = GUICreate('', 200, 200, -1, -1, $iStyle1)
$bt1 = GUICtrlCreateButton('Click me to enable', 5, 5, 120, 25)
$bt2 = GUICtrlCreateButton('Click me to disable', 5, 35, 120, 25)
GUISetState()

While 1
    $gm = GUIGetMsg()
    Switch $gm
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $bt1
            GUISetStyle($iStyle1)
        Case $bt2
            GUISetStyle($iStyle2)
    EndSwitch
WEnd
Link to comment
Share on other sites

Or you want do disable after a specified time you can use this code wrote by SmOke_N.

#include <WinAPI.au3>
$h_gui = GUICreate("Example GUI")
GUISetState()

$n_timer = TimerInit()
While GUIGetMsg() <> -3
    If $n_timer > 0 And TimerDiff($n_timer) / 1000 >= 3 Then
        _WinRemoveMinMaxBox($h_gui)
        $n_timer = 0
    EndIf
WEnd


Func _WinRemoveMinMaxBox($h_wnd)
    Local Const $GWL__STYLE = -16
    Local Const $WS__MAXIMIZEBOX = 0x0010000
    Local Const $WS__MINIMIZEBOX = 0x0020000
   
    If IsString($h_wnd) Then $h_wnd = WinGetHandle($h_wnd)
   
    Local $a_old_style = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $h_wnd, "int", $GWL__STYLE)
    If @error Then Return SetError(1, 0, 0)
   
    Local $i_style = 0
    If BitAND($a_old_style[0], $WS__MAXIMIZEBOX) Then $i_style = BitOR($i_style, $WS__MAXIMIZEBOX)
    If BitAND($a_old_style[0], $WS__MINIMIZEBOX) Then $i_style = BitOR($i_style, $WS__MINIMIZEBOX)
   
    If Not $i_style Then Return $a_old_style[0]
   
    Local $a_set_window = DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $h_wnd, "int", $GWL__STYLE, "long", $a_old_style[0] - $i_style)
    If @error Then Return SetError(2, 0, 0)
   
   ; Cheap way to refresh the title bar
    WinSetTitle($h_wnd, "", WinGetTitle($h_wnd))
   
    Return $a_set_window[0]
EndFunc

When the words fail... music speaks.

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