Inspector problem

L

Lloyd Dupont

I want to create some "inspector/tool windows" in my WinForm/Desktop
application.
Ideally I would like to hide them when the main form is not active.
The problem is: I can't use the deactivate event because the toll window,
when it is shown/activate deactivate the main form.
So clicking on it will hide it :S

So, how does one do that?
Ideally I would like to track if the whole application is active (or not)
and the order in which the windows are.
So I could determine the right target windows. (I would like to have only 1
inspector/tool window, but multiple document windows/forms)
 
B

Bob Powell [MVP]

Use p/invoke and the ShowWindow API with the SW_SHOWNOACTIVATE setting.

You can show and hide the window as your main form is shown or hidden.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
L

Lloyd Dupont

thanks Bob, I'll try but I'm not convinced.
because when you click on the inspector (I mean it's here to be used), I
think it will activate the window, IIRC.

Anyway someone else suggested me WM_APPACTIVATE (or something like that),
looks promising..

Bob Powell said:
Use p/invoke and the ShowWindow API with the SW_SHOWNOACTIVATE setting.

You can show and hide the window as your main form is shown or hidden.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
N

Nick Z.

I think in a situation like that a better approach will be to have the
tool window 'watch' if a main window is activated and then show itself.

However, when the 'main window' is deactivated, check the type of the
newly activated window, if the newly activated window is NOT another
window of a 'main window' OR 'tool window' type, then hide the tool window.

Hope this helps,
Nick Z.
 

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