The MFC Professional

PAST TIPS . . . STUFF YOU MIGHT HAVE MISSED

1 Avoiding a second instance by activating the current instance
Most of us check to make sure the user can't run multiple instances of our app -- that's easy. But wouldn't it be nice to automatically bring up the version that's currently running while we're at it? Well, here's the secret!
2 Centering a CView-derived window
Sure, you know how to center a dialog box. Geez, my mother can do that. But can you center a CView-derived window within the CMainFrame window? Yeah, you're smart, you can figure it out, but why bother? Just copy the code like my mom did!
3 Using a rich edit control in a dialog box
The App Wizard won't let you stick a rich edit control in the dialog box, and that just ain't fair. We'll show you a (cough) simple workaround.
4 Disabling a control at runtime
VB programmers can type this code in about ten seconds. It'll take you about twelve.
5 Preventing the RETURN key from firing the OK button
Do you want an OK button that isn't the default button? Don't feel bad -- everyone wants a non-default OK button from time to time.
6 Getting from a view to the document
Given a CView, how do you find the CDocument that owns it? Or, given a CDocument, how do you find the CView(s) owned by it?
7 Sizing an MDI Child Window
If I know I want my view's drawable region to be 100 x 100, how do I make it so?
8 Finding a File Association in the Registry
I have a program that lists files, like File Manager or Explorer, and I need to be able to let the user double-click on a file, and invoke the proper executable. How can I do this? This is not really an MFC question, but what the heck. We're not overly formal here -- anything that solves a problem is a good thing, even if it is standard SDK stuff!
9 File I/O with MFC
I want to just read in (and write out) a text file, but when I use ClassWizard, it seems to want to stick some kind of versioning information in the I/O stream (like its "typing" each kind of file).



| Future Tips | Home |

Got an idea for a Tip you'd like us to write? Let us know.

Solved a problem lately that would make a good Tip? PLEASE tell us about it!!!
We'll give you prominent credit, and we'll even buy you a beer next time you're in town.