求指点CString strNum;
Font font(L"宋体", 10);
strNum = L"0";
graph.DrawString(strNum, -1, &font, 
PointF(8, 290), &SolidBrush(Color::Black)); for (int i = 0; i < 256; i += 5)
{
if (i % 50 == 0)
graph.DrawLine(&Pen(Color::Black), 10 + i, 280, 10 + i, 286);
else if (i % 10 == 0)
graph.DrawLine(&Pen(Color::Black), 10 + i, 280, 10 + i, 283);
}
报错:
C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(197) : error C2065: 'Font' : undeclared identifier
C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(197) : error C2146: syntax error : missing ';' before identifier 'font'
C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(197) : error C2065: 'font' : undeclared identifier
C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(199) : error C2228: left of '.DrawString' must have class/struct/union type
C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(200) : error C2065: 'PointF' : undeclared identifier
C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(200) : error C2653: 'Color' : is not a class or namespace name
C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(205) : error C2228: left of '.DrawLine' must have class/struct/union typeMFCGDI双环重绘图

解决方案 »

  1.   


    这个我大小写都试过了   直接是没有,  打不开C:\Users\colefet\Desktop\文件\毕设\image\image\HistogramDlg.cpp(10) : fatal error C1083: Cannot open include file: 'Gdip.h': No such file or directory
      

  2.   

    额~你这个回答太简单了,我估摸着是在Font前加“gdip::”?
    应该不是这个原因吧,我试了一下没有改变
    一开始我以为是要引进某库,
    网上馊的几个头文件我都导过了,一般是cannot open
      

  3.   

    你用的是vc6?那需要自己去下载gdi+库
      

  4.   

    你用的是vc6?那需要自己去下载gdi+库
    我用的VC6已经配置过GDI+的库了
      

  5.   

    你用的是vc6?那需要自己去下载gdi+库
    我用的VC6已经配置过GDI+的库了
    那就是 路径设置有问题了。百度搜一下
      

  6.   

    你用的是vc6?那需要自己去下载gdi+库
    我用的VC6已经配置过GDI+的库了
    那就是 路径设置有问题了。百度搜一下
    额,今天晚上照着百度文库里的MFC配置GDI+折腾了一整个晚上,貌似也不是这个问题
    目测最根本的问题还是这个:error C2065: 'Graphics' : undeclared identifier
    根本识别不出来。。
      

  7.   

    #include <GdiPlus.h>
    using namespace Gdiplus;不仅得包含头文件,还得引入Gdiplus的名字空间
      

  8.   

    http://www.cppblog.com/Lee7/archive/2009/04/28/81292.html
      

  9.   


    调试了2天 
    error C2664: 'enum Gdiplus::Status __thiscall Gdiplus::Graphics::DrawString(const unsigned short *,int,const class Gdiplus::Font *,const class Gdiplus::PointF &,const class Gdiplus::Brush *)' : cannot convert parameter 1 from 'class CString' to 'const unsigned short *'        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called没看到过这种格式的DrawString()函数啊,这是库的问题还是什么呢?换了一个包也没用。
      

  10.   

    楼主应该看看MSDN上关于GDI+相关类的说明,例如Graphics类。GDI+的文本绘制方法中所有涉及到字符串类型的参数都是UNICODE的WCHAR类型,而你调用的时候传递的却是MFC的CString类,明显的驴唇不对马嘴,应该使用strNum.GetString()方法获得字符串再传递给graph.DrawString()。
      

  11.   

    第一个问题写在stdAfx.h里边的东西要注意:(有时要放到InitInstance()所在的文件中才有效)
    #define ULONG_PTR ULONG
    #include <afxdtctl.h> //此处必须添加,否则出错
    #include <gdiplus.h>  
    using namespace Gdiplus;  
    #pragma comment(lib, "gdiplus.lib") #include <comdef.h>//初始化一下com口
    #ifndef ULONG_PTR
    #define ULONG_PTR unsigned long*
    #include "GdiPlus.h"
    using namespace Gdiplus;
    #endif这两段都试一下。第二个问题19楼的方法应该也是对的,不过这个已经解决了。
    “主要是UNICODE和ANSI的问题,CString可以是unsigned short*,也可以是char *,关键是编译时是否指定了_UNICODE选项” 
    解决办法:
    从主菜单中选择“Project | Settings”打开工程设置对话框 => 然后选择“C/C++”标签 => 在“Preprocessor definitions”编辑框中添加 UNICODE 或者 _UNICODE 预处理宏指令。