⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messageloop.h

📁 c+++ game uploading now
💻 H
字号:
/**
 @file
 Win32 message loop idiom
*/
#if !defined _MESSAGELOOP_H_
#define _MESSAGELOOP_H_
#include <windows.h>

namespace Win
{
    /**
     class MessageLoop encapsulates the win32 message loop idiom */
    class MessageLoop
    {
    public:
        /**
         @param applicationWnd handle to the application window
         @param haccel handle to the accelerator table */
        MessageLoop(HWND applicationWnd, HACCEL haccel)
            : _appWnd(applicationWnd), 
              _haccel(haccel)
        {}

        /**
         runs the message loop */
        int Run();

    private:
        HWND _appWnd;
        HACCEL _haccel; 
    };

    //this is inline only because I am too lazzy to create another file
    inline int MessageLoop::Run()
    {
        MSG msg;
        int status;
        while((status=::GetMessage(&msg, 0, 0, 0)) != 0)
        {
            if(status==-1)
                return -1;
            if(!::TranslateAccelerator(_appWnd, _haccel, &msg))
                ::TranslateMessage(&msg);
            ::DispatchMessage(&msg);
        }
        return msg.wParam;
    }
}
#endif //_MESSAGELOOP_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -