Question about resources

Answered

Hey everyone,

i am fairly new to programming (took a course at university, language C) and im currently trying to get into creating windows applications.

My question is about resource files (xxx.rc). I can neither figure out how to create these files in CLion nor how to integrate them into my project (so they get compiled properly).

If you could help me with this or clarify my misconceptions about this topic i would be very grateful!!

thanks in advance & greetings

qiq

0
1 comment

Hello!

You can work with them as with other files. For example, this is a procedure of adding an icon to an application:

  • Create a C++ project in CLion.
  • Create in the project a new file "my.rc" (right-click in the Project tool window > New > File). After entering a file name, CLion will suggest you to associate *.rc pattern with some file type, you can choose.
  • Add the following code in my.rc:
#include "winresrc.h"

IDR_MAINFRAME           ICON                    "<path_to_ico_file>"

  • Add my.rc to the project in CMakeLists.txt (add_executable(hello_world main.cpp my.rc)).
  • Reload the CMake project and built the project.
2

Please sign in to leave a comment.