Search the Community
Showing results for tags 'leading zeroes'.
-
I'm trying to create an inputbox that automatically formats numbers with leading zeroes when the updown control is used. I found an example from Melba23 (see below) that shows a step incremented inputbox, and based on that, I tried to create one that would work, but it does not. I am creating separate inputs for hours and minutes, and I want to make sure the inputbox is always 2 digits. And right up front, I don't pretend to really understand the DLLStruct* calls.. Melba23's sample: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <UpDownConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("5000", 10, 10, 100, 20) $hUpDown = GUICtrlCreateUpdown($hInput, BitOR($UDS_WRAP, $UDS_NOTHOUSANDS)) GUICtrlSetLimit($hUpDown, 6000, 5000) GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ; Is it from the UpDown? If BitAND($wParam, 0xFFFF) = $hUpDown Then ; Create NMUPDOWN structure Local $tStruct = DllStructCreate("hwnd;long;int;long;long", $lParam) ; Is it a change message? If DllStructGetData($tStruct, 3) = 0xFFFFFD2E Then ; $UDN_DELTAPOS ; Alter the change value DllStructSetData($tStruct, 5, 100 * DllStructGetData($tStruct, 5)) EndIf EndIf EndFunc ;~ The NMUPDOWN structure holds: ;~ 1 - Handle of UpDown ;~ 2 - ControlID of UpDown ;~ 3 - Message type sent by UpDown ;~ 4 - Current value of UpDown ;~ 5 - Change to apply to input (+/-1) And here is my non-working sample (it runs, and the initial value shows correctly, but when you hit the updown, you lose the leading zeroes. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $hGUI = GUICreate("Window", 300, 100, -1, -1) $Count = 1 Global $hEdit = GUICtrlCreateInput($Count, 15, 15, 100, 30) GUICtrlSetFont(-1, 12, 400, "", "Tahoma") GUICtrlSetData(-1, StringFormat("%03u",$Count)) Global $hUpDown = GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 100, 0) GUISetState() While 1 $hMsg = GUIGetMsg() Switch $hMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ; Is it from the UpDown? If BitAND($wParam, 0xFFFF) = $hUpDown Then ; Create NMUPDOWN structure Local $tStruct = DllStructCreate("hwnd;long;int;long;long", $lParam) ; Is it a change message? If DllStructGetData($tStruct, 3) = 0xFFFFFD2E Then ; $UDN_DELTAPOS ; Alter the change value $ValueToSet = DllStructGetData($tStruct, 4) $ValueToSet = StringFormat("%03u", $ValueToSet) GUICtrlSetData($hEdit, $ValueToSet) EndIf EndIf EndFunc
- 2 replies
-
- inputbox
- leading zeroes
-
(and 1 more)
Tagged with: