梦书之家(移动开发)

你有一个苹果,我有一个苹果,我们交换一下,一人还是一个苹果;你有一个思想,我有一个思想,我们交换一下,一人就有两个思想。 ——肖伯纳

导航

在对话框上增加菜单项

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

 1BOOL 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

posted on 2007-11-28 10:40  梦书  阅读(1144)  评论(1编辑  收藏  举报