Form Subclassing question...I don't want a form to get focus
I have 2 forms.
I do not want one form to get focus.
This can be done by disabling the form...but I don't want to do this and more to the point, I can't do this. I have my reasons.
I am subclassing the form and somehow how have to trap for the "get focus" event.
I think if I ignore this message the form won't get focus...I think :confused:
What event is it I'm looking for here? Is there such thing as I a "get focus" event on a form...Hmmmm...It's late and I'm tired.
Whimper
Re: Form Subclassing question...I don't want a form to get focus
As the simplest you can just pass focus back to your "main" form:
VB Code:
'Form2
Private Sub Form_GotFocus()
Form1.SetFocus
End Sub
Problem is that you might need to do the same thing for every control that can get focus.
Re: Form Subclassing question...I don't want a form to get focus
Hmmmmm...not sure.
I am tired and should have explained exactly what I wanted to do sorry, my bad :(
I have a form, form1...and I have a picture box on this form.
I am using the SetParent API command to place form2 inside the picturebox on form1. Standard stuff, we've all seen it before.
What I would like...and I am not sure if this is possible, but I would like a control on form2 to get focus but I would form1 to keep focus.
Am I taking rubbish :(
Woof
Re: Form Subclassing question...I don't want a form to get focus
Quote:
Originally Posted by Wokawidget
... Am I taking rubbish ...
I don't think so ...
I recently noticed kind of weird SourceSafe behaviour: while running project in IDE main form looses focus but all controls are accessible but you'll need to single click twice on each to set focus ... So maybe you want incorporate SS in your exe, eh ... :p ;)
But seriously, I'm afraid you're taking a little too far though.
Re: Form Subclassing question...I don't want a form to get focus
Quote:
I would like a control on form2 to get focus but I would form1 to keep focus
Do you really mean focus? Only one Window/Control can have focus at a time.
Are you saying you want all mouse and keyboard input to go to two things at once?
1 Attachment(s)
Re: Form Subclassing question...I don't want a form to get focus
Here's an example of what I have so far.
Notice how the controls don't get a click event...boooo. This isn't an issue though.
Anyways...I want to intercept the lost and got focus events of the forms.
But am not sure what messages to look for.
WOka
Re: Form Subclassing question...I don't want a form to get focus
You do nothing more that passing focus back to Form1 - that is what I suggested in my very first reply ...
What you are after, Woka, requires system wide hook and not just simple subclassing.
I recommend you to visit vbaccelerator and download what Steve Mac calls journal - some serious sample project that requires lots of attention. I don't want to describe what is does but you'll figure it out.
Cheers and good luck.
Re: Form Subclassing question...I don't want a form to get focus
Yea...I added in SetFocus after your post :)
Ahhh poo sticks :(
That's what I was afraid of.
I suppose I could code round the controls issue...they were't in my agenda anyways. It was just that if you click form2 fast then u can see a flciker when form1 loses focus. That's what I want to get rid of...but I can't disable the form.
Woof
Re: Form Subclassing question...I don't want a form to get focus
Out of curiosity Woka, what are you trying to accomplish? Some sort of MDI type function?
Phreak
Re: Form Subclassing question...I don't want a form to get focus
I am going to combine it with my "multithreading" code and produce a usercontrol that runs entirely in another "thread"...including the graphix rendering. Regardless of what your UI is doing the usercontrol will ALWAYS refresh itself...unless IT crashes that is :D
So the form in the pic box will be a form in another process.
It's something for my LiveUpdate code.
Woka
Re: Form Subclassing question...I don't want a form to get focus
I have done this before...I'm just trying to make it a little neater.
WOof
Re: Form Subclassing question...I don't want a form to get focus
I'm not sure what a system-wide Journal hook is going to do for you.
You can, however, set a thread-specific CBT hook which processes HCBT_SETFOCUS messages. You can prevent the focus from changing to another control on your form, by returning a non-zero value when this message is received.