Re: TDD for MFC

Anthony Williams <[email protected]> Thu, 17 Mar 2005 17:00:56 +0000
Newsgroups gmane.comp.programming.test-driven-development,gmane.comp.programming.test-first-user-interfaces
Message-ID <[email protected]>
Phlip <[email protected]> writes:

> I wrote a recipe for submitting a legacy MFC program to the TFUI
> principles here:
>
>  http://www.xpsd.org/cgi-bin/wiki?TfuiForMfc

Which says:

"The bad news is MFC flashes the window at Create() time."

The good news is that it only does this if WS_VISIBLE is set for the dialog in
the resource file.

As for your reveal() function --- I don't like the idea of overriding handlers
to post quit messages. You could utilise the fact that a modal dialog box is
intended to close using EndDialog, in which case you can use
CWnd::RunModalLoop() as your reveal (don't forget to ShowWindow first), or
poll CWnd::ContinueModal() yourself.

If I need a reveal, then I'll use RunModalLoop, but I haven't found the need
yet (other than to prove that it can be done).

And for taking pictures, using meta files is far easier than using a bitmap,
as CreateEnhMetaFile creates a DC for you, so takePicture can be reduced to:

void takePicture(HWND window,CString const& fileName)
{
    HDC dc=CreateEnhMetaFile(NULL,fileName,NULL,NULL);
    LPARAM lParam = PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | 
        PRF_NONCLIENT | PRF_OWNED;
    SendMessage(window, WM_PRINT, (WPARAM) dc, lParam);    
    DeleteEnhMetaFile(CloseEnhMetaFile(dc));
}

I also have a whole host of helper functions for poking the GUI as-if by a
user, for those that are interested.

Anthony
-- 
Anthony Williams
Software Developer



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/testdrivendevelopment/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/