WinAPI - Custom sizing border (WS_THICKFRAME) - c++

I don't like how the native sizing border looks like :
I would like to have something like this fancy purple border instead :
Should I implement my own sizing border manually or should I keep using the WS_THICKFRAME window style and customize it ?
And if I can customize it, I'd like it to be done without nasty hacks too...

You may create a window without border and caption bar by specifying the WS_POPUP flag in the window type flags.
Your handler of the WM_NCHITTEST message you must check which part of your window a certain pixel really belongs to (e.g. resinzing frame) and return the code for that part.
The drawback: You'll have to draw the entire window content (including caption etc.) your own.

I think you should implement your own redraw procedure (for example to draw a purple rectangle at the bottom, and then draw an icon in the corner). If you're wanted to make your window similar to VS2013 window, then you should use WS_POPUP style and then implement your own redraw routine. If you wanted to customize your window's form you can use regions (SetWindowRgn(), CreateRectRgn(), CreateRoundRectRgn(), CreateEllipticRgn(), CreatePolygonRgn(), etc.) Broadly speaking, using WinAPI you can do everything, but are you limited to WinAPI only? It is good idea to use MFC or Windows Forms to make window interface creation much easier.

Related

Using DwmExtendFrameIntoClientArea to draw a solid color dialog with standard non-client controls

I'm trying to create a dialog that looks more or less like this:
So in other words, I'd like it to be one solid color, with the seamless non-client area, and standard-looking non-client controls (close, minimize, etc.).
I imagine that that particular dialog uses some very custom rendering and custom controls, but I'm trying to achieve a similar effect using DwmExtendFrameIntoClientArea and the techniques described here. So in other words, I'd like to preserve the standard non-client controls provided by Windows (close, minimize etc.), and avoid having to draw them myself using DrawThemeBackground.
The first thing I don't understand is about having to paint the window black in order to see the extended non-client area. Does that mean that, even if the dialog itself is white or gray via WM_CTLCOLORDLG, you need to handle WM_PAINT in the dialog to paint certain areas black?
And then my second question is how to actually paint the non-client area white (while still preserving the standard non-client controls).
Thanks for any input or guidance on how to accomplish this. By the way, I tried the sample provided in this answer, but that doesn't include the non-client controls (close, minimize, etc.).

How to achieve Steam-like window using winapi?

This is a screenshot of Steam's client window being resized.
Steam's client window has two cool features.
Custom window which is very responsive.
Cool glass resize effect, different from standard windows (Thought it might be a side effect strongly related to 1)
Let's say I wanna create similar window using winapi. How can I do it?
I don't ask about widget-management related stuff, but about technical winapi tricks.
Basically, you can do almost anything with your window. But most of the tricks are to be implemented manually.
What is 'very responsive' I don't know. If you mean that the window has no standart border, it is easy to implement: do not specify WS_BORDER and WS_CAPTION when creating a WS_POPUP window. After that you will have to draw a border and a caption yourself. Handle WM_ERASEBKGND and WM_PAINT messages, draw background, menus, all as usual.
This effect seems to me more like a bug. It happens this way: the window is resized, it gets a WM_SIZE message, processes it, Windows sends a WM_ERASEBKGND message which the window ignores. Thus, the system draws a new shadow around new window frame which is not yet filled with new window image. And here we get this cool glass effect: old image of underlaying windows with a windows aero shadow. You can try to disable windows shadows and look at this effect.
In order to create a custom resizing border, you might find useful these functions: LoadCursor, SetCursor, MoveWindow.
In order to draw your custom borders, you can use standart GDI functions. Also you can create a handful of child windows and delegate drawing to them. This is basics of winapi.

Borderless window in clutter(mm)

I'm trying to use cluttermm to create a borderless window (for example, something like this).
In other words, I want to draw a rectangle on screen and some text on it, but NOT in a window, and NOT with borders.
Is clutter a really bad choice for this, or how can I do this?
Thanks!
Clutter itself doesn't offer any API to do this, and defers to the platform's API to control the actual window.
you can use Clutter-GTK and the GtkWindow API to remove the decoration from the window embedding the stage.

flicker free tab control with WS_EX_COMPOSITED

I have a VS2008 C++ application for Windows XP SP3 developed using WTL 8.1. My application contains a tab control that flickers when the application border is resized.
My window hierarchy looks like this:
CFrameWindowImpl CMainFrm
|-CSplitterWindow Splitter
|-CTabView Configuration Tabs
| |-CDialogImpl Configuration View 1
| |-CDialogImpl Configuration View 2
| |-CDialogImpl Configuration View 3
|-CDialogImpl Control View
The solution I'm trying is to make the CFrameWindowImpl derived class use the WS_EX_COMPOSITED style and all windows beneath it use the WS_EX_TRANSPARENT style. Unfortunately, this makes the tab control buttons show as an empty black bar and the controls of any Configuration View to not show at all.
If I remove the WS_EX_COMPOSITED and WS_EX_TRANSPARENT styles, the form displays properly, but the CTabView and everything beneath it flickers horribly when resized.
What do I need to change to eliminate the flicker and draw the controls properly?
Thanks,
PaulH
Edit:
Got it working. I removed all the WS_EX_TRANSPARENT styles per Mark Ransom's suggestion. I put the WS_EX_COMPOSITED style on only the CTabCtrl (contained within the CTabView). Other controls get double-buffering as needed through WTL::CDoubleBufferImpl<>.
A window flickers because it gets erased before it's drawn. To eliminate this you need to disable erasing of the window entirely and use double buffering - draw the window contents into a bitmap, then copy the bitmap to the window. Because the bitmap contains the entire contents including the background, there's no need to erase anymore.
It looks like WS_EX_COMPOSITED will handle the double buffering automatically, but you still probably need to use a NULL background brush and/or handle the WM_ERASEBKGND message.
Whats not mentioned in MSDN is that the Desktop Window Manager - the component that hooks window painting on Windows Vista and 7 to perform the desktop composition necessary to get the aero glass effect - does NOT implement WS_EX_COMPOSITED.
Which means all the work you put into getting this style to work on XP, is doomed to become irrelevent on Vista or later.
The other problem with WS_EX_COMPOSITED - and why it was an optional style and not a default on XP: The double buffering only picks up painting performed during the BeginPaint / EndPaint block of the parent window. Lots of, even standard controls, perform painting outside of their WM_PAINT handlers, and as a result the backbuffer gets only partially painted.
Sadly, the result is, the only way to "eliminate" flicker in native API apps is to try to minimize it: WS_CLIPCHILDREN and WS_CLIPSIBLINGS can help if you dont have overlapping controls - to ensure that each control's area is painted only once. And ensure that the main dialog does not perform any flood filling in WM_ERASEBKGND
It is not, in my experience, possible to use double-buffering for anything that contains child controls (unless they all fully support WM_PRINT, which most do not).

Problems encountered when implement a float, translucent sub-window in MFC with C++

I have tried several methods, but problems always exist. Sometimes the sub-window didn't refresh and sometimes the sub-window will keep blink.
This is a sample project that i have written
http://rapidshare.com/files/283950611/TestProject.7z.html
My method to implement that is:
Put a scroll bar on the top of sub-window, whenever the scroll bar was dragged, the sub-window would be moved as well.
And every dialog is inherited from CDialogBase, All the drawing is done in this class, Drawer.h is a helper for drawing.
Only when the DC that user assigned is dirty, then system will redraw the window, it is used for accelerating the painting.
WS_EX_LAYERED only can be added to with top level window, not sub-window; I've tried to modify the window style from WS_CHILD to WS_OVERLAPPED, and then using layed window, and then clip the visiable area of the window, but, the result is not what I expected.
Anywhere, thank you for your advice...
Have you considered using WS_EX_LAYERED and then using UpdateLayeredWindow. It can get quite complicated but allows for things like per-pixel alpha and eliminates flicker like you are seeing.
Look here:
http://www.nuonsoft.com/blog/2009/05/27/how-to-use-updatelayeredwindow/
for more info.