Узнать имя файла дериктории и сделать ее текущей
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellApi, FileCtrl, ExtCtrls, jpeg, Buttons, ComCtrls;
type
TForm1 = class(TForm)
FileListBox1: TFileListBox;
DirectoryListBox1: TDirectoryListBox;
DriveComboBox1: TDriveComboBox;
FileListBox2: TFileListBox;
DirectoryListBox2: TDirectoryListBox;
DriveComboBox2: TDriveComboBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x,y: string;
iconindex:integer;
implementation
{$R *.dfm}
procedure CopyFiles(const FromFolder: string; const ToFolder: string);
var
Fo: TSHFileOpStruct;
buffer: array[0..4096] of char;
p: pchar;
begin
FillChar(Buffer, sizeof(Buffer), #0);
p := @buffer;
StrECopy(p, PChar(FromFolder)); //директория, которую мы хотим скопировать
FillChar(Fo, sizeof(Fo), #0);
Fo.Wnd := Application.Handle;
Fo.wFunc := FO_COPY;
Fo.pFrom := @Buffer;
Fo.pTo := PChar(ToFolder); //куда будет скопирована директория
Fo.fFlags := 0;
if ((SHFileOperation(Fo) <> 0) or (Fo.fAnyOperationsAborted <> false)) then
ShowMessage('File copy process cancelled')
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
CopyFiles(directorylistbox1.Directory,Directorylistbox2.Directory);
Showmessage('Копирование завершено');
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
close;
end;
end.
Скрытый файл сделать видимым. Поменять атрибут.
Windows.setfileattributes(‘c:\test.txt’,fahidden); -сделать скрытым файл
программа
Function filesethidden(filename:string;hid:Boolean):Boolean;
Var flags:integer;
Begin
Result:=false;
Flags:=getfileattributes(pchar(filename));
If hid then flags:=flags or fahidden
Else flags:=flags and not fahidden;
Result:=setfileattributes(pchar(filename),flags);end;
Hid=true сделать файл скрытым
Hid=false сделать файл не скрытым
Сумма эл-тов ниже побочной диагонали
|
|
Var a: array[1..5,1..5] of integer;
Sum,I,j:integer;
Begin
For i:=1 to 5 do
For j:=1 to 5 do
A[i,j]:=strtoint(stringgrid1.cells[j-1,i-1];
Sum:=0;
If(5-j-1)<i then
Begin
Sum:=sum+a[I,j];
End;
При наведении мыши показывает сколько файлов содержится.
procedure TForm1.FileListBox1Change(Sender: TObject);
begin
memo1.Lines.Add(filelistbox1.FileName);
end;
procedure TForm1.DriveComboBox1Change(Sender: TObject);
begin
DirectoryListBox1.Drive:=DriveComboBox1.Drive;
end;
procedure TForm1.FilterComboBox1Change(Sender: TObject);
begin
filelistbox1.Mask:=filtercombobox1.Mask;
end;
Создание класса треугольника. Нахождение площади
Type
TTreug
private
fsidelength: integer;//dlina storony
fhidelength: integer;//vysota treuga
farea: integer;//plowad
procedure area;
procedure create;
end;
procedureTTreug.Create(length:integer);
begin
sidelength:=length;
hidelength:=length1;
end;
procedureTTreug.Area(a:integer);
a:=sidelength*hidelength/2;
end;
procedureTForm1.Button1.Click(Sender:TObject);
begin
sidelength:=strtoint(edit1.Text);
hidelength:=strtoint(edit2.Text);
Treug.Area(a);
label1.caption:=inttostr(a);
end;
Строка состояния студента
statusbar1.Panels[0].Text:='Иванов Иван Иванович';
statusbar1.Panels[1].Text:=datetostr(now);
statusbar1.Panels[2].Text:=timetostr(now);
Объект машина. Старт и стоп движения
//Машина представляет собой рисунок
procedureTForm1.FormCreate(Sender:TObject);
Timer1.active:=false;
procedureTForm1.Timer1Timer(Sender:TObject);
begin
image1.left:=image1.left+50;
if(image1.left>form1.clientwidth) then
image1.left:=1;
end;
//stop mawina
procedureTForm1.Button1.Click(Sender:TObject);
begin
Timer1.active:=false;
end;
//go mawina
procedureTForm1.Button1.Click(Sender:TObject);
begin
|
|
Timer1.active:=true;
end;
end.
Создать программу, в которой при нажатии на кнопку выводится на печать страница перечеркнутая до диагонали линиями красного цвета
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls,printers;
type
TForm1 = class(TForm)
Button1: TButton;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
printer.begindoc;
with form1.Canvas do
begin
pen.Color:=clred;
pen.Width:=2;
clientheight:=338;
clientwidth:=316;
Printer.canvas.lineto (316,338);
lineto(316,338);
Printer.canvas.lineto (316,0);
moveto(316,0);
Printer.canvas.lineto (0,338);
lineto(0,338);
end;
printer.enddoc;
end;
Дата добавления: 2018-04-15; просмотров: 170; Мы поможем в написании вашей работы! |
Мы поможем в написании ваших работ!