win32API中如何更改光标设置
在win32API 中如何设置更改光标呀!我的头真的要炸了,,烦好心人帮帮忙啊!感激不尽!!下面程序想要达到:当按下改变光标按钮时,光标改变;
#include <windows.h>
#include <stdio.h>
//HINSTANCE hInstance;
LRESULT CALLBACK WndProc(HWND ,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW |CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName ="六一";
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,"窗口注册失败","六一",MB_ABORTRETRYIGNORE);
return 0;
}
hwnd = CreateWindow("六一",
"有意思",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,
LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static HWND hButton,hwndEdit,hButton1;
HCURSOR hcousor;
char strEdit[80];
int x,y;
switch (message)
{
case WM_CREATE:
hButton = CreateWindow("button","读取",WS_CHILD | WS_VISIBLE|BS_PUSHBUTTON,
420,200,80,25,hwnd,NULL,NULL,NULL);
hwndEdit = CreateWindow("edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER,
100,100,150,80,hwnd,NULL,NULL,NULL);
hButton1 = CreateWindow("button","改变光标",WS_CHILD | WS_VISIBLE|BS_PUSHBUTTON,
300,200,80,25,hwnd,NULL,NULL,NULL);
return 0;
case WM_COMMAND:
if (((HWND)lParam==hButton)&&(HIWORD(wParam)==BN_CLICKED))
{
GetWindowText(hwndEdit,strEdit,20);
MessageBox(NULL,strEdit,"攻取",MB_COMPOSITE);
}
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
TextOut(hdc,320,110,"请输入",9);TextOut(hdc,x,y,"jfeof",10);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
[ 本帖最后由 洪溪 于 2011-3-27 21:29 编辑 ]