Dll里有一个FORM 退出出错

大悟还俗 2013-01-29 11:53:34


我在dll里建了一个FORM

在Form里用了 Create事件加了

Application.OnMessage := WMDropMessage;


procedure Tfm_TS.WMDropMessage(var Msg: TMsg; var Handled: Boolean);
var
……
begin
…… 
end;

当退出时报错,怎么解决啊????????????
...全文
146 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
大悟还俗 2013-01-29
  • 打赏
  • 举报
回复
在dll里如果屏了 Application.OnMessage := WMDropMessage; Dll就没办法处理拖动 因为我直接写procedure WMDropFiles2(var message: TMessage); message WM_DROPFILES; 根本不会触发 或者在主程序中屏了 FreeLibrary(DLLHandle); 都不会报错 屏 Application.OnMessage := WMDropMessage;肯定是不能的 如果屏 FreeLibrary(DLLHandle);那么就没办法释放了
hsfzxjy 2013-01-29
  • 打赏
  • 举报
回复
引用 7 楼 key_ok 的回复:
引用 1 楼 HSFZXJY 的回复:报什么错?? 我报的是地址错 --------------------------- Pro_dwhs --------------------------- Access violation at address 032DB6D4. Read of address 032DB6D4. --------------……
好吧。。
大悟还俗 2013-01-29
  • 打赏
  • 举报
回复
引用 1 楼 HSFZXJY 的回复:
报什么错??
我报的是地址错 --------------------------- Pro_dwhs --------------------------- Access violation at address 032DB6D4. Read of address 032DB6D4. --------------------------- 确定 ---------------------------
大悟还俗 2013-01-29
  • 打赏
  • 举报
回复
引用 2 楼 bdmh 的回复:
dll的 Application 设置为调用者的 Application
我的Dll的 Application 已经是主程序的Application 了
大悟还俗 2013-01-29
  • 打赏
  • 举报
回复
这个Dll是动态加载的, function openDllModal(DLLName: string; ProcName: string; vhand: THandle): THandle; stdcall; type TDllModalFun = function(hand: THandle): THandle; stdcall; var DLLHandle: THandle; //dll句柄 pDll: Pointer; vHd:THandle; begin try DLLHandle := LoadLibrary(PChar('Modal\' + DLLName)); if DLLHandle > 0 then begin pDll := GetProcAddress(DLLHandle, PChar(ProcName)); if pDll <> nil then begin try //Result := TDllModalFun(pDll)(vhand); vHd:=TDllModalFun(pDll)(vhand); Result:=vHd; except on e: Exception do begin DisplayMessage('error', '执行' + ProcName + '函数出错!' + #13 + e.Message); Exit; end; end; end else begin DisplayMessage('error', '加载dll函数出错!'); Exit; end; end else begin DisplayMessage('error', '获取dll句柄出错!'); Exit; end; finally //FreeLibrary(DLLHandle); end; end; //FreeLibrary(DLLHandle); 这个屏了就不报错了 这个是 procedure Tfm_TS.WMDropMessage(var Msg: TMsg; var Handled: Boolean); var WMD: TWMDropFiles; vWinControl: TWinControl; begin case Msg.message of WM_DROPFILES: begin vWinControl := FindControl(Msg.hwnd); //ShowMessage(vWinControl.Name + '发送的消息'); end; end; if Msg.message = WM_DROPFILES then begin WMD.Msg := Msg.message; WMD.Drop := Msg.wParam; WMD.Unused := Msg.lParam; WMD.Result := 0; WMDropFiles(WMD); Handled := TRUE; end; end;
yangtao6888 2013-01-29
  • 打赏
  • 举报
回复
关注,留脚印,每天拿十分
hsfzxjy 2013-01-29
  • 打赏
  • 举报
回复
你把WMDropMessage贴上来。。
bdmh 2013-01-29
  • 打赏
  • 举报
回复
dll的 Application 设置为调用者的 Application
hsfzxjy 2013-01-29
  • 打赏
  • 举报
回复
报什么错??

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧