Hi all,
Hopefully the solution is very easy, but I've been searching online for the past few days for how to use/reference a custom cursor in an application without it being an external file (That is, while it's a resource of the application, itself), but I keep coming up empty.
There are most likely several things I'm over looking while attempting to do this as I'm still rather new to C++, so even a push in the right direction would be greatly appreciated.
The following code is how I've manged to do this so far, but the cursor is external :(
//Included extra as I do plan to build on this more.
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <stdlib.h>
#include <windows.h>
main()
{
// Change System Cursor.
HCURSOR hcur;
hcur = ::LoadCursorFromFile("test.cur");
::SetSystemCursor(hcur,OCR_NORMAL);
// Wait 10 seconds
Sleep(10000);
}
After I modified the code (as below), I've been adding the resource file to the compiled exe
The version information adds correctly, and when viewing the exe's resources, the cursor has been added, but nothing I have tried so far has been able to use the cursor when it's included.
//Included extra as I do plan to build on this more.
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <stdlib.h>
#include <windows.h>
int main()
{
// Change System Cursor.
HINSTANCE hInst; // handle to current instance
hInst = GetModuleHandle(NULL);
HCURSOR hCurs; // cursor handles
hCurs = LoadCursor(hInst, MAKEINTRESOURCE(2));
/* 2 is the number I've set for the cursor in the .rc file
------------------------------
1 ICON "icon1.ico"
2 CURSOR "test.cur"
------------------------------
*/
::SetSystemCursor(hCurs,OCR_NORMAL);
//Wait for 10 seconds.
Sleep(10000);
}
I've tried #include 'ing the .rc file instead of adding it later, as well as replacing 2 CURSOR with MAINCUR CURSOR and then #define 'ing MAINCUR in the application and various other things that I can't remember off the top of my head.
I'm using Code::Blocks on Windows XP 32bit.
Much thanks in advance to anyone who can offer hints, help or a solution,
Gremz.