我做了个DLL的插件。是通过别人的主程序来呼出。   方法是这样。主程序。调用他原来的DLL原来的1.DLL在调用时。再调用我的form.DLL窗体。  用的是静态调用。   我的dll窗体里面是这样写的   
 procedure showform();stdcall;
  var f:TForm_main;begin f:=TForm_main.Create(nil);
//SetApplication(Application.Handle);
  f.Show;end;在1.dll中加入
Procedure    showform;stdcall;   far   external   'Form.dll';
showform;我的调用方法是这个。有人说不能用FORM show的方式在新的线程里show
我不是太理解。我现在想要的功能就是能够让主程序在查询数据。或者其它工作时。我的DLL窗体能分离出来做自己的工作。不会让DLL窗体的工作暂停。有人说用多线程。但是我从网上COPY了好几个方法。试了还是不行。我一共发了3张贴。300分回报。如果不行。我再加分。已经困扰了我快一个星期了。

解决方案 »

  1.   

    dll窗体如果不涉及交互,就用多线程
      

  2.   

    多线程的例子?
    你还是把想在dll窗口中做什么事情说的再明白些
      

  3.   

       我想实现在主程序运行大工作的查询或者其它事情时。DLL窗体还可以进行输入。查询。里面的TIMER事件。不会停滞。
       我现在的情况是。主程序一查询。我的DLL窗体就点不了了。等数据查完。TIMER和DLL窗体上的按键才可以按。
    听有人说。可以用多线程来不停的SHOW DLL窗体。我没学过多现程。但我写了个过程。放在BUTOON1里面。自己按了几次。结果出来了N个窗体
      

  4.   

    delphi自己创建的窗口,好象用的是同一个线程,所以主程序中不通过多线程进行时,所有窗口应该都停止相应了吧.
    如果只是TIMER事件,就用多线程,很简单的。
    如果要响应用户的查询那还得用窗口
      

  5.   

      关键主程序不是我写的。我只是写了个给他调用的DLL。这样一来。他主程序一进行大数据量的工作。我的DLL他跟他的界面一起停住了。  为什么好多人都说多线程可以。但是我认为,如果我不修改他的主程序。多线程和TIMER还不是一样吗?我实在是不明白。 这个问题我已经被困扰三四天了。查了不少DLL窗体和多线程的资料还是不知道如何解决XIAOXIAO你能帮帮我吗?我已经N天没睡好觉了。有个问题解决不了。实在是闹心啊
      

  6.   


    其实分没什么用,我已经好多年不上这里了,这几天有空才来看看的。你的问题确实比较麻烦,本来应该在主程序中很好解决的问题。
    你要么这样处理:在DLL中启动一个自己的程序,然后进程间进行通讯。
      

  7.   

    主程序在处理大数据时,和DLL中的窗口交互,最好用WINDOWS的消息,这样,主程序不用等DLL中的窗口处理完数据就可以继续自己的工作,而DLL中的窗口也必须在一个新的TRHREAD中Create And Show以下是我在作APS系统时,遇到跟你一样的情况,可以参考如下代码(我的是开启一个Dailog窗口)--- 欢迎访问我的空间,第一篇Log:我的MIS FrameWork我的MIS Systemunit DataProcessStep;interfaceuses
      Windows, Classes, SysUtils, CommCtrl, Messages, Forms;type
      TDataProcessStep=class(TThread)
      public
        procedure Start(Max:integer);
        procedure Step(Data:integer);
        procedure Stop;    procedure ActiveTimer(Active:boolean);    procedure FreeStepTip;    class function GetStepTip:TDataProcessStep;
      private
        D,P,L:HWND;
        Actived:boolean;
        Str,Title:String;
        TotalTime:integer;
      private
        procedure ShowTip;    procedure OnTimer;    procedure Execute;override;
      end;implementation{$R ProcessStepDlg.res}uses QPMessage;  const USER_SHOW=WM_USER+1;
      const USER_HIDE=WM_USER+2;  threadvar Steper:TDataProcessStep;function DlgProc(Dlg:HWND;Msg:DWORD;wParam:WPARAM;lParam:LPARAM):INT_PTR;stdcall;
    begin
      if Msg=USER_SHOW then
      begin
        ShowWindow(Dlg,SW_SHOW);    SetFocus(Dlg);    UpDateWindow(Dlg);
      end
      else if Msg=USER_HIDE then ShowWindow(Dlg,SW_HIDE)
      else if Msg=WM_TIMER then Steper.OnTimer;  result:=0;
    end;procedure TDataProcessStep.Start(Max:integer);
    begin
      self.TotalTime:=1;  if self.D<>0 then SendMessage(self.D,USER_SHOW,0,0);  if self.P<>0 then SendMessage(self.P,PBM_SETRANGE32,0,Max);  self.ShowTip;  self.Actived:=true;
    end;procedure TDataProcessStep.Step(Data:integer);
    begin
      if self.P<>0 then PostMessage(self.P,PBM_SETPOS,Data,0);
    end;procedure TDataProcessStep.Stop;
    begin
      self.Actived:=false;  if self.D<>0 then SendMessage(self.D,USER_HIDE,0,0);
    end;procedure TDataProcessStep.ActiveTimer(Active:boolean);
    begin
      self.Actived:=Active;
    end;procedure TDataProcessStep.FreeStepTip;
    begin
      self.Terminate;
    end;class function TDataProcessStep.GetStepTip:TDataProcessStep;
    begin
      result:=TDataProcessStep.Create(true);  result.D:=0;
      result.P:=0;
      result.L:=0;  result.Actived:=false;  result.Str:=ProcessTimeTip;  result.Title:=ProcessTimeTitle;  result.Resume;
    end;procedure TDataProcessStep.OnTimer;
    begin
      if self.Actived then
      begin
        Inc(self.TotalTime);    self.ShowTip;
      end;
    end;procedure TDataProcessStep.ShowTip;
    var
      T1,T2,H,M:integer;
    begin
      if self.L<>0 then
      begin
        T1:=self.TotalTime;    T2:=T1 mod 3600;    H:=(T1-T2) div 3600;    T1:=T2;    T2:=T1 mod 60;    M:=(T1-T2) div 60;    SetWindowText(self.L,PChar(Format(self.Str,[H,M,T2])));
      end;
    end;procedure TDataProcessStep.Execute;
    var
      Msg:TMsg;
      Rect:TRect;
    begin
      self.D:=CreateDialog(0,PChar(102),0,@DlgProc);  if self.D<>0 then
      begin
        Steper:=self;    self.P:=GetDlgItem(self.D,1001);
        self.L:=GetDlgItem(self.D,1002);    SetTimer(self.D,1,1000,nil);    GetWindowRect(self.D,Rect);    MoveWindow(self.D,Rect.Left,Rect.Top-100,Rect.Right-Rect.Left,Rect.Bottom-Rect.Top,true);    SetWindowText(self.D,PChar(self.Title));    SetClassLong(self.D,GCL_HICON,Application.Icon.Handle);    while not self.Terminated do if GetMessage(Msg,0,0,0) then
        begin
          TranslateMessage(Msg);
          DispatchMessage(Msg);
        end
        else SwitchToThread;                         KillTimer(self.D,1);    EndDialog(self.D,0);
      end;
    end;end.
      

  8.   

       我的意思是。如果让DLL窗体不会停滞。如果我让DLL不同的发送消息。在主程序进行查询时。会锁住吗?
      

  9.   


     Type
        Tdllform = class(TThread)
      private
           T_AHandle:THandle; T_ACaption:Pchar   ;
      protected
        procedure Execute; override;  public
        constructor Create(AHandle:THandle;ACaption:Pchar);
      end;constructor  TdllForm.Create(AHandle:THandle;ACaption:Pchar);
    begin
        T_AHandle :=  AHandle  ;
        T_ACaption  :=  ACaption;
        inherited Create(False);
    end;  procedure    TdllForm.Execute ;
          var AForm:TForm_main;AMsg :Tmsg;
      begin
           AForm:=TForm_main.Create(nil);
           Aform.Caption:=T_ACaption;
           AForm.Show;
            while GetMessage(AMsg, 0, 0, 0) do begin
                TranslateMessage(AMsg);
                DispatchMessage(AMsg);
           end;
      end;Function ShowForm(AHandle:THandle;ACaption:Pchar):Boolean;StdCall;
    begin
        TdllForm.Create(Ahandle,Acaption);
        Result:=true;
    end;