注册 登录
编程论坛 VC.NET论坛

求教VS2010 win32app 窗口光标自定义

mythabc 发布于 2012-02-20 22:13, 5882 次点击
求教怎样才能在自己定义的窗口里显示自定义光标

我做了如下试验但是窗口里显示的还是正常的windows箭头

添加cur文件到project 资源选项卡下
然后看到.rc文件下有定义
程序代码:

// Cursor
//

IDC_CURSOR1             CURSOR                  "cursor1.cur"


在头文件Resource.h里也看到有定义
#define IDC_CURSOR1                     129


最后在t_WinMain里自己定义的WNDCLASSEX里设置光标
程序代码:

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

     WNDCLASSEX winclass;
    MSG msg;      // generic message
    HWND hwnd;
    HACCEL hAccelTable;

    winclass.cbSize  = sizeof(WNDCLASSEX);
winclass.style     = CS_DBLCLKS | CS_OWNDC |
                     CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc    = WndProc;
winclass.cbClsExtra     = 0;
winclass.cbWndExtra     = 0;
winclass.hInstance      = hInstance;
winclass.hIcon          = LoadIcon(NULL, MAKEINTRESOURCE(IDI_TEST120218));
winclass.hIconSm          = LoadIcon(NULL, MAKEINTRESOURCE(IDI_TEST120218));
winclass.hCursor        = LoadCursor(NULL, (LPCTSTR)IDC_CURSOR1);
winclass.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName   = NULL;
winclass.lpszClassName  = WINDOW_CLASS_NAME;



    // register the window class
if (!RegisterClassEx(&winclass))
    return(0);

   
    if (!(hwnd = CreateWindowEx(NULL, // extended style
                  L"WINCLASS1",            // class
                  L"Your Basic Window",    // title
                  WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                  0,0,       // initial x,y
                  400,400,   // initial width, height
                  NULL,      // handle to parent
                  NULL,      // handle to menu
                  hInst, // instance of this application
                  NULL)))    // extra creation parms

   
    return(0);

自己在光标文件里定义了3个光标BMP图像.. 一个1位 一个24位 一个8位 全部出不来 求教
0 回复
1