kklee69 Posted September 12, 2017 Share Posted September 12, 2017 Hello everyone , Do you have any experience dealing with this kind of problem ? How to intercept the message " WM_PAINT " in the input box built by " GUICtrlCreateInput " ? Could we separate the store data and the display data like EXCEL ? For example , we input and save the value as 1000 but what we see is 1,000 . So I can read in 1000 by using " GUICtrlCreateInput " but what I see is 1,000 . Is it possible to make it ? Thank you for all your assistance ! Link to comment Share on other sites More sharing options...
mikell Posted September 12, 2017 Share Posted September 12, 2017 Yes, but the message to intercept is WM_COMMAND You should post a small running sample code so we can work with Link to comment Share on other sites More sharing options...
kklee69 Posted September 13, 2017 Author Share Posted September 13, 2017 (edited) Thank you for your response Do you mean $ EN_KILLFOCUS in WM_COMMAND to change it? So that when I press ENTER in INPUT will not react expandcollapse popup#include <GuiEdit.au3> #include <WinAPI.au3> ; used for Lo/Hi word #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> GUICreate("INPUT GUI", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1); 接受拖?文件 WS_EX_ACCEPTFILES $EDTE1 = GUICtrlCreateInput("", 10, 5, 300, 20) $EDTE2=GUICtrlCreateInput("", 10, 35, 300, 20) ;$EDTE3=GUICtrlCreateInput("", 10, 65, 300, 20) ;$EDTE4=GUICtrlCreateInput("", 10, 95, 300, 20) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() While 1 Switch GUIGetMsg() Case -3 ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case GUICtrlGetHandle($EDTE1), GUICtrlGetHandle($EDTE2) Switch $iCode Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus ; CHANGE HERE ????? ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Edited September 13, 2017 by kklee69 Link to comment Share on other sites More sharing options...
kylomas Posted September 14, 2017 Share Posted September 14, 2017 kklee69, No, more like EN_CHANGE... expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <editconstants.au3> #include <GuiEdit.au3> Opt("GUIOnEventMode", 1) $hForm = GUICreate("Example", 411, 200, 302, 218, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Cancel_ButtonClick") $hCustomerID_Label = GUICtrlCreateLabel("Customer ID:", 10, 109, 110, 17, $SS_RIGHT) $hCustomerID_Edit = GUICtrlCreateInput("", 125, 106, 180, 21) $hCustomerName_Label = GUICtrlCreateLabel("Customer:", 10, 140, 110, 17, $SS_RIGHT) $hCustomerName_Edit = GUICtrlCreateInput("", 125, 137, 180, 21) GUICtrlSetOnEvent(-1, '_CustomerName_Edit2') $hCancel_Button = GUICtrlCreateButton("Cancel", 320, 15, 75, 25) GUICtrlSetOnEvent(-1, "_Cancel_ButtonClick") ; added these two dummy controls which will be actioned by $EN_CHANGE as the user types ; This let's you get out of the registered function as quickly as possible as per the Help Doc $hDummyCustomerID_Edit = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, '_CustomerID_Edit') $hDummyCustomerName_Edit1 = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, '_CustomerName_Edit1') GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') While 1 Sleep(100) WEnd Func _Cancel_ButtonClick() Exit EndFunc ;==>_Cancel_ButtonClick Func _CustomerID_Edit() ; adapted from code by Smoke_N $sText = _GUICtrlEdit_GetText($hCustomerID_Edit) If $sText = '' Then Return ; added in case the first char typed is invalid which caused loop due to $EN_CHANGE If Not StringRegExp($sText, "(?i)^[0-9]+\z") Then _GUICtrlEdit_SetText($hCustomerID_Edit, StringTrimRight($sText, 1)) _GUICtrlEdit_SetSel($hCustomerID_Edit, StringLen($sText), StringLen($sText)) _GUICtrlEdit_ShowBalloonTip($hCustomerID_Edit, "Error", "You can only use characters 0-9", $TTI_ERROR) EndIf EndFunc ;==>_CustomerID_Edit Func _CustomerName_Edit1() ; edit for valid chars only $sText = _GUICtrlEdit_GetText($hCustomerName_Edit) If $sText = '' Then Return ; added in case the first char typed is invalid which caused loop due to $EN_CHANGE If Not StringRegExp($sText, '(?i)^[[:alpha:] ,]+\z') Then _GUICtrlEdit_SetText($hCustomerName_Edit, StringTrimRight($sText, 1)) _GUICtrlEdit_SetSel($hCustomerName_Edit, StringLen($sText), StringLen($sText)) _GUICtrlEdit_ShowBalloonTip($hCustomerName_Edit, "Error", "You can only enter letters, spaces or a comma", $TTI_ERROR) EndIf EndFunc ;==>_CustomerName_Edit1 Func _CustomerName_Edit2() ; ; do other kinds of edits here (actioned after control looses focus) ; EndFunc ;==>_CustomerName_Edit2 Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch BitShift($wParam, 16) Case $EN_CHANGE Switch BitAND($wParam, 0xFFFF) Case $hCustomerID_Edit GUICtrlSendToDummy($hDummyCustomerID_Edit) Case $hCustomerName_Edit GUICtrlSendToDummy($hDummyCustomerName_Edit1) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Note that the registered routine is exited as soon as possible. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
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