嗯,想把源码发上来。
工程请选“Win32 Application”
我用的是VC++ 6.0 。
这个,我初学者的,请多见谅。#include<windows.h>
#include<stdio.h>
LRESULT CALLBACK WinPro(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASS wndClass;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndClass.hInstance = hInstance;
wndClass.lpfnWndProc = WinPro;
wndClass.lpszClassName = "ClassName";
wndClass.lpszMenuName = "MenuName";
wndClass.style = CS_HREDRAW | CS_VREDRAW; if(!RegisterClass(&wndClass))
{
MessageBox(NULL,TEXT("注册窗口失败"),TEXT("注册窗口"),MB_ICONERROR);
return 0;
} HWND hWnd;
hWnd = CreateWindow(TEXT("ClassName"),
TEXT("Test Windows"),
WS_OVERLAPPEDWINDOW,
0,0,600,460,
NULL,NULL,hInstance,NULL); ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);

MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return msg.wParam;
}LRESULT CALLBACK WinPro(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
static int type;//type为1时,鼠标为黑色围棋样式。为2时,为白色围棋样式
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_CREATE:
SetTimer(hWnd,1,1000,NULL);
break;
case WM_PAINT:
HDC hdc;
hdc = BeginPaint(hWnd,&ps);
TextOut(hdc,20,100,TEXT("每点击鼠标左键一次,鼠标样式在 “黑色围棋” 和 “白色围棋” 样式之间转换"),strlen("每点击鼠标左键一次,鼠标样式在 “黑色围棋” 和 “白色围棋” 样式之间转换"));
EndPaint(hWnd,&ps);
break;
case WM_LBUTTONDOWN:
type++;//每点击鼠标左键一次,鼠标样式变化一次
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
我是想实现这样的功能:当我点击鼠标左键的时候,鼠标的样式,会在两个不同的鼠标样式直接切换。
现在,我就只剩下不知道怎么改变鼠标样式了。
这个,请哪位大侠,指点下嘛,谢谢!注:不要发MFC的那种来哈。
还有,最好,能直接把需要加的东西加上去,这样,我看的更懂些的,谢谢了哈!
哦,对了这个,只能麻烦下各位大侠自己随便画个鼠标的图了哈我不知道怎么发上来的
再次,谢谢!

解决方案 »

  1.   

    SetCursor Function--------------------------------------------------------------------------------The SetCursor function sets the cursor shape. SyntaxHCURSOR SetCursor(          HCURSOR hCursor
    );
    ParametershCursor
    [in] 
    Handle to the cursor. The cursor must have been created by the CreateCursor function or loaded by the LoadCursor or LoadImage function. If this parameter is NULL, the cursor is removed from the screen.Windows 95/98/Me: The width and height of the cursor must be the values returned by the GetSystemMetrics function for SM_CXCURSOR and SM_CYCURSOR. For Microsoft Windows 95, either the cursor bit depth must match the bit depth of the display or the cursor must be monochrome. However, for Windows 98 and Windows 98, if the cursor bit depth does not match the bit depth of the display then the cursor is converted to 4bpp VGA color. Return ValueThe return value is the handle to the previous cursor, if there was one. If there was no previous cursor, the return value is NULL. 
    ResThe cursor is set only if the new cursor is different from the previous cursor; otherwise, the function returns immediately. The cursor is a shared resource. A window should set the cursor shape only when the cursor is in its client area or when the window is capturing mouse input. In systems without a mouse, the window should restore the previous cursor before the cursor leaves the client area or before it relinquishes control to another window. If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved. The cursor is not shown on the screen if the internal cursor display count is less than zero. This occurs if the application uses the ShowCursor function to hide the cursor more times than to show the cursor. ExampleFor an example, see Displaying a Cursor.Function InformationMinimum DLL Version user32.dll 
    Header Declared in Winuser.h, include Windows.h 
    Import library User32.lib 
    Minimum operating systems Windows 95, Windows NT 3.1 
    Unicode Implemented as Unicode version. 
      

  2.   

    SetCursor可以调用2种光标1种是系统标准的SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); 这是等待2是自定义的光标资源SetCursor(LoadCursor(NULL,MAKEINTRESOURCE(资源号)));