By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,775 Members | 1,345 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,775 IT Pros & Developers. It's quick & easy.

DESPERATE: Focussless form

P: n/a
Anyone knows what in the world do I have to do to prevent a form from ever
getting the focus?

I tried using the IMessageFilter interface like this.:

public bool PreFilterMessage(ref Message m)
{
return true;
}

This stoped pretty much all messages from being processed but the damn focus
still goes to the form.
May 18 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Have you tried to override the the form's focus behavior ?

May 18 '06 #2

P: n/a
I tried overriding a lot of things, what do you mean by "the form's focus
behavior", could you be a little more specific?

"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@j55g2000cwa.googlegr oups.com...
Have you tried to override the the form's focus behavior ?

May 18 '06 #3

P: n/a
Form.CanFocus

May 18 '06 #4

P: n/a
Hello Tasos,
as fas as I know, is CanFocus readonly.
I think, you cannot set it to false.
I suggest to use event Activated, within you can Activate another form
e.g. the owner of the form.
I don't know whether this is a good solution, but it works.
regards Alwin

"Tasos Vogiatzoglou" <tv*****@gmail.com> schrieb im Newsbeitrag
news:11*********************@38g2000cwa.googlegrou ps.com...
Form.CanFocus

May 18 '06 #5

P: n/a
Unfortunatelly I am stupid. Alwin is absolutely write. The code that
does what you want is this

[DllImport("user32.dll")]
private extern static IntPtr SetActiveWindow(IntPtr handle);
protected override void WndProc(ref Message m)
{
if(m.Msg == 6)
{
SetActiveWindow(m.LParam);
}

base.WndProc(ref m);
}

....
Regards,
Tasos

May 18 '06 #6

P: n/a
ok ... right even

.... pffffffffff

May 18 '06 #7

P: n/a
Hello Tasos,

Please don't worry. I feel it's no problem. We only try to give hints.
If anybody means it is a problem he should not join usenet.

regards Alwin
"Tasos Vogiatzoglou" <tv*****@gmail.com> schrieb im Newsbeitrag
news:11**********************@j33g2000cwa.googlegr oups.com...
ok ... right even

... pffffffffff

May 19 '06 #8

P: n/a
At least the code above works ... (Note to self, never propose things
you haven't checked)

May 19 '06 #9

P: n/a
Tasos:

The code sample was pretty good. The only problem is that it appears that
when the target form is clicked the last form that had the focus does loose
the focus and then the focus is given back to it.

What I needed is for the previous focused form not to loose the focus
whatsoever (no flicker). In short, what I need is a behavior identical to
what happens when the dropdown form of a combo box is dropped. Showing the
dropdown does not cause any other window to loose its focus, even clicking
on the dropdown does not cause any other form to loose focus.

I have been trying to figure out how replicate this behavior for the long
time, I think I am going to have to call Microsoft for help on this one.

Thanks for the help.
"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
At least the code above works ... (Note to self, never propose things
you haven't checked)

May 19 '06 #10

P: n/a
Dropdown form is not a Form ... You want to create a custom dropdown ?

May 19 '06 #11

P: n/a
Yes I would like to create a custom dropdown.

The dropdown may not be a form but as far as I understand it's a window and
I believe the combobox dropdown is a list control but at the end everything
is a window and it should all behave the same way (I think).

"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
Dropdown form is not a Form ... You want to create a custom dropdown ?

May 19 '06 #12

P: n/a
Consider a simple Panel control ... This shouldn't get focus when
visibility is changed.

May 20 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.