简体   繁体   English

cxgrid ib dll德尔福

[英]cxgrid ib dll delphi

Good day, I write plugins dll from the main form call the dll 美好的一天,我从主窗体调用dll编写插件dll

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;

in the dll itself, it looks like 在dll本身中,它看起来像

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;

the problem is that I can not edit cells cxGrid can I do something wrong? 问题是我无法编辑单元格cxGrid,我可以做错什么吗?

I have encountered this before, and there are a couple of ways around it. 我以前曾遇到过这种情况,并且有几种解决方法。 It was a long time ago, so you will have to do a bit of trial and error. 这是很久以前的,所以您将不得不进行一些反复试验。

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;

That should fix your problem. 那应该解决您的问题。 Failing that, try setting DLL's Application.Handle to the application's Application.Handle. 如果失败,请尝试将DLL的Application.Handle设置为应用程序的Application.Handle。 I usually do this with an Init function in the DLL. 我通常使用DLL中的Init函数执行此操作。 This function stores the the DLL's Application.Handle in a global variable and reassigns it to the application's handle, passed as a parameter to the function. 该函数将DLL的Application.Handle存储在全局变量中,并将其重新分配给应用程序的句柄,并作为参数传递给函数。 When you unload the DLL, you assign the DLL's application.handle back to its original value, otherwise everything goes South. 当您卸载DLL时,您将DLL的application.handle分配回其原始值,否则一切都变南了。

var
    FOldHandle: THandle;

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

procedure UnInit; stdcall;
begin
    Application.Handle := FOldHandle;
end;
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM