有时候做一些编辑器挺方便的。

http://blog.csdn.net/akof1314/article/details/8133800

核心就是:

1:AppDelegate 加上 runmy() 函数

int AppDelegate::runMy()
{
    // Main message loop:
    MSG msg;
    LARGE_INTEGER nFreq;
    LARGE_INTEGER nLast;
    LARGE_INTEGER nNow;

    QueryPerformanceFrequency(&nFreq);
    QueryPerformanceCounter(&nLast);

    // Initialize instance and cocos2d.
    if (!applicationDidFinishLaunching())
    {
        return 0;
    }

    CCEGLView& mainWnd = CCEGLView::sharedOpenGLView();
    //mainWnd.centerWindow();   // 为了把这句给屏蔽掉
    ShowWindow(mainWnd.getHWnd(), SW_SHOW);

    while (1)
    {
        if (! PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // Get current time tick.
            QueryPerformanceCounter(&nNow);

            // If it's the time to draw next frame, draw it, else sleep a while.
            if (nNow.QuadPart - nLast.QuadPart > m_nAnimationInterval.QuadPart)
            {
                nLast.QuadPart = nNow.QuadPart;
                CCDirector::sharedDirector()->mainLoop();
            }
            else
            {
                Sleep(0);
            }
            continue;
        }

        if (WM_QUIT == msg.message)
        {
            // Quit message loop.
            break;
        }

        // Deal with windows message.
        if (! m_hAccelTable || ! TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    return (int) msg.wParam;
}

2:初始化这样了

// “Open Cocos2d-x”按钮事件
void CCocos2dXEditDlg::OnBnClickedButton1()
{
    GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
    AppDelegate app;
    CCEGLView& eglView = CCEGLView::sharedOpenGLView();
    eglView.setViewName("Hello World");
    eglView.setFrameSize(480, 320);

    ::SetParent(eglView.getHWnd(), this->GetSafeHwnd());
    SetWindowLong(eglView.getHWnd(), GWL_STYLE, GetWindowLong(eglView.getHWnd(), GWL_STYLE) & ~WS_CAPTION);

    // IDC_STATIC_X为图片控件ID
    CRect rc;
    GetDlgItem(IDC_STATIC_X)->GetWindowRect(&rc);
    ScreenToClient(&rc);
    ::SetWindowPos(eglView.getHWnd(), HWND_TOP, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOCOPYBITS | SWP_HIDEWINDOW);
    app.runMy();
    // 之后的阻塞
}