Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TArray with TListWindow

Posted on 1998-01-10
15
Medium Priority
?
287 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
[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
  • 7
  • 6
  • 2
15 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1299520
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
ID: 1299521
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
ID: 1299522
Hello Thui

Please Answer my last comment
I need an example
0
Industry Leaders: 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 15

Expert Comment

by:Tommy Hui
ID: 1299523
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
ID: 1299524
Sorry but I need an example
Thanks for your answer

0
 
LVL 2

Expert Comment

by:JensUniweb
ID: 1299525
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
ID: 1299526
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
 

Author Comment

by:dreynier
ID: 1299527
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
ID: 1299528
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
ID: 1299529
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
ID: 1299530
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
ID: 1299531
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
ID: 1299532
Have you tried the new code?
0
 

Author Comment

by:dreynier
ID: 1299533
Ok
I've sent you an @mail

Thanks for all
0
 
LVL 2

Accepted Solution

by:
JensUniweb earned 1500 total points
ID: 1299534
OK, now you can grade me.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

618 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