BCB配置和使用GDI+

来源:互联网 发布:收购淘宝账号400元 编辑:程序博客网 时间:2024/06/05 07:39

在BCB6中编译GDI+程序   
    
  1.)   在BCB6中已自带了ghiplus.h文件,故只需要生成gdiplus.lib文件就可以:   
          在命令行下运行implib   gdiplus.lib   gdiplus.dll。(如果ghiplus.dll不在当前文件夹下,注意写完整路径)   
    
  2.)   在工程的编译选项中加入STRICT条件编译:   
          Project-->Options-->Directories/Conditionals-->Condtionals-->点击旁边的"..."按钮-->输入STRICT,然后Add。

 

  3.)   在工程中加入Gdiplus.lib:   
          Project-->Add   To   Project-->找到Gdiplus.lib添加进来。   
    
  4.)   在工程的.h文件中包含所需的头文件,注意先后顺序:   
          #include   "math.hpp"   
          #include   <algorithm>   
          using   std::min;   
          using   std::max;   
          #include   "gdiplus.h"   
          using   namespace   Gdiplus;   
    
  5.)   为避免编译时产生的Warning,可以在.cpp文件头部加入:   
    
          #pragma   warn   -inl   
          #pragma   warn   -8022   
    
  6.)   在单元文件的.h中添加以下内容:   
          private: //   User   declarations   
            ULONG_PTR   GdiplusToken;   
            Gdiplus::GdiplusStartupInput   GdiplusStartupInput;   
          public: //   User   declarations   
            __fastcall   TMainForm(TComponent*   Owner);   
            __fastcall   ~TMainForm(void);   
    
  7.)   在单元文件的.cpp中添加:   
          //---------------------------------------------------------------------------   
          __fastcall   TMainForm::TMainForm(TComponent*   Owner)   
                  :   TForm(Owner)   
          {   
                  GdiplusStartup(&GdiplusToken,   &GdiplusStartupInput,   NULL);   //   初始化GDI+   
          }   
          //---------------------------------------------------------------------------   
          __fastcall   TMainForm::~TMainForm(void)   
          {   
                  GdiplusShutdown(GdiplusToken);   //   关闭GDI+   
          }   

  8.) 编译错误
[C++ Error] GdiplusGraphics.h(34): E2015 Ambiguity between 'Gdiplus::Graphics::Graphics(void *)' and 'Gdiplus::Graphics::Graphics(void *,int)'
[C++ Error] MainFormUnit.h(37): E2303 Type name expected
[C++ Error] MainFormUnit.cpp(53): E2045 Destructor name must match the class name
[C++ Error] MainFormUnit.cpp(54): E2171 Body has already been defined for function '_fastcall TForm1::~TForm1()'

原创粉丝点击