我做了个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分回报。如果不行。我再加分。已经困扰了我快一个星期了。
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分回报。如果不行。我再加分。已经困扰了我快一个星期了。
解决方案 »
- Canon SDK变焦使用问题
- 大哥 们 帮小弟侃侃啊
- TreeView1展开问题?
- 如何实现一次点击实现多线程下载(多个页面,每个页面有多个链接) 100分
- Delphi中怎么样定义静态变量?
- 如何将6个edit中的数据排序后,在他们的下面对应显示IMAGE格式的第一....第六的图图片???
- 怎样调用系统的计算器?
- 定时屏幕取词
- 关于一个模态窗口在主窗口中移动时,主窗口发生闪动,什么原因呢?
- :database连接sql server7时怎样避免连接不通而死机或无止的等待!!谢谢!
- 数据流+字符串
- 安装ExpressQuantumGrid后为什么会覆盖之前安装的ExpressQuantumTreeList
你还是把想在dll窗口中做什么事情说的再明白些
我现在的情况是。主程序一查询。我的DLL窗体就点不了了。等数据查完。TIMER和DLL窗体上的按键才可以按。
听有人说。可以用多线程来不停的SHOW DLL窗体。我没学过多现程。但我写了个过程。放在BUTOON1里面。自己按了几次。结果出来了N个窗体
如果只是TIMER事件,就用多线程,很简单的。
如果要响应用户的查询那还得用窗口
其实分没什么用,我已经好多年不上这里了,这几天有空才来看看的。你的问题确实比较麻烦,本来应该在主程序中很好解决的问题。
你要么这样处理:在DLL中启动一个自己的程序,然后进程间进行通讯。
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.
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;