Solved

TArray with TListWindow

Posted on 1998-01-10
15
241 Views
Last Modified: 2013-12-26
hello

Could you give me more informations about TArray in TListWindows.

I use a TISArrayAsVector because the size of my table of structure is dynamical.
I don't know how to implement the LWColumClickInfo(TLwNotify& info) of TListWindow to get
the items in different order.

for example

struct MyStruct
  {
  char Nom[20];
  char Prenom[20];
  char Adresse[40];
  }
I declare a TISArrayAsVector<MyStruct> aStruct

// also defined
MyStruct(nom, prenom,adresser)
MyStruct( const MyStruct& aStruct )
MyStruct& operator = ( const MyStruct& aStruct )
int operator == ( const MyStruct& aStruct ) const
int operator < ( const MyStruct& aStruct ) const  };

how can I obtain aStruct sorting on Nom or on Prenom or on Adresse and show the result inTListWindow.

Thanks for your help

Daniel
0
Comment
Question by:dreynier
  • 7
  • 6
  • 2
15 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
For every item in a TListWindow, you can associate a 32-bit value. That value can be a pointer to an aStruct (don't forget to cast). That way, when you insert items into the TListWindow, you can use that pointer to get to the members of the structure. This is required if you want sorting. The callback for the sort gets two 32-bit values (the ones associated with the item). Then you can cast those 32-bit values into pointers to aStructs and compare the two structures and return the right value depending on the sorting column (either Nom or Prenom or Adresse).

0
 

Author Comment

by:dreynier
Comment Utility
Thanks for your answer

I don't really understand how to do with TArray AND TListWindow
a short(but complete) example would be appreciated
Daniel
0
 

Author Comment

by:dreynier
Comment Utility
Hello Thui

Please Answer my last comment
I need an example
0
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
Sorry, I don't have an example in OWL. I have an example in MFC if you like to see that.

0
 

Author Comment

by:dreynier
Comment Utility
Sorry but I need an example
Thanks for your answer

0
 
LVL 2

Expert Comment

by:JensUniweb
Comment Utility
Are you trying to use the SortItem() member of TListWindow or are you trying to do something else? How are you using TListWindow anyway? Are you using the InsertItem() member. Or don't you know how to use TListWindow at all? Do you have all the examples comming with the Boarland C++ compiler? I'll try to put together a simple example if you still need one.
0
 
LVL 2

Expert Comment

by:JensUniweb
Comment Utility
So, now I have made a small example that will do what you want. I've not used TISArrayAsVector. But there is many ways to exchange my struct to the TISArrayAsVector. So you should not have any problems with my code. I don't know how I should distribute it to you. One way could be for me to put it on my WWW site. Or I could put it at the "OWL How" site.

 Jens Yllman
 (http://www.uniweb.se/~jens/)
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:dreynier
Comment Utility
Some informations

I need to show a list of Nom, Prénom,Adresse in a TListWindow.
I need to sort this list in the TlistWindow when I select the colomn header ( sort by Nom, Prenom or Adesse)
The size of the array of struct is dynamical so I use TArray to automatically increase the size of my array of structs.
My problem is how to swap the data from my array (TIArray or TISArray ?) to   the  items list of TListWindows and get the list sorted

I suggest that you send me an e-mail for your example at dreynier@asi.fr

thanks for ypur answer

0
 

Author Comment

by:dreynier
Comment Utility
Thanks for your answer but...

The example doesn't work
I've made some change (AddItems is not a part of TListWindows and SetItemText has only two parameters)
The fonction compare is never called !
The second column is not filled and crash the program when I click on the header
Sorry but my problem is not solved :-(

I'll give a good grade to anybody who can send me an example
with TArray and TListWindow that really work


0
 
LVL 2

Expert Comment

by:JensUniweb
Comment Utility
What compiler are you using. My example was compiled under Borland C++ 5.02 with OWL 5. And it works great. Do you want the executable? If you tell me what compiler you have maybe I can help you again.
0
 

Author Comment

by:dreynier
Comment Utility
Thanks for your answer
The executable works !
I use BC+ version 5.0A and OWL 5.0 and I don't know what goes wrong !

Could  you send me an short example with TIArray instead of a Static array.
I 've tried to undestand what goes wrong with the compare fonction by setting breakpoints, but the compare function is never called!
 

0
 
LVL 2

Expert Comment

by:JensUniweb
Comment Utility
OK. I'll try to change the code to use TIArray. I don't know when I'm ready because I'm VERY busy. But maybe I'll be done today.

 Jens Yllman
0
 
LVL 2

Expert Comment

by:JensUniweb
Comment Utility
Have you tried the new code?
0
 

Author Comment

by:dreynier
Comment Utility
Ok
I've sent you an @mail

Thanks for all
0
 
LVL 2

Accepted Solution

by:
JensUniweb earned 500 total points
Comment Utility
OK, now you can grade me.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to dynamically set the form action using jQuery.

771 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

16 Experts available now in Live!

Get 1:1 Help Now