WPF per monitor DPI Aware dialog positioning issue - wpf

I have a WPF .Net 4.7 application with per monitor DPI Aware.
I enable the DPI awareness following the solution explained here.
I want to open a dialog at the top left corner of my mainWindow, and I do the following:
var window = new Window();
window.Owner = mainWindow;
window.WindowStartupLocation = WindowStartupLocation.Manual;
window.Left = mainWindow.Left;
window.Top = mainWindow.Top;
window.Show();
I have 2 monitors with different DPI scale.
If I run the application from Visual Studio, it all works fine: regardless of which monitor the mainWindow is, the dialog is always positioned at the top-left corner of the mainWindow.
But if I run the application from Windows Explorer, the dialog is positioned correctly only on the monitor in which the Windows Explorer was when I launched the application.
Why this different behaviour, and how can I correctly position the dialog when I run the application from Windows Explorer?

Related

Automatic taskbar reveal not working when my WPF app is running from Visual Studio

When Windows has "Automatically hide the taskbar in desktop mode" = Off, the taskbar is displayed and my app displays in the remaining desktop area, which is correct.
When that setting is set to On, the taskbar is hidden but slides into view when you move the mouse to the edge of the screen. This also works correctly with my app when running the executable in the normal way.
But when my app is launched by Visual Studio 2019 and is maximized and has focus, the taskbar does NOT slide into view when you mouse to the edge.
What's going on here and how can it be fixed?

Which windows should be shown in Windows taskbar for a program?

Are there any guidelines to this? WPF windows are shown in taskbar by default. You must excplicitly set them not be shown there by
ShowInTaskbar = False
However it seems that many Microsoft programs seem to have only main window in taskbar.
Please refer to MSDN.
Make the following window types appear on the taskbar (for Windows 7, by using a taskbar button thumbnail):
Primary windows (which includes dialog boxes without owners)
Property sheets
Modeless progress dialog boxes
Wizards
For Windows 7, use taskbar button thumbnails to group the following window types with the primary window taskbar button it was launched from. Each program (specifically, each program perceived as a separate program) should have a single taskbar button.
Secondary windows
Workspace tabs
Project windows
MDI child windows

WPF host Win32 window frozen because of multiple WM_NCHITTEST when moving mouse over the bottom right corner

I have a WPF window that hosts Win32 window, I have class inherited from HwndHost.
Everything seems to work fine except when I move the mouse over the bottom right corner of the WPF window, the window freezes.
I used Spy++ to see what is going on. It turns out that the WPF Window receives few WM_WINDOWPOSCHANGING messages every 2-3 seconds and the Win32 Window keeps receiving a lot of WM_NCHITTEST all the time.
How can I resolve this problem? Thank you.
I found the solution by setting the size of Win32 window to be 1 pixel (both width and height) smaller than the WPF Host Window, the issue is gone.
I think it's because both Win32 and WPF windows were sharing the same non-client area and the messages got looping.

Extjs 4 - Panel vs Window

what's the different between window and panel in Extjs ? is it fine if i use window to display and handle too much data from database ?
Window is a specialized panel intended for use as an application
window. Windows are floated, resizable, and draggable by default.
Windows can be maximized to fill the viewport, restored to their prior
size, and can be minimized.
So if you don't need any of the features the window has - use a panel.

Attaching a WPF window to the Desktop

I have created a WPF application that has no chrome and a transparent background
WindowStyle="None" AllowsTransparency="True"
IntPtr windowHandle = new WindowInteropHelper(window).Handle;
IntPtr oldParent = SetParent(windowHandle, desktopHandle);
But whenever i try to set this window to be a child of the desktop process (So that it isn't affected by "Show Desktop" commands) it stops drawing. If i change AllowsTransparency back to False it works as expected, however I do want it to be transparent and have no borders.
Can anyone give me any suggestions on how to make this work correctly? I can get this to work by using the same method in a Winforms application.
I suspect that the reason it worked for Winforms and not for WPF is that Winforms uses GDI for rendering and WPF uses DirectX. These technologies have interoperability issues that are more fully detailed here, in particular in a section called "Transparency and Top-Level Windows".
http://msdn.microsoft.com/en-us/library/aa970688.aspx
You might be able work around the issue by hosting the WPF visual in a Win32 window, as detailed here:
http://msdn.microsoft.com/en-us/library/ms742522.aspx#hosting_a_wpf_page

Resources