Programm beenden



  • Hallo
    irgendwie dumme Frage... Wie beende ich eine MFC anwendung per code? Also nicht im ersten Fenster da geht es schon.. aber wen ich einen zweiten Dialog modal angezeigt habe gehts nicht mehr.. Wie könnte man das lösen?

    Mfg Burnner



  • Hier steht wie man den Dialog schließen kann
    [msdn]
    CDialog::EndDialog
    void EndDialog( int nResult );

    Parameters

    nResult

    Contains the value to be returned from the dialog box to the caller of DoModal.

    Remarks

    Call this member function to terminate a modal dialog box. This member function returns nResult as the return value of DoModal. You must use the EndDialog function to complete processing whenever a modal dialog box is created.

    You can call EndDialog at any time, even in OnInitDialog, in which case you should close the dialog box before it is shown or before the input focus is set.

    EndDialog does not close the dialog box immediately. Instead, it sets a flag that directs the dialog box to close as soon as the current message handler returns.

    Example

    // MyWnd.cpp
    #include "MyDialog.h"
    
    void CMyWnd::ShowDialog()
    {
       CMyDialog myDlg;
       int nRet = myDlg.DoModal();
    
       if ( nRet == IDOK || nRet == 5  )
          AfxMessageBox("Dialog closed successfully");
    }
    
    // MyDialog.cpp
    void CMyDialog::OnSomeAction()
    {
       // Do something
    
       int nRet = 5; // Just any value would do!
       EndDialog(nRet); // This value is returned by DoModal!
    
       // Do something
    
       return; // Dialog closed and DoModal returns only here!
    }
    

    [/msdn]



  • habs anders gelöst aber thx.. aber gibts nicht ne möglich keit das Programm einfach abzuschalten..



  • Ich weiß nicht ob das jetzt die feine Art ist, aber versuch's mal mit exit(0);
    Gruß
    Sebastian


Anmelden zum Antworten