Solved

passing a TListItems as a parameter to a DLL ??

Posted on 1998-03-17
7
299 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

12 Experts available now in Live!

Get 1:1 Help Now