Sign in to follow this  
Followers 0
david7411

GUICtrlCreateInput

5 posts in this topic

Hi Guys

I appreciate if someone could help me or direction with GUICtrlCreateInput which is except only certain formatted input, for example, input for MAC address field have format of : 12-12-12-AA-1A-12

Thanks

Share this post


Link to post
Share on other sites



you'll have to adapt it for GuiCtrlCreateInput, but this regexp should work.

Do 
    $str = InputBox("","Enter MAC Address (XX-XX-XX-XX-XX-XX)")
Until StringRegExp($str,"^(?:[[:xdigit:]]{2}[-]){5}[[:xdigit:]]{2}$",0)

Share this post


Link to post
Share on other sites

Hi

Thanks for reply . The expression is very cool, but I am looking for something similar of GUICtrlCreateInput with style $ES_NUMBER , so user can type directly into input control.

Is is possible ?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Question is, how elaborate do you want it to be.

If you're ok with format checking done after user enters whole string/only when you actually need it, then you don't need much more than that RegExp (assuming it works fine). Read input when you need it, check with RegExp and notify user to try again if it doesn't match the correct pattern.

If you want realtime checking, possibly preventing user entering illegal characters, but at the same time keep the thing convenient and not confusing for the user, then you could have 6 GUICtrlCreateInput controls and do the monitoring on each of them. That's the method M$ uses too, for example some CD key dialog, and even the common IP address control is actually 4 edits rolled into one. Or have 1 GUICtrlCreateInput, but it could get a bit messy.

Anyway, for realtime checking, you'd need GuiRegisterMsg() WM_COMMAND, to catch EN_UPDATE notification. Search the forum with these keywords, there are a lot of examples.

Edited by Siao

"be smart, drink your wine"

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