Thread: Need Help. Going Insane

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    37

    Need Help. Going Insane

    I have an MDI application, been developed in C++ Builder. On each child form there is an image object.
    To cycle through the child forms I use a For loop.
    My problem is this.
    Going through the loop I can only access properties, methods and events of the form and NOT the objects on the form. How can I access the objects on the form.

    Code:
    for (int index = MDIChildCount - 1; index >= 0; index--)
    {
       something = MDIChildren[index]............... STUCK............?????
    }
    What I am looking for is the pixel array of an image object on the form.
    I would be greatful of any suggestions or input.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    If you have an array of objects, you can access public methods and members with:
    Code:
    objArray[i].method();
    objArray[i].member;
    //or if array of pointers
    objArray[i]->method();
    objArray[i]->member;
    If you are looking for something more specific related to windows programming using C++ Builder, you might want to try the Windows programming board.

    gg

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    37
    I think i'll go back to a SDI application. Not as good but it will do. Life is too short to be fn around with simple problem that are probably smacking you in the face, but you are looking at it so long you can't see the answer.



    ohh...

    Code:
    void main(void)
    {
    }
    does it really matter

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    45
    AARGG... again a stupid thread title? I think I am going insane now...

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Originally posted by Ivan!
    AARGG... again a stupid thread title? I think I am going insane now...
    Hey, thanks for your contribution to this thread. It was obviously well thought out and took you many hours to think up, as well as being TOTALLY WORTHLESS. If you don't have anything to contribute, shut your damn mouth.

    Now, to add something:

    > does it really matter

    Yes, it matters. Declaring main as anything other than int is undefined. main always returns an int.

  6. #6
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    I haven't used MDI applications in CBuilder, but can't you access it like this:

    PHP Code:
    myMDIForm[index]->myMDIObject->ObjectProperty
    And tell the file that will use this line to include the unit header for the file that contains myMDIForm?

    ~ Paul
    Last edited by nickname_changed; 03-28-2003 at 07:11 PM.

  7. #7
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by spidereen
    ohh...

    Code:
    void main(void)
    {
    }
    does it really matter
    Yes it does matter. Don't do it!

  8. #8
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    But why does main always return an int? Don't worry, I always declare it as int and I dont mean to question you o great Polymorphic OOP, but why? Is it something to do with the operating system knowing that the process has finished?

    ~ Paul

  9. #9
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    because in the c runtime the call to main will look something like this...

    int return_value = main(argc,argv);

    the runtime may then use this value before passing up to OS. Not sure but i think thats implementation defined.Usually the return value from main gets passed back to the OS.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  10. #10
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    C Runtime? I thought languages like Java use a runtime, but not langauges like C/C++?

    Or do you mean like theres a C Runtime located in the kernel of the operating system that looks for a main function?

    But if that is so, how does the OS know whats an ASM file and whats a C++ file? Would a compiled ASM file and a compiled C++ file look reliatively the same at byte-level if they are supposed to do the same thing, ie add 2 numbers?

    Or is the C Runtime included inside the compiled application?

    Now I'm even more confused.

    ~ Paul

  11. #11
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    The c runtime is part of every program you write. The compiler slides it in. It has several jobs. One of which is to call main. Others are to open some streams(files), stdin,stdout,stderr etc....
    All of this must happen before main gets called.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  12. #12
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Ohh okay, I never knew that. Thanks very much

    ~ Paul

  13. #13
    Registered User
    Join Date
    Jan 2003
    Posts
    37
    PHP Code:
    myMDIForm[index]->myMDIObject->ObjectProperty
    And tell the file that will use this line to include the unit header for the file that contains myMDIForm?
    Thanks for your help. But I tried that. It compiled. But during execution it crashed with pointer errors.

  14. #14
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Try it again but make sure your pointing to objects/forms that do exist on the form and make index a number that you know will work for a test.

    ~ Paul

  15. #15
    Registered User
    Join Date
    Jan 2003
    Posts
    37
    Yeah I tried
    Code:
    store = ChildForm[1]->imgScene->Canvas->Pixels[1][1];
    And this returns a pointer error during execution.

    1 is the second last form to be created.
    i.e. 0 being the last and MDIChildCount - 1 being the first.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Insane MIdget Assassins and Abachler
    By abachler in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-03-2009, 11:10 AM
  2. OMG I'm Going Insane (insertion function...help!)
    By spinner in forum C Programming
    Replies: 2
    Last Post: 05-04-2003, 02:22 PM
  3. Need Help. Going Insane
    By spidereen in forum Windows Programming
    Replies: 0
    Last Post: 03-26-2003, 01:45 PM
  4. help me before i go insane!!
    By andy_d in forum C Programming
    Replies: 3
    Last Post: 03-16-2002, 12:53 PM
  5. need help quickly, going insane with this
    By Mkk84 in forum C++ Programming
    Replies: 2
    Last Post: 01-13-2002, 10:58 AM