Sign in to follow this  
Followers 0
Zedna

System menu customize

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Nice work Zedna!!! :o

I've always wondered if it was possible to add menu function to the system menu :)


My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

Share this post


Link to post
Share on other sites

Nice work Zedna!!! :o

I've always wondered if it was possible to add menu function to the system menu :)

Thanks.

I have been using it in many of my projects for a long time.

I have sent _GUICtrlMenu_InsertMenu() UDF proposition to standard inlude files unfortunately it wasn't accepted.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

I know about that.

I have just created _GUICtrlMenu_InsertMenu() on the same basis as existing _GUICtrlMenu_AppendMenu()

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