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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How can i call function in WindowsApplication.cpp?


I will try to call function in WindowsApplication.h, WindowsApplication.cpp.

How can i call function in WindowsApplication.cpp?

Product Version: Not Selected
more ▼

asked Jan 22 '15 at 06:35 AM in C++ Programming

avatar image

51 9 16 18

avatar image joeGraf STAFF Jan 22 '15 at 04:35 PM

Which function?

avatar image zompi2 Jan 22 '15 at 10:45 PM

Do you want to run a function from FWindowsApplication? Or just make a new function inside it and run it somehow?

I think that to get access to the FWindowsApplication you can use


which should return the pointer to the GenericApplication which you should be able to cast to the FWindowsApplication and use it's functions.

But the function's name is worrying because it says it creates application, not getting the current, running instance. I think that to get it you will have to make new method.

Why do you need it anyway?

avatar image 황용수 Jan 23 '15 at 03:21 AM

Thanks for your answer. zompi2.

At first, i wanted to call only function in FWindowsApplication. But now, i want to create function in FWindowsApplication and use it.

Because I will include thirdparty static library in my program. It not worked correctly by compile error.

Then i try to include by orginal c++ program method(ex. #pragma comment(lib, "testlib.lib") in FWindowsApplication.

avatar image zompi2 Jan 23 '15 at 10:24 AM

If you want to add ThirdParty library (called testlib) you should add libraries with headers to the Engine/Source/ThirdParty/testlib

Check how other libraries are added, for example libcurl or WebSockets to get a better picture. Then you just have to add PublicDependencyModuleNames of "testlib" to the Core.Build.cs somewhere, so the engine will use this library.

After that you should be able to include the header of the library and use it inside the Core module.

#pragma comment(lib, "testlib.lib") should work but it is quite inelegant ;)

If you are digging so deep in the engine it won't be a bad idea to add a getter to the WindowsApplication. My suggestion is to create a static getter in FWindowsApplication that returns FWindowsApplication* WindowApplication and a public interface in FWindowsPlatformMisc (because it has access to the FWindowsApplication) that will get it.

avatar image 황용수 Jan 25 '15 at 08:09 AM

Hi! zompi2.

First, thanks you for detailed answer.

I created Build.cs file for testlib and added PublicDependencyModuleNames of "testlib" to the Core.Build.cs. Then it worked correctly in WindowsApplication.

But i can't understand to create a static getter and public interface. I can't use testlib function in my own project.

Can you descripe more detail?

Sorry to bother you.

avatar image zompi2 Jan 25 '15 at 09:18 PM

First of all: Do you really need to use your library inside the FWindowsApplication not anywhere?

When you add the PublicDependencyModuleNames of "testlib" in Build.cs of yout project you should be able to use Your library inside the game, not engine.

And you should do this, not dig around the core part of the engine. Unless the library needs some part of WindowsApplication which are private.

If you really need to get the WindowsApplication then:

In WindowsApplication.cpp in line 39 you have a pointer to the current WindowsApplication:

FWindowsApplication* WindowApplication = NULL;

You need to get it. Write a static public getter function, like:

FWindowsApplication* FWindowsApplication::GetWindowsApplication() { return WindowApplication; }

The part about the interface... it's not a good idea, my bad. The solution above should work.

avatar image 황용수 Jan 26 '15 at 04:01 AM

Because - i have to initialize variables when windows is created, and call that.

  • i have to add windows message(WM_USER + @).

I added statements :

  • WindowsApplication.h

    static FWindowsApplication* GetWindowsApplication();

  • WindowsApplication.cpp

    static FWindowsApplication* GetWindowsApplication() { return WindowApplication; }

But, i can't call GetWindowsApplication function in my project.

avatar image zompi2 Jan 27 '15 at 12:22 PM

Sorry for such a hiatus. I tried to get an access to the WindowsApplication from the game and I think I've done it. I posted a solution in answer. Please confirm if it works.

(And and yet it need interface...)

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

2 answers: sort voted first

You don't need to link the lib into the application. The whole point of modules is that you can create a module that contains your unique library without having to modify our base code. See the Apsalar plugin source as an example

more ▼

answered Jan 23 '15 at 05:08 PM

avatar image

joeGraf STAFF
1.5k 35 12 69

avatar image 황용수 Jan 28 '15 at 02:17 AM

Hi! Thanks for answer.

Where can i find Apsalar plugin source?

avatar image joeGraf STAFF Jan 28 '15 at 06:27 AM

It's part of the source up on GitHub. It's in the Plugins/Runtime subdiretories

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

To get access to the FWindowsApplication instance from the game you need to write a getter (because the Engine isn't give an access to it by default).

In WindowsApplication.h in public section of class FWindowsApplication add:

 static FWindowsApplication* GetWindowsApplication();

In WindowsApplication.cpp add:

 FWindowsApplication* FWindowsApplication::GetWindowsApplication()
     return WindowApplication;

In WindowsPlatformMisc.h in FWindowsPlatformMisc struct add:

 static class GenericApplication* GetApplication();

In WindowsPlatformMisc.cpp add:

 GenericApplication* FWindowsPlatformMisc::GetApplication()
     return FWindowsApplication::GetWindowsApplication();

Now in the game in the file when you want to use WindowsApllication #include "WindowsApplication.h" and use it like:


I hope it will help.

more ▼

answered Jan 27 '15 at 12:21 PM

avatar image

650 24 48 145

avatar image 황용수 Jan 28 '15 at 05:47 AM

Hi! zompi2.

Thanks for answer.

It's very helpful to me.

(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