Code Snippets
The following articles discuss various programming techniques in Visual C++ using MFC. Feel free to use any of the code provided, for whatever reason.
General Windows Programming
- Simple Windows Registry Access
- Learn how to store application specific preferences in the Windows registry with this short article.
- Advanced Windows Registry Access
- Take your Windows registry knowledge a step further with this article, which details how to read values from anywhere in the registry.
- Application Context Menus
- Create a right-click context menu that works anywhere inside your application.
- Control Specific Context Menus
- Learn how to create a custom context menu unique to a specific window control.
- Copying Text to the Clipboard
- Send the contents of a CString to the Windows clipboard using this simple function call.
- A Cleaner MRU List
- Improve the control you have over the registry settings that get created when using a “most recently used” list.
Dialog Based Programs
- Adding Accelerator Keys
- Learn how to add accelerator keys to your dialog based program.
- Adding Tool Tips to Dialog Controls
- Want to add tool tips to individual dialog controls? This article takes a look at one method presented in the MSDN documentation.
- Adding UpdateCommandUI to Dialog Menus
- Restore the missing UpdateCommandUI feature to your dialog based program’s menus.
- System Menu Icon Bug
- Make your application’s system menu icon display properly by fixing an MFC bug.
Window Placement and Sizing
- Automatically Size CListView Columns
- Force the columns of a CListView to fit neatly within a resizable window.
- Keep a Window on Top
- A simple function call is all that is needed to prevent your window from disappearing below others.
- Limiting the Size of a View
- Prevent your users from making a view window too small — or even too large.
- Minimize All Windows
- Learn how to minimize and restore all open windows at once in just one line of code.
- Snap a Window to the Screen Edge
- Want a window that acts like WinAmp, Photoshop or other such snap-able programs? Learn how to do it properly with this article.