?
Solved

passing a TListItems as a parameter to a DLL ??

Posted on 1998-03-17
7
Medium Priority
?
307 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 400 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

719 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