Main frame collecting Dialog info?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Sun Feb 25, 2007 4:19 am

Auria wrote:Is ListCtrlName a wxString?? You need to append to the wxListCtrl, not to the wxString!! there is no InsertItem method in wxString
Exactly. Sorry for not mentioning that, was doing a quick and dirty post, many things going on today :)

So what I'm attempting to do right now is collect the name of the listctrl to be updated (currently saved as a wxString). Thing is, I need to convert that to a format that I can use for 'NameGivenByUser->InsertItem(NameGivenByUser->GetItemCount(), String);'. Thats why I asked if I would need to convert it to a char array, which I assume (Would that be what I could use to state the listctrl name?) would be able to be seen as a name of a listctrl.

Thanks again!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sun Feb 25, 2007 3:25 pm

FlyingIsFun1217 wrote:
Auria wrote:Is ListCtrlName a wxString?? You need to append to the wxListCtrl, not to the wxString!! there is no InsertItem method in wxString
Exactly. Sorry for not mentioning that, was doing a quick and dirty post, many things going on today :)

So what I'm attempting to do right now is collect the name of the listctrl to be updated (currently saved as a wxString). Thing is, I need to convert that to a format that I can use for 'NameGivenByUser->InsertItem(NameGivenByUser->GetItemCount(), String);'. Thats why I asked if I would need to convert it to a char array, which I assume (Would that be what I could use to state the listctrl name?) would be able to be seen as a name of a listctrl.

Thanks again!
FlyingIsFun1217
I just don't understand what you're trying to do. You want the user the enter the name of the pointer to a wxListCtrl object?? Why the hell would you want that? The user is not supposed to know about the name you gave the pointer in your code! If the user needs to choose one in a selection of many, then maybe present a combo box or something like that?

What is your program trying to do?

And: In C++ there is no way you can call anything at runtime by the name it had in compile time. You would nned to go this way:

if(name.IsSameAs("List1")) List1->InsertItem...
else if(name.IsSameAs("List2")) List2->InsertItem...
else if(name.IsSameAs("List3")) List3->InsertItem...
else if(name.IsSameAs("List4")) List4->InsertItem...

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Sun Feb 25, 2007 8:36 pm

No, the user shouldn't have to know it. I will though, as I need to update the list specified by myself in

Code: Select all

NUDInfo instancename;
instancename.UpdateListCtrl(NameOfListCtrl);
It just makes it easier for me to know what list control I am inserting the name into.

If I go down the path of telling it what listctrl I want it to update, in the function, I just get that the listctrl was not defined anyway. Obviously it can't see it in ContactManagerFrame.cpp, even when I include the file, and I assume this is because the wxListCtrl is constructed in another class (ContactManagerFrame). If I want one class to access it, should I just make the declaration of it public?

Code to follow up soon...
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sun Feb 25, 2007 9:00 pm

FlyingIsFun1217 wrote:No, the user shouldn't have to know it. I will though, as I need to update the list specified by myself in

Code: Select all

NUDInfo instancename;
instancename.UpdateListCtrl(NameOfListCtrl);
It just makes it easier for me to know what list control I am inserting the name into.

If I go down the path of telling it what listctrl I want it to update, in the function, I just get that the listctrl was not defined anyway. Obviously it can't see it in ContactManagerFrame.cpp, even when I include the file, and I assume this is because the wxListCtrl is constructed in another class (ContactManagerFrame). If I want one class to access it, should I just make the declaration of it public?

Code to follow up soon...
FlyingIsFun1217
You can make it public and access it, but that's not recommended. Use methods to change members. I'm not sure why you want to pass the name as argument. Yo ucan just make a method for a each control. e.g. appendName(wxString name), appendX(wxString X), etc.

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Sun Feb 25, 2007 9:25 pm

Yeah, I think I know how I'll do it.
I'll try just making instancename.UpdateListCtrl(); return the name of the person and from there just insert the persons name into the listctrl within the frame.

I'll try, and post the results :)

Thanks!
FlyingIsFun1217

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Sun Feb 25, 2007 10:26 pm

Ok, almost done with the Frame.cpp file, I have:

Code: Select all

void ContactManagerFrm::dialogClosed()
{
    NUDInfo instancename;
    ID_CONTACTLISTCTRL->InsertItem(ID_CONTACTLISTCTRL->GetItemCount, instancename.UpdateListCtrl());
}
But it just tells me:
error: base operand of '->' is not a pointer
So...What? What does it expect?

Thanks!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Feb 26, 2007 1:03 am

It expects .

On pointers, use ->
On instances use .

Sadly, this shows me that you did not read and practice as i asked you since this is very basic.

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 26, 2007 7:30 pm

Guess I just figured that it was supposed to be -> when after trying . I just received:
error: 'InsertItem' has not been declared
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Feb 26, 2007 11:39 pm

Okay you haven't taken me seriously but now please do.

Forget about your app for a while. Forget about wxWidgets for a while. By a while i mean at least 1 or 2 weaks. You will most probably need more to master everything.

You're posting more and more bits of code that doesn't make any sense, you obviously have no idea what you are doing.

So please learn C++ now. When you master writing classes, then come back here.

As i already offered, you can even contact me personnally and i'll be glad to offer help you learning when you're stuck. But i'm not going to provide any more ireplies to this topic since you don't seem to have any clue what you're doing. Furthermore, i even wrote down a model for you and you don't follow it!

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Tue Feb 27, 2007 5:33 pm

I am practicing writing classes, but the only problem is applying what I've learned in the non-wxwidgets classes is so unrelated to the problems that I am dealing with in my app, it doesn't even seem to be like each other except in the format of declaration and functions.

How can I learn classes for (ultimately) wxWidgets projects when I am writing it in standard c++?

Thanks!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Tue Feb 27, 2007 11:52 pm

FlyingIsFun1217 wrote:I am practicing writing classes, but the only problem is applying what I've learned in the non-wxwidgets classes is so unrelated to the problems that I am dealing with in my app, it doesn't even seem to be like each other except in the format of declaration and functions.

How can I learn classes for (ultimately) wxWidgets projects when I am writing it in standard c++?

Thanks!
FlyingIsFun1217
wxWidgets is standard C++. I don't know what you find so different.

In the latest snippet, you tried calling a method on an ID. If you don't know yo ucan't call methods on an ID, then i think you definitely need to practice more.

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Wed Feb 28, 2007 9:44 pm

Well, after thinking about it, I came up with this...

Why not just make the dialog send a close message to the main frame when it closes, and when the main frame gets this message, just have it refresh the list ctrl?

Saves me much hassle with classes. Which I am still working more on :)

Thanks again!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Thu Mar 01, 2007 12:07 am

FlyingIsFun1217 wrote: Why not just make the dialog send a close message to the main frame when it closes, and when the main frame gets this message, just have it refresh the list ctrl?
Hmm, isn't that exactly what i had suggested right from the start? ;)

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Thu Mar 01, 2007 5:29 pm

:oops: :)

Guess learning more about classes and stuff shows me which way is really the easiest :)

I will try that with the advice you gave me, and see what comes from it :)

Thanks!
FlyingIsFun1217

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Thu Mar 01, 2007 10:34 pm

Ok, trying to do that. I'm gonna clear everything first using DeleteAllItems like so:

Code: Select all

ContactList.DeleteAllItems();
But again, I am running into the dilemma of ClearAllItems not being declared. I've linked to the wx/listctrl.h, so what is it that I am still missing?

Thanks again, still learning :)
FlyingIsFun1217

Post Reply