在对话框上增加菜单项
本文讲述的是基于MFC的对话框,而基于WIN32API的可以参考SDK下的例程\Windows CE Tools\wce500\Windows Mobile 5.0 Smartphone SDK\Samples\CPP\Win32\Menudemo。
主要代码如下:(EVC)
CCeCommandBar m_wndCommandBar;//WM 5.0以上版本 将CCeCommandBar -> CCommandBar
1
BOOL CMyAppDlg::OnInitDialog()
2
{
3
CDialog::OnInitDialog();
4
5
// Set the icon for this dialog. The framework does this automatically
6
// when the application's main window is not a dialog
7
SetIcon(m_hIcon, TRUE); // Set big icon
8
SetIcon(m_hIcon, FALSE); // Set small icon
9
10
CenterWindow(GetDesktopWindow()); // center to the hpc screen
11
12
m_wndCommandBar.Create(this);
13
m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME);
14
m_wndCommandBar.AddAdornments();
15
m_wndCommandBar.LoadToolBar(IDR_MAINFRAME) ;
16
m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() |
17
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
18
19
// TODO: Add extra initialization here
20
21
return TRUE; // return TRUE unless you set the focus to a control
22
}
23
BOOL CMyAppDlg::OnInitDialog()2
{3
CDialog::OnInitDialog();4

5
// Set the icon for this dialog. The framework does this automatically6
// when the application's main window is not a dialog7
SetIcon(m_hIcon, TRUE); // Set big icon8
SetIcon(m_hIcon, FALSE); // Set small icon9
10
CenterWindow(GetDesktopWindow()); // center to the hpc screen11

12
m_wndCommandBar.Create(this);13
m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME);14
m_wndCommandBar.AddAdornments();15
m_wndCommandBar.LoadToolBar(IDR_MAINFRAME) ;16
m_wndCommandBar.SetBarStyle(m_wndCommandBar.GetBarStyle() |17
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);18

19
// TODO: Add extra initialization here20
21
return TRUE; // return TRUE unless you set the focus to a control22
}23

EVC工程代码:MyApp


浙公网安备 33010602011771号