unit1.~cpp
来自「可实现对文件夹的遍历,它的控件都可以在C++BUILDER的控件中找到。如有意外」· ~CPP 代码 · 共 86 行
~CPP
86 行
//---------------------------------------------------------------------------
#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;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?