TArray with TListWindow


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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tommy HuiEngineerCommented:
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).

dreynierAuthor Commented:
Thanks for your answer

I don't really understand how to do with TArray AND TListWindow
a short(but complete) example would be appreciated
dreynierAuthor Commented:
Hello Thui

Please Answer my last comment
I need an example
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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

dreynierAuthor Commented:
Sorry but I need an example
Thanks for your answer

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.
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
dreynierAuthor Commented:
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

dreynierAuthor Commented:
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

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.
dreynierAuthor Commented:
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!

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
Have you tried the new code?
dreynierAuthor Commented:
I've sent you an @mail

Thanks for all
OK, now you can grade me.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.