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那个函数的各个变量,谢谢

解决方案 »

  1.   

    BOOL BitBlt(
      HDC hdcDest, // handle to destination DC
      int nXDest,  // x-coord of destination upper-left corner
      int nYDest,  // y-coord of destination upper-left corner
      int nWidth,  // width of destination rectangle
      int nHeight, // height of destination rectangle
      HDC hdcSrc,  // handle to source DC
      int nXSrc,   // x-coordinate of source upper-left corner
      int nYSrc,   // y-coordinate of source upper-left corner
      DWORD dwRop  // raster operation code
    );
      

  2.   

    D:.cpp(58) : error C2065: 'bmWidth' : undeclared identifier
    D:cpp(58) : error C2065: 'bmHeight' : undeclared identifier
    =====================
    你这个没有定义啊,在前面加上int bmWidth,bmHeight;
      

  3.   

    刚才仔细看了下你的代码,发现问题竟是这里:
    BitBlt(hdc,180,80,bm,bmWidth,bm,bmHeight,hdcmenu,0,0,SRCCOPY);
    ===================================
    应该是:
    BitBlt(hdc,180,80,bm.bmWidth,bm.bmHeight,hdcmenu,0,0,SRCCOPY);