[4.6] Compilation error when adding MainFrame module ?

Hi,

I need a ParentWindowWindowHandle for a call to OpenFileDialog.

Apparently i need the IMainFrameModule to get it, but when i add this module to my build:

PrivateDependencyModuleNames.AddRange(new string[] { "MainFrame" });

I get the following error at compilation:

1>C:/Program Files/Unreal Engine/4.6/Engine/Source/Editor/UnrealEd/Classes/Editor/EditorUserSettings.h(83): error : In EditorUserSettings: Invalid reference to unparsed class: '/Script/Kismet.BlueprintPaletteFavorites'

Am i doing anything wrong ?

Thanks

Cedric

You don’t strictly speaking need the parent window to be MainFrame, we just use that when we’re unsure which window to use (if you don’t provide a parent window, Windows does weird things to the window focus when the dialog is closed). If this is a window you’ve made yourself, then you could, and should, use that window as the parent instead of MainFrame.

Also remember that MainFrame is editor-only, so won’t build in game configurations. Which configuration are you trying to build?

This should get you your game window:

UGameEngine* GameEngine = Cast<UGameEngine>(GEngine);
GameEngine->GameViewportWindow;

We typically don’t use DesktopPlatform functionality in games, as that functionality is only available for desktop platforms (Windows, Mac, Linux), additionally, opening a OS file picker dialog may do undesirable things to full-screen windows, so I’d advise you test that.

If we needed to pick a file in a game, we’d typically implement a custom Slate widget to handle it without having to spawn any additional windows, or rely on OS behaviour.

Hi Jamie,

Thanks for your answer.

To be honest, i am playing apprentice sorcerer here.

I never had the need to dig this module thing, so i tried the quick and dirty way, as i just need an openfiledialog from within the game (i need to load a file from disk at runtime).

The parent window should be the game window, as i create no window during the game, if there is an easy way to get it, i would be quite happy to read it here, but of course, otherwise i will do my homework and go for the long and clever way of understanding what i do.

Thanks

Cedric

Thank you very much.

Desktop only is not a problem for me (aiming only windows/mac).

Oh, i didn’t think making a dedicated widget was possible for that, so i started to look for some window to do the job, but a widget would be a much better solution, as it would give a more natural integration in my UI. I’ll search in this direction now that i know it’s feasible.

Again, thanks a lot for your time, advices, and answer !

Cedric

Another reason to avoid DesktopPlatform for your game, as I realised when answering another question on this topic, is that DesktopPlatform is a Development module, and it’s against the EULA to distribute use them with shipped games.

Other question for reference: Loading DesktopPlatform module - Programming & Scripting - Epic Developer Community Forums

1 Like

woo, thanks, i wasn’t aware of that. Anyway, i am currently working on my super widget, but it’s good to have this in mind for other dev modules.

Thanks again Jamie