MFC - CPropertyPageEx and scaling (4K monitor) - mfc

I'm upgrading an old MFC app to support 4K monitors. According to what information I can find, CPropertySheetEx 'implements Wizard97 style functionality'. It's a dialog with Previous and Next buttons and a banner.
Now MFC has done a poor job of scaling this dialog and I'm not sure what control I have over it.
4K is usually 200% scaling. The banner height is unchanged at 59 pixels (so is too small on a 4K monitor). The rest of the dialog seems to have scaled to about 150% (width, height).
I've tried SetWindowPos on the banner. This doesn't resize it and causes other dialog issues.
There's this note in the code, which makes me think the banner is dynamically constructed with the property sheet.
// If the page has a header, we need to paint the area above the border.
// By inspection (Spy++), the border is a static control with ID 0x3027
CWnd* pTopBorder = GetDlgItem(0x3027);
Any suggestions or guides would be appreciated.
The app is DPI aware. Many MFC components scale properly (some need some work)
Question - How can I get CPropertyPageEX dialogs to support scaling?
Here's an image ![Scaling Issue]https://imgur.com/a/Ww8SLnU
Edit -
The icon and the text in the banner can be resized and repositioned, only the height of the banner seems stuck at 50 pixels.
CPropertyPageEx is defined as CPropertyPage in MFC 11. It's derived directly from CWnd.
Having a look at the sources for CPropertyPage (atlmfc\src\mfc\dlgprop.cpp) there's no constructor where it creates buttons or banners (so I may be looking in the wrong place).
A PropertySheet seems to consist of
a graphic (user supplied),
a horizontal bar (static control),
a dialog resource from the Property Page currently displayed
another horizontal bar
a series of buttons (Prev , Next etc)
Have a look at my high def screenshot https://imgur.com/a/yR97H96
The dialog and controls have rescaled
The vertical position of the horizontal bar and the property page are both unchanged from the unscaled version, leading to the ugly overlap you can see.
.

Related

How to set size and Transparent / Clear CMFCToolBar Button and Icon in mfc?

I have created some (CMFCToolBar) toolbars and added buttons and icons to them. I read on Microsoft's official website that CMFCToolBar takes 23x22 button size and 16x15 icon size (ref: link).
If I use 16x15 for the icons, then icons appear blurry. This is because the icons are originally with size 16x16. I used the function SetSizes(CSize (23,23), CSize(16,16)) to change icon size but the icons do not appear right:
Is there another way to set icon and button size?
Update
I called the SetSize function before create toolbar but the icon still appear a little blurry:
I want to know if there is a way to set Icon/button Transparent or make it clear like we can set toolbar transparent through TBSTYLE_TRANSPARENT in CreateEx function.
SetSizes is a static function that affects the complete library.
It should be called before you create any toolbar or menu object.
Best location is in InitInstance of you applicxation.
But my tipp: Use the sizes that are recommended! 16x15 and 23x22....
Transparency can be done with standard 32bit RGB/A bitmaps.
If you have a 16 color bitmap you should use RGB(192,192,192) as the standard color for the background. It is automatically replaced with the needed background color.
This has been answered here too.

C++ Win32 how to remove tab borders WC_TABCONTROL

Hi I am trying to convert an existing WC_TABCONTROL window with TCS_OWNERDRAWFIXED so that I have full control of its appearance.
But it seems all I can draw is the tab headers and even there I do not have much control on how the borders are drawn around tab page as well as tab headers.
Can someone point me to some material that explain how to custom draw, tab items and tab pages. I need to have control on how both the background and borders are drawn.

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.

in wxpython using a GLCanvas, tooltips sometimes covered by the GLCanvas

I have a wxpython application, and I'm using both a toolbar and a wx.glcanvas.GLCanvas sub-window to draw my client area content. The toolbar is vertically just above the GLCanvas. When I roll over a tool and the tool tip pops up, it often (but not always) gets overdrawn by the GLCanvas, so the part of the tooltip that extends into the canvas area gets whited out by the all-white canvas rect. As I say, it doesn't happen all the time -- sometimes the tooltip shows over the canvas area just fine. I assume the difference is just in whether wxpython (or Windows?) happens to decide to sent me a paint message to repaint the canvas while the tooltip is shown. But even if the canvas is repainted, you'd think it could just respect its z order and repaint under the tooltip. But I realize opengl canvases might be special in not playing nice with the window z order.
Any suggestions for a solution or work-around? I was hoping to be able to tell the tooltips to show above the tools instead of below them, but there doesn't appear to be a way to set that.

How to draw something to the screen and have the underlying ui interactive

I seeking solution for Windows first.
I need to add visual effects to screen image without breaking the interactivity of all and every controls, that are on this screen.
The solution can be straightforward:
1. take a screenshot
2. show this screenshot in a separate window, above other windows
3. apply the effect to image, being shown on this window
But, this window (containing screenshot) makes any buttons and other controls below, unreachable for mouse interaction (clicking, hovering)
Is there any way to do this ?
From MSDN's documentation on layered windows...
"Hit testing of a layered window is based on the shape and transparency of the window. This means that the areas of the window that are color-keyed or whose alpha value is zero will let the mouse messages through. However, if the layered window has the WS_EX_TRANSPARENT extended window style, the shape of the layered window will be ignored and the mouse events will be passed to other windows underneath the layered window."
Here's an article about it. Notice this additional warning:
"setting the WS_EX_TRANSPARENT attribute affects the entire window: the user can't close the window using the 'x' button, select it with the mouse, or select any controls on the window. The application can still close the window programmatically."
Depending on what you're actually drawing and where, it might be more appropriate to use Owner-Drawn Controls rather than hover an "onion skin" over your whole window.