0

I'm not very familar with WinAPI programming, so that's more or les a beginners question.

I'm currently porting a plain console-application to Windows. It does use only some socket functions and don't has any GUI, so this is an easy thing. To hide the ugly, black console I'm using

int APIENTRY WinMain()

and don't open any windows. Now I have to show a tray icon to just to notify user this application is running. I also found some nice example code demonstrating how to use Shell_NotifyIcon(). Where I'm failing at is loading of related icon:

niData.hIcon=
   (HICON)LoadImage(hInstance,
   MAKEINTRESOURCE(IDI_AAAA),
   IMAGE_ICON,
   GetSystemMetrics(SM_CXSMICON),
   GetSystemMetrics(SM_CYSMICON),
   LR_DEFAULTCOLOR);

I already have a .ico file containing severals icons in different sizes and a .rc file where IDI_AAAA points to this icon:

IDI_AAAA               ICON                    "my_icon.ico"

.rc file is added to my project but the compiler - of course - complains it does not know IDI_AAAA. So...how do I have to make the connection from IDI_AAAA in .rc file to a valid definition in .cpp file making it possible for LoadImage() to get the icon?

Thanks!

Elmi
  • 5,899
  • 15
  • 72
  • 143
  • You have to link the compiled resource file to the executable. – David Heffernan Oct 06 '14 at 07:24
  • David Heffernan: it fails earlier, the compiler complains about "error C2065: 'IDI_AAAA' : undeclared identifier" which is clear since IDI_AAAA currently exists in .rc file only – Elmi Oct 06 '14 at 07:34
  • 1
    Well, that error could not be any clearer. You understand what "undeclared identifier" means right? Normally you'd put that declaration in a resources header file and include it in the .rc file and the source file. – David Heffernan Oct 06 '14 at 07:58

0 Answers0