一个窗口中,放了三个组件:button1、OpenDialog1、RichEdit1各一个,源程序见下,单击按钮,打开对话框,选择桌面,有一个对话框弹出,不知是什么原因?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);
procedure OpenFile(FileName: String);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
OpenDialog1.Execute;
if OpenDialog1.FileName <> '' then
begin OpenFile(OpenDialog1.FileName);
end;
end;
procedure Tform1.OpenFile(FileName: String);
{将选择的文件打开,然后设置窗口的标题名称}
begin
RichEdit1.Lines.LoadFromFile(FileName);
Caption := FileName;
end;
end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);
procedure OpenFile(FileName: String);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
OpenDialog1.Execute;
if OpenDialog1.FileName <> '' then
begin OpenFile(OpenDialog1.FileName);
end;
end;
procedure Tform1.OpenFile(FileName: String);
{将选择的文件打开,然后设置窗口的标题名称}
begin
RichEdit1.Lines.LoadFromFile(FileName);
Caption := FileName;
end;
end.
解决方案 »
- 请帮忙把一个VC函数申请转换成DELPHI的
- 2000元求购一程序!!高手请进
- 救助:怎么捕获QQ的在线查看的窗口?
- sql server 中存储过程是否会发生冲突?
- 没人能搞定它吗?shbrowseforfolder函数?
- 关于流的问题:怎么处理流到DataSet中去,存进去又如何读入到OleContainer中去,多谢帮忙!
- 怎么样将数据集存成文本格式?
- *****高分收购原程序!谁有请快快回答!!!分数多多,望能达到你的满意!******************
- 急救远程办公解决方案!
- 出尽血求解,权限设置的思路,方法,有下列结构,帮忙分析
- TStrings与string
- 用API怎么实现截获窗体最小化消息,并响应?
我是用的DELPHI6
我在编一个文档编辑程序中用到相似的程序,但是更严重:只要打开那个"打开文件"的对话框就出来了这个东西。
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute and (OpenDialog1.FileName <> '') then
OpenFile(OpenDialog1.FileName);
end;
我要找过一个DELPHI来用!!!!!