I need to move focus from popup window to parent window without closing popup window. For example Find and replace dialog-box behavior in Excel.
how to achieve this in WPF C# coding.
Call .Show() instead of .ShowDialog() when you displaying your popup. If you want to keep it on top - set popup window 'TopMost' property to true.
Related
I have a window that I open up with ShowDialog(). The window will open in te center of my previous window. To close this window with background click I found the solution:
protected override void OnDeactivated(EventArgs e)
{
base.OnDeactivated(e);
Close();
}
The solution only works (look in picture the bracket on bottom) if I click outside any of my windows. But if I click on my Window(right bracket) I only get that sound and nothing happens(OnDeactivated does not proc).
Any Ideas?
Because ShowDialog prevents you from activating dialog's parent window, hence no activation change is made, hence no proccing.
You could use Show, as in non-modal way to show your dialog form, in case you don't "wait" on the calling code for the dialog to finish with some result.
If you do, there are workarounds, like a callback solution, or a how to close a WPF Dialog Window when the user clicks outside it link that #BWA pointed out.
I have a Form control named MyForm, which is the parent of some WPF BaseWindow, named MyWindow.
I'm setting their relationship as follows:
new WindowInteropHelper(myWindowInstance).Owner = myFormInstance.Handle;
And am showing the window using
myWindowInstance.ShowDialog();
The window is set with
ResizeMode="CanResize"
Therefor, it has a minimize button. On minimizing the window, its not minimized as expected, but rather minimized to the bottom of the form.
What I would like to experience is that the parent would be minimized as well. Meaning that minimizing the window, will be translated to minimizing the form.
You probably want to create event handlers to control their behavior relationship when events (minimize) occurred.
For WPF, you could use Window_StateChanged event with checking if this.WindowState == WindowState.Minimized
Then for the WinForm you could do the trick by Resize event and checking if WindowState == FormWindowState.Minimized
If any of these is true, then you could minimize both.
I want to add a popup window which is a child window of my main asp.NET form. This window accepts the information through drop down list selected by the user. When this window is opened the focus will go to this window and main window will disable.
Use showModalDialog for opening the popup window.
window.showModalDialog("childpage.aspx", "", "center:yes;resizable:no;dialogHeight:480px;dialogWidth:750px;");
This will make parent page disabled in IE.
i am using normal Form2.Show() and From1.Hide() to navigate the Form1 to Form2.
Application button is disappearing and appearing on the task bar while navigating just like flickering.
How to avoid this flickering?
Your approach is wrong. You should have one main form which will be showing in taskbar. And all child forms should be set ShowInTaskBar = false. When ever, button on taskbar is clicked, application should activate / minimize the current visible child. This way you wont see button changing in taskbar. But personally I dont see any issue with current flickering, it is by default and there is nothing wrong with it.
I need a window that does not activate when I click on it but is should elsewhere react normal. By normal I mean if there is a button on it and I click on the button it should execute the click and call the click function ( or event handle or what so ever). So it should be a normal window except that it shouldn't get activated when you interact with it.
I know you can do this with a message filter or hooks but is there any window style that does this automatically?
this is for windows.
thanks!
Have you tried the WS_EX_NOACTIVATE extended window style?
A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.
To activate the window, use the SetActiveWindow or SetForegroundWindow function.
Otherwise, if that doesn't do what you want, you will need to handle the WM_MOUSEACTIVATE message and return MA_NOACTIVATE.