![]() |
![]() |
|||||||
|
Login Change Info Logout
DOWNLOADS |
by Alan Oursland Changing Your StyleThe last part of this introduction to a simple MFC application deals with changing the style of your window. When the window is maximized, I'd like to get rid of the borders (after all, if I'm dealing with graphics I want all the screen space I can get). We will remove the WS_THICKFRAME style from the window on WM_MAXIMIZE and add it back on WM_RESTORE. Add "ModifyStyle(WS_THICKFRAME, 0, 0)" to OnPopuptopMaximize and "ModifyStyle(0, WS_THICKFRAME, 0)" to OnPopuptopRestore. The thick borders will be removed when you maximize the window. There is still some border left. This is the 3D look that Windows provides. I want to remove this as well. The 3D look is controlled by the Extended Style WS_EX_CLIENTEDGE. Add "ModifyStyleEx (WS_EX_CLIENTEDGE, 0, 0)" to OnPopuptopMaximize and "ModifyStyleEx (0, WS_EX_CLIENTEDGE, 0)" to OnPopuptopRestore. Just for fun, let's add a real System Menu to our window. This will let us right-click on the icon in the task bar. Add "ModifyStyle(0, WS_SYSMENU, 0)" to the constructor after Create (we could just add it into Create, but what fun would that be?). Using ModifyStyle and ModifyStyleEx you can change the appearance of you window in all sorts of ways - add/remove menus, scrollbars, make the window stay on top, give it a title bar, among other things. Play around with it. Note that you will have to repaint your window after the style changes. The maximize and restore do it for us here. ConclusionI hope that at this point you find yourself a little more familiar with how windows work in Windows. I've provided the source code with the article. Until next time, have fun.
|
|
|
||||||||||||||||||||||||
|
Questions or Comments? devcentral AT iticentral DOT com PRIVACY POLICY |