
// mymfc10View.cpp : implementation of the CMymfc10View class

#include "stdafx.h"
#include "mymfc10.h"

#include "mymfc10Doc.h"
#include "mymfc10View.h"
#include "SpecFileDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMymfc10View

IMPLEMENT_DYNCREATE(CMymfc10View, CView)

BEGIN_MESSAGE_MAP(CMymfc10View, CView)
	//{{AFX_MSG_MAP(CMymfc10View)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMymfc10View construction/destruction

CMymfc10View::CMymfc10View()
{
	// TODO: add construction code here

}

CMymfc10View::~CMymfc10View()
{
}

BOOL CMymfc10View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc10View drawing

void CMymfc10View::OnDraw(CDC* pDC)
{
	// TODO: add draw code for native data here
	pDC->TextOut(30, 30, "Press the left mouse button lol!");
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc10View diagnostics

#ifdef _DEBUG
void CMymfc10View::AssertValid() const
{
	CView::AssertValid();
}

void CMymfc10View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMymfc10Doc* CMymfc10View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMymfc10Doc)));
	return (CMymfc10Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMymfc10View message handlers

void CMymfc10View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CSpecialFileDialog dlgFile(TRUE, NULL, "*.obj");
    CString strMessage;
    int nModal = dlgFile.DoModal();
    if ((nModal == IDCANCEL) && (dlgFile.m_bDeleteAll))
    {
        strMessage.Format("Are you very sure you want to delete all %s files?",
			dlgFile.m_strFilename);
        if (AfxMessageBox(strMessage, MB_YESNO) == IDYES)
        {
         HANDLE h;
         WIN32_FIND_DATA fData;
         while((h = ::FindFirstFile(dlgFile.m_strFilename, &fData))
			 != (HANDLE)0xFFFFFFFF)
            { // no MFC equivalent
                if (::DeleteFile(fData.cFileName) == FALSE)
                {
                    strMessage.Format("Unable to delete file %s\n",
						fData.cFileName);
                    AfxMessageBox(strMessage);
                    break;
                }
            }
        }
    }
    else if (nModal == IDOK)
    {
        CString strSingleFilename = dlgFile.GetPathName();
        strMessage.Format("Are you very sure you want to delete %s?",
			strSingleFilename);
        if (AfxMessageBox(strMessage, MB_YESNO) == IDYES)
        {
            CFile::Remove(strSingleFilename);
        }
    }
}

