MFC dialog window on top of tablet mode view windows 10 - windows

We are creating a dialog window to display information, this dialog is invoked by application which is running in background on local (Host) machine when it receives instructions from remote machine. This is working fine in Windows 10 OS when running in desktop mode. But we are NOT seeing the dialog when the Windows 10 OS is switched to tablet mode, rather it is in background.
So far we have tried the following,
building the application with "UIAccess=true"
SetWindowLong(m_hWnd, GWL_STYLE,
GetWindowLong(m_hWnd, GWL_STYLE) | WS_MINIMIZEBOX);
SetWindowLong(m_hWnd, GWL_STYLE,
GetWindowLong(m_hWnd, GWL_STYLE) & ~WS_MAXIMIZEBOX);
SetWindowPos(m_hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE );
Any suggestions.

Related

How to monitor all the top level Windows from an inactive Win32 application?

I am trying to create a Windows Win32 API application which has a requirement to get the Window RECT size of all the overlaying Windows oriented above my App Window.
Currently I am monitoring WM_ACTIVATE messages to keep track of when my app windows has another Window placed on top of it. This works fine but there is a hard limitation. It only helps when my app Window is going from "active/foreground" state to "inactive/background" state. Once it goes to "inactive" state, my app is no longer subscribing to windows messaging. So thereafter, when more windows are opened and my app goes below the Z-counts, I cannot get their handles at all.
What I am looking for is to persistantly get the messaging for the Windows which are opened.
I am currently using EnumWindows API to enumerate all the Windows from the active screen. I want to know how can I continually keep track of the other Windows irrespective of my app being active/inactive?
Right now, I am creating my main Window using standard CreateWindow arguments as this:
auto window_type = WS_OVERLAPPEDWINDOW;
auto window_ex_type = CW_USEDEFAULT;
HWND hWnd = CreateWindowW(szWindowClass, szTitle, window_type,
window_ex_type, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);

DPI scaling a complete dialog box from resource

I setup per-monitor DPI scaling in a Win32 app, and my part works fine, however opening up a dialog box created in the resource editor doesn't scale itself (I would think using dialog units, it would).
Is there a way to scale everything from a dialog resource and be compatible with, say, Win8.1, as well as Win10, and even Win7?
Per-Monitor and Per-Monitor (V2) DPI Awareness:
It is recommended that desktop applications be updated to use
per-monitor DPI awareness mode, allowing them to immediately render
correctly whenever the DPI changes. When an application reports to
Windows that it wants to run in this mode, Windows will not bitmap
stretch the application when the DPI changes, instead sending
WM_DPICHANGED to the application window. It is then the complete
responsibility of the application to handle resizing itself for the
new DPI. Most UI frameworks used by desktop applications (Windows
common controls (comctl32), Windows Forms, Windows Presentation
Framework, etc.) do not support automatic DPI scaling, requiring
developers to resize and reposition the contents of their windows
themselves.
You can resize the dialog box in the WM_DPICHANGED message.
case WM_DPICHANGED:
{
LPRECT lpRect = (LPRECT)lParam;
SetWindowPos(hWnd, nullptr, lpRect->left, lpRect->top, lpRect->right - lpRect->left, lpRect->bottom - lpRect->top, SWP_NOZORDER | SWP_NOACTIVATE);
return 0;
}
Updated:
For per-monitor DPI, v2 is the only one that can handle the dialog DPI scale., v1 does not so on WIndows 8.1 and older versions of Window 10, it has to be done manually. Windows 8.1 and older Windows 10, we don't scale controls. So the solution should be just resize the dialog. It has to enumerate all controls and resize them during WM_DPICHANGED if the dialog is not resizable.

Windows 10, DPI scaling and fullscreen

I have an application which is PROCESS_PER_MONITOR_DPI_AWARE from Windows 8.1 and DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 from Windows 10 v1703. My windows have the WS_OVERLAPPEDWINDOW style when in windowed mode, and I switch them to a monitor-sized WS_POPUP when fullscreening.
When I change DPI on the same monitor, a windowed-mode window get a correctly-scaled window size in the WM_DPICHANGED message on both Windows 8.1 and Windows 10 v1703. When fullscreened however, Windows 8.1 doesn't resize a fullscreen window (it keeps the same dimensions) but Windows 10 v1703 does. This means that a 2560x1440 fullscreen window at 96 dpi stays 2560x1440 on Windows 8.1 when going to, say, 144 dpi, but gets resized to 3840x2160 on Windows 10 v1703.
Is this normal i.e. is keeping a fullscreen window the same size something I should now be manually doing when receiving the WM_GETDPISCALEDSIZE message, which just used to be done automatically on Windows 8.1?
EDIT: After further testing, the WM_GETDPISCALEDSIZE message doesn't even seem to be sent if the window is fullscreen, only if it's windowed (WS_POPUP works but only if the size isn't the same as the monitor). Therefore I can't even override this behaviour, and Windows 8.1 works different to Windows 10 v1703 for fullscreened windows.
Try this:
void ShowFullScreen(HWND hwnd)
{
LONG exStyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
LONG style = ::GetWindowLong(hwnd, GWL_STYLE);
::SetWindowLong(hwnd, GWL_STYLE,
(style & ~WS_OVERLAPPEDWINDOW) | WS_POPUPWINDOW);
::SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_TOPMOST);
::ShowWindow(hwnd, SW_SHOWMAXIMIZED);
}
Will it help to solve the problem on W8.1?

MFC Application font issues - dialogs look wrongon Win2k8

My legacy application that runs on win2k3 citrix is about to be migrated to win2k8 citrix.
While testing on win2k8 I noticed UI issues that are not apparent on 2k3 - buttons are not wide enough for their labels, text fields are truncated, etc.
I noticed Win2k3 default font is Tahoma and 2k8 uses Segoe UI, not sure if this is the cause
It's a controlled environment that hosts only my application so changing the windows UI settings is preferable to redesigning all my windows and dialogs.
How can i make my application look the same on win2k8 as it does on win2k3?
Here is an example of my login dialog from the rc file. On win2k8 the text "please enter your user id" wraps over 2 lines and is hidden under the edit box.
IDD_LOGON DIALOG DISCARDABLE 0, 0, 545, 361
STYLE WS_POPUP | WS_VISIBLE
FONT 8, "Arial"
BEGIN
LTEXT "Welcome",IDC_USER_LOGON_HEAD1,368,192,140,19
LTEXT "Please enter your User ID",IDC_USER_LOGON_HEAD2,368,220,
118,14
EDITTEXT IDC_USER_LOGON_USER,368,236,81,12,ES_AUTOHSCROLL
LTEXT "and your password",IDC_USER_LOGON_HEAD3,368,260,118,14
EDITTEXT IDC_USER_LOGON_PASSWORD,368,276,81,12,ES_PASSWORD |
ES_AUTOHSCROLL
PUSHBUTTON "OK",IDOK,368,316,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,424,316,50,14
END
edit:
I did some further investigation by taking some screen shots of the above dialog. it appears the problem is not that the text is the wrong size - the problem in the controls on the dialog are too small!
eg:
for the control IDC_USER_LOGON_PASSWORD which is 81 dialog units x 12 dialog units.
it should be rendered as 142 px by 24 px
instead it is rendered too small as 122 px by 21 px
Does this give anyone any clues?
Looks like you have "Desktop Experience" installed. You can uninstall it, and the server will run in "Classic" mode.
Additionally, you can play with "Personalisation Settings". Open Control panel\Appearance and Personalisation\Display and select "Make text and other items larger or smaller". There you can set the size of each elements. I recommend you set everything at 100%.
Also, if this does not help, you can change Compatibility for the application in Win2k8 to run as Win2k3.
As suggested by Hans, the problem was a DPI setting. The Win2k8 system has a DPI of 96 and the win2k3 system has a DPI of 120.
Setting the DPI on win2k8 to 120 resolves the issue when logged on via remote desktop, however there are still some issues getting citrix settings to respect this DPI settings, but I'm on the right track now.
thanks everyone

PropertySheet Full Screen

I'm porting an application from windows Pocket PC2003 to Windows Mobile 6.5.
On startup my application shows a PropertySheet with two Pages which I want
to show in full screen mode.
The problem is this:
What ever I do the Taskbar and the menubar will never disapear. Windows Button,
SIP-Button and all other Buttons stay in foreground.
I tried this:
CPropertySheet::OnInitDialog();
// Call SHInitDialog with flags for full screen.
SHINITDLGINFO shidi;
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_FULLSCREENNOMENUBAR;
shidi.hDlg = m_hWnd;
::SHInitDialog(&shidi);
// SHFullScreen fails if dialog box is not foreground.
SetForegroundWindow();
SHFullScreen(m_hWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
and in normal dialogs it will work with
m_bFullScreen = FALSE;
on top but m_bFullScreen is not available for CPropertySheet.
Has anyone any solution for this problem?

Resources