HOME
Login
Change Info
Logout


TUTORIALS

C, C++
Win32
Java
Visual Basic
MFC
DCOM
Networking
C#
Perl
HTML
XML
ASP
PHP
Javascript
Other

DOWNLOADS
ITCLib
SourceVizor meets the notification, reporting, and admin needs of teams using Microsoft Visual SourceSafe.
Free 30-day trial!


Creating a Simple MFC Program

by Alan Oursland

Changing Your Style

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

Conclusion

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

Developed Under:

Visual C++ 6.0 Service Pack 5



Previous Page
Return to beginning of article

Next Page


Featured Article

An Introduction to C#
By Joey Mingrone

Register Today!


100% FREE

Members enjoy these benefits:
Access to ITI Downloads
Access to more articles and tutorials
Optional weekly newsletter
And more...

Click here to register
Or
Click here to log in



© 2010 Interface Technologies, Inc. All Rights Reserved
Questions or Comments? devcentral AT iticentral DOT com
PRIVACY POLICY