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

MDI Style focus without using MDI forms

P: 4
Does anyone know of any way to switch focus between a main form and a child form without the usual flickering you get while changing focus between windows?

This works fine if the main form is an MDI container and the child form is within that container, but MDI is not appropriate for this application. I would like to be able to interact with a form without losing focus on the main form.

Obvious workarounds such as setting focus on the main form each time the mouse exits the child form produce a lot of flickering and simply arent acceptable.

Any ideas?

Thanks in advance for any help with this one,

Daniel.
Jan 15 '09 #1
Share this Question
Share on Google+
5 Replies


Plater
Expert 5K+
P: 7,872
Flickering?
My windows don't flicker when I switch between them?

EDIT:
I would like to be able to interact with a form without losing focus on the main form.
Oh ok, hmm. Have you tried the TopMost setting?
Although I mean by definition, if you are interacting with a window it should have the focus
Jan 15 '09 #2

P: 4
I mean the general flicker if you actually switch focus between two windows, for example, if you do it fast you get a flicker - perhaps it wasnt the best way to describe it!

Basically if you create a standard MDI app with the main form as an MDI Container and then add a child form, when you actually "select it" i.e. it gets focus you do not loose focus on the main window.

For example, if I were to open a new window from a main window without it being an MDI application I would lose focus on the main window when entering the new one. If i were then to click on the main windows file menu I would have to click twice, once to gain focus, a second time to perform the action I was expecting. Within an MDI situation you do not have to do this.

Is there any way of replicating this behaviour without it being an MDI application?

The main reason I ask is that I need a semi-transparent tool window within an MDI application, if you create a form and set its opacity all's well - but as soon as you set it to be a child form of an MDI parent you loose that opacity because the window layering utilized by Windows to deal with opacity isnt supported on non-top level forms.

As for TopMost, yes I have tried that and it didn't help much.

Thanks for the reply and I hope this clears up my question.
Jan 15 '09 #3

Plater
Expert 5K+
P: 7,872
What OS are you running?
I only have to click once to open up file menus on a non-focused window.

As a thought, what if you made the main window NEVER have focus? I think that's how a lot of programs with floating toolbars do it (like gimp)
Jan 15 '09 #4

P: 4
Vista at the moment, it does appear to only happen within "my" program and not if I do it between two windows.. odd.

I'll have a look into that one, cheers.
Jan 16 '09 #5

P: 4
Managed to solve this, if anyone is interested I disabled the "flickering" (read: visual focus change) by overriding WndProc and on WM_NCACTIVATE and WParam == 0 send a message to the window:

SendMessage(this.Handle, WM_NCACTIVATE, 1, IntPtr.Zero);

This re-activates the window, causing it to "appear" in focus every time.
Jan 16 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.