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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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,MAKEI NTRESOURCE (IDC_CURSO R1)); //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_APPLICAT ION); //Custom..
RegW.hIconSm = LoadIcon(NULL,IDI_WINLOGO) ; //Custom..
Rather than the defaults.
But I have done the following:
File-> New -> Resource Script
Add Cursor...
RegW.hCursor = LoadCursor(hInstance,MAKEI
and IDC_CURSOR1 is its name.
MrBlue, I am looking for something around the lines of:
RegW.hIcon = LoadIcon(NULL,IDI_APPLICAT
RegW.hIconSm = LoadIcon(NULL,IDI_WINLOGO)
Rather than the defaults.
"Undeclared Identifier IDC_CURSOR1"
Add
#include "resource.h"
Add
#include "resource.h"
ASKER
I don't have a resource.h.
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).
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);
SetCursor(RegW.hCursor);
ASKER
WNDCLASSEX RegisterClassEx
Check if "LoadCursor()" returns value != NULL
How did you get "hInstance" ? Is it NULL ?
How did you get "hInstance" ? Is it NULL ?
ASKER
Ah, forgot to switch hInstance, that solved that.
What about the icons, how do I get those working? (Small and large)
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()
By the way use also MAKEINTRESOURCE() also in LoadIcon()
ASKER
I mean both for titlebar and for the application icon.
...when you pass your own icon ID.
RegW.hIcon = LoadIcon(NULL,IDI_APPLICAT ION); //Custom..
RegW.hIconSm = LoadIcon(NULL,IDI_WINLOGO) ; //Custom..
Doesn't it work ? Or you want your own icons ?
RegW.hIconSm = LoadIcon(NULL,IDI_WINLOGO)
Doesn't it work ? Or you want your own icons ?
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.
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)"
In resource editor you have:
Device: [Standard (32x32)] [button]
Click on that button & add "Small (16x16)"
ASKER
I have done this, but when I can not get it to use the 16X16, it always uses the 32X32
ASKER
I would like hIconSm to use the 16
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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);
LRegW.hIcon = oadImage(hInst, MAKEINTRESOURCE(ID_*), IMAGE_ICON, 16, 16, 0);
ASKER
Both methods work well.
DrawIcon(hDC, X, Y, hIcon);