// MyDlgBarFuncKey.cpp: 实现文件 // #include "pch.h" #include "MTerm2.h" #include "MyDlgBarFuncKey.h" #include "afxdialogex.h" // CMyDlgBarFuncKey 对话框 CMyDlgBarFuncKey::structButton myButtons[3][12] = { {33101,_T("11"), 33102,_T("12") ,33103,_T("13"), 33104,_T("14") ,33105,_T("15") ,33106,_T("16") ,33107,_T("17") ,33108,_T("18") ,33109,_T("19") ,33110,_T("110") ,33111,_T("111"), 33112,_T("112") }, {33201,_T("21"), 33202,_T("22") ,33203,_T("23"), 33204,_T("24") ,33205,_T("25") ,33206,_T("26") ,33207,_T("27") ,33208,_T("28") ,33209,_T("29") ,33210,_T("210") ,33211,_T("211"), 33212,_T("212") }, {33301,_T("31"), 33302,_T("32") ,33303,_T("33"), 33304,_T("34") ,33305,_T("35") ,33306,_T("36") ,33307,_T("37") ,33308,_T("38") ,33309,_T("39") ,33310,_T("310") ,33311,_T("311"), 33312,_T("312") }, }; static int myButtonCount = sizeof(myButtons) / sizeof(CMyDlgBarFuncKey::structButton); IMPLEMENT_DYNAMIC(CMyDlgBarFuncKey, CDialogBar) CMyDlgBarFuncKey::CMyDlgBarFuncKey(CWnd* pParent /*=nullptr*/) { } CMyDlgBarFuncKey::~CMyDlgBarFuncKey() { } void CMyDlgBarFuncKey::DoDataExchange(CDataExchange* pDX) { } BEGIN_MESSAGE_MAP(CMyDlgBarFuncKey, CDialogBar) ON_MESSAGE(WM_INITDIALOG, CMyDlgBarFuncKey::OnInitDialog) ON_BN_CLICKED(IDC_BUTTON1, &CMyDlgBarFuncKey::OnBnClickedButton1) END_MESSAGE_MAP() // CMyDlgBarFuncKey 消息处理程序 LRESULT CMyDlgBarFuncKey::OnInitDialog(WPARAM wParam, LPARAM lParam) { // TODO: 在此处添加实现代码. //CDialogBar::OnInitDialog(); // TODO: Add extra initialization here CString(s1); s1.Format(_T(" MyDlgBarFuncKey OnInitDialog ")); SysLog(s1); LRESULT bRet = HandleInitDialog(wParam, lParam); if (!UpdateData(FALSE)) { TRACE("InitDialogBar Failed!"); } CRect rect0; GetClientRect(&rect0); int nWidth = rect0.Width(); int nHeight = rect0.Height(); int nLeftMargin = 48; int nSpace = nWidth - nLeftMargin; int x1, y1, x2, y2; CRect rect1(0, 0, 100, 24); for (int i = 0; i < m_Lines; i++) { for (int j = 0; j < 12; j++) { x1 = nLeftMargin + j * nSpace / 12; y1 = i * nHeight / 3; x2 = x1 + nSpace / 12; y2 = y1 + nHeight / 3; rect1.SetRect(x1, y1, x2, y2); m_buttons[i][j].Create(myButtons[i][j].sCaption, BS_FLAT | WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON, rect1, this, myButtons[i][j].nID); } } return bRet; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE return false; } BOOL CMyDlgBarFuncKey::Create(CWnd* pParentWnd, UINT nIDTemplate, UINT nStyle, UINT nID) { // TODO: 在此添加专用代码和/或调用基类 BOOL bRes = CDialogBar::Create(pParentWnd, nIDTemplate, nStyle, nID); // OnInitDialog(0,0); return bRes; // // return CDialogBar::Create(pParentWnd, nIDTemplate, nStyle, nID); } void CMyDlgBarFuncKey::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHandler) { // TODO: 在此添加专用代码和/或调用基类 CDialogBar::OnUpdateCmdUI(pTarget, FALSE); } void CMyDlgBarFuncKey::OnBnClickedButton1() { // TODO: 在此添加控件通知处理程序代码 CString s1; s1.Format(_T("Button1 Clicked")); SysLog(s1); }