小编Rai*_*ain的帖子

OpenDialog没有出现在Delphi MultiThreaded应用程序中

我试图在新线程中使用openDialog,但它做了如此奇怪的行为..

如果我把if opendialog.execute然后放在create构造函数中,如下所示:

constructor TChatMemberThread.Create(Name: string);
begin
  inherited Create(True);
  FName := Name;
  FreeOnTerminate := True;
  Opendialog := TOpenDialog.create(nil);
  if opendialog.execute then
    for 0 to opendialog.filescount do
      somecodeishere
    end;
end;
Run Code Online (Sandbox Code Playgroud)

opendialog正常打开但是当我把它放在线程的执行生成器中时它根本没有打开!!

我是线程的初学者,所以任何人都可以向我解释发生了什么?

提前致谢 .

[编辑]

unit Unit1;

interface

uses
  Classes,Dialogs,ComCtrls,SysUtils,DCPcrypt2, DCPmd5;

type
  TOpenThread = class(TThread)
  private
    { Private declarations }
    OpenDlG : TOpenDialog;
    LI : TListItem;
    Procedure Openit;
    Function MD5it(Const filename : string ):String;
  protected
    procedure Execute; override;
  Public
    Constructor Create;
    Destructor Destroy;Override;
  end;

implementation
uses Main;

{ TOpenThread }

Constructor …
Run Code Online (Sandbox Code Playgroud)

delphi multithreading delphi-2009 fileopendialog topendialog

2
推荐指数
1
解决办法
1744
查看次数