在对话框上增加菜单项

本文讲述的是基于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

EVC工程代码:MyApp

你可能感兴趣的:(对话框)