How to ignore the accent color on Windows 10? - c++

On Windows 10, you can turn on an accent color on the title bar of windows via Personalization settings.
Could a window of my app ignore that preference and display like if the setting is disabled? All the tricks I found in the web are just drawing own title bar (usually using a framework). Is there no simpler way to do that?
UPD: I need to draw an image on the window. The image should be partly inside the rect of the title bar, partly outside. For that reason, I need visually hide the boundary between the title and the client area.

Related

MFC - CPropertyPageEx and scaling (4K monitor)

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.
.

How to create a borderless window with titlebar in windows c++

I am trying to create a Direct3D app that is operating in windowed mode with a title bar and minimize/quit button. However, I'd really like to be able to axe the border around the window.
I am looking to do this because it looks pretty cheesy on dual monitors when the app is filling the primary monitor horizontally (with room to move the app vertically), but its window border overflows onto the secondary screen. I've tried a bunch of combinations of setwindowlong with GWL_STYLE and GWL_EXSTYLE, but can't seem to make headway unless I disable the title bar.
I've seen a bunch of apps that are borderless however they seem to emulate the title bar rather than using the built in one provided by Microsoft.
Thanks for any suggestions.
You can't remove the border and keep the titlebar AFAIK.
You can reimplement the titlebar by using WM_NCHITTEST but you still need to draw it yourself which would not be a bad idea if you want your D3D app to look its best.
Visual Studio, last time I checked, achieves its border with transparent layered windows standing behind the primary one. They are the shadows you see.

MFC VC++: How to remove blank space between the Window caption and Client area

I am developing a desktop app using MFC. The following image shows the current state of the app's window top part. The area marked in red is unnecessary and I want to remove it.
How can I remove that space or atleast change the color to match the rest of the window background?
More Info:
The App is using Ribbon UI. I have added the App button programmatically in onCreate of CMainFrame. Is it the bar that holds the Ribbon categories? I tried SetMenubarState(AFX_MVS_HIDDEN) thinking it was the menu bar, but that didn't work. Just changing its color is also acceptable.
Update:
I have managed to change the color of that ribbon strip, and removed the caption bar I used for showing the 'add' button. Now I need to figure out how to place the 'Add' button on the right side of the ribbon strip.

Program that displays content on screen but no window

In windows: I would like to know if it is possible (and if so, how) to make a program in C++ that displays images/text on the screen directly, meaning no window; if you are still confused about what I am after some examples are: Rocketdock and Rainmeter.
you can do it certainly without using Qt or any other framework. Just Win32 API helps you do that and internally, every framework calls these API so there is no magic in any of these frameworks
First of all, understand that no image or text can be displayed without a window. Every program uses some kind of window to display text or image. You can verify it using the Spy++ that comes with windows SDK. click the cross-hair sign, click the image or text you think is displayed without any windows. The Spy++ will show you the window it is contained in.
Now how to display such image or text that seems like not contained in any window. Well you have to perform certain steps.
Create a window with no caption bar, resize border, control box, minimize, maximize or close buttons. Use the CreateWindowEx() and see the various windows style WS_EX_XXX, WS_XXX for the desired window style.
Once the window is there you need to cut the window. Much like a cookie cutter. for this you need to define an area. This area is called region and you can define it using many functions like CreateEllipticRgn(), CreatePolygonRgn(), CreateRectRgn(), CreateRoundRectRgn() etc. all these functions return a HRGN which is the handle to the region. Elliptical or rectangle regions are OK as starter.
Now the last part. You have to cut the window like that particular region. Use the SetWindowRgn() function which requires a handle to your window and a handle to that region (HRGN). This function will cut the window into your desired shape.
Now for the image or text. Draw the image or text inside the window. I assume you must have cut the window according to your image, You just need to give window a face. so just draw the image either on WM_ERRASE BACKGROUND or WM_PAINT messages
Use the SetWindowPos() to move the window to the location you wish to on screen. If you have used correct parameters in CreateWindowEx() then this step is not necessary
You can set any further styles of windows using SetWindowLong() function.
Congratulations, you have your image displayed without using any windows ;)

How are controls put in the caption bar?

I noticed Firefox 4, Opera and Chrome, and IE 7/8 put buttons and controls in the title/caption bar, how is this done?
Thanks
http://img199.imageshack.us/img199/3307/slayerf.png
alt text http://img199.imageshack.us/img199/3307/slayerf.png
What they probably do is turn the caption bar off entirely (by excluding the WS_CAPTION window style), add a glass area to the top of the window, and then draw their own controls.
See http://msdn.microsoft.com/en-us/magazine/cc163435.aspx for more on glass.
Probably they simply handle the WM_NCPAINT message and draw part of the non-client area (which includes the borders and the caption bar) by themselves; they will also handle WM_NCLBUTTONDOWN, WM_NCHITTEST and other WM_NC* messages to emulate the behavior of a button on the caption bar.
Or at least, this was the way it was commonly done before Aero; I don't know how much it changed this kind of things.
Yes, you can do that.. you have use window hooks, insert your dll in remote process and run the function of dll remotely. here is full fledged article dealing with it :-
http://www.codeproject.com/KB/threads/winspy.aspx