2012-03-06 7 views
0

良い日、私はプラグインがメインフォームから をdllを書くDLLにDLL自体でcxgridのIBの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; 

を呼び出し、それが

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私は何か間違っていますか?

+0

コードには、cxGrid(DevExpressグリッド)についての記述はありませんので、わかりにくいです。関連するコードと既に試したいくつかのステップを投稿できますか? – Birger

+0

DLL境界を越えてDelphiオブジェクトを安全に渡すことはできません。そのTWinControlパラメータはいいえです。なぜあなたはそれをHWNDと同様に渡す必要がありますか?しかしそれが問題に関連しているかどうかはわかりません。メインプログラムの –

+0

私はScrollBoxのコンポーネントを持っていて、dllフォームからファイルを置く必要があります。フォームの "СКРЫТЬ"日を押すと、上の2つのキャッチアップの量がコードIで上がります上で提供されていますが、動作しますが、cxGridを編集することはできません。スクリーンショットへのリンクはこちらhttp://s51.radikal.ru/i132/1203/da/3787a490fd8f.jpg – fedormoore

答えて

0

これまでにこの問題が発生しました。その周りにはいくつかの方法があります。それはずっと前のことだったので、少し試行錯誤しなくてはなりません。

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関数でこれを行います。この関数は、DLLのApplication.Handleをグローバル変数に格納し、それを関数のパラメータとしてアプリケーションのハンドルに再割り当てします。 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; 
... 
+0

残念ながら、それは私を助けませんでした... – fedormoore

関連する問題