Board index » delphi » Desperate: Assigning Panel.Parent from DLL to TabSheet in EXE

Desperate: Assigning Panel.Parent from DLL to TabSheet in EXE

First, sorry about the cross-posting, but the question seems
relevant to both newsgroups.  :)

Here's what I am doing:

1)  Creating a DLL that contains a Form.  On the form is a Panel
    that contains a few buttons and a PageControl with 2 or more
    tabsheets.

2)  Creating an EXE that contains a PageControl with 2 or more
    tabsheets.

You can view the EXE as the module level and the DLLs as the
sub-module levels.

What I am doing is calling a function in the DLL passing in
a pointer to a TTabSheet in the EXE.  The DLL then assigns the
Parent property of the Panel to the EXE's tabsheet.

This works wonderfully, except for the PageControl on the
DLLs panel.

If the PageControl on the DLLs panel has more than one tabsheet,
when I click on tabs once it is in the EXEs PageControl, the
tabbing functionality no longer works as expected.  When the
PageControl is created within the EXE, all looks normal until
I click on another tab.  The tab I click comes the the forefront,
but the tabsheet associated with the tab I clicked does not appear.
The tabsheet that originally appeared upon transfer (via the
parent property) is still visible.

This whole process works as you would expect if I am doing all the
transferring within a single EXE...between two forms.  But doing
it between an EXE and a DLL causes unexpected problems.

There is something going on that I'm not aware of and I desperately
need some information or a solution.  Hopefully someone from TeamB
can help.

Here are some code snippets (I relaize that this code is in
C++Builder, but the problem should be equally applicable to
Delphi, since the VCL is in Delphi....and I thought I might
have a better chance of getting an answer here since Delphi
has been around much longer...and I've been using Delphi for
awhile too):

--------------------from the DLL----------------------------------
void __fastcall TSatisTestModule::TransferPanelFromDLL()
{
  pnlContainer->Parent = winPage;

Quote
}

void __fastcall TSatisTestModule::TransferPanelToDLL()
{
  pnlContainer->Parent = this;
Quote
}

//---------------------------------------------------------------------------
//                 DLL Entry Points
//---------------------------------------------------------------------------
void LoadTestModule(TWinControl* i_winPage)
{
  SatisTestModule = new TSatisTestModule(NULL);
  SatisTestModule->Page = i_winPage;
  SatisTestModule->TransferPanelFromDLL();

Quote
}

void DestroyTestModule()
{
  SatisTestModule->TransferPanelToDLL();
  if(SatisTestModule->ShutDownCallback != NULL)
  {
    SatisTestModule->ShutDownCallback(SatisTestModule->Page);
  }
  delete SatisTestModule;

Quote
}

-------------------from the EXE------------------------------------

void __fastcall TfrmSatisMain::mnuClientLocateSSNClick(TObject *Sender)
{
  FLoadModuleCB LoadModule;
  HINSTANCE hDLL = LoadLibrary("Test");
  if(hDLL != NULL)
  {
    LoadModule = (FLoadModuleCB)GetProcAddress(hDLL, "_LoadTestModule");
  }
  if(LoadModule)
  {
    // tabTest is of type TTabSheet
    LoadModule(tabTest);
  }

Quote
}

--
Michael Heacock         "Hail hail the lucky ones,
MSJ Corp.                I refer to those in love"
Palm Desert CA USA                -- Eddie Vedder
 

Re:Desperate: Assigning Panel.Parent from DLL to TabSheet in EXE


Hallo,

Michael Heacock <mheac...@sprynet.com> scritto nell'articolo
<344F5E97.F19A0...@sprynet.com>...

Quote
> First, sorry about the cross-posting, but the question seems
> relevant to both newsgroups.  :)

> Here's what I am doing:

> 1)  Creating a DLL that contains a Form.  On the form is a Panel
>     that contains a few buttons and a PageControl with 2 or more
>     tabsheets.

> 2)  Creating an EXE that contains a PageControl with 2 or more
>     tabsheets.

> You can view the EXE as the module level and the DLLs as the
> sub-module levels.

> What I am doing is calling a function in the DLL passing in
> a pointer to a TTabSheet in the EXE.  The DLL then assigns the
> Parent property of the Panel to the EXE's tabsheet.

> This works wonderfully, except for the PageControl on the
> DLLs panel.

Try to assign to the "Application" variable defined in the
Dll the value of "Application" received from the EXE, try
the same for the "Screen" variable in the Dll and BEWARE:
set the values of Application and Screen in the Dll to nil before
unloading the Dll.

For Example in the Dll

DllFunction(ExeApplication:TApplication; ExeScreen: TScreen): Integer;
begin

 Application.free;
 Application:=ExeApplication;
 Screen.free;
 Screen:=ExeScreen;

.... your code here .....

{
 Remember: Do this before unloading the Dll from the exe
  Application:=nil;
  Screen:=nil;

Quote
}

end;

Reply me if this works.

Ciao.
  Andrea

Other Threads