一个FROM 使用两个GUICtrlCreateDummy() 如何使两个 都有作用??[已解决]
本帖最后由 kk_lee69 于 2016-6-19 20:36 编辑一个FROM 使用两个GUICtrlCreateDummy() 如何使两个GUICtrlCreateDummy() 都有作用??
如 范例如何使 两个GUICtrlCreateDummy()的控件 在 WM_COMMAND 可以区分开来互不影响
#include <Constants.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
DIM $hEnter,$hF1
$A=GUICreate("設置快捷方式", 225, 80)
GUICtrlCreateLabel("請選擇一個按鈕.", 10, 10)
$Yes = GUICtrlCreateInput("", 10, 50, 200, 25)
; 設置按鈕控制項的加速鍵, 這裡是 Ctrl + y 和 Ctrl + n
Local $aAccelKeys = [["{ENTER}", $hEnter]]
Local $bAccelKeys = [["{F1}", $hF1]]
Global $iEnter = GUICtrlCreateDummy()
Global $iEnter2 = GUICtrlCreateDummy()
$hEnter = GUICtrlGetHandle($iEnter)
$hF1 = GUICtrlGetHandle($iEnter2)
GUISetAccelerators($aAccelKeys,$A);
GUISetAccelerators($bAccelKeys,$A);
GUISetState(@SW_SHOW) ; 顯示 GUI.
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
MsgBox($MB_SYSTEMMODAL, "你選擇了", "關閉")
ExitLoop
EndSwitch
WEnd
GUIDelete() ; 刪除 GUI.
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam, $ilParam
Local $hWndFrom, $iIDFrom, $iCode
$hWndFrom = $hWnd
$iCode = _WinAPI_HiWord($iwParam);獲取高位 $iMsg = BitShift($iwParam, 16)
$iIDFrom =_WinAPI_LoWord($iwParam);獲取低位 $iControl = BitAND($iwParam, 0xFFFF)
Switch $ilParam
Case $hEnter;虛擬控制項消息觸發收到回車消息才觸發
ConsoleWrite("回車"&@CRLF)
Case $hF1
ConsoleWrite("F1"&@CRLF)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_COMMAND
#include <Constants.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
$A = GUICreate("設置快捷方式", 225, 80)
GUICtrlCreateLabel("請選擇一個按鈕.", 10, 10)
$Yes = GUICtrlCreateInput("", 10, 50, 200, 25)
Global $iEnter = GUICtrlCreateDummy()
Global $iEnter2 = GUICtrlCreateDummy()
; 設置按鈕控制項的加速鍵, 這裡是 Ctrl + y 和 Ctrl + n
Local $aAccelKeys = [["{ENTER}", $iEnter], ["{F1}", $iEnter2]]
GUISetAccelerators($aAccelKeys, $A) ;
GUISetState(@SW_SHOW) ; 顯示 GUI.
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
MsgBox($MB_SYSTEMMODAL, "你選擇了", "關閉")
ExitLoop
EndSwitch
WEnd
GUIDelete() ; 刪除 GUI.
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam, $ilParam
Local $wID = _WinAPI_LoWord($iwParam)
Local $iIDFrom = BitAND($iwParam, 0xFFFF)
Local $iCode = _WinAPI_HiWord($iwParam)
Switch $wID
Case $iEnter ;虛擬控制項消息觸發收到回車消息才觸發
ConsoleWrite("回車" & @CRLF)
Case $iEnter2
ConsoleWrite("F1" & @CRLF)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
页:
[1]