小编Der*_*her的帖子

SDL2 + Win32 API 菜单栏单击事件不起作用

我目前正在 Visual C/C++ 中使用 SDL2 + windows.h 库开发 GameBoy/GameBoyColor 模拟器以获取附加功能。我已成功将菜单项附加到 SDL 创建的窗口,但是在单击菜单项时尝试处理窗口发送的消息时遇到了麻烦...带有窗口菜单项的正在运行的应用程序的图像

在我的设计中,我决定创建一个单独的源文件,其命名空间包含各种程序实用程序(例如窗口管理功能)。因此,我创建了一个名为的函数getMenuEvent(),它由窗口实例的消息循环组成,从技术上讲,它应该WndProc()在同一名称空间中调用我定义的函数来查看其中的内容wParam......

这是我编写的实用程序命名空间源文件

HWND getSDLWinHandle(SDL_Window* win)
{
    SDL_SysWMinfo infoWindow;
    SDL_VERSION(&infoWindow.version);
    if (!SDL_GetWindowWMInfo(win, &infoWindow))
    {
        std::cout << "test";
        return NULL;
    }
    return (infoWindow.info.win.window);
}

//Initializes the native windows drop down menu elements of the window
void ActivateMenu(HWND windowRef)
{
    hMenuBar = CreateMenu();
    hFile = CreateMenu();
    hEdit = CreateMenu();
    hHelp = CreateMenu();

    AppendMenu(hMenuBar, MF_POPUP, (UINT_PTR)hFile, "File");
    AppendMenu(hMenuBar, MF_POPUP, (UINT_PTR)hEdit, "Edit");
    AppendMenu(hMenuBar, MF_POPUP, (UINT_PTR)hHelp, "Help"); …
Run Code Online (Sandbox Code Playgroud)

c++ winapi emulation menubar sdl-2

2
推荐指数
1
解决办法
2176
查看次数

标签 统计

c++ ×1

emulation ×1

menubar ×1

sdl-2 ×1

winapi ×1