程序报错

P8618282287827770 2010-11-28 06:22:04
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那个函数的各个变量,谢谢
...全文
36 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
P8618282287827770 2010-11-28
  • 打赏
  • 举报
回复
3楼的,实在谢谢了。
wltg2001 2010-11-28
  • 打赏
  • 举报
回复
刚才仔细看了下你的代码,发现问题竟是这里:
BitBlt(hdc,180,80,bm,bmWidth,bm,bmHeight,hdcmenu,0,0,SRCCOPY);
===================================
应该是:
BitBlt(hdc,180,80,bm.bmWidth,bm.bmHeight,hdcmenu,0,0,SRCCOPY);
wltg2001 2010-11-28
  • 打赏
  • 举报
回复
D:.cpp(58) : error C2065: 'bmWidth' : undeclared identifier
D:cpp(58) : error C2065: 'bmHeight' : undeclared identifier
=====================
你这个没有定义啊,在前面加上int bmWidth,bmHeight;
Eleven 2010-11-28
  • 打赏
  • 举报
回复
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
);

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧