How can i add window message?

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

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

I updated the answer.