Click to See Complete Forum and Search --> : Custom Icon


packagedeliverer
July 12th, 2005, 03:15 PM
Ok, my first problem as a noob;

I want to have a custom icon, here's the source; what's the error pls?

test.cpp
_______


// INCLUDES ///////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN // just say no to MFC
#include <windows.h> // include all the windows headers
#include <windowsx.h> // include useful macros
#include <stdio.h>
#include <math.h>
#include RESOURCES.H
// DEFINES ////////////////////////////////////////////////
// defines for windows
#define WINDOW_CLASS_NAME "WINCLASS1"
// GLOBALS ////////////////////////////////////////////////
// FUNCTIONS //////////////////////////////////////////////
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;

switch(msg){
case WM_CREATE:
{
return(0);
} break;
case WM_PAINT:
{
hdc = BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
} break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
} break;
default:break;
}
return (DefWindowProc(hwnd, msg, wparam, lparam));
}
// WINMAIN ////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow){
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_ICON1));
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(hinstance,MAKEINTRESOURCE(ID_ICON1));
if (!RegisterClassEx(&winclass))
return(0);
// create the window
if (!(hwnd = CreateWindowEx(NULL, WINDOW_CLASS_NAME, "Format C", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0, 400,400, NULL, NULL, hinstance,NULL)))
return(0);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return(msg.wParam);
}


RESOURCES.RC
____________


#include “RESOURCES.H”

ID_ICON1 ICON test.ico


RESOURCES.H
___________


#define ID_ICON1 100




The error:

Compiling resources...
C:\Program Files\Microsoft Visual Studio\MyProjects\test7\files\RESOURCES.H(1) : fatal error RC1004: unexpected end of file found
Error executing rc.exe.

test7.exe - 1 error(s), 0 warning(s)



thanks in advance!

Bond
July 12th, 2005, 03:39 PM
In my resource files, the filename of the icon is enclosed by quotes, so you might want to try this:

#include “RESOURCES.H”

ID_ICON1 ICON "test.ico"

packagedeliverer
July 12th, 2005, 03:55 PM
still the same problem, the error says it's the header ...I really don't have a clue since this is one of my first experiments...

kkez
July 12th, 2005, 06:48 PM
...
#include <windows.h> // include all the windows headers
#include <windowsx.h> // include useful macros
#include <stdio.h>
#include <math.h>
#include "RESOURCES.H" //quotes

you did it in your rc file :p

Bond
July 13th, 2005, 08:18 AM
...
#include <windows.h> // include all the windows headers
#include <windowsx.h> // include useful macros
#include <stdio.h>
#include <math.h>
#include "RESOURCES.H" //quotes

you did it in your rc file :p
Good catch, kkez. My intuition told me that he was missing quotes -- I just picked the wrong spot! :)

packagedeliverer
July 13th, 2005, 02:59 PM
Well it still has the same error, so it doesn't seem to be the quotes :(

Could any one run a test and verify the error if you'd see it?

packagedeliverer
July 14th, 2005, 01:35 PM
Zipped the dir of the project:
>>Download (http://www.packagedeliverer.l2p.net/includes/test9.zip)<<
Please have a look at it.
(created in visual c++ 6.0)

packagedeliverer
July 14th, 2005, 06:10 PM
Oh c'mon guys gimme a hint...