Solved

passing a TListItems as a parameter to a DLL ??

Posted on 1998-03-17
7
303 Views
Last Modified: 2010-04-06
Can anyone help me out with this one ?

I've created a program which fills a TListView with several hundred items (300) with 2 or 3 subitems.

These TListItems need to be send to a dll, which is a quickreport dll.

in the dll i have a procedure like this one :

procedure ShowReport(tli:TListItems);
  frmReport := TfrmReport.Create(Application);
  try
    frmReport.ListView1.Items.Assign(tli);
    frmReport.QuickRep1.Preview;
  finally
    frmReport.Free;
  end;
end;

this procedure is exported from the dll, when i call it from my program i get an error like "cannot asign a TListItems to a TListItems"

I don't know anymore.

Thanx for your help.
0
Comment
Question by:mories
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:d003303
ID: 1360528
When you create a DLL have a look at the comment on top. For item collections of this size you have to use the SHAREMEM unit.

Slash/d003303
0
 
LVL 1

Author Comment

by:mories
ID: 1360529
What do i have to do with it, when i add the sharemem as the first unit in both program and the dll, i get the same errormessage "cannot assign a TListItems to a TListItems"
0
 
LVL 4

Expert Comment

by:d003303
ID: 1360530
OK, I found the problem (but not the solution yet). I run into similar problems when I used a TTreeView on a form in a DLL. I'll review that, hang on.

Slash/d003303
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:mories
ID: 1360531
ok i'll be hanging on.
0
 
LVL 1

Author Comment

by:mories
ID: 1360532
Adjusted points to 100
0
 
LVL 4

Expert Comment

by:d003303
ID: 1360533
Hi mories,
I just got a little of the problem right now. The problem is a general misbehaviour of the TListView and TTreeView components on forms in DLLs. The bad boy may be the Forms or the ComCtrls unit.
I am going to CeBIT for the next 4 days, so probably I cannot check back until I return (no Delphi installation there:-().

Slash/d003303
0
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
ID: 1360534
OK, got the problem. The two run-time libraries (main application and DLL) don't like each other very much if nested objects are transfered over a procedural interface.
This is a workaround, not a 'real' solution, but it works. I mainly re-coded the assign method of TListItems. Here we go :

procedure ShowReport(tli: TListItems);
var Index1,
    Index2 : Integer;
begin
  frmReport := TfrmReport.Create(Application);
  try
    for Index1 := 0 to tli.Count - 1 do
     with frmReport.ListView1.Items.Add do
      begin
        Caption := tli[Index1].Caption;
        Data := tli[Index1].Data;
        ImageIndex := tli[Index1].ImageIndex;
        OverlayIndex := tli[Index1].OverlayIndex;
        StateIndex := tli[Index1].StateIndex;
        if tli[Index1].SubItems <> nil then
         begin
           for Index2 := 0 to tli[Index1].SubItems.Count - 1 do
            SubItems.AddObject(tli[Index1].SubItems[Index2], tli[Index1].SubItems.Objects[Index2]);
         end;
      end;
    frmReport.QuickRep1.Preview;
  finally
    frmReport.Free;
  end;
end;

Hope this helps,
Slash/d003303
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question