close - Programmer

This is a discussion on close - Programmer ; Can anyone answer a simple question on the MFC framework? I have a SDI application I when the user selects the 'X' button i want to call a function in my cformview derived classes called OnAppExit(). This function is mapped ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: close

  1. close

    Can anyone answer a simple question on the MFC framework?

    I have a SDI application

    I when the user selects the 'X' button i want to call a function in my
    cformview derived classes called OnAppExit(). This function is mapped
    to a exit menuitem and displays a confirmation dialog. If my user
    selects the 'X' button I catch the event in the
    CMainFrame::OnClose() function but am unable to call my new function
    from here.

    Can anyone help or explain where im going wrong?

    Kind Regards
    Clive


    --
    Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

  2. Re: close

    Clive Moore wrote:
    > Can anyone answer a simple question on the MFC framework?
    >
    > I have a SDI application
    >
    > I when the user selects the 'X' button i want to call a function in my
    > cformview derived classes called OnAppExit(). This function is mapped
    > to a exit menuitem and displays a confirmation dialog. If my user
    > selects the 'X' button I catch the event in the
    > CMainFrame::OnClose() function but am unable to call my new function
    > from here.
    >
    > Can anyone help or explain where im going wrong?
    >
    > Kind Regards
    > Clive
    >
    >


    Your CMainFrame::OnClose handler will need a pointer to the view in
    order to call a view function. In order to compile you will first need
    to #include your doc.h and view.h files in CMainFrame. Then something
    like this will let you call the view:

    CMyView* pView = (CMyView*)GetActiveView();
    pView->OnAppExit();

    --
    Scott McPhillips [VC++ MVP]


+ Reply to Thread