⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 C++ builder 完全攻略 学习C++ Builder 不可缺少
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
   ListBox1->Items->Add(Edit1->Text);
   Edit1->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
   if (Edit1->Text != "")
      BitBtn1->Enabled = true;
   else
      BitBtn1->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
  if (ListBox1->ItemIndex >= 0)
  {
    ListBox2->Items->Add(ListBox1->Items->Strings[ListBox1->ItemIndex]);
    ListBox1->Items->Delete(ListBox1->ItemIndex);
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
  if (ListBox2->ItemIndex >= 0)
  {
    ListBox1->Items->Add(ListBox2->Items->Strings[ListBox2->ItemIndex]);
    ListBox2->Items->Delete(ListBox2->ItemIndex);
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1DragOver(TObject *Sender, TObject *Source,
      int X, int Y, TDragState State, bool &Accept)
{
  if (Source == ListBox2)
    Accept = true;
  else
    Accept = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox2DragOver(TObject *Sender, TObject *Source,
      int X, int Y, TDragState State, bool &Accept)
{
  if (Source == ListBox1)
    Accept = true;
  else
    Accept = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1DragOver(TObject *Sender, TObject *Source,
      int X, int Y, TDragState State, bool &Accept)
{
  if (Source == ListBox1)
    Accept = true;
  else
    Accept = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1DragDrop(TObject *Sender, TObject *Source,
      int X, int Y)
{
  TListBox *buf = (TListBox *)Source;

  ListBox1->Items->Add(buf->Items->Strings[buf->ItemIndex]);
  ListBox2->Items->Delete(buf->ItemIndex);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBox2DragDrop(TObject *Sender, TObject *Source,
      int X, int Y)
{
  TListBox *buf = (TListBox *)Source;

  ListBox2->Items->Add(buf->Items->Strings[buf->ItemIndex]);
  ListBox1->Items->Delete(buf->ItemIndex);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Image1DragDrop(TObject *Sender, TObject *Source,
      int X, int Y)
{
  if (Source == ListBox1)
  {
    TListBox *buf = (TListBox *)Source;

    buf->Items->Delete(buf->ItemIndex);
  }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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