// FlgDel.cpp : implementation file
//

#include "stdafx.h"
#include "nc.h"
#include "FlgDel.h"
#include "resource.h"
#include <afxwin.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFlgDel dialog


CFlgDel::CFlgDel(CWnd* pParent /*=NULL*/)
	: CDialog(CFlgDel::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFlgDel)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

BOOL CFlgDel::PreTranslateMessage(MSG* pMsg) 
{

	if(pMsg->wParam==VK_ESCAPE)//
	{
		return TRUE;
	}
	if(pMsg->wParam==VK_RETURN)//
	{
		return TRUE;
	}
	
	return CDialog::PreTranslateMessage(pMsg);
}
BOOL CFlgDel::OnEraseBkgnd(CDC* pDC) 
{
	CDC MemDC;
	CBitmap Bitmap,*pOldBitmap;
	BITMAP bm;
	Bitmap.LoadBitmap(IDB_DEL_DLG);
	Bitmap.GetObject(sizeof(BITMAP),&bm);
	MemDC.CreateCompatibleDC(pDC);
	pOldBitmap=(CBitmap*)(MemDC.SelectObject(&Bitmap));

	CRect rcClient;
	GetClientRect(rcClient);

	pDC->BitBlt(0,0,rcClient.Width(),rcClient.Height(),&MemDC,0,0,SRCCOPY);
	MemDC.SelectObject(pOldBitmap);
	MemDC.DeleteDC();

    return TRUE;
	//return CDialog::OnEraseBkgnd(pDC);
}
BOOL CFlgDel::OnInitDialog() 
{
	CDialog::OnInitDialog();
	SetWindowPos(&CWnd::wndTop ,0,0,279,94,SWP_DRAWFRAME);
	CenterWindow();
	//init interface
	//m_butstop.MoveWindow(207,57,257,74);
	m_btyes.LoadBitmaps(IDB_DELDLG_YES_N,IDB_DELDLG_YES_H,IDB_DELDLG_YES_N,IDB_DELDLG_YES_H,IDB_DELDLG_YES_D);
	m_btyes.SetTextAlignment(CBitButton::AlignBelow);
	m_btno.LoadBitmaps(IDB_DELDLG_NO_N,IDB_DELDLG_NO_H,IDB_DELDLG_NO_N,IDB_DELDLG_NO_H,IDB_DELDLG_NO_D);
	m_btno.SetTextAlignment(CBitButton::AlignBelow);
	
	//圆角
	RECT r;
	GetClientRect(&r);
	CRgn rgn;
	rgn.CreateRoundRectRgn( 0, 0,r.right , r.bottom, 5,5 ); 
	SetWindowRgn(rgn,TRUE);
	//end 
	CFont *font = new CFont;
	font->CreateFont(12,0,0,0,100,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
	DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"宋体"); 
	delinfo.SetFont(font);
	delinfo.SetWindowText("确信要删除这些文件吗？");

    return 0;

//	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
void CFlgDel::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDCANCEL, m_btno);
	DDX_Control(pDX, IDOK, m_btyes);
	DDX_Control(pDX, IDC_DELINFO, delinfo);
	//{{AFX_DATA_MAP(CFlgDel)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}
HBRUSH CFlgDel::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

	// TODO: 在此更改 DC 的任何属性
	if (nCtlColor == CTLCOLOR_STATIC)
	{
		pDC->SetTextColor(RGB(0, 0, 0));//设置成背景
		pDC->SetBkColor(RGB(255,255,255));
		//pDC->SetBkMode(TRANSPARENT);//透明
		return (HBRUSH)::GetStockObject(NULL_BRUSH);
	}
	
	return hbr;
}
BEGIN_MESSAGE_MAP(CFlgDel, CDialog)
	ON_WM_ERASEBKGND()
	ON_WM_CTLCOLOR()
	//{{AFX_MSG_MAP(CFlgDel)
	ON_WM_LBUTTONDOWN()
	ON_WM_CANCELMODE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CFlgDel message handlers

void CFlgDel::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CDialog::OnLButtonDown(nFlags, point);
	PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));
}

void CFlgDel::OnCancelMode() 
{
	CDialog::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}
