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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating OCX with Validate Event & CausesValidation

Status
Not open for further replies.

TheTuna

Programmer
Dec 13, 2002
544
US
I have a self-developed OCX with the following Properties:

Windowless = true
CanGetFocus = False
ClipControl Uses Region

Among others...

Because the control is NOT allowed to get focus, only a few intrinsic components are allowed. They are the label control and the image control. That's it, nothing else... the control is an on screen keyboard for touch screens, in case you're wondering.

Everything works fine, except I want this control to include the CAUSESVALIDATION property, so I can set it to FALSE! :) No sweat... I'm about to add the get/let for that property, and the Validate event, just in case I change my mind and want to raise the event.

But hold on... it doesn't get focus, so it can't fire the validate event, right?!? WRONG, IT DOES FIRE THE VALIDATE EVENT! But can I stop it? Stay with me...

Within my validate event on some text boxes, I filter profanity (public computer you see). I wanted to use the validate event to also verify if a field is blank, which should be simple, right?

Well, every time the OCX is used (clicked), the text box that currently has focus, LOOSES FOCUS. It's not allowed to get focus, but the validate event fires anyway. Now I realize that the OCX doesn't actually RECEIVE focus (it can't), but the text boxes do LOOSE FOCUS... causing my need prevent the OCX from triggering the Validate event.

Who's still with me? Those of you who are might want to discuss this scenario...

So be thinking about it while I ignore the need for sleep and try to make it work. *Deep Breath In*...

Ok, post midnite logic could be flawed: Is it actually my OCX that is triggering the validate?



[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!
 
Early this morning when I started this thread, Tek-Tips seemed to go down. When I hit submit button it never returned, so I was surprised to see this actually posted. Anyway...

Ok, it's around 8 AM now... I just read my initial post. I made a mistake, just as I figured I might. The Validate event fires prior to the Lost Focus Event (not the other way around as I stated previously), and in this case, the Lost Focus event does not fire. My bad.

So, this brings me back to the initial reasoning for the CausesValidation property being necessary on my OCX. I've got to prevent my OCX from triggering the Validate event. I doubt that simply adding the property will do the job. Does anyone know how the CausesValidation property signals the Validate event on the control about to lose focus? I assume it sends a message to the control via it's handle (hWnd), but I don't know what message it should send...

Strongm, I bet you know the answer to this... others?





[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top