📄 testsvrdlg.cpp
字号:
// TestSvrDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TestSvr.h"
#include "TestSvrDlg.h"
#include <comcat.h>
#include <assert.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()
/////////////////////////////////////////////////////////////////////////////
// CTestSvrDlg dialog
CTestSvrDlg::CTestSvrDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestSvrDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestSvrDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTestSvrDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestSvrDlg)
DDX_Control(pDX, IDC_LIST1, m_listWorld);
//}}AFX_DATA_MAP
}
extern CTestSvrApp theApp;
BEGIN_MESSAGE_MAP(CTestSvrDlg, CDialog)
//{{AFX_MSG_MAP(CTestSvrDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_DESTROY()
ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
ON_COMMAND_RANGE(_BASE_COMMAND_ID_,_BASE_COMMAND_ID_+200, OnAddInExport)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestSvrDlg message handlers
///////////////////////////////////////////////////////////
//
BOOL CTestSvrDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetDlgItemText(IDC_STATIC1,"说明:菜单列举功能可参见本程序的系统菜单.");
// 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);
// 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
//////////////////////////////////////////////////////////////////////////
//初始化
m_emExcemManage.SetKeepInMemory(TRUE);
m_emExcemManage.EnumClassesOfCategories(NULL);
//////////////////////////////////////////////////////////////////////////
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);
pSysMenu->AppendMenu(MF_SEPARATOR);
//////////////////////////////////////////////////////////////////////////
//添加到菜单
m_emExcemManage.AppendDescriptsToMenu(pSysMenu);
//
//////////////////////////////////////////////////////////////////////////
}
}
//////////////////////////////////////////////////////////////////////////
//添加到ListBox
int n = m_emExcemManage.GetSize();
for(int i=0;i<n;i++)
{
AddInModel* m = m_emExcemManage.GetAt(i);
int index = m_listWorld.AddString(m->m_sDescription) ;
m_listWorld.SetItemDataPtr(index, (void*)m->m_nID) ;
}
//////////////////////////////////////////////////////////////////////////
return TRUE; // return TRUE unless you set the focus to a control
}
void CTestSvrDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else if(nID>=_BASE_COMMAND_ID_ && nID <= _BASE_COMMAND_ID_+200)
{
SendMessage(WM_COMMAND,nID);
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CTestSvrDlg::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 CTestSvrDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CTestSvrDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CTestSvrDlg::OnDestroy()
{
CDialog::OnDestroy();
}
void CTestSvrDlg::OnDblclkList1()
{
//执行ListBox双击动作
int n = m_listWorld.GetSelCount();
if(n)
{
long id = m_listWorld.GetItemData(m_listWorld.GetCurSel());
m_emExcemManage.DoCommandByID(id);
return;
}
}
void CTestSvrDlg::OnAddInExport(UINT nID)
{
//执行菜单动作
m_emExcemManage.DoCommandByID(nID);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -