欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基 礎(chǔ) 函 數(shù) 參 考


GUICtrlCreateContextMenu

創(chuàng)建控件或 GUI 的上下文菜單.

GUICtrlCreateContextMenu ( [控件ID] )

參 數(shù)

控件ID [可選參數(shù)] 由 GUICtrlCreate... 返回的控件標(biāo)識符

返 回 值

成功: 返回控件標(biāo)識符(控件ID).
失敗: 返回 0.

備 注

使用本函數(shù)創(chuàng)建右鍵菜單的主控件, 每個菜單項使用 GUICtrlCreateMenuItem 函數(shù)創(chuàng)建.
子菜單則使用 GUICtrlCreateMenu 函數(shù)創(chuàng)建.

若參數(shù)為空或 -1, 則創(chuàng)建的右鍵菜單將關(guān)聯(lián)整個 GUI 窗口, 而不是個別控件l.

每個控件只能設(shè)置一個右鍵菜單. 因此要創(chuàng)建新的右鍵菜單則必須先刪除現(xiàn)有的菜單.

注意: 不能為本身已有系統(tǒng)右鍵菜單的控件創(chuàng)建右鍵菜單, 比如 編輯框/輸入控件等.

相 關(guān) 函 數(shù)

GUICtrlCreateMenuItem, GUICtrlCreateMenu, GUICtrlGetHandle, GUICtrlSetState, GUICtrlDelete

函 數(shù) 示 例


#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

;Example1()
Example2()

; ****************
; * 示例 1 *
; ****************
Func Example1()
    ;右鍵點擊窗口彈出右鍵菜單.
    ;右鍵點擊"確定"按鈕,彈出控件特定右鍵菜單.

    GUICreate("我的上下文菜單 GUI", 300, 200)

    Local $contextmenu = GUICtrlCreateContextMenu()

    Local $button = GUICtrlCreateButton("確定", 100, 100, 70, 20)
    Local $buttoncontext = GUICtrlCreateContextMenu($button)
    GUICtrlCreateMenuItem ("關(guān)于按鈕", $buttoncontext)

    Local $newsubmenu = GUICtrlCreateMenu("新建", $contextmenu)
    GUICtrlCreateMenuItem ("文本", $newsubmenu)

    GUICtrlCreateMenuItem ("打開", $contextmenu)
    GUICtrlCreateMenuItem ("保存", $contextmenu)
    GUICtrlCreateMenuItem ("", $contextmenu) ; 分隔線

    GUICtrlCreateMenuItem ("信息", $contextmenu)

    GUISetState()

    ; 運行 GUI, 直到 GUI 被關(guān)閉
    While 1
        Local $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
EndFunc   ;==>Example1


; *****************
; * 示例 2 *
; *****************
Func Example2()
    Local $hGui, $OptionsBtn, $OptionsDummy, $OptionsContext, $msg
    Local $OptionsExit, $HelpBtn, $HelpDummy, $HelpContext, $HelpAbout
    $hGui = GUICreate("我的上下文菜單 GUI", 170, 40)

    $OptionsBtn = GUICtrlCreateButton("選項 &O", 10, 10, 70, 20, $BS_FLAT)

    ; 創(chuàng)造一個虛擬的"選項"控件,并添加左鍵菜單
    $OptionsDummy = GUICtrlCreateDummy()
    $OptionsContext = GUICtrlCreateContextMenu($OptionsDummy)
    GUICtrlCreateMenuItem ("常規(guī)", $OptionsContext)
    GUICtrlCreateMenuItem ("文件", $OptionsContext)
    GUICtrlCreateMenuItem ("", $OptionsContext)
    $OptionsExit = GUICtrlCreateMenuItem ("退出", $OptionsContext)


    $HelpBtn = GUICtrlCreateButton("幫助 &H", 90, 10, 70, 20, $BS_FLAT)

    ; 創(chuàng)造一個虛擬的"幫助"控件,并添加左鍵菜單
    $HelpDummy = GUICtrlCreateDummy()
    $HelpContext = GUICtrlCreateContextMenu($HelpDummy)
    GUICtrlCreateMenuItem ("網(wǎng)站", $HelpContext)
    GUICtrlCreateMenuItem ("", $HelpContext)
    $HelpAbout = GUICtrlCreateMenuItem ("關(guān)于...", $HelpContext)


    GUISetState()

    While 1
        $msg = GUIGetMsg()

        Switch $msg
            Case $OptionsExit, $GUI_EVENT_CLOSE
                ExitLoop

            Case $OptionsBtn
                ShowMenu($hGui, $msg, $OptionsContext)

            Case $HelpBtn
                ShowMenu($hGui, $msg, $HelpContext)

            Case $HelpAbout
                MsgBox(64, "關(guān)于...", "GUICtrlGetHandle-Sample")
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example2


; 顯示特定 GUI 控件的菜單
Func ShowMenu($hWnd, $CtrlID, $nContextID)
    Local $arPos, $x, $y
    Local $hMenu = GUICtrlGetHandle($nContextID)

    $arPos = ControlGetPos($hWnd, "", $CtrlID)

    $x = $arPos[0]
    $y = $arPos[1] + $arPos[3]

    ClientToScreen($hWnd, $x, $y)
    TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc   ;==>ShowMenu


; 轉(zhuǎn)換用戶(GUI)座標(biāo)到屏幕(桌面)座標(biāo)
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")

    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))

    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; 不必真正需要釋放數(shù)據(jù)結(jié)構(gòu),因為它只是一個局部結(jié)構(gòu)
    $stPoint = 0
EndFunc   ;==>ClientToScreen


; 在給定坐標(biāo)(x,y)上顯示屬于給定 GUI 窗口的彈出菜單
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc   ;==>TrackPopupMenu

provider with jb51.net (unicode)