Link to home
Start Free TrialLog in
Avatar of List244
List244

asked on

Icons and Cursors

Alright, I have a window all set up with CreateWindow using VC++ 6.  However, I can not get
LoadImage to load icons and cursors.  Can someone please tell me how I can get a type of walkthrough?
By this I mean not only code, but how to create the icons to work with the code as well?
SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To draw icon you can use:
DrawIcon(hDC, X, Y, hIcon);
Avatar of List244
List244

ASKER

JKR, I do not know what you mean by "Go to 'Add Resource'"

But I have done the following:

File-> New -> Resource Script

Add Cursor...

RegW.hCursor = LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CURSOR1)); //Undeclared Identifier IDC_CURSOR1

and IDC_CURSOR1 is its name.

MrBlue, I am looking for something around the lines of:

      RegW.hIcon = LoadIcon(NULL,IDI_APPLICATION); //Custom..
      RegW.hIconSm = LoadIcon(NULL,IDI_WINLOGO); //Custom..

Rather than the defaults.
"Undeclared Identifier IDC_CURSOR1"

Add

#include "resource.h"
Avatar of List244

ASKER

I don't have a resource.h.
Avatar of List244

ASKER

Okay, sorry that was the wrong project.  Okay, this works, but it still is not loading my cursor.
It is loading an uparrow (No matter what naming).
Is RegW in RegW.hCursor struct of type WNDCLASS passed to RegisterClass() function ?
If not you need handle WM_SETCURSOR message and call
SetCursor(RegW.hCursor);
Avatar of List244

ASKER

WNDCLASSEX RegisterClassEx
Check if "LoadCursor()" returns value != NULL
How did you get "hInstance" ? Is it NULL ?
Avatar of List244

ASKER

Ah, forgot to switch hInstance, that solved that.

What about the icons, how do I get those working? (Small and large)
Do you mean title bar or drawing on window ?
By the way use also MAKEINTRESOURCE() also in LoadIcon()
Avatar of List244

ASKER

I mean both for titlebar and for the application icon.
...when you pass your own icon ID.
    RegW.hIcon = LoadIcon(NULL,IDI_APPLICATION); //Custom..
     RegW.hIconSm = LoadIcon(NULL,IDI_WINLOGO); //Custom..

Doesn't it work ? Or you want your own icons ?
Avatar of List244

ASKER

Okay, I got this working, cursor and icon, one question though.. Is the title-bar icon not supposed to be 16X16?
I can only get the 32x32 to work for that.
You can add 16x16 icon to your 32x32 one.

In resource editor you have:

Device: [Standard (32x32)] [button]

Click on that button & add "Small (16x16)"
Avatar of List244

ASKER

I have done this, but when I can not get it to use the 16X16, it always uses the 32X32
Avatar of List244

ASKER

I would like hIconSm to use the 16
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of List244

ASKER

Works great, thanks.
MSDN suggests LoadImage(). Maybe here's the problem (not sure).

LRegW.hIcon = oadImage(hInst, MAKEINTRESOURCE(ID_*), IMAGE_ICON, 16, 16, 0);
Avatar of List244

ASKER

Both methods work well.