关于EVC4.0下图形编程的问题
小弟刚毕业来单位工作,以前尚未接触过EVC和WINCE。
今天在照着《EVC高级编程及其开发应用》的示例写入一段代码,编译后除了这么三个错误:
G:\陈述程序\6281\6281.cpp(23) : error C2146: syntax error : missing '; ' before identifier 'brush '
G:\陈述程序\6281\6281.cpp(23) : error C2501: 'CBrush ' : missing storage-class or type specifiers
G:\陈述程序\6281\6281.cpp(23) : fatal error C1004: unexpected end of file found
代码是我直接把示例的一段原样加到编译器的。
CBrush类是CCdiObject类的派生类,用于指定环境的刷子。我写进的程序是与设备无关的位图画刷的使用。
请各位前辈帮帮我啊,小弟初来乍到,或者说,初到贵地,各位大哥大姐一定要帮我,超级谢谢!在线等....
代码如下:
#include "stdafx.h "
#include "6281.h "
#include <commctrl.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCEhInst;// The current instance
HWNDhwndCB;// The command bar handle
// Forward declarations of functions included in this code module:
ATOMMyRegisterClass(HINSTANCE, LPTSTR);
BOOLInitInstance(HINSTANCE, int);
LRESULT CALLBACKWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACKAbout(HWND, UINT, WPARAM, LPARAM);
HRSRC hRes;
HGLOBAL hDate;
HGLOBAL hLockedDate;
CBrush brush;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
//后加的
CDC *pDC = new CClientDC(this);
hRes = ::FindResource(AfxGetResourceHandle(),MAKEINTRESOURCE(IDB_BRUSH), RT_BITMAP);
if(hRes != NULL)
{
if(((hData = ::LoadResource(AfxGetResourceHandle(),hRes))!= NULL)&& ((hLockedDate = (HGLOBAL)::LockResource(hData))!= NULL))
{
brush.CreateDIBPatternBrush(hLockedDate, DIB_RGB_COLORS);
CBrush* pOldBrush = pDC-> SelectObject(&brush);
pDC-> Rectangle(0, 50, 250, 200);
pDC-> SelectObject(pOldBrush);
brush.DeleteObject();
::FreeResource(hLockedDate);
}
}
delete pDC;
////
......
[解决办法]
你这是SDK的Sample code, CDC CBrush 只能在MFC Frame中试用。你要么用SDK写,要么新建MFC project