// kartendialog.cpp: Implementierungsdatei
//

#include "stdafx.h"
#include "Ecopay.h"
#include "kartendialog.h"
#include "visdireckt.h"

// kartendialog-Dialogfeld

IMPLEMENT_DYNAMIC(kartendialog, CDialog)

kartendialog::kartendialog(CWnd* pParent /*=NULL*/)
: CDialog(kartendialog::IDD, pParent)
{

}

kartendialog::~kartendialog()
{
}

BOOL kartendialog::OnInitDialog()
{
    CDialog::OnInitDialog();
    CCreateContext pContext;
    /**
     * Note:CDialig derived pointer is converted to
     * CWnd pointer (a common base class for CDialog and CFrameWnd).
     * Thus casting it back to CFrameWnd is also easy.
     */
    CWnd* pFrameWnd = this;
    CMDIChildWnd * pChild = ((CMDIFrameWnd*) (AfxGetApp()->m_pMainWnd))
            ->MDIGetActive();

    //CDocument * pDoc = pChild->GetActiveDocument();

    // pContext.m_pCurrentDoc = new CMyDocument;
    pContext.m_pCurrentDoc = pChild->GetActiveDocument();
    pContext.m_pNewViewClass = RUNTIME_CLASS( visdireckt);
    visdireckt *pView = (visdireckt *) ((CFrameWnd*) pFrameWnd)->CreateView(
            &pContext);
    ASSERT( pView);
    pView->ShowWindow( SW_NORMAL);
    /**
     * After a view is created, resize that to 
     * have the same size as the dialog.
     */
    CRect rectWindow;
    GetWindowRect( rectWindow);
    /**
     * Leave a little space for border and title...
     */
    rectWindow.right += 15;
    rectWindow.top -= 10;
    pView->MoveWindow( rectWindow);
    CString str( AfxGetApp()->m_lpCmdLine);
    /**
     * Note: "CMyVw" is a CHTMLView derived class to add some 
     *       spice to the view, I have provided a HTML page 
     *       to which it navigates when the dialog is up.

     char strPath[255];
     ::GetCurrentDirectory(255,(LPSTR)(LPCSTR)strPath);
     strcat(strPath,"\\defaultpage.html");
     pView->Navigate(strPath);
     */

    return TRUE; // return TRUE  unless you set the 
                 // focus to a control
}

void kartendialog::DoDataExchange( CDataExchange* pDX)
{
    CDialog::DoDataExchange( pDX);
}

BEGIN_MESSAGE_MAP(kartendialog, CDialog)
END_MESSAGE_MAP()

// kartendialog-Meldungshandler
