This is the first time im using DevCPP i used to use VC++6. Now im having trouble setting the icon of my app. The exe have the icon correctly set but the titlebar doesnt have it set when i open it. I always see the exclamation mark icon. Im not used to creating my resource script manually so probably it must be it or maybe i just forgot something and i cant see it.
Heres the code.
Main:
Code:
int WINAPI WinMain( HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
LPSTR lpStrArg, int iCmdShow )
{
MSG msg;
CWindow *CWMain = new CWindow( hThisInstance );
SelfMessageBox *msgBox = new SelfMessageBox( CWMain->getWindowHandle() );
CWMain->setWindowProc( CWindowProc );
CWMain->setIcon( LoadIcon( 0,
MAKEINTRESOURCE( IDI_FIDE_ICON ) ) ); // Seticon here
if( CWMain->initializeWindow() == 0 ){
msgBox->newMessage( "Initialization Error:", "Error", MB_OK );
goto cleanup;
}
while( GetMessage( &msg, NULL, 0, 0 ) > 0 ){
TranslateMessage( &msg );
DispatchMessage( &msg );
}
cleanup:
delete msgBox;
delete CWMain;
return msg.wParam;
}
Heres is CWindow Class:
Code:
#ifndef _CWINDOW_H_
#define _CWINDOW_H_
class CWindow {
public:
CWindow( HINSTANCE );
int initializeWindow();
void setVisible( int );
void setWindowProc( WNDPROC );
HWND getWindowHandle();
void setTitle( char *sTitle );
void setIcon( HICON );
private:
WNDPROC wndProc;
HWND hwnd;
HINSTANCE hInstance;
HICON appIcon;
long width, height;
char szClassName[128] ;
char szTitle[128];
};
#endif
int CWindow::initializeWindow()
{
WNDCLASSEX wc = { 0 };
wc.cbSize = sizeof( WNDCLASSEX );
wc.style = 0;
wc.lpfnWndProc = wndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = appIcon;
wc.hCursor = LoadCursor( 0, IDC_ARROW );
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
wc.lpszMenuName = 0;
wc.lpszClassName = szClassName;
wc.hIconSm = appIcon;
if( RegisterClassEx( &wc ) == 0 )
return 0;
else {
hwnd = CreateWindowEx( 0, szClassName, szTitle,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,CW_USEDEFAULT,
CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL );
if( hwnd == 0 )
return 0;
}
setVisible( 1 );
return 1;
}
void CWindow::setVisible( int iCmdShow )
{
ShowWindow( hwnd, iCmdShow );
UpdateWindow( hwnd );
}
void CWindow::setIcon( HICON pIcon )
{
appIcon = pIcon;
}
Heres the .rc
Code:
IDI_FIDE_ICON ICON DISCARDABLE "resfiles/fide.ico"
here Resource.h
Code:
#define IDI_FIDE_ICON 101