Download

Create an additional window

Hello,
I need to create an additional window to my game (if possible a classic win32 window), which would be able to exchange datas with actors.
I need to have some controls (button, edit etc.) in it and to achieve some drawing staff with HDC functions.

I found a way but a ugly one :
a plugin which create a win32 window with a “button”

  • some changes into engine source code (Launch.cpp and LaunchEngineLoop.cpp) in order to get pointers toward actors instances.
    And when I click on the button of the additional window, the speed of an actor is changed.

Is there a prettier way to achieve that ?
I’m currently trying to put my “CreateWindowEx” code into a “false” actor but no success so far.
No better result with my research about FWindowsWindow class.

Thank you in advance for any advice,

Why would you go with native win32 window when you can create an SWindow and have all of the Slate benefits (styling and input processing)? Slate windows are actually native windows, they just look prettier and are easier to control from the engine.

In fact, there is not much examples about SWindow. I thought it was for additionnal windows INSIDE the UE4 game window.
I need a real additionnal window, outside the game window, to be used with multiples screens.
Is it possible with SWindow ? Any example code about how and where to create it ?

Thank you

Well, by definition SWindows are not meant to be used with the games. They were made to create a flexible editor.

Although, if you need one, you can do it and it will work for sure.

First off you will have to create SWindow reference like this:


auto MyWindow = SNew(SWindow)
.ClientSize(640,480)

// put your window content here
];


then, you have to register it so its actually shown:


FSlateApplication::Get().AddWindow(MyWindow, true);

from here you should be able to get it running if you’re at least somewhat familiar with Slate. Please keep in mind that you will have to clean the window up (destroy it) manually on game end. This part can be a bit tricky ; )

As for where to keep you window, you can either create a singleton class, something like “MyWindowManager”, that will take care of bringing the window up and destroying it, or you can just keep it in player’s HUD, initialize it in BeginPlay event or something.

Take a look at STestSuite.cpp file for examples of Slate windows and widgets in general.

Top !! That sounds full of promise.
Thank you very much