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

📄 unit1.cpp

📁 可实现对文件夹的遍历,它的控件都可以在C++BUILDER的控件中找到。如有意外
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   FilterComboBox1->Filter="all file(*.*)|*.*|jpg file(*.jpg)|*.jpg|";    
}
//---------------------------------------------------------------------------

void __fastcall TForm1::DriveComboBox1Change(TObject *Sender)
{
   DirectoryListBox1->Drive=DriveComboBox1->Drive;    
}
//---------------------------------------------------------------------------

void __fastcall TForm1::DirectoryListBox1Change(TObject *Sender)
{
    FileListBox1->Directory=DirectoryListBox1->Directory;    
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FilterComboBox1Change(TObject *Sender)
{
  FileListBox1->Mask=FilterComboBox1->Mask;    
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FileListBox1Change(TObject *Sender)
{
    String name=FileListBox1->FileName;
    Edit1->Text=name;    
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   String sd[100];
   TSearchRec sr;
   int i=0;
   String path=FileListBox1->Directory+"\\";
   path=path+"*.jpg";
   ComboBox1->Items->Clear();
   if(FindFirst(path,faAnyFile,sr)==0)
     {
       do
         {
           sd[i]=sr.Name;
           ComboBox1->Items->Add(sd[i]);
           i=i+1;
         }
       while(FindNext(sr)==0);
       FindClose(sr);
     }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  int length;
  String path;
  Label6->Caption="windows的目录:";
  Label7->Caption="windows的system目录:";
  path.SetLength(MAX_PATH);
  length=GetWindowsDirectoryA(path.c_str(),path.Length());
  ShowMessage(length);
  Label6->Caption=Label6->Caption+path;
  path.SetLength(MAX_PATH);
  length=GetSystemDirectoryA(path.c_str(),path.Length());
  Label7->Caption=Label7->Caption+path;
  ShowMessage(length);
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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