none
如何创建一个带菜单的窗口,能否给一些源码示例? RRS feed

  • 问题

  • bool CCEGLView::Create(LPCTSTR pTitle, int w, int h)
    {
        bool bRet = false;
        do
        {
            CC_BREAK_IF(m_hWnd);
    
            HINSTANCE hInstance = GetModuleHandle( NULL );
            WNDCLASS  wc;        // Windows Class Structure
    
            // Redraw On Size, And Own DC For Window.
            wc.style          = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
            wc.lpfnWndProc    = _WindowProc;                    // WndProc Handles Messages
            wc.cbClsExtra     = 0;                              // No Extra Window Data
            wc.cbWndExtra     = 0;                              // No Extra Window Data
            wc.hInstance      = hInstance;                      // Set The Instance
            wc.hIcon          = LoadIcon( NULL, IDI_WINLOGO );  // Load The Default Icon
            wc.hCursor        = LoadCursor( NULL, IDC_ARROW );  // Load The Arrow Pointer
            wc.hbrBackground  = NULL;                           // No Background Required For GL
            wc.lpszMenuName   = NULL;                           // We Don't Want A Menu
            wc.lpszClassName  = kWindowClassName;               // Set The Class Name
    
            CC_BREAK_IF(! RegisterClass(&wc) && 1410 != GetLastError());
    
            // center window position
            RECT rcDesktop;
            GetWindowRect(GetDesktopWindow(), &rcDesktop);
    
            // create window
            m_hWnd = CreateWindowEx(
                WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,               // Extended Style For The Window
                kWindowClassName,                                    // Class Name
                pTitle,                                              // Window Title
                WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX,        // Defined Window Style
                0, 0,                                                // Window Position
                0,                                                   // Window Width
                0,                                                   // Window Height
                NULL,                                                // No Parent Window
                NULL,                                                // No Menu
                hInstance,                                           // Instance
                NULL );
    
            CC_BREAK_IF(! m_hWnd);
    
            m_eInitOrientation = CCDirector::sharedDirector()->getDeviceOrientation();
            m_bOrientationInitVertical = (CCDeviceOrientationPortrait == m_eInitOrientation
                || kCCDeviceOrientationPortraitUpsideDown == m_eInitOrientation) ? true : false;
            m_tSizeInPoints.cx = w;
            m_tSizeInPoints.cy = h;
            resize(w, h);
    
            // init egl
            m_pEGL = CCEGL::create(this);
    
            if (! m_pEGL)
            {
                DestroyWindow(m_hWnd);
                m_hWnd = NULL;
                break;
            }
    
            s_pMainWindow = this;
            bRet = true;
        } while (0);
    
        return bRet;
    }
    如上例是无菜单的设计

    ajian

    2014年6月23日 6:38

答案

  • 你好,

    如果你建的是win32 project, 那么当你不选择建空工程的时候,默认建的工程是有菜单项的:默认是File, Help菜单。

    如果你想自己建菜单,然后添加进去,你可以参考如下链接中的步骤来操作:

    http://www.functionx.com/win32/Lesson03.htm


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年6月24日 8:52

全部回复

  • 利用VS创建一个的Win32 Application工程,就有带菜单项的。

    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.

    2014年6月24日 7:52
    版主
  • 你好,

    如果你建的是win32 project, 那么当你不选择建空工程的时候,默认建的工程是有菜单项的:默认是File, Help菜单。

    如果你想自己建菜单,然后添加进去,你可以参考如下链接中的步骤来操作:

    http://www.functionx.com/win32/Lesson03.htm


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年6月24日 8:52