Delphi VJ VB VC 討論 聯繫 首頁
DELPHI參考文件

 單元架構元件
 Pascal語言元件
 Standard元件
 Additional元件
 Win31元件
 Win32元件
 Dialog元件
 Dialog範例
 資料庫(上)
 資料庫(中)
 資料庫(下)
 報表製作
 鍵盤資料(上)
 鍵盤資料(中)
 鍵盤資料(下)

作品介紹

免費下載

廠商軟體


Dialog對話盒使用範例

表單設計

 

Standard元件頁,加入Memo元件
Addition元件頁,加入一個image元件及12個BitButton元件
Dialogs元件頁,加入所有的對話盒,共十個

元件

屬性

屬性值

元件

屬性

屬性值

BitButton1

Caption

開檔

BitButton8

Caption

色彩

Glyph

Fileopen.bmp

Glyph

Brush.bmp

BitButton2

Caption

存檔

BitButton9

Caption

列印圖檔

Glyph

Filesave.bmp

Glyph

Property.bmp

BitButton3

Caption

尋找字串

BitButton10

Caption

列印

Glyph

Find.bmp

Glyph

Print.bmp

BitButton4

Caption

開啟圖檔

BitButton11

Caption

印表機設定

Glyph

One2one.bmp

Glyph

Comppc1.bmp

BitButton5

Caption

存圖檔

BitButton12

Caption

結束

Glyph

Picture.bmp

Kind

bkClose

BitButton6

Caption

替換字串

Memo1

Lines

清為空白

Glyph

Retry.bmp

Align

Top

BitButton7

Caption

字型

ScrollBar

Both

Glyph

Font.bmp

     

 

程式設計

//因為使用Printer物件的函式,記得要將Printer加入函式庫
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtDlgs, ExtCtrls, StdCtrls, Buttons,
Printers;


procedure TForm1.BitBtn1Click(Sender: TObject);
//開檔
begin
If Opendialog1.Execute Then
Memo1.Lines.
LoadFromFile(Opendialog1.FileName);//開檔命令
end;

procedure TForm1.BitBtn2Click(Sender: TObject); //存檔
begin
If Savedialog1.Execute Then
Memo1.Lines.
SaveToFile(Savedialog1.FileName); //存檔命令
end;

procedure TForm1.BitBtn4Click(Sender: TObject); //開啟圖檔
begin
If OpenPictureDialog1.Execute Then
image1.Picture.
LoadFromFile(OpenPictureDialog1.FileName); //開檔命令
end;

procedure TForm1.BitBtn5Click(Sender: TObject); //存圖檔
begin
If SavePictureDialog1.Execute Then

image1.Picture.SaveToFile(SavePictureDialog1.FileName); //存檔命令
end;

procedure TForm1.BitBtn7Click(Sender: TObject); //字型
begin
If FontDialog1.Execute Then
Memo1.Font:=FontDialog1.Font;
end;

procedure TForm1.BitBtn8Click(Sender: TObject); //色彩
begin
If ColorDialog1.Execute Then
Memo1.Font.Color:=ColorDialog1.Color;
end;

procedure TForm1.BitBtn11Click(Sender: TObject); //印表機設定
begin
PrinterSetupDialog1.Execute;
end;

procedure TForm1.BitBtn9Click(Sender: TObject); //列印圖檔
begin
If PrintDialog1.Execute Then
With Printer do
    Begin
    BeginDoc;
     Printer.
Canvas.Draw(0,0,image1.Picture.Bitmap);
    EndDoc;
    End;
end;

procedure TForm1.BitBtn10Click(Sender: TObject); //列印
var
Line:Integer;
PrintText:TextFile;
Begin
     If Printdialog1.Execute Then
        Begin

               AssignPrn(PrintText);
               Rewrite(PrintText);
           try
            For Line:=0 to Memo1.Lines.Count-1 do
            Writeln(PrintText,Memo1.Lines[Line]);
          finally

            Closefile(PrintText);
         End;
      End;
end;

procedure TForm1.BitBtn3Click(Sender: TObject); //尋找字串
var
Str:String;
Posit:Integer;
begin
finddialog1.Execute;
Str:=Finddialog1.FindText;
Posit:=Pos(Str,Memo1.Text);
    If Posit <>0 Then
        Begin
           Memo1.SelStart:=posit-1;
           Memo1.SelLength:=Length(Str);
           Memo1.SetFocus;
        End;
end;

procedure TForm1.BitBtn6Click(Sender: TObject); //替換字串
var
Fstr:String;
Rstr:String;
Posit:Integer;
begin
ReplaceDialog1.Execute;
Fstr:=ReplaceDialog1.FindText;
Rstr:=ReplaceDialog1.ReplaceText;
Posit:=
Pos(Fstr,Memo1.Text); //利用Pos函式來尋找字串
         If Posit <> 0 Then
       Begin
       Memo1.SelStart:=posit-1;
       Memo1.SelLength:=Length(FStr);
       Memo1.SelText:=Rstr;
       Memo1.SelStart:=posit-1;
       Memo1.SelLength:=Length(Rstr);
       Memo1.
SetFocus; //反白
End;

end;


本網頁由昱得資訊工作室製作(C) Copyright Valor-Studio since in 1993

 

本網站全部內容係屬【昱得資訊工作室】版權所有,轉載必究,
非經正式書面同意,不得將全部或部分內容,以任何方式轉載於其他網站或用於任何商業行為