Jump to content

System menu customize


Zedna
 Share

Recommended Posts

Used main functions:

_GUICtrlMenu_GetSystemMenu

_GUICtrlMenu_InsertMenu

_GUICtrlMenu_AppendMenu

#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Global $hGUI, $hSysMenu, $iCount
Global Enum $idOptions = 1000, $idAbout

$hGUI = GUICreate("System Menu", 400, 300)

$hSysMenu = _GUICtrlMenu_GetSystemMenu($hGUI)
$iCount = _GUICtrlMenu_GetItemCount($hSysMenu)
; insert items before end
_GUICtrlMenu_InsertMenu ($hSysMenu, $iCount - 1, BitOr($MF_BYPOSITION, $MF_STRING), $idOptions, "&Options")
_GUICtrlMenu_InsertMenu ($hSysMenu, $iCount, BitOr($MF_BYPOSITION, $MF_SEPARATOR), 0, "")
; append items after end
_GUICtrlMenu_AppendMenu ($hSysMenu, $MF_SEPARATOR, 0, "")
_GUICtrlMenu_AppendMenu ($hSysMenu, $MF_STRING, $idAbout, "&About")

GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func Options()
    MsgBox(0, "Options","Options clicked")
EndFunc

Func About()
    MsgBox(0, "About","About clicked")
EndFunc

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iId = BitAnd($wParam, 0xFFFF)

    Select
        Case $iId = $idOptions
            Options()
        Case $iId = $idAbout
            About()
    EndSelect
EndFunc

Func _GUICtrlMenu_InsertMenu($hMenu, $iPosition, $iFlags, $iNewItem, $pNewItem)
    Local $aResult

    If BitAND($iFlags, $MF_BITMAP) = 0 Then
        $aResult = DllCall("User32.dll", "int", "InsertMenu", "hwnd", $hMenu, "int", $iPosition, "int", $iFlags, "int", $iNewItem, "str", $pNewItem)
    Else
        $aResult = DllCall("User32.dll", "int", "InsertMenu", "hwnd", $hMenu, "int", $iPosition, "int", $iFlags, "int", $iNewItem, "int", $pNewItem)
    EndIf
    If @error Then Return False
    _GUICtrlMenu_DrawMenuBarEx($hMenu)
    Return $aResult[0] <> 0
EndFunc   ;==>_GUICtrlMenu_InsertMenu
Edited by Zedna
Link to comment
Share on other sites

There is already a function to do that: _GUICtrlMenu_InsertMenuItem (but less options)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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