// CDlgMain.cpp: 实现文件 // #include "stdafx.h" #include "hgjson.h" #include "afxdialogex.h" #include "CDlgMain.h" #include "resource.h" #include "hgjsonDlg.h" #include "CDlgLang.h" #include "DlgTwain.h" #include "DlgOptJson.h" // CDlgMain 对话框 IMPLEMENT_DYNAMIC(CDlgMain, CDialogEx) CDlgMain::CDlgMain(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_MAIN, pParent) { #ifndef _WIN32_WCE EnableActiveAccessibility(); #endif m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } CDlgMain::~CDlgMain() { } void CDlgMain::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_TAB1, tab_); } BOOL CDlgMain::OnInitDialog() { CDialogEx::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 LRESULT lret = 0; CDialogEx* page = new ChgjsonDlg(this); page->Create(ChgjsonDlg::IDD, this); insert_page(page, L"\u626B\u63CF\u4EEA\u914D\u7F6E"); page = new CDlgLang(this); page->Create(CDlgLang::IDD, this); insert_page(page, L"\u8BED\u8A00\u5305\u5236\u4F5C"); page = new CDlgTwain(this); page->Create(CDlgTwain::IDD, this); insert_page(page, L"TWAIN"); page = new CDlgOptJson(this); page->Create(CDlgOptJson::IDD, this); insert_page(page, L"Opt-JSON"); tab_.SetCurSel(0); OnTcnSelchangeTab1(NULL, &lret); return TRUE; // return TRUE unless you set the focus to a control } void CDlgMain::insert_page(CDialogEx* page, const wchar_t* title) { RECT r = { 0 }; int ind = 0; TCITEM item = { 0 }; GetDlgItem(IDC_STATIC_CHILD)->GetWindowRect(&r); ScreenToClient(&r); page->MoveWindow(&r); page->ShowWindow(SW_HIDE); ind = tab_.InsertItem(tab_.GetItemCount(), title); item.lParam = (LPARAM)page; item.mask = TCIF_PARAM; tab_.SetItem(ind, &item); } BEGIN_MESSAGE_MAP(CDlgMain, CDialogEx) ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CDlgMain::OnTcnSelchangeTab1) ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, &CDlgMain::OnTcnSelchangingTab1) END_MESSAGE_MAP() // CDlgMain 消息处理程序 void CDlgMain::OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: 在此添加控件通知处理程序代码 *pResult = 0; TCITEM item = { 0 }; item.mask = TCIF_PARAM; tab_.GetItem(tab_.GetCurSel(), &item); ((CWnd*)item.lParam)->ShowWindow(SW_SHOW); } void CDlgMain::OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: 在此添加控件通知处理程序代码 *pResult = 0; TCITEM item = { 0 }; item.mask = TCIF_PARAM; tab_.GetItem(tab_.GetCurSel(), &item); ((CWnd*)item.lParam)->ShowWindow(SW_HIDE); }