Jump to content
Sign in to follow this  
Champak

GUI control customize

Recommended Posts

Champak

I know how to make the minimize and close button do something else. However, when I assign the minimize button to do something else, it activates the function I want, but it also STILL minimizes, which is what I don't want. Also, I don't know how to have the minimize button activate a specific function when the GUI is on one particular GUI. So if I have GUI A, B, C, and D, the minimize activates the function only when on GUI C.

Along with this I'd like to deactivate/gray out GUI C's close button so it doesn't do anything.

Share this post


Link to post
Share on other sites
Siao

#include <GUIConstants.au3>
#Include <GuiMenu.au3>

Const $SC_CLOSE = 0xF060
Const $SC_MINIMIZE = 0xF020

$hGuiA = GUICreate("Gui A", 200, 60)
$hGuiC = GUICreate("Gui C", 200, 60, -1, @DesktopHeight*0.6, -1, -1, $hGuiA)
$cBtnExit = GUICtrlCreateButton("Exit", 50, 20, 100, 30)
_GUICtrlMenu_RemoveMenu(_GUICtrlMenu_GetSystemMenu($hGuiC), 6) ;kill "Close" option

GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
GUISetState(@SW_SHOW, $hGuiA)
GUISetState(@SW_SHOW, $hGuiC)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cBtnExit
            Exit
    EndSwitch
WEnd

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    Switch BitAND($wParam, 0xFFF0)
        Case $SC_MINIMIZE
            If $hWnd = $hGuiC Then
                YourFunc()
                Return 0 ;don't minimize
            EndIf
        Case $SC_CLOSE
;~          If $hWnd = $hGuiC Then
;~              Return 0 ;don't close (stops ALT+F4 too)
;~          EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func YourFunc()
    MsgBox(0,'','Min')
EndFunc

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites
Champak

Thanks, it works great.

I tried looking up the help file to understand this, but couldn't find answers to the following questions.

1/ How did you get "6" as the number for the close button? I've been trying to find out the number that correlates with the minimize button for another GUI and tried 1-8, but none work.

2/ I've been meaning to ask this but never got around to it, what is "BitAND"? I don't understand the explanation the help file gives.

Thanks.

Edited by Champak

Share this post


Link to post
Share on other sites
Siao

1/ How did you get "6" as the number for the close button? I've been trying to find out the number that correlates with the minimize button for another GUI and tried 1-8, but none work.

6 is a zero based position of "Close" item in the menu.

If you open the menu of a AutoIt GUI by clicking the icon in the top left or whichever else method, you can easily see that (separator counts as an item too).

Another approach would be use _GUICtrlMenu_GetItemCount($hMenu)-1 instead of 6. That's assuming that "Close" is the last item of course. Which for some apps is not the case (AutoIt helpfile for example).

Could use _GUICtrlMenu_FindItem() too.

2/ I've been meaning to ask this but never got around to it, what is "BitAND"? I don't understand the explanation the help file gives.

Bit AND/OR/XOR operations perform boolean logic on all corresponding bits of input numbers. Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites
Champak

1/ I went another way, and got pretty much what I wanted, but I would still like to understand what you have here, because, I tried to find the minimize button with what you said and couldn't find it.

2/ I have no idea what that page you pointed me to said. It reads like rocket science...maybe I was just too sleepy, but even so, it still wouldn't make enough sense for me to understand and implement it. Anyone else have a more laymen explanation? I did a google search, but just came up with more rocket science.

Thanks.

Share this post


Link to post
Share on other sites
Siao

1)

#Include <GuiMenu.au3>

Run("Calc.exe")
WinWait("Calculator")
$hWin = WinGetHandle("Calculator")

If IsHWnd($hWin) Then
    $hMenu = _GUICtrlMenu_GetSystemMenu($hWin)
    $sList = ""
    For $i = 0 To _GUICtrlMenu_GetItemCount($hMenu)-1
        $sList &= $i & " = " & _GUICtrlMenu_GetItemText($hMenu, $i) & @CRLF
    Next
    ControlSend($hWin, "", "", "!{SPACE}")
    MsgBox(0,'Success',$sList)
Else
    MsgBox(0,'Error','Bad window handle, foo!')
EndIf

Exit

2) You don't need to understand these to use them, especially if you copy and paste.

Anyway, maybe this will help.

http://www.autoitscript.com/forum/index.ph...&pid=466668

Edited by Siao

"be smart, drink your wine"

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.