Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl crashes with "embedded" Ctrls referenced by Id [SOLVED]
ArrayCtrl crashes with "embedded" Ctrls referenced by Id [SOLVED] [message #2256] Wed, 05 April 2006 13:50 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Try this code:
#include <CtrlLib/CtrlLib.h>

GUI_APP_MAIN
{
	TopWindow   w;
	ArrayCtrl   arr;
	EditString  editName, editSurName;
	Option      editAvail;
	
	arr.SetRect(50,50,550,350);
	w.Add(arr);

	editName.SetRect(90,10,150,20);
	w.Add(editName);
	
	editSurName.SetRect(315,10,150,20);
	w.Add(editSurName);

	editAvail.SetRect(550,10,150,20);
	w.Add(editAvail);

	arr.AddColumn("ID","ID",3);
	arr.AddColumn("Name", "Name", 20);
	arr.AddColumn("SurName", "SurName", 20);
	arr.AddColumn("Avail" "Avail?", 3).Ctrls<Option>();  //10
	
	arr.Add("1","Luigi","Forlano", true);
	arr.Add("2","Diego","Maradona", false);
	arr.Add("3","Paolo","Maldini", false);
	arr.Add("4","Roberto","Carlos", false);
	arr.Add("5","David","Beckham", false);

	editName    <<= arr.Get(0,"Name");
//    editName    <<= arr.Get(0,"name"); //crash when Id "not in list"!!!
	editSurName <<= arr.Get(0,"SurName");
//	editAvail  <<= arr.Get(0,"Avail"); //should work or at least must not crash!!!
	editAvail  <<= arr.Get(0,3);  //works only this way

	
	w.Run();
}

?bugs?

[Updated on: Mon, 01 May 2006 20:22]

Report message to a moderator

Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2257 is a reply to message #2256] Wed, 05 April 2006 13:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well.... before trying to fix that...

fudadmin wrote on Wed, 05 April 2006 07:50

Try this code:
#include <CtrlLib/CtrlLib.h>

	arr.AddColumn("ID","ID",3);
	arr.AddColumn("Name", "Name", 20);
	arr.AddColumn("SurName", "SurName", 20);
	arr.AddColumn("Avail" "Avail?", 3).Ctrls<Option>();  //10

?bugs?


... where is the comma after "Avail"?

Mirek
Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2258 is a reply to message #2257] Wed, 05 April 2006 14:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Also: This usage of Id is quite ineffective. You should rather define your Id constants and use them:

Id AVAIL("avail");

.....

Get(i, AVAIL)

- that is much faster.

Mirek
Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2259 is a reply to message #2257] Wed, 05 April 2006 14:12 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Wed, 05 April 2006 12:59

Well.... before trying to fix that...

fudadmin wrote on Wed, 05 April 2006 07:50

Try this code:
#include <CtrlLib/CtrlLib.h>

	arr.AddColumn("ID","ID",3);
	arr.AddColumn("Name", "Name", 20);
	arr.AddColumn("SurName", "SurName", 20);
	arr.AddColumn("Avail" "Avail?", 3).Ctrls<Option>();  //10

?bugs?


... where is the comma after "Avail"?

Mirek


That means, this one is my bug... Laughing
Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2260 is a reply to message #2258] Wed, 05 April 2006 14:14 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Wed, 05 April 2006 13:03

Also: This usage of Id is quite ineffective. You should rather define your Id constants and use them:

Id AVAIL("avail");

.....

Get(i, AVAIL)

- that is much faster.

Mirek


This is a very nice tip! Smile
Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2261 is a reply to message #2256] Wed, 05 April 2006 14:16 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
but what about this one?
//    editName    <<= arr.Get(0,"name"); //crash when Id "not in list"!!!
Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2262 is a reply to message #2261] Wed, 05 April 2006 14:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Wed, 05 April 2006 08:16

but what about this one?
//    editName    <<= arr.Get(0,"name"); //crash when Id "not in list"!!!



What do you expect?

This should by all means crash! (Well, I hope it fails on ASSERT, does not it?).

Mirek
Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2264 is a reply to message #2262] Wed, 05 April 2006 14:43 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
luzr wrote on Wed, 05 April 2006 13:22

fudadmin wrote on Wed, 05 April 2006 08:16

but what about this one?
//    editName    <<= arr.Get(0,"name"); //crash when Id "not in list"!!!



What do you expect?

This should by all means crash! (Well, I hope it fails on ASSERT, does not it?).

Mirek


And if I want to connect the same ArrayCtrl to different sources and fill columns names and get values dynamically that means I need to my own checking or...?

[Updated on: Wed, 05 April 2006 14:43]

Report message to a moderator

Re: ArrayCtrl crashes with "embedded" Ctrls referenced by Id [message #2268 is a reply to message #2264] Wed, 05 April 2006 14:59 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
fudadmin wrote on Wed, 05 April 2006 08:43


And if I want to connect the same ArrayCtrl to different sources and fill columns names and get values dynamically that means I need to my own checking or...?



...or use some of

ArrayCtrl::
int GetIndexCount() const;
Id GetId(int ii) const;
int GetPos(Id id) const;

Mirek
Previous Topic: ArrayCtrl: is it possible to set gaps between cells? [NEEDS IMPLEMENTATION...]
Next Topic: How to sort the ArrCtrl [SOLVED]
Goto Forum:
  


Current Time: Mon Apr 29 13:22:04 CEST 2024

Total time taken to generate the page: 0.03066 seconds