|
-
November 25th, 1999, 02:51 AM
#1
general
i want only numbers to be entered in my text box and must not allow any thing to be entered into it.
how can i do it.
i am not getting with like operator in keydown event.
please help me
-srikanth
-
November 25th, 1999, 02:59 AM
#2
Re: general
There is only ONE truly reliable solution to this that I know of:
use the SetWindowLong API and set the GWL_STYLE to ES_NUMBER.
Other approaches (trapping keyup, keypress and so on), although widely used, do not work in all cases, because the usually fail to trap Paste operations via Ctrl+V and Shift+Ins or the context menu.
-
November 25th, 1999, 06:18 AM
#3
Re: general
Hi Lothar,
ES_NUMBER for GWL_STYLE of a Text box is defined only for WINVER > 0x400. DOes that mean it works on 95? I dont think so. It sure works on WIn nt 4.0 SP3 through. I tried.
As an aside:
Whay is that this code doesn't work for setting the text box read only??
lStyle = GetWindowLong(txtboxHwnd, GWL_STYLE)
lStyle = lStyle Or ES_READONLY
' lrtn = SetWindowLong(txtboxHwnd, GWL_STYLE, lStyle) ' DOESnt work
lrtn = SendMessageLong(txtboxHwnd, EM_SETREADONLY, 1, 0) ' Only works??
Any ideas?
RK
-
November 25th, 1999, 08:33 AM
#4
Re: general
some styles are only interpreted when the control is created. ES_READONLY is one of them.
from the docs:
"To change this style after the control has been created, use the EM_SETREADONLY message"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|