// 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 对话框 static bool logic_calc(bool b1, bool b2, bool b3, bool b4, bool b5) { return ((b1 && !(b2 || b3)) ^ b4) && b5; } static bool logic_expression(const char* exp, void* param) { int v = (int)param; v >>= atoi(exp + 1) - 1; return v & 1; } IMPLEMENT_DYNAMIC(CDlgMain, CDialogEx) CDlgMain::CDlgMain(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_MAIN, pParent) { #ifndef _WIN32_WCE EnableActiveAccessibility(); #endif m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); //simple_logic logic; //int end = 0; //bool bv = logic.parse("b1 && !(b2 || b3) ^ b4 && b5", &end); //std::string text(logic.to_expression()); //for (int i = 0; i < 32; ++i) //{ // bool b1 = logic.value(logic_expression, (void*)i), // b2 = logic_calc(i & 1, i & 2, i & 4, i & 8, i & 16); // if (b1 != b2) // { // char info[40] = { 0 }; // sprintf_s(info, _countof(info) - 1, "Error when input: 0x%02X\r\n", i); // OutputDebugStringA(info); // } //} } 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(2); 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); }