mdi dll içinde child dll çalıştırma da hata?

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
loribnaczo54
Üye
Mesajlar: 60
Kayıt: 24 Nis 2006 07:42
Konum: Bahçelievler/İst.

mdi dll içinde child dll çalıştırma da hata?

Mesaj gönderen loribnaczo54 »

s.a

Benim projem öncelikle bir kullanıcı giriş ekranı (.exe) sonrasında Anamenu.dll yükleniyor. Anamenüdende formların bulunduğu dll ler yükleniyor. mesela Ticaret.dll, Finans.dll, Uretim.dll vb.gibi... mesela Ticaret.dll i LoadLibrary(Ticaret.dll) şeklinde yükledikten sonra içindeki datamodulu create ediyorum ve sql bağlantısını hazır hale getiriyorum.

şimdi bu şekilde çalışmada hiçbir problem yok fakat 5-6 form açıldığında windows görev çubuğunda hiçte hoş olmayan görüntü oluşuyor. Formlar haliyle görev çubuğunda yer işgal ediyor.
ben bu şekilde değilde mdi-child form sistemine geçmek istiyordum. uğraşlarım sonucu önce exe sonra yüklenen dll ve yüklenen dll içine yüklenen child dll yapmayı başardım. Fakat sorunlar da beraberinde başladı. birincisi yüklenen child formun içinde cxVerticalGrid component var ise "Cannot assing TFont to a Tfont" hata mesajı alıyorum.
Kullandığım dll çağırma sistemindemi hata var başka bir yerdemi anlayamadım. örnek kodlar aşağıda yardımlarınızı bekliyorum.
Teşekkürler.

bu örneği kodbank' tan bulmuştum.

exe kodları...

Kod: Tümünü seç

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, dxBar, dxBarExtItems, Menus;

type
  TShowFrm = procedure(App: TApplication; Scr:TScreen); stdcall;
  TForm1 = class(TForm)
    btnYukle: TButton;
    procedure FormCreate(Sender: TObject);
    procedure btnYukleClick(Sender: TObject);
  private
    { Private declarations }
    hInstance: THandle;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
   try
      hInstance := SafeLoadLibrary('Project1.dll', SEM_NOOPENFILEERRORBOX);
      {load the library on form create as will need to know what
      forms are available, so they can be listed for creation.}
   except
      on e: exception do ShowMessage(e.Message);
   end;

end;

procedure TForm1.btnYukleClick(Sender: TObject);
var
   AFunc: Pointer;
begin
    if Form1.MDIChildCount = 0 then
        try
          begin
            Pointer(AFunc) := GetProcAddress(hInstance, PChar ('ShowFrm'));
            TShowFrm(AFunc)(Application, Screen); {Open the child form}
          end;
        except
            on e: exception do ShowMessage(e.Message);
        end;
end;
end.
örnek dll proje kodları...

Kod: Tümünü seç

library Project1;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes,
  Forms,
  Windows,
  Dialogs,
  Unit1 in 'Unit1.pas' {F_form1},
  datamodul in 'datamodul.pas' {DataModule3: TDataModule};

{$R *.res}

var
   AppDLL: TApplication;
   ScrDLL: TScreen;

   procedure MyDLLProc(Reason: Integer);
   begin
      try
         if Reason = DLL_PROCESS_DETACH then
         begin
            Application := AppDLL;
            Screen := ScrDLL;
         end;
      except
         on e: exception do ShowMessage(e.Message);
      end;
   end;

   procedure ShowFrm(App:TApplication; Scr: TScreen); stdcall;
   begin
      Application := App;
      Screen := Scr;
      App.ShowHint:= False;

      App.CreateForm(TDataModule3, DataModule3);
      App.CreateForm(TF_form1, F_form1);
      F_form1.ShowHint := False;
      F_form1.Show;
   end;

exports
   ShowFrm;

begin
   try
      AppDLL := Application;
      ScrDLL := Screen;
      DLLProc := @MyDLLProc;
   except
      on e: exception do ShowMessage(e.Message);
   end;

end.

Not : dll projesinde Datamodule ve F_Form1 açmak yeterlidir. proje bu şekilde çalışıyor. fakat F_Form1 formunun içine cxVerticalGrid koyduğmda Font Hatası alıyorum.
Kullanıcı avatarı
loribnaczo54
Üye
Mesajlar: 60
Kayıt: 24 Nis 2006 07:42
Konum: Bahçelievler/İst.

Re: mdi dll içinde child dll çalıştırma da hata?

Mesaj gönderen loribnaczo54 »

arkadaşlar yardımlarınızı bekliyorum. hiç değilse düşünce fırtınası yapalım. içinden çıkamıyorum işin.
Kullanıcı avatarı
CiTiZEN
Üye
Mesajlar: 1163
Kayıt: 06 Oca 2008 04:15

Re: mdi dll içinde child dll çalıştırma da hata?

Mesaj gönderen CiTiZEN »

ben de de yaklaşık 8 form war bunlar dll değilde exe nin içinde durmaktalar, ilk önce ana form ve data modülü create ediyorum daha sonrasında lazım oldukca diğer formları create ediyorum ve işi bitince free ediyorum dll e ihtiyaç duymuyorum böyle bir olay işinizi görmez mi?
UWESIS CORPORATION
Ertugrul
Üye
Mesajlar: 136
Kayıt: 09 May 2009 12:05

Re: mdi dll içinde child dll çalıştırma da hata?

Mesaj gönderen Ertugrul »

google'a gore TApplication instance'ini DLL e aktarmak ya da DLL ve EXE yi runtime packagelarla derlemek gerekiyormus.
Lanista
Üye
Mesajlar: 18
Kayıt: 14 Tem 2008 11:31

Re: mdi dll içinde child dll çalıştırma da hata?

Mesaj gönderen Lanista »

Kod: Tümünü seç

the right is the right
Cevapla