how use resource files?

Pages: 12
i undertsand that the MAINICON it's for exe icon:
1
2
3
4
5
6
#ifndef _resource_rc
#define _resource_rc

	MAINICON ICON  "x-7.ico"

#endif 

imagine that i need add more files like MP3 or even a GIF... how can i add them?
i'm confused:
nameID typeID filename
'typeID' it's like a keyword, or i can use any name?
typeId refers to the type of the resource like ICON or WAV or BITMAP etc. The nameID you can choose freely
anotherthing: from resource name(nameID), can i get just the string of filename?
Why do you need the filename when you have both the resource and its name? That information is lost because it is irrelevant.
my big problem is how i can get the file extension. what you can tell me?
Why do you need the file extension? You already know what it is - you're already hard-coding the files in the resources, may as well hard-code the file extensions in your code.
you have right.. the typeID can be the file format for help more ;)
thanks for all
i need more help... i'm falling on using the resources :(
resource file:
1
2
3
4
5
6
7
#ifndef _resource_rc
#define _resource_rc


	MAINICON ICON  "x-7.ico"
    songoku ICO "C:\\Users\\Cambalinho\\Documents\\CodeBlocks\\classcontrols\\bin\\Release\\x-7.ico"
#endif 

on main.cpp:
mnuExitSys.imgMenu.FromResource(songoku, "ICO");
error: 'songoku' was not declared in this scope.
can anyone tell me where i faill?
Cambalinho wrote:
mnuExitSys.imgMenu.FromResource
I am not familiar with this code - what library or framework are you using? Is this pure C++, or is this C++/CLI?
my how library... it's pure C++. but i was doing several problems without know it. give me sometime, i will be back. and now i get the image.
i need create a resource.h for resource consts:
#define songoku 101
the resource.h must be inclued on main.cpp and on resource.rc:
1
2
3
4
#include "resource.h"

MAINICON ICON  "x-7.ico"
songoku ICON "C:\\Users\\Cambalinho\\Documents\\CodeBlocks\\classcontrols\\bin\\Release\\x-7.ico"

and on LoadImage():
1
2
3
void FromResource(DWORD strResource, string strType)
{
HICON hicon = (HICON)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(strResource), IMAGE_ICON, 0, 0, NULL);

how i use it:
mnuExitSys.imgMenu.FromResource(songoku, "ICON");
i need more help:
- with 'songoku', can i get the type?(because i use 2 parameters on FromResource)
Read the documentation more carefully:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms648045

The second parameter should be MAKEINTRESOURCE(songoku), since you are loading by ordinal and not by name. You may need to refactor your FromResource function.
honestly i don't know use the string name. just with ' MAKEINTRESOURCE(songoku)'.
maybe you can teach me how use it... but i continue with same problem :(
how can i get the resource type?
i'm sorry, but what means 'refactor'?(i'm portuguese)
Why do you need to get the resource type? You already know what it is - you wrote it once in the resource file, just write it again in your code.

Refactor:
https://en.wikipedia.org/wiki/Code_refactoring
https://pt.wikipedia.org/wiki/Refatora%C3%A7%C3%A3o
i mean for avoid the second parameter on FromResource(). what you can advice me more?
Why is it a problem to provide the second parameter?
for do the things automatic
for do the things automatic

Huh? Could you rephrase that?
Pages: 12