程序报错
D:.cpp(58) : error C2065: 'bmWidth' : undeclared identifier
D:cpp(58) : error C2065: 'bmHeight' : undeclared identifier
代码如下
# include <windows.h>
# include <stdlib.h>
# include "stdio.h"
# include <string.h>
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
BOOL InitWindowClass(HINSTANCE hInstance);
BOOL InitWindow( HINSTANCE hInstance, int nCmdShow);
HWND hwnd;
HDC hdc,hdcmenu;
HBITMAP hbitmap;
BITMAP bm;
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
MSG msg;
if(!InitWindowClass(hInstance))
return false;
if(!InitWindow(hInstance,nCmdShow))
return false;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CREATE:
{
hdc=GetDC(hwnd);
hdcmenu=CreateCompatibleDC(hdc);
ReleaseDC(hwnd,hdc);
}
case WM_PAINT:
{
PAINTSTRUCT ps;
hdc=BeginPaint(hwnd,&ps);
SelectObject(hdc,hbitmap);
BitBlt(hdc,180,80,bm,bmWidth,bm,bmHeight,hdcmenu,0,0,SRCCOPY);
EndPaint(hwnd,&ps);
break;
}
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
}
BOOL InitWindow( HINSTANCE hInstance, int nCmdShow)
{
HWND hwnd;
hwnd=CreateWindow
(
"lavender",
"Winged Monkey",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
if(!hwnd)
return FALSE;
hbitmap=LoadBitmap(hInstance,"MYMAP");
GetObject(hbitmap,sizeof(BITMAP),(LPVOID)&bm);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
return true;
}
BOOL InitWindowClass(HINSTANCE hInstance)
{
WNDCLASS wndclass1;
wndclass1.style=0;
wndclass1.lpfnWndProc=WinSunProc;
wndclass1.cbClsExtra=0;
wndclass1.cbWndExtra=0;
wndclass1.hInstance=hInstance;
wndclass1.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass1.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass1.lpszClassName="lavender";
wndclass1.lpszMenuName="Menu";
wndclass1.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
return RegisterClass(&wndclass1);
}
麻烦大家改一下错,和解释BITBlt那个函数的各个变量,谢谢