`
aigo
  • 浏览: 2542632 次
  • 性别: Icon_minigender_1
  • 来自: 宜昌
社区版块
存档分类
最新评论

[UE4]C++中集成Windows系统消息

UE4 
阅读更多

原文:https://answers.unrealengine.com/questions/162868/how-can-i-add-window-message.html

 

Implement the IWindowsMessageHandler interface and register it with FWindowsApplication::AddMessageHandler(). Don't forget to remove it when you don't need it anymore. Also note that this is only for Windows, so you should only use it in code that is wrapped in #if PLATFORM_WINDOWS. 

 

 #if PLATFORM_WINDOWS
     class FMyWindowsMessageHandler
         : public IWindowsMessageHandler
     {
         public:
             virtual bool ProcessMessage(HWND hwnd, uint32 msg, WPARAM wParam, LPARAM lParam, int32& OutResult) override
             {
                 // Handle your messages here
             }
     }
 #endif
 
 
 #if PLATFORM_WINDOWS
     TSharedPtr<GenericApplication> GenericApplication = FSlateApplication::Get().GetPlatformApplication();
     FWindowsApplication* WindowsApplication = (FWindowsApplication*)GenericApplication.Get();
     WindowsApplication->AddMessageHandler(MyMessageHandler);
     //...
     WindowsApplication->RemoveMessageHandler(MyMessageHandler);
 #endif

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics