React if any Window appears - c#

I want to have an event in my application if any window appears. For example if i open the windows-explorer then my application should recognise this and can react.
Is this possible in c#?
I already got that i need to override the WndProc-Method. But now i need to know which message appears when a new window is created

The Window message you are looking for is is WM_ACTIVATEAPP. See http://msdn.microsoft.com/en-us/library/ms632614(v=vs.85).aspx

Related

Detect Shift+Click on taskbar to open new window

If Notepad is open (or many other programs, don't need to be pinned) and user shift+clicks its taskbar item, it will open a new window. This behavior doesn't seem to be handled but the Windows Shell so it won't open another instance by default.
I have tried creating a hook MainWindowProc to get all window messages but that is not one of them and I don't know how to detect that event. Is there a way to get it from .NET?

Click outside wpf window without losing focus

I was wondering if there is a window property, for a wpf application, that disables any actions outside of the window. For example, when you open a message dialog and click outside of it, the message dialog background flashes. Kind of saying you can't do any actions outside of the message dialog untill you click the 'OK' button. I want that implemented in some windows that I open in a program i'm developing but can't seem to find any info on it. Looking for ways on how i might approach this.
Try ShowDialog() instead of Show()
Opens a window and returns only when the newly opened window is closed.
Window childWindow = new Window();
childWindow.ShowDialog();
Note that it will prevent clicks only on parent window(s). Clicks on other applications or Desktop can't be prevented by the Dialog.

VSIX and VS SHELL : problems with window show()

If I make non-modal window I get different problems. Firts of all I open the Experimental version of Visual Studio and open a Solution where I navigate to a C# page. Then I open my Extension's WPF window where I can happily type into TextBoxes in that WPF window. However, whenever I click the backspace [<-] or the [delete] keys, this doesn't affect the current WPF textbox but the previously opened C# code window in the current solution. I open my window in this way:
window = new MyWindow()
window.show();
I know that I could resolve my problem with :
uiShell.EnableModeless(0);
window = new MyWindow()
window.ShowDialog();
uiShell.EnableModeless(1);
But I don't want this solution. I want to navigate file in visual studio shell and at the same time using my addin without having problem with input. How Can I resolve this problem using Show() ?
If you want to display a "non-modal" window, it needs to be a toolwindow, or a document window. Otherwise, VS will not know about it, and you'll encounter all sorts of problems with it not getting messages, events, accelerators, etc...
If you want a modal window, use the DialogWindow class as previously mentioned to ensure the IDE can properly disable/enable it's windows when the dialog is displayed or dismissed.
Sincerely,

WPF application with several windows including a non active: focus issue

I have a .Net 4 application with two windows in WPF 4:
One uses the WS_EX_NOACTIVATE style to prevent gaining focus.
The other is a basic Window.
The "no-activate" window behavior is appropriate as soon as I do not select the basic window (it doesn't gains the focus). But when the basic window is selected, the "no-activate" window can be focused... and gains it when the user clicked on it.
It is as if WPF considered two windows of the same application had the right to give focus even if they are not supposed to.
This behavior does not happen if both windows are WS_EX_NOACTIVATE.
Have you ever been faced with this problem?
I have read this: WPF in Visual Studio 2010 – Part 3 : Focus and Activation, but does not solve it.
Edit: I have been able to get around by using a Popup as a base class for my no-active Window. However, I don't want to have a Popup. Why !? The popup never receives the focus: does someone know why / how ? How can I reproduce this behavior to a Window ?
I try to step into Popup / Window code, but it is not very clear !
Thanks !
Try also giving it the WS_EX_TOOLWINDOW.
http://www.daniweb.com/software-development/csharp/threads/273724/a-form-that-doesnt-steal-focus#
OK. I partially solved the problem.
The Window already got the focus if it is directly selected, but it is not focused when a component of the window is selected.
Just add :
Focusable = false;
to any WPF controls contained in the Window and they will never been focused even if the previous focus is a Window of the same Application.

Showing a dialog after the main window appears

I have found several similar questions, but nothing that fits perfectly.
I want my main window to show up first, and if the application can't find an application configuration file I want it to pop up a dialog box to get some necessary values from the user.
If I do anything in App.xaml etc - then obviously the main window won't be open, the same goes for if I put it in my main window's OnInitialized. If I put it in OnActivated, it seems to work, but when I close the dialog or somehow click on the main window it pops up another copy of the dialog. I could put a bool in my main window that indicates whether the dialog box is open already, but that just doesn't seem optimal or the best way of doing things.
Any suggestions?
Use Loaded instead.

Categories

Resources