Solved

TArray with TListWindow

Posted on 1998-01-10
15
254 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
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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 500 total points
ID: 1299534
OK, now you can grade me.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

786 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