Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numeric / Char only Text Box using SetWindowLong

Status
Not open for further replies.

ufobaby

MIS
Sep 25, 2001
238
0
0
US
Hi,

I am very new to API Programming. from examples on the allapi.net i have figured out how to have a numeric only text box. but.....

1.] The Text Box also accepts Special Char (!,@,[,.) etc. How to avoid all of them except (- & .)

2.] How to a have a Text only i.e w/t Spc Char and Nmbers.

Thanks in advance for any help

Cheers!!!
Niraj >:):O>
 
Try to look up 'subclassing' in your manual/reference book. The solution is there. Unfortunately I'm not very familiar with it too, I just know you need to use the 'subclassing' technique. He he he.

Now, what you want to do is to replace a certain dword in the edit box's window definition. This dword happens to be a pointer to that particular edit box's window procedure. You then replace it with your own.

Now, your edit box's new window procedure will 'filter' any messages you are interested in. In particular, you are interested in WM_CHAR messages. If you get a character you don't want, then you just return a zero (I think). If you get a message you want to process yourself, then process it within your new edit box window procedure.

However, implementing the edit box is a LOT of code and most of this code is already provided by Windows. A majority of the messages your new window procedure will get should be passed to the old, Windows-provided edit box window procedure. So with subclassing, you can call the previous, Windows-provided edit box window procedure using another SDK routine whose name escapes me at the moment.

Note that this is an overview, the specifics should be in your reference book(s) or site(s). "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Derive a class for Edit Control say myeditctrl and write your own message handler for WM_Char in myeditctrl. In this message process the inpute character and if it fell in your choice of character pass it to WM_Char handler for CWnd

rest will be handled by that class member
 
Derive a class for Edit Control say myeditctrl and write your own message handler for WM_Char in myeditctrl. In this message process the inpute character and if it fell in your choice of character pass it to WM_Char handler for CWnd

rest will be handled by that class member

riffat_nazir@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top