首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cxgrid ib dll delphi

cxgrid ib dll delphi
EN

Stack Overflow用户
提问于 2012-03-06 14:25:10
回答 1查看 618关注 0票数 0

大家好,我写的插件dll是从主窗体调用的dll

代码语言:javascript
复制
type
  TCreateCustomWindow=function(ParentFrame:TWinControl; ParentHandle:integer; ParentRect:TRect; var WinHandle:THandle):integer; stdcall;

var
CreateW:TCreateCustomWindow;
begin
CreateW:=GetProcAddress(FHLib,'Create_LEF');
if Assigned(CreateW) then
begin
  if Assigned(CreateW) then LEFT_OKNO:=CreateW(ScrollBox2, ScrollBox2.Handle, ClientRect, FChildHandle);
end;

在dll本身中,它看起来像

代码语言:javascript
复制
function Create_LEF(ParentFrame:TWinControl; ParentHandle:integer; ParentRect:TRect; var WinHandle:THandle):integer; stdcall; export;
begin
  Result:=0;
  WinHandle:=0;
  try
    FD3:=TForm3.Create(nil);
    FD3.Parent:= ParentFrame;
    Result:=integer(FD3);
    WinHandle:=FD3.Handle;
    if ParentHandle<>0 then begin
      SetParent(WinHandle,ParentHandle);
      with FD3 do begin
      FD3.Align:=alTop;
      FD3.Width:=ParentFrame.Width;
      hirina_left:=ParentFrame.Width;
      FD3.Show;
      end;
    end;
  except
    On E:exception do MessageDlg(E.Message,mtError,[mbOK],0);
  end;
end;

问题是我不能编辑单元格cxGrid我能做错什么吗?

EN

回答 1

Stack Overflow用户

发布于 2012-03-07 00:24:02

我以前遇到过这种情况,有几种方法可以解决它。这是很久以前的事了,所以你需要做一些试验和错误的工作。

代码语言:javascript
复制
function Create_LEF(ParentFrame:TWinControl; ParentHandle:integer; ParentRect:TRect; var WinHandle:THandle):integer; stdcall; export;
begin
  Result:=0;
  WinHandle:=0;
  try
    FD3:=TForm3.Create(nil);
    FD3.Parent:= ParentFrame;
    Result:=integer(FD3);
    WinHandle:=FD3.Handle;
    if ParentHandle<>0 then begin
      with FD3 do begin
        ParentWindow := ParentFrame.Handle;
        Parent := ParentFrame;
        Align:=alTop;
        Width:=ParentFrame.Width;
        hirina_left:=ParentFrame.Width;
        Show;
      end;
    end;
  except
    On E:exception do MessageDlg(E.Message,mtError,[mbOK],0);
  end;
end;

这应该会解决你的问题。如果失败,请尝试将DLL的Application.Handle设置为应用程序的Application.Handle。我通常使用DLL中的Init函数来完成此操作。此函数将动态链接库的Application.Handle存储在全局变量中,并将其重新分配给应用程序的句柄,作为参数传递给函数。卸载DLL时,将DLL的application.handle赋值回其原始值,否则一切都会出错。

代码语言:javascript
复制
var
    FOldHandle: THandle;

procedure Init(AHandle: THandle); stdcall;
begin
    FOldHandle := Application.Handle;
    Application.Handle := AHandle;
end;

procedure UnInit; stdcall;
begin
    Application.Handle := FOldHandle;
end;
...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9578915

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档