Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can i add window message?

Hi! guys.

Now, i want to add window message(ex. WM_USER + 200), and i want to insert command when windows are created.

where can i add this message and insert command?

please help me.

UE4 version : 4.6.1 OS : Windows 7

Product Version: Not Selected
more ▼

asked Jan 23 '15 at 03:52 AM in C++ Programming

avatar image

46 8 14 17

avatar image gmpreussner STAFF Jan 24 '15 at 12:03 AM

There is currently no way to hook into the Windows message queue, but it's something I actually started working on. I may have something by the end of next week. In the meantime you'll have to modify the Engine code, if that is a possibility for you. The relevant code is in FWindowsApplication::ProcessMessage() in WindowsApplication.cpp.

avatar image wutong10wl1 Jul 24 '16 at 12:22 PM

So, It's not Difficule. But I Wonder, How Can Make the Blueprint Event of Windows Message ? How Can ?

avatar image gmpreussner STAFF Aug 17 '16 at 09:33 PM

That's a completely separate topic. Please start a new post for that.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Check out this GitHub commit for the new API that allows you to intercept Windows messages. I haven't tested it yet, but it should work. 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.


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

more ▼

answered Mar 27 '15 at 03:35 PM

avatar image Ogreveins Apr 02 '15 at 08:41 AM

I would like to request that you provide a tutorial or snippet for using this in either a game mode or actor class. Right now what makes the most sense is to simply shove a conditional or switch statement into the FWindowsApplication::ProcessMessage() and create a global that signals whatever was looking for the message.

avatar image 황용수 Apr 05 '15 at 06:27 AM

Hi. gmpreussner.

Thanks for your answer.

I modified WindowsApplication.cpp and WindowsApplication.h.

But I will try to call AddMessageHandler funcion of WindowsApplication class.

How can i call AddMessageHandler funtion in my project?

avatar image gmpreussner STAFF Apr 15 '15 at 05:44 PM

I updated the answer with example code. MyMessageHandler is assumed to be of type FMyWindowsMessageHandler, which is a class you need to implement.

avatar image 황용수 Apr 16 '15 at 11:11 AM


I tried to test your example, but it's error.

Is 'GenericApplication' correct in 'FWindowsApplication* WindowsApplication = (FWindowsApplication*)GenericApplication.Get();' statements?

avatar image gmpreussner STAFF Apr 16 '15 at 02:46 PM

Apologies, I forgot to copy/paste one line. Please add:

 TSharedPtr<GenericApplication> GenericApplication = FSlateApplication::Get().GetPlatformApplication();

I updated the answer.

avatar image 황용수 Apr 17 '15 at 02:39 AM

Thanks, gmpreussner. It was very useful for me.

avatar image gmpreussner STAFF Dec 11 '15 at 10:26 PM

I implemented an example plug-in for this API. You can find it on GitHub

avatar image Zaeran24 Mar 01 '16 at 11:54 AM

Hi gmpreussner, thanks for the code! I have tried cloning the plug-in to my projects plugin directory but I am presented with errors when I try to build. I have attached the build output. I'm wondering what I'm doing wrong.link text

build output.txt (24.0 kB)
avatar image gmpreussner STAFF Mar 10 '16 at 06:11 PM

Looks like there were some changes to Slate headers (which are still severely broken in terms of forward declarations and dependency includes). I updated the plugin to make it compile.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question