Click to See Complete Forum and Search --> : Subclassing events
DragonSteve
Oct 8th, 2001, 09:01 AM
Hi,
i'm trying to catch events through subclassing.
You can get all mouse events en key events.
Is it possible to catch events that are specific to a control?
Ex.
Trap the change event of a textbox.
Also is this the way of doing it.
The reason why I have to catch these events is because I'm generating my form. So I can not place the event in code.
I have to trap these events in an other way.
All suggestions are welcom.
Thanks.
jim mcnamara
Oct 8th, 2001, 09:14 AM
Yes. Subclassing is your answer.
I don't know what you want to define as an event. But, if you subclass a control (almost all of which are windows, except labels), EVERY thing that goes to the control goes thru the wndproc you create. All OS messages, plus OS messages that are user input.
If you know what message, eg. WM_QUIT, EM_UNDO, etc you want to look at just use a case statement to trap the set of messages you want. Unfortunately, several of them could be considered a change event of one kind or another.
DragonSteve
Oct 8th, 2001, 10:07 AM
Thanks for clearing this out. I've just encountered that.
If you have a control placed on your form, how would you trap the change event of that control.
Or let us make it more interresting. I have a True DB Combo control from APEX. Here you have several events that are not listed as common events.
You have the change event but you also have the item change event.
How would you distinquishe those two?
Thanks.
jim mcnamara
Oct 8th, 2001, 12:33 PM
First off - they really are not events - they are messages.
VB looks at messages and groups them into events for you in order to make your life easier as a programmer.
All of the stuff that happens to controls on the screen, happens because Windows sends messages to the control. If you move the cursor, hit tab, type letter "A" -- all of these are sent to the control as a message of one flavor or another.
What you have to do is translate from the concept of "event" to message type. One event may be 6-7 different messages, one event may just be one message type. The problem for me is that you need to define what constitutes a "change event"
Possibilities for listbox, for example:
A character is added/deleted on a the currently selected line
You encounter a cr/lf in the text stream
A line is deleted
New text is selected
This list might be different for another kind of control. Why? Because you are taking over for VB in deciding what message or messages define a "change event".
goto www.allapi.net and look around. This page:
http://www.allapi.net/vbtutor/subclass.php
has a nice discussion of what's going on here.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.