Solved

passing a TListItems as a parameter to a DLL ??

Posted on 1998-03-17
7
297 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:mories
Comment Utility
ok i'll be hanging on.
0
 
LVL 1

Author Comment

by:mories
Comment Utility
Adjusted points to 100
0
 
LVL 4

Expert Comment

by:d003303
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now