using listboxes

hey i made a form with an listbox on it?
but now got an printout function
where the print function gets info from another class than form
en he needs to print it on the form

form->button to print->map(from other class)->print(again another class)

i now got:
void Drukbox::drukStringAf(string blaat)
{
lb1->Items->Add(blaat.c_str());
}

but how does Drukbox knows what lb1 is(it must be an pointer to the listbox on the form)

does anyone knows how this could work?
TY
...NoiK

Comments

  • : hey i made a form with an listbox on it?
    : but now got an printout function
    : where the print function gets info from another class than form
    : en he needs to print it on the form
    :
    : form->button to print->map(from other class)->print(again another class)
    :
    : i now got:
    : void Drukbox::drukStringAf(string blaat)
    : {
    : lb1->Items->Add(blaat.c_str());
    : }
    :
    : but how does Drukbox knows what lb1 is(it must be an pointer to the listbox on the form)
    :
    : does anyone knows how this could work?
    : TY
    : ...NoiK
    Hi NoiK,
    it might be a good idea to give English names instead of Dutch to your controls before posting (only Dutchmen will understand the stringname blaat).

    I do not understand the question actually, but can try to help. I guess it is about the code you posted (restyled to common English conventions):

    [code]
    : void PushBox::drukStringAf(const std::string& myString)
    : {
    : lb1->Items->Add(myString.c_str());
    : }
    [/code]

    I think you should realize this would be the same as:

    [code]
    void PushBox::drukStringAf(const std::string& myString)
    {
    this->lb1->Items->Add(myString.c_str());
    }
    [/code]

    As PushBox is the class (descendant of type TForm) that has a member called lb1 (of type TListBox). You can see the pointers declared under the .h tab of your Form's code (under the __published section, keep your fingers off this section).

    I hope to have helped you out! See ya and haudoe,

    bilderbikkel

  • : Hi NoiK,
    : it might be a good idea to give English names instead of Dutch to your controls before posting (only Dutchmen will understand the stringname blaat).
    :
    : I do not understand the question actually, but can try to help. I guess it is about the code you posted (restyled to common English conventions):
    :
    : [code]
    : : void PushBox::drukStringAf(const std::string& myString)
    : : {
    : : lb1->Items->Add(myString.c_str());
    : : }
    : [/code]
    :
    : I think you should realize this would be the same as:
    :
    : [code]
    : void PushBox::drukStringAf(const std::string& myString)
    : {
    : this->lb1->Items->Add(myString.c_str());
    : }
    : [/code]
    :
    : As PushBox is the class (descendant of type TForm) that has a member called lb1 (of type TListBox). You can see the pointers declared under the .h tab of your Form's code (under the __published section, keep your fingers off this section).
    :
    : I hope to have helped you out! See ya and haudoe,
    :
    : bilderbikkel
    :
    :
    HEY thanks again for reacting..
    i must say before you ask again, it is homework
    what i meant is that i have a form with some easy-non-related-just-for-trying objects. i have a input box to put things in a map, now i need to make a Tlistbox that will display the keys from the map(the map is in another class), so when i push a button it must display the info. i now have every key of the map sent to the class that must add it to the listbox,but the last thing to do is to make the listbox accessible.
    hope this makes it more clear

    ...NoiK
    P.S. everytime before i post/ask i checked the my textbooks/internet an tried for a few days
    within a few days i will recieve another book written by stroustrup;)
  • : but the last thing to do is to make the listbox accessible.
    A ListBox on a Form is always publicly accessable, if the Form is accessible. Every Form has a global pointer. Your standard Form, TForm1 has a global pointer called Form1. You can therefore always use it (except when you create Forms dynamically).

    : P.S. everytime before i post/ask i checked the my textbooks/internet an tried for a few days
    : within a few days i will recieve another book written by stroustrup;)
    Which Stroustrup book? If it is 'The Complete C++ Language' and you are a beginner, please tell me what you think about it. Nowadays I love it, but IMHO it is not a book for beginners.

    And where is this course of you given? I know it is not Groningen at the Facultuy of Biology, as I have teached that course :-).

    See ya,
    bilderbikkel

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories