drop-down box
//MFCDay002Dlg.cpp: Implementing Files//#include"stdafx.h"#include"MFCDay002.h"#include"MFCDay002Dlg.h"#include"afxdialogex.h"#include"CmyDialog.h"#ifdef _DEBUG#defineNew Debug_new#endif//CAboutDlg dialog box for application "about" menu itemsclassCAboutDlg: Publiccdialogex{ Public: CAboutDlg ();//dialog box Data enum{IDD =Idd_aboutbox}; protected: Virtual voidDoDataExchange (cdataexchange* PDX);//DDX/DDV Support//Implementprotected: Declare_message_map ()}; Caboutdlg::caboutdlg (): CDialogEx (Caboutdlg::idd) {}voidCAboutDlg::D Odataexchange (cdataexchange*PDX) {cdialogex::D odataexchange (PDX);} Begin_message_map (CAboutDlg, CDialogEx) end_message_map ()//Cmfcday002dlg dialog BoxCmfcday002dlg::cmfcday002dlg (CWnd* pparent/*=null*/): CDialogEx (Cmfcday002dlg::idd, pparent) {M_hicon= AfxGetApp ()LoadIcon (IDR_MAINFRAME);}voidCmfcday002dlg::D Odataexchange (cdataexchange*PDX) {cdialogex::D odataexchange (PDX); DDX_Control (PDX, Idc_combo2, M_comboboxctrol);} Begin_message_map (Cmfcday002dlg, CDialogEx) On_wm_syscommand () On_wm_paint () On_wm_querydragicon () ON_BN_CLICK ED (Idc_radio1,&cmfcday002dlg::onbnclickedradio1) On_bn_clicked (IDOK,&Cmfcday002dlg::onbnclickedok) End_message_map ()//CMFCDAY002DLG message handlersBOOL Cmfcday002dlg::oninitdialog () {cdialogex::oninitdialog (); //add the "About ..." menu item to the System menu. //Idm_aboutbox must be within the scope of the system command. ASSERT ((Idm_aboutbox &0xfff0) ==Idm_aboutbox); ASSERT (Idm_aboutbox<0xf000); CMenu* Psysmenu =GetSystemMenu (FALSE); if(Psysmenu! =NULL) {BOOL bnamevalid; CString Straboutmenu; Bnamevalid=straboutmenu.loadstring (Ids_aboutbox); ASSERT (Bnamevalid); if(!Straboutmenu.isempty ()) {Psysmenu-AppendMenu (Mf_separator); Psysmenu-AppendMenu (mf_string, Idm_aboutbox, Straboutmenu); } } //sets the icon for this dialog box. When the main application window is not a dialog box, the framework automatically//Perform this actionSetIcon (M_hicon, TRUE);//Set Large IconsSetIcon (M_hicon, FALSE);//Set Small Icons//TODO: Add additional initialization code hereM_comboboxctrol.addstring (TEXT ("Tianjin")); M_comboboxctrol.addstring (TEXT ("Beijing")); M_comboboxctrol.addstring (TEXT ("Shanghai")); returnTRUE;//returns TRUE unless focus is set to the control}voidCmfcday002dlg::onsyscommand (UINT NID, LPARAM LPARAM) {if(NID &0xfff0) ==Idm_aboutbox) {CAboutDlg dlgabout; Dlgabout.domodal (); } Else{Cdialogex::onsyscommand (NID, LParam); }}//If you add a Minimize button to the dialog box, you need the following code//to draw the icon. For MFC applications that use the document/view model,//this will be done automatically by the framework. voidCmfcday002dlg::onpaint () {if(Isiconic ()) {CPaintDC DC ( This);//device context for drawingSendMessage (wm_iconerasebkgnd, reinterpret_cast<WPARAM> (DC. GETSAFEHDC ()),0); //Center The icon in the workspace rectangle intCxicon =GetSystemMetrics (Sm_cxicon); intCyicon =GetSystemMetrics (Sm_cyicon); CRect rect; GetClientRect (&rect); intx = (rect. Width ()-Cxicon +1) /2; inty = (rect. Height ()-Cyicon +1) /2; //Draw IconDC. DrawIcon (x, y, M_hicon); } Else{cdialogex::onpaint (); }}//The system calls this function to get the cursor when the user drags the minimized window//display. hcursor Cmfcday002dlg::onquerydragicon () {returnStatic_cast(M_hicon);}voidCmfcday002dlg::onbnclickedradio1 () {//TODO: Add control notification handler code here}voidCmfcday002dlg::onbnclickedok () {Cdialogex::onok (); CMyDialog Mydialog; Mydialog.domodal (); }
Options tab
//CmyDialog.cpp: Implementing Files//#include"stdafx.h"#include"MFCDay002.h"#include"CmyDialog.h"#include"afxdialogex.h"//CMyDialog dialog Boximplement_dynamic (CMyDialog, CDialogEx) cmydialog::cmydialog (CWnd* pparent/*=null*/): CDialogEx (Cmydialog::idd, pparent) {}cmydialog::~CMyDialog () {}voidCMyDialog::D Odataexchange (cdataexchange*PDX) {cdialogex::D odataexchange (PDX); DDX_Control (PDX, IDC_TAB1, m_tab);} Begin_message_map (CMyDialog, CDialogEx) on_command (Idd_dialog1,&cmydialog::onidddialog1) On_notify (Tcn_selchange, IDC_TAB1,&cmydialog::ontcnselchangetab1) On_wm_create () End_message_map ( )//CMyDialog message handlersvoidCmydialog::onidddialog1 () {}voidCMYDIALOG::ONTCNSELCHANGETAB1 (NMHDR *pnmhdr, LRESULT *PResult) { intn =M_tab. GetCurSel (); if(n = =0) {Obj_mylo2. ShowWindow (Sw_show); Obj_mydlog3.showwindow (Sw_hide); } Else if(n = =1) {Obj_mylo2. ShowWindow (Sw_hide); Obj_mydlog3.showwindow (Sw_show); } //TODO: Add control notification handler code here*presult =0;}intcmydialog::oncreate (lpcreatestruct lpcreatestruct) {if(Cdialogex::oncreate (lpcreatestruct) = =-1) return-1; return 0;} BOOL Cmydialog::oninitdialog () {cdialogex::oninitdialog (); //TODO: Add additional initialization hereM_tab. InsertItem (0, TEXT ("Student Information")); M_tab. InsertItem (1, TEXT ("Additional Information")); CRect rtparent= {}; Obj_mylo2. Create (IDD_DIALOG2,&m_tab); Obj_mydlog3.create (Idd_dialog3,&m_tab); M_tab. GetClientRect (rtparent); Rtparent.deflaterect (5, -,5,5); Obj_mylo2. ShowWindow (Sw_show); Obj_mylo2. MoveWindow (Rtparent,true); Obj_mydlog3.showwindow (Sw_hide); Obj_mydlog3.movewindow (Rtparent,true); returnTRUE;//return TRUE Unless you set the focus to a control//Exception: OCX property page should return FALSE}
//MyDlog2.cpp: Implementing Files//#include"stdafx.h"#include"MFCDay002.h"#include"MyDlog2.h"#include"afxdialogex.h"//CMyDlog2 dialog Boximplement_dynamic (CMyDlog2, CDialogEx) cmydlog2::cmydlog2 (CWnd* pparent/*=null*/): CDialogEx (Cmydlog2::idd, pparent) {}cmydlog2::~CMyDlog2 () {}voidCMYDLOG2::D Odataexchange (cdataexchange*PDX) {cdialogex::D odataexchange (PDX); DDX_Control (PDX, Idc_list1, M_listctrl);} Begin_message_map (CMYDLOG2, CDialogEx) end_message_map ()//CMYDLOG2 message handlersBOOL Cmydlog2::oninitdialog () {cdialogex::oninitdialog (); M_listctrl.insertcolumn (0, TEXT ("name"),0, -); M_listctrl.insertcolumn (1, TEXT ("Age"),0, -); M_listctrl.insertcolumn (2, TEXT ("Hometown"),0, -); for(inti =0; I < -; i++) {M_listctrl.insertitem (i, TEXT ("")); M_listctrl.setitemtext (i,0, L"Raivenjie"); M_listctrl.setitemtext (i,1, L" -"); M_listctrl.setitemtext (i,2, L"XX"); } //TODO: Add additional initialization here returnTRUE;//return TRUE Unless you set the focus to a control//Exception: OCX property page should return FALSE}
Control Synthesis 2