Sign in to follow this  
Followers 0
YellowLab

Disable / Enable Minimization

4 posts in this topic

#1 ·  Posted (edited)

Doing a search I found this OLD (2006) topic:

http://www.autoitscript.com/forum/index.php?showtopic=35748

This is exactly what I am seeing - using version 3.2.12 and this code:

$hMain=GuiCreate("Main",100,100,100,100)
$hButton = GUICtrlCreateButton("Open",0,0,50,20)

$hSecond=GUICreate("Second",50,50,125,125)
$hSButton=GUICtrlCreateButton("Close",0,0,50,20)

GUISetState(@SW_SHOW,$hMain)

While 1
    $nMSG = GUIGetMsg()
    Switch $nMSG
        Case -3
            Exit
        Case $hButton
            GUISetState(@SW_DISABLE,$hMain)
            GUISetState(@SW_SHOW,$hSecond)
        Case $hSButton
            GUISetState(@SW_HIDE,$hSecond)
            GUISetState(@SW_ENABLE,$hMain)
    EndSwitch
WEnd

modifying it to

Case $hSButton

GUISetState(@SW_HIDE,$hSecond)

GUISetState(@SW_ENABLE,$hMain)

GUISetState(@SW_RESTORE,$hMain)

causes the GUI to flicker - not so bad in this small example, but very noticeable in larger GUI's. Any ideas on how to fix it?

Thanks,

Bob

Edited by YellowLab

You can't see a rainbow without first experiencing the rain.

Share this post


Link to post
Share on other sites



Look here at concept (unfortunatelly not working for me):

#include <GUIConstants.au3>

;~ Const $SC_CLOSE = 0xF060
Const $MF_BYCOMMAND = 0x0
;~ Const $MF_GRAYED = 0x1
;~ Const $WM_SYSCOMMAND = 0x0112

$gui = GuiCreate("Catch the Minimize Click", 300, 100)
GUISetState()
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

$hMenu = DllCall("user32.dll", "hwnd", "GetSystemMenu", "hwnd", $gui, "int", 0)
;~ DllCall("user32.dll","hwnd","DeleteMenu", "hwnd", $hMenu[0], "int",$SC_MINIMIZE, "int", $MF_BYCOMMAND)
DllCall("user32.dll","hwnd","EnableMenuItem", "hwnd", $hMenu[0], "int",$SC_MINIMIZE, "int", BitOr($MF_BYCOMMAND,$MF_GRAYED))

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

; to disable minimize hotkeys
Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFF0) = $SC_MINIMIZE Then Return
EndFunc

original post about "X button disable":

http://www.autoitscript.com/forum/index.ph...st&p=423242

Share this post


Link to post
Share on other sites

ellowLab

Strange... I don't see any flickering :mellow:

Share this post


Link to post
Share on other sites

Okay, so I figured it out - not so difficult really:

$hMain=GuiCreate("Main",100,100,100,100)
$hButton = GUICtrlCreateButton("Open",0,0,50,20)

$hSecond=GUICreate("Second",50,50,125,125)
$hSButton=GUICtrlCreateButton("Close",0,0,50,20)

GUISetState(@SW_SHOW,$hMain)

While 1
    $nMSG = GUIGetMsg()
    Switch $nMSG
        Case -3
            Exit
        Case $hButton
            GUISetState(@SW_DISABLE,$hMain)
            GUISetState(@SW_SHOW,$hSecond)
        Case $hSButton
            GUISetState(@SW_ENABLE,$hMain)
            GUISetState(@SW_HIDE,$hSecond)
    EndSwitch
WEnd

The first window must be enabled before the second window is hidden. Doing it this way makes everything good.

Bob


You can't see a rainbow without first experiencing the rain.

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