Sign in to follow this  
Followers 0
EKY32

~ Insert a point in a $ES_NUMBER Input control? (SOLVED)

7 posts in this topic

#1 ·  Posted (edited)

I need to insert a point to type a floating-point number, but I also need to deny the user from typing characters.. any help?

Thank you.

#include <EditConstants.au3>
GUICreate("Title", 265, 132)
GUICtrlCreateInput("", 32, 32, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
GUICtrlCreateLabel("Type 1.25 if you can :'(", 32, 72, 114, 17)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit

EndSwitch
WEnd
Edited by EKY32

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Initialy you create an input control without $ES_NUMBER style and then you can register WM_COMMAND message and then you can check when $EN_UPDATE message is received and then replace the input of control to keep just characters you want.

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Initialy you create an input control without $ES_NUMBER style and then you can register WM_COMMAND message and then you can check when $EN_UPDATE message is received and then replace the input of control to keep just characters you want.

Thank you, but I see this way is too long! I need a best smart way if any.


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Initialy you create an input control without $ES_NUMBER style and then you can register WM_COMMAND message and then you can check when $EN_UPDATE message is received and then replace the input of control to keep just characters you want.

Hi,

Here is what Andreik was thinking about :

#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1)

GUICreate("toto")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$tbMyInputNumber = GUICtrlCreateEdit("", 10, 10, 100, 20, $ES_AUTOHSCROLL)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState()

While 1
Sleep(1000)
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
Local $iCode = BitShift($wParam, 16)
Local $iIDFrom = _WinAPI_LoWord($wParam)

Switch $iIDFrom
Case $tbMyInputNumber
Switch $iCode
Case $EN_UPDATE
Local $sWMCOMMAND_MyInputNumberRead = GUICtrlRead($tbMyInputNumber)
Local $sWMCOMMAND_MyInputNumberLastChar = StringRight($sWMCOMMAND_MyInputNumberRead, 1)
Local $aWMCOMMAND_MyInputNumberDotSplit = StringSplit($sWMCOMMAND_MyInputNumberRead, ".")

If $aWMCOMMAND_MyInputNumberDotSplit[0] > 2  Or (Not StringIsInt($sWMCOMMAND_MyInputNumberLastChar) And $sWMCOMMAND_MyInputNumberLastChar <> ".") Then
GUICtrlSetData($tbMyInputNumber, StringTrimRight($sWMCOMMAND_MyInputNumberRead, 1))
EndIf
EndSwitch
EndSwitch

Return $GUI_RUNDEFMSG
EndFunc

Func _Exit()
Exit
EndFunc

And I'm sure this can be more clear with a RegExp test.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Mr.FireFox :bye:

Thank you very much, thanks to every one who helped. :wub:


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

This is something like what I had in mind.

#include <EditConstants.au3>
GUICreate("Title", 265, 132)
$hInput = GUICtrlCreateInput("", 32, 32, 121, 21, $GUI_SS_DEFAULT_INPUT)
GUICtrlCreateLabel("Type 1.25 if you can :'(", 32, 72, 114, 17)
$button = GUICtrlCreateButton("go", 172, 72, 20, 20)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
        Exit
    Case $button
        $Number = _CheckInput($hInput)
    EndSwitch
WEnd

Func _CheckInput($var)
    Local $sInput = GUICtrlRead($var)
    MsgBox(0,0,Number($sInput))
    Return Number($sInput)
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0