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.
-
10Best to have a window anyway, even if the only part of it that's visible is what you display on it. Using the screen's DC is asking for trouble when you expect it to work properly. – chris Jul 25 '13 at 04:45
-
2Rocketdock and Rainmeter almost certainly use transparent windows. – user253751 Jul 25 '13 at 05:36
-
@immibis then how do I make a transparent window? – lewisjb Jul 25 '13 at 05:40
-
@Pyro, lots of good tutorials out there. One option is a plain layered window. – chris Jul 25 '13 at 05:42
-
I don't know enough about win32 to tell you how to make one yourself. – user253751 Jul 25 '13 at 05:43
-
You could use the Qt framework, see http://stackoverflow.com/questions/2235360/looking-for-qt-styling-with-borderless-window-tutorial-or-how-to for an example – arne Jul 25 '13 at 05:57
-
I dislike Qt, but thanks for the suggestion. – lewisjb Jul 25 '13 at 06:07
-
well i have answered it how to do it without using Qt. I think it shud be marked as the rite ans – Simple Fellow Sep 23 '13 at 09:50
-
@SimpleFellow May you please read the comment above you? – lewisjb Sep 27 '13 at 21:39
-
@Pyro "I dislike Qt, but thanks for the suggestion" - I read it. so? – Simple Fellow Sep 27 '13 at 23:12
1 Answers
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 ;)

- 4,315
- 2
- 31
- 44