DESPERATE: Focussless form

R

Rene

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.
 
R

Rene

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

Alwin Belschner

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
 
T

Tasos Vogiatzoglou

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
 
A

Alwin Belschner

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
 
T

Tasos Vogiatzoglou

At least the code above works ... (Note to self, never propose things
you haven't checked)
 
R

Rene

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.
 
R

Rene

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).
 
T

Tasos Vogiatzoglou

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top