How to set font to the Popup Menu? - c++

I have an issue with showing Popup Menu in a Windows application. I have no opportunity to set it's font size. I need to do this, for example, when I have two monitors with different DPI and want to show the menu at the monitor with a DPI different from the system DPI. The application I create uses Per Monitor DPI Aware manifest.
I know that in Windows 10 it's possible to create menu with a particular DPI Awareness Context so it will be bitmap stretched (found the information here), but I would like to not to stretch anything. In addition, creating menu with a System or Unaware DPI Aware Context leads to it's incorrect behavior like bad mouse positioning in the menu.

Related

QT: Different dpi behavior for different widgets

I have two widget inside of one window.
First widget is a program main menu.
Second one open when user presses 'New project' button.
I have enabled DPI via QT_SCREEN_SCALE_FACTORS + setAttribute(UseHighDpiPixmaps).
I have icons dynamically scaled for second widget when I move app from one monitor (windows dpi 100%) to another monitor (windows dpi 175%).
But first one (main menu) does not work this way.
It just preserves 2x icons without any respect to DPI.
I found this by marking 2x icons.
Also I was not able to reproduce this on the toy example.
Could anyone please point me the right direction?

Image in picture control in MFC dilaog is larger when running applicaiton than is shown in dialog editor

I am creating a MFC CDialog and adding a bitmap in a picture control and I have edit controls that need to be placed relative to positions on the image. However the size of the image in the picture control changes when I run my application.
This makes it difficult to align my edit boxes with the image.
Can anybody tell me why this happens?
There is no code to post as this is entirely done in the dialog editor of VS2013.
Windows adjusts the size of dialogs to match the system font, which can be changed by the user. For information about this look up dialog base units. If you need your dialog layout to match a bitmap then you need to override the Windows adjustment and explicitly set the size and location of the controls at run time. That would mean that in OnInitDialog you use MoveWindow on the dialog itself and on every control to set their size and location in pixel units that match the bitmap.

Wrong scaled up icon in taskbar of a Win32 application on Windows 7

I have a UI C++ Win32/WTL app. I have an application icon with many embedded sizes, including 16x16, 32x32, 48x48 and 64x64. I do a SetIcon() for both small and large icons and yet my Windows 7 task bar shows a blurry scaled up icon.
Are there any special APIs that need to be called or some special considerations?
The icon shown in the taskbar is not the one you set with SetIcon() but the one that explorer also shows for the exe file itself. That means it shows the very first icon in your exe resources.
Change the resource ID of your icon to e.g. 1 so it's the first icon, or add other sizes to the first icon your exe currently uses.
Icons are in the order? I have information, that Windows use icons in direct order. Try place icon 64x64 in the first place in array.
Unusual DPI / font size setting? I've seen XP ask for a 20x20 icon.

How to detect height and orientation of taskbar in Windows with autohide enabed?

I am using Qt, what I want to do is to display custom popup over the icon in system tray in Windows. I can obtain icon coordinates by using geometry() and taskbar height by finding difference between screenGeometry() and availableGeometry(). So the popup can be alligned correctly and does not overlap taskbar for different taskbar orientations (e.g. when taskbar is on the left side or on the top of the screen).
The problem starts when autohide of taskbar is turned on, then apparently availableGeometry returns the same value as screenGeometry, and I cannot find the taskbar height anymore. This results in the popup overlapping with taskbar, or even displayed at the wrong location.
My question is: how can I detect correctly orientation and size of taskbar in Windows, when the autohide is enabled? Should I use some winapi function, or can I do it purely in Qt (preferable) ?
1) Autohide state you check using this: http://msdn.microsoft.com/en-us/library/bb787947(v=vs.85).aspx
2) And find width/height/orientation using this: http://msdn.microsoft.com/en-us/library/bb787953(v=vs.85).aspx
Hope this helps. Yes, this is WinAPI functions, so you should use this code in "#ifdef Q_OS_WINDOWS" only - if want to compile on Linux too.

Needed: A popup window without a taskbar icon

I am designing a UI engine that needs to render into popup (WS_POPUP) windows. As these windows cannot be children of other windows, each instance is given its own taskbar icon.
I need a way to prevent the taskbar icons from appearing for certain windows that are created as "dialogs". I cannot use an OS-provided dialog because they all have frames (and I can't figure out how to render into them) or a tool-created custom dialog (which seem to require the CLR).
I am not an expert with the windows API and I feel that I have missed something obvious...
Also: Anything involving CLI/CLR is not an option.
EDIT:
The WS_EX_NOACTIVATE style can be used for this purpose as well, though the activation behavior would need to be emulated by the program.
If you set the WS_EX_TOOLWINDOW extended style for your window, it won't be shown in the task bar or Alt+Tab list. This does cause the window to be rendered slightly differently, however (thinking floating tool palette).