Jump to content

Add to context menu?


PantZ4
 Share

Recommended Posts

For modifying system menu are these API functions:

GetSystemMenu, InsertMenu

But for modiy external app look at ANYGUI UDF

Here is modification system menu in AutoIt GUI:

#include <GUIConstants.au3>

Global Const $WM_SYSCOMMAND = 0x0112
Global Const $MF_BYPOSITION = 0x0400
Global Const $MF_SEPARATOR  = 0x0800

$Form1 = GUICreate("Test", 300, 200)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

CreateSystemMenuItem("")
$nItem_about = CreateSystemMenuItem("About")

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

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    $nID = BitAnd($wParam, 0xFFFF)
    If $nID = $nItem_about Then About()
EndFunc

Func About()
    MsgBox(64, "About","Test 1.0" & @CRLF & @CRLF & _
        "Zedna" & @CRLF & _
        "AutoIt")
EndFunc

Func GetSystemMenu($hWnd, $bRevert = 0)
    Local $hMenu = DllCall("user32.dll", "hwnd", "GetSystemMenu", _
                                                "hwnd", $hWnd, _
                                                "int", $bRevert)
    Return $hMenu[0]
EndFunc

Func InsertMenu($hMenu, $nPosition, $nFlags, $nIDNewItem, $lpNewItem)
    Local $nResult = DllCall("user32.dll", "int", "InsertMenu", _
                                                "hwnd", $hMenu, _
                                                "int", $nPosition, _
                                                "int", $nFlags, _
                                                "int", $nIDNewItem, _
                                                "str", $lpNewItem)
    Return $nResult[0]
EndFunc

Func CreateSystemMenuItem($sText, $hMenu = -1)
    If $hMenu = -1 Then $hMenu = GetSystemMenu($Form1)

    Local $nID = GUICtrlCreateDummy()
    Local $nFlags = 0

    If $sText = "" Then $nFlags = $MF_SEPARATOR
    $nFlags = BitOr($MF_BYPOSITION, $nFlags)
        InsertMenu($hMenu, 0xFFFFFFFF, $nFlags, $nID, $sText)
    Return $nID
EndFunc
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...