Grayhat Posted April 16, 2011 Posted April 16, 2011 I have an input control, and I need this: When the user press a key and it's have the focus, show a messagebox and don't pass the pressed key into it. When I click a button to set the text in the input (GuiCtrlSetData), don't show the messagebox. I've tried WM_COMMAND, but the button click to set data and the keypress returns the same message code. Global Const $WM_COMMAND = 0x0111 Local $hWnd = GUICreate("Test", 225, 100) Local $hInput = GUICtrlCreateInput("", 10, 25) Local $hButton = GUICtrlCreateButton("Change", 10, 60) GUIRegisterMsg($WM_COMMAND, "MyCommand") GUISetState(@SW_SHOWNORMAL, $hWnd) While WinExists($hWnd) Switch GUIGetMsg() case -3 Exit case $hButton GUICtrlSetData($hInput, GUICtrlRead($hInput) & Random(1, 10, 1)) EndSwitch WEnd Func MyCommand($hWnd, $Msg, $wParam, $lParam) if $lParam = GUICtrlGetHandle($hInput) then ConsoleWrite($wParam & @CRLF & $lParam & @CRLF & $Msg & @CRLF & @CRLF) EndFunc Thanks in advance.
wolf9228 Posted April 17, 2011 Posted April 17, 2011 I have an input control, and I need this: When the user press a key and it's have the focus, show a messagebox and don't pass the pressed key into it. When I click a button to set the text in the input (GuiCtrlSetData), don't show the messagebox. I've tried WM_COMMAND, but the button click to set data and the keypress returns the same message code. Global Const $WM_COMMAND = 0x0111 Local $hWnd = GUICreate("Test", 225, 100) Local $hInput = GUICtrlCreateInput("", 10, 25) Local $hButton = GUICtrlCreateButton("Change", 10, 60) GUIRegisterMsg($WM_COMMAND, "MyCommand") GUISetState(@SW_SHOWNORMAL, $hWnd) While WinExists($hWnd) Switch GUIGetMsg() case -3 Exit case $hButton GUICtrlSetData($hInput, GUICtrlRead($hInput) & Random(1, 10, 1)) EndSwitch WEnd Func MyCommand($hWnd, $Msg, $wParam, $lParam) if $lParam = GUICtrlGetHandle($hInput) then ConsoleWrite($wParam & @CRLF & $lParam & @CRLF & $Msg & @CRLF & @CRLF) EndFunc Thanks in advance. WM_COMMAND Message http://msdn.microsoft.com/en-us/library/ms647591%28v=vs.85%29.aspx expandcollapse popup#Include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $hWnd = GUICreate("Test", 225, 100) Local $hInput = GUICtrlCreateInput("", 10, 25) Local $hButton = GUICtrlCreateButton("Change", 10, 60) GUIRegisterMsg($WM_COMMAND, "MyCommand") GUISetState(@SW_SHOWNORMAL, $hWnd) While WinExists($hWnd) Switch GUIGetMsg() case -3 Exit case $hButton GUICtrlSetData($hInput, GUICtrlRead($hInput) & Random(1, 10, 1)) EndSwitch WEnd Func MyCommand($hWnd, $Msg, $wParam, $lParam) $HiWord = _WinAPI_HiWord($wParam) $LoWord = _WinAPI_LoWord($wParam) Switch $HiWord Case 0 ConsoleWrite("Menu identifier ==> " & $LoWord & @CRLF) Case 1 ConsoleWrite("Accelerator identifier ==> " & $LoWord & @CRLF) Case Else if $lParam = GUICtrlGetHandle($hInput) then ConsoleWrite("Input control ==> $hInput" & @CRLF) ConsoleWrite("Control identifier ==> " & $LoWord & @CRLF) ConsoleWrite("notification code ==> " & $HiWord & @CRLF ) ConsoleWrite("Handle to the control window ==> " & $lParam & @CRLF ) EndSwitch Return $GUI_RUNDEFMSG EndFunc صرح السماء كان هنا
wolf9228 Posted April 17, 2011 Posted April 17, 2011 (edited) Edit Control Notificationshttp://msdn.microsoft.com/en-us/library/ff485924%28v=VS.85%29.aspxexpandcollapse popup#Include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Const $EN_UPDATE = 0x400 , $EN_CHANGE = 0x300 , $EN_SETFOCUS = 0x100 Global $Test = 0 , $Data = "" Local $hWnd = GUICreate("Test", 225, 100) Local $hInput = GUICtrlCreateInput("", 10, 25) Local $hButton = GUICtrlCreateButton("Change", 10, 60) GUIRegisterMsg($WM_COMMAND, "MyCommand") GUISetState(@SW_SHOWNORMAL, $hWnd) $Data = GUICtrlRead($hInput) While WinExists($hWnd) Switch GUIGetMsg() case -3 Exit case $hButton $Test = 1 GUICtrlSetData($hInput, GUICtrlRead($hInput) & Random(1, 10, 1)) $Test = 0 EndSwitch WEnd Func MyCommand($hWnd, $Msg, $wParam, $lParam) $HiWord = _WinAPI_HiWord($wParam) $LoWord = _WinAPI_LoWord($wParam) Switch $HiWord Case 0 ConsoleWrite("Menu identifier ==> " & $LoWord & @CRLF) Case 1 ConsoleWrite("Accelerator identifier ==> " & $LoWord & @CRLF) Case Else if $LoWord = $hInput And $HiWord = $EN_UPDATE Then if ($Test) Then $Data = GUICtrlRead($hInput) Return $GUI_RUNDEFMSG Else GUICtrlSetData($hInput,$Data) MsgBox(0,"Msg","Test") Return $GUI_RUNDEFMSG EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc Edited April 17, 2011 by wolf9228 صرح السماء كان هنا
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now