I'm doing a little game with Allegro 4.2.2
in Code::Bloks 16.01
and I would like to add a custom icon.
Searching the Internet I found that adding a resource file to the project could be done, but I only managed to get the executable .exe
and the terminal to have the Icon, but the Allegro No! Window.
I found that using windows.h
could add the icon to the window. But you can not load windows.h
and Allegro
at the same time, because they collide. Then I found here that I should load winalleg.h
as a replacement for the windows.h
, although I do not handle the Windows API very well, I kept searching and I found in the following links how to do it but this does not work for me in allegro
link
link
If I use this, it tells me
error: 'hInstance' was not declared in this scope
Código
HICON hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(MAINICON));
If someone can help me, I'd appreciate it
Game.cpp
#include\<allegro.h\>
#include<winalleg.h>
#define V_Ancho 800
#define V_Alto 600
BITMAP *buffer;
int main() {
allegro_init();
install_keyboard();
install_mouse();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED,V_Ancho,V_Alto,0,0);
show_mouse(screen);
buffer = create_bitmap(V_Ancho,V_Alto);
buffer = load_bitmap("background.bmp",0);
blit(buffer,screen,0,0,0,0,V_Ancho,V_Alto);
while(!key[KEY_ESC]){
readkey;
}
destroy_bitmap(buffer);
return 0;
}
END_OF_MAIN();
resource.rc
#ifndef _resource_rc
#define _resource_rc
MAINICON ICON "ICON 32x32.ico"
#endif // _resource_rc
I leave the project in the following link: link