1. edit text field question

If you have an editText field with style ES_NUMBER, you cannot enter a
period. This seems a little dumb....Is there a way around this w/o doing my
own enforcement?

George Walters

new topic     » topic index » view message » categorize

2. Re: edit text field question

----- Original Message ----- 
From: <gwalters at sc.rr.com>

> If you have an editText field with style ES_NUMBER, you cannot enter a
> period. This seems a little dumb....Is there a way around this w/o doing my
> own enforcement?
> 
> George Walters

ES_NUMBER Allows only digits to be entered into the edit control. 
Note that, even with this set, it is still possible to paste non-digits into the
edit control.
To change this style after the control has been created, use SetWindowLong. 

In a prior post I mention this:

I do know how to trap certain keys and send a message to the subclassed from the
subclass
"sending the message to itself", I do it like this.

elsif iMsg = WM_KEYDOWN then
        if wParam = VK_BACK then
junk = c_func(xPeekMessage,{tagMSG, c_func(xGetParent,{handle}), 0,
            0, PM_REMOVE})
junk = SendMessage(handle, WM_CHAR, wParam, MAKELONG(1, 14)) --send
            it to ourself

this traps the BACK-BUTTON in the edit control and sends a WM_CHAR message which
I could
inturn process further. Pretty easy stuff, right..

Now instead of using SetWindowLong you could use my method (above) to trap any
key value.
Note: The Edit control would have to be subclassed to make this easy.

Hope this helps,

Euman
euman at bellsouth.net

new topic     » goto parent     » topic index » view message » categorize

3. Re: edit text field question

Hi George,

----- Original Message -----
From: <gwalters at sc.rr.com>
To: "EUforum" <EUforum at topica.com>
Subject: edit text field question


>
> If you have an editText field with style ES_NUMBER, you cannot enter a
> period. This seems a little dumb....Is there a way around this w/o doing
my
> own enforcement?

You are right. The style ES_NUMBER only permits the digits '0' - '9' in an
edit field. My guess is that it excludes punctuation because that starts to
get too complex for a general routine. Just consider different cultural
standards - Europeans use a comma as a decimal marker and those from British
heritage use a period.

However, using you own enforcement is not difficult using win32lib. Here one
way of doing it...

  --------------
  constant NumberChars = "0123456789."
  procedure NumberOnly(integer self, integer event, sequence params)
    -- Is this character a valid one?
    if find(params[1], NumberChars) = 0 then
        -- No, so tell windows to ignore it.
        returnValue(-1)
    end if
  end procedure
  -- Set the handler for every edit field that needs this
  setHandler({editfld1, editfld2, ...etc...},
w32HKeyPress,routine_id("NumberOnly"))
  --------------

cheers,
Derek.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu