CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Custom Icon

Threaded View

  1. #1
    Join Date
    Jul 2005
    Posts
    5

    Custom Icon

    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
    _______


    Code:
    // 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
    ____________

    Code:
    #include “RESOURCES.H”
    
    ID_ICON1 ICON test.ico
    RESOURCES.H
    ___________

    Code:
    #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!
    Last edited by packagedeliverer; July 12th, 2005 at 03:41 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured