Results 1 to 2 of 2

Thread: without using wizard creating window

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Posts
    163

    without using wizard creating window

    Without using mfcapp wizard, I want to create my own classes using mfc.

    class MyWinublic CWnd
    {
    .....
    };

    class MyFrameublic CFrameWnd
    {
    ....
    };
    class MyAppublic CWinApp
    {
    virtual BOOL InitInstance();
    };

    MyApp theApp;

    How to attach MyWin in MyFrame and MyFrame into MyApp?

    Thanks
    Purushottam

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Tick the "Disable smilies in this post" to avoid your class derivations be converted to smilies.

    CWinThread has a member named m_pMainWnd of type CWnd*. In InitInstance you create a new MyFrame object on the heap and assign the pointer to this variable:
    m_pMainWnd = new MyFrame();

    Then you have to add a message map to MyFrame. Catch the WM_CREATE message (ON_WM_CREATE() -> int OnCreate(LPCREATESTRUCT pCS)) and create the view there. Make it a class member, CFrameWnd provides no mechanism for that. It was made to use document templates and views.
    In the class declaration of MyFrame:
    MyWin m_win;
    In OnCreate:
    m_win.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0,0,0,0), this, AFX_IDW_PANE_FIRST, NULL);
    You should also check for an error return.

    This is the bare minimum. You should also override CFrameWnd::OnCmdMsg and forward the messages to the client window, as well as forwarding the focus in OnSetFocus (response to WM_SETFOCUS).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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