Thread: vc++ picturebox array

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    4

    vc++ picturebox array

    Hi, I'm currently working on a project that will need to use an array for a image. (Or a way to print one image multiple times in different locations). I have got this much of the code, yet it does not work.

    - Note its compiled in vc++ .net 2005
    Code:
    array<PictureBox^> ^picB = gcnew array<PictureBox^>(10);
        for(Int32 i = 0; i < 10; ++i)
        {
             picB[i] = gcnew PictureBox;
    		 picB[i]->Location = Point(i, i);
    		picB[i]->Size = Drawing::Size(20, 20);
    		picB[i]->Image = Image::FromFile("square.bmp");
        }
    Any help would be appreciated.
    Thanks in advance,
    Crypteasy

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    i think this would be more suitable in the windows-specific platform forum (check the main CBoard forums page for the list of them all).

    but you said 'it does not work'. ive never used VC++, but i know C++, and VB.net, so im somewhat familiar with the syntax. however, if something doesnt work, you have to tell us what exactly doesnt work (which i guess you have) and why it doesnt work (ie error messages), or what happens instead when your expecting it to do something else.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    4
    Well I'm guessing it's probably the way i set it up. (I haven't a clue, since i rarely do vc++ [i mostly stick with basic c++]). There is no error message (compiles fine), and the images don't appear on the screen (Like I'm hoping). So I'm just looking for someone that knows about this subject, or someone that has a different way of setting it up.
    Last edited by Crypteasy; 01-09-2008 at 08:09 PM.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    i dont have .NET installed so i cant test (or learn VC++!) right now. but the logic looks very straightforward. create an array of pictures and show them.

    i just have one point/suggestion, keeping in mind, NB: i dont know VC++.
    if your using the same image (ie not a collage of different pictures), and if the image responds (ie to mouse press, etc) the same way no matter what location/image is in question, then i would look for a different method. is there a 'paintimage' or some other function that lets you simply display an image somewhere? because if your using the same image 10 times, its a waste of resources and time you can imagine.

    you probably have thought about this and looked for other methods, but if not then check it out. having just the one actual object and reusing that would be better.

    EDIT:oh, i see your edit now too! images not appearing would be a problem for sure! again, since i dont know this stuff either im not sure. do you have to set the .visible true or something like that? or a repaint function on the frame? try getting just one to show up first before using a bunch of them, too.
    Last edited by nadroj; 01-09-2008 at 08:22 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM