CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    MFC without the wizards

    Has anyone seen, or at least tried (successfully) to create an MFC application without using any of the wizards to start with? The reason for my askin is that it seems to me that Visual Studio adds loads of its own code, much of which might not be necessary to, say, complete a simple window application.


  2. #2
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: MFC without the wizards

    Yes, I have - but it was because of my ignorance of the doc-view architecture and how to use it; I really DON'T recommend doing it without the Wizards. Yes, they put in a lot of code; but so what? It doesn't do your project any harm, and provides a very handy framework to build on. My recommendation: don't do it! However, if you still want to, you can e-mail me at [email protected] and I'll guide you where necessary as to how to start.

    --
    Jason Teagle
    [email protected]

  3. #3
    Join Date
    Apr 1999
    Posts
    383

    Re: MFC without the wizards

    Much of the MFC code isn't necessary to create a simple Windows application, but a Windows application that simple is not much practical use, and MFC is intended for developing 'industrial strength' applications for practical use.

    The wizards are there because implementing all the basic code for a functioning MFC application is not a trivial exercise.

    Dave


  4. #4
    Join Date
    May 1999
    Posts
    12

    Re: MFC without the wizards

    Hi,
    First question, what kind of application are you trying to create ? Does your app require Doc-View architecture OR is it plain windows without the Doc-View stuff. Now I faced the situation where I wanted the functionality of classes like CWnd, CDialog but without the overheads of Doc-View architecture.
    I am not saying that Doc-View architecture is bad, just that you may not need
    it at times.
    So I created a "Win32 Application" project. I had a WinMain function. The skeletal code is given below. Here I am instantiating an object of type CWnd
    and then making a simple window . And then I am switching on the message pump.
    You can derive a class from CWnd and place message handlers for the messages
    that you would like to hanlde, say WM_PAINT,WM_DESTROY ,etc. The command line option for making the Exe is:
    "cl SampleCode.cpp /link user32.lib mfc42d.lib"

    Code is as follows:

    #include <afxwin.h>
    int WINAPI WinMain(
    HINSTANCE hInstance, // handle to current instance
    HINSTANCE hPrevInstance, // handle to previous instance
    LPSTR lpCmdLine, // pointer to command line
    int nCmdShow // show state of window
    )

    {
    //the following line is neccessary.
    AfxWinInit( hInstance, // handle to current instance
    hPrevInstance, // handle to previous instance
    lpCmdLine, // pointer to command line
    nCmdShow // show state of window
    );

    const char *class_name = AfxRegisterWndClass ( 0 ,
    LoadCursor(NULL,IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH),
    NULL);

    CWnd *x = ::new CWnd;
    x->CreateEx ( 0,
    class_name,
    "Using CWnd class in a simple Win32 Application",
    WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_BORDER | WS_MINIMIZEBOX | WS_SYSMENU,
    100,100,
    700,700,
    HWND_DESKTOP,
    NULL
    );

    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
    TranslateMessage(&msg); // allow use of keyboard
    DispatchMessage(&msg); //return control to key board
    }
    return(msg.wParam);
    return 0;
    }






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured