Solved

passing a TListItems as a parameter to a DLL ??

Posted on 1998-03-17
7
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

623 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