[求助]关于加载自定义图标的问题]
#include<Windows.h>#include<stdio.h>
#define IDI_ICON1 WM_USER+1
#define IDC_CURSOR2 WM_USER+2
//HICON hIcon;
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor=LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CURSOR2));/*为什么我定义的自定义图标和自定义的光标都加载不了?*/
wndclass.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WindowProc;
wndclass.lpszClassName="lucis";
wndclass.lpszMenuName="Menu";
wndclass.style=CS_VREDRAW|CS_HREDRAW;
RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow("lucis","Test",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
CW_USEDEFAULT,500,500,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOW);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_CHAR:
char ch[20];
sprintf(ch,"Char is %d",wParam);
MessageBox(hwnd,ch,"Test",MB_OK);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"Are you sure to quit?","Exit",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_PAINT:
HDC hdc;
PAINTSTRUCT paint;
hdc=BeginPaint(hwnd,&paint);
SetTextColor(hdc,RGB(0,0,255));
SetBkColor(hdc,RGB(255,255,255));
SetBkMode(hdc,OPAQUE);
TextOut(hdc,0,0,"I have a test this afternoon!",strlen("I have a test this aftenoon!"));
EndPaint(hwnd,&paint);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"The test is successfully","Your success",MB_ICONWARNING);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
break;
}
return 0;
}