mainform.cpp

来自「C++ BUILDER精彩编程实例集锦(源码)3 第五部分 系统编程 第六部」· C++ 代码 · 共 70 行

CPP
70
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Mainform.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
char *StrClipboardFormats[17]={"cf_text","cf_bitmap","cf_metafilepict","cf_sylk",
                         "cf_dif","cf_tiff","cf_oemtext","cf_dib","cf_palette",
                         "cf_pendata","cf_riff","cf_wave","cf_unicodetext",
                         "cf_enhmetafile","cf_hdrop","cf_locale","cf_max"};
String GetUnknownFormatName(long lFormatID)
{
  char StrBuffer[255];
  long lIndex;
  lIndex = GetClipboardFormatName(lFormatID,StrBuffer,255);
  if(lIndex!=0)
    return String(StrBuffer);
  else
    return "-----None------";
}

void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
 int lIndex;
 int iCount;
 ListBox1->Items->Clear();
 if(OpenClipboard(Handle))
 {
    try
    {
      lIndex=EnumClipboardFormats(0);
      if(lIndex!=0)
      {
        do
        {
          iCount++;
          if(lIndex<18)
            ListBox1->Items->Add(StrClipboardFormats[lIndex]);
          else
            ListBox1->Items->Add(GetUnknownFormatName(lIndex));
          lIndex = EnumClipboardFormats(lIndex);
        }while(lIndex!=0);
      }
    }
    catch(...)
    {
      CloseClipboard();
    }
  }
  CloseClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
  this->Close();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?