// HelloDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Hello.h"
#include "HelloDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CHelloDlg dialog




CHelloDlg::CHelloDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHelloDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CHelloDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_BUTTON2, Button2);
	DDX_Control(pDX, IDC_EDIT1, edit1);
}

BEGIN_MESSAGE_MAP(CHelloDlg, CDialog)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, &CHelloDlg::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &CHelloDlg::OnBnClickedButton1)
//	ON_BN_CLICKED(IDOK, &CHelloDlg::OnBnClickedOk)
	ON_BN_CLICKED(IDC_BUTTON3, &CHelloDlg::OnBnClickedButton3)
END_MESSAGE_MAP()


// CHelloDlg message handlers

BOOL CHelloDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	edit1.SetWindowTextW(L"Aktywuj to pole i kliknij Enter");
	edit1.SetFocus();

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

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CHelloDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		PostMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CHelloDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}


void CHelloDlg::OnBnClickedButton1()
{	
	this->MessageBox(L"Hello World");
	this->MessageBox(L"Witaj świecie!");
	AfxMessageBox(L"Witaj świecie");

	if (MessageBox(L"Czy chcesz zamknąć aplikację?",L"Helion",MB_ICONQUESTION | MB_YESNO)==IDYES)
		//this->PostMessage(WM_CLOSE);
		//this->OnOK();
		this->EndDialog(IDOK);
	else this->SetWindowText(L"Zamknięcie anulowane");	
}

//void CHelloDlg::OnBnClickedOk()
//{
//	// TODO: Add your control notification handler code here
//	OnOK();
//}


void CHelloDlg::OnBnClickedButton3()
{
	Button2.SetButtonStyle(BS_CHECKBOX,TRUE);
	Button2.SetCheck(TRUE);

	Button2.SetWindowText(L"Helion");
}
