Draw a border around a STATIC control

Anybody knows how to draw a border around a STATIC control, inside the WM_PAINT message or any other? I cannot find anything on MSDN or Google. People don't draw borders too often, as I see.
Thanks
You can control various border states with the extended window styles of static controls. Of course, you need to use CreateWindowEx() instead of CreateWindow() to use the extended styles. I'm not sure if any of the styles draw a black edge around the control or not; you would have to experiment. Most affect such things as sunken edge, raised edge, etc.

If that doesn't meed your needs, then I'd make my own static (label) custom control. Astually, that's a tremendously good way of moving your coding to the 'next level'. Static controls are very easy to make (on your own - nor the one pre-defined in Windows). Doing that teaches dynamic memory allocation, pointers, instance data, etc. Very good stuff to know.
I feel that the more I immerse into the world of C++ and Win32 API I need to start creating my own controls. I don't have a clue about how to do it but I will look for some tutorials.

Regarding my problem, yes, I can create a border around a STATIC control with extended styles but it disappears when I subclass the control.
Last edited on

..but it disappears when I subclass the control.


That shouldn't happen. You've got an error or another issue somewhere that needs to be resolved first. Are you doing the subclassing correctly? The basic issue is, Windows will call your subclass procedure before the internal 'real' Window Procedure is called. If in your subclass procedure you are not calling the internal Window Procedure with the message, odd things can happen, i.e., repaint failures, anything really.
Topic archived. No new replies allowed.