// Eg7_1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "Eg7_1.h"
#include "Eg7_1Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEg7_1Dlg dialog

CEg7_1Dlg::CEg7_1Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CEg7_1Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CEg7_1Dlg)
	m_Edit = _T("");
	m_Email = _T("");
	m_Name = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CEg7_1Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEg7_1Dlg)
	DDX_Control(pDX, IDC_COMBO1, m_Province);
	DDX_Control(pDX, IDC_STATIC_DISPLAY, m_Display);
	DDX_Control(pDX, IDC_COMBO2, m_City);
	DDX_Text(pDX, IDC_EDIT_EDIT, m_Edit);
	DDX_Text(pDX, IDC_EDIT_EMAIL, m_Email);
	DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CEg7_1Dlg, CDialog)
	//{{AFX_MSG_MAP(CEg7_1Dlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_CBN_DROPDOWN(IDC_COMBO2, OnDropdownCombo2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEg7_1Dlg message handlers

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

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// 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
	
	// TODO: Add extra initialization here
	m_Province.AddString("湖南");
	m_Province.AddString("河南");	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CEg7_1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// 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 CEg7_1Dlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (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 to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CEg7_1Dlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CEg7_1Dlg::OnOK() 
{
	// TODO: Add extra validation here
	 UpdateData(TRUE);
	CString m_1,m_2,m_3,str;	
	m_3=GetRadio();
	str=GetCheck();
	m_Province.GetWindowText(m_1);
	m_City.GetWindowText(m_2);
	SetDlgItemText(IDC_STATIC_NAME," ");
    SetDlgItemText(IDC_STATIC_EMAIL," ");
	SetDlgItemText(IDC_STATIC_EDIT," ");
	SetDlgItemText(IDC_STATIC_SEX," ");
	SetDlgItemText(IDC_STATIC_HOBBY," ");
	SetDlgItemText(IDC_STATIC_PROVINCE," ");
	SetDlgItemText(IDC_STATIC_CITY," ");
	m_Display.SetWindowText(m_Name+","+m_3+","+m_1+m_2+"人也。\n您的兴趣有:"
	+str+"\n"+"您的地址:"+m_Email+"\n"+"您要说的话:"+m_Edit);
	m_Display.ShowWindow(TRUE);
	m_City.ShowWindow(FALSE);
    m_Province.ShowWindow(FALSE);	
	((CEdit*)GetDlgItem(IDC_EDIT_NAME))->ShowWindow(FALSE);
	((CEdit*)GetDlgItem(IDC_EDIT_EMAIL))->ShowWindow(FALSE);
	((CEdit*)GetDlgItem(IDC_EDIT_EDIT))->ShowWindow(FALSE);
	GetDlgItem(IDC_STATIC1)->ShowWindow(FALSE);
	GetDlgItem(IDC_STATIC2)->ShowWindow(FALSE);
	((CButton*)GetDlgItem(IDC_RADIO1))->ShowWindow(FALSE);
	((CButton*)GetDlgItem(IDC_RADIO2))->ShowWindow(FALSE);
	for(int j=IDC_CHECK1;j<IDC_CHECK6+1;j++)
    {
	((CButton*)GetDlgItem(j))->ShowWindow(FALSE);
	
	}
	((CButton*)GetDlgItem(IDOK))->ShowWindow(FALSE);
	SetDlgItemText(IDCANCEL,"退出 ");
	
}

void CEg7_1Dlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}



CString CEg7_1Dlg::GetRadio()
{
    CString Radiotext;
    UINT m_6=GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO2);
	if(m_6==IDC_RADIO1)
	{
        Radiotext="男";
	}
	else
	{
		Radiotext="女";
	}
	return(Radiotext);
}

CString CEg7_1Dlg::GetCheck()
{
    int	m=0;
	CString str,Checktext;
    for(int i=IDC_CHECK1;i<IDC_CHECK6+1;i++)
    {
      m=((CButton*)GetDlgItem(i))->GetCheck();
	  if (m==1)
	  {
	  CWnd::GetDlgItemText(i,str);
	  str+=";";
	  Checktext+=str;
	  }
	}
	return(Checktext);
}

void CEg7_1Dlg::OnDropdownCombo2() 
{
	// TODO: Add your control notification handler code here
		CString m_1;
	m_Province.GetWindowText(m_1);
    
	if(m_1=="河南")
	{
	m_City.ResetContent();
	m_City.AddString("郑州");
	m_City.AddString("洛阳");
	
	}
	if(m_1=="湖南")
	{
	m_City.ResetContent();
	m_City.AddString("长沙");
	m_City.AddString("岳阳");
	}	
}
