Click here to Skip to main content
15,882,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm making a program that loads all Gifs in a WinForms window run by an exe in a folder, I need to make the maximum value bigger than 32,767 and show an enormous number of Gifs in a single panel.

What I have tried:

panelGifs.MaximumSize = new Size(int.MaxValue, int.MaxValue);
panelGifs.VerticalScroll.Maximum = int.MaxValue;


if (lpb[i - 1].Right + pb.Width > this.Width - 37)
{
    pb.Location = new Point(0, lastBottomYforXZero);
    lastBottomYforXZero = pb.Bottom + 1;
}
else
{
   pb.Location = new Point(lpb[i - 1].Right + 1, lpb[i - 1].Top);
}



private void getThisPictureBoxBellowAllOthers(PictureBox pb)
        {
            for (int j = 0; j < lpb.Count; j++)//list picture boxes
            {
                if (pb.Bounds.IntersectsWith(lpb[j].Bounds))
                {
                    pb.Location = new Point(pb.Left, lpb[j].Bottom + 1);
                }
            }


            for (int z = 0; z < ll.Count; z++)//list labels
            {
                if (pb.Bounds.IntersectsWith(ll[z].Bounds))
                {
                    pb.Location = new Point(pb.Left, ll[z].Bottom + 1);
                }
            }
        }
Posted
Updated 3-Nov-21 11:02am
v6
Comments
Luc Pattyn 3-Nov-21 16:20pm    
ints have grown up many years ago: int.MaxValue does not equal 32767, and ScrollProperties.Maximum isn't limited to 32767 either.

PS: good luck with your enormous number of gifs...
john1990_1 3-Nov-21 16:37pm    
But the gifs stop going down at 32,767 as tested by me and realizing that this is the limit.
Luc Pattyn 3-Nov-21 16:44pm    
You'll need to explain in more detail, or better yet, show relevant code.
john1990_1 3-Nov-21 16:50pm    
I make PictureBoxes, and put each new one below or on the right of the one before it, if its Bounds intersect with any of the previous ones, it goes down, but it hangs on 32,767 because when I put the new pic below the one before it, it doesn't go below it because of the limit, so it's an infinite loop. I added code to the question.

1 solution

Here is a simple stacking of pictureboxes, it goes well beyond 64K pixels:

private void test() {
    try {
        Panel p = new Panel();
        p.Size = new Size(100000, 100000);
        for (int y = 0; y < 99000; y += 1000) {
            PictureBox pb = new PictureBox();
            pb.Size = new Size(900, 900);
            pb.Location = new Point(0, y);
            p.Controls.Add(pb);
        }
        Log.Success("All done");
    } catch (Exception exc) {
        Log.Error(exc.ToString());
    }
}


Your
Quote:
pb.Location = new Point(pb.Left, ...


may be using an invalid pb.Left value causing all pb's to tend to the right.

:)
 
Share this answer
 
Comments
john1990_1 3-Nov-21 17:05pm    
Thx, it only seems like logging "All Done", but it's not all done, all the pics below (under in view) 32,767 pixels I think would be stuck there one over the other.
Luc Pattyn 3-Nov-21 17:37pm    
OK, I turned my test code into a complete app and now I can see what you were trying to explain. It seems whatever Control gets added below y=32767 gets stuck at that depth. Tested for PictureBoxes and Panels.

It must be one the quirks of the very oldGDI+ graphics library, upon which all of WinForms is based.

Well, it probably isn't a good idea to create virtual forms that are hundreds of screen heights tall anyway. I don'tknow whether WPF does any better, it might.

You may reconsider your user interface, showing less information at any point in time. That is the normal approach, sparing a lot of scrolling...
john1990_1 4-Nov-21 5:34am    
I'm thinking of making when arriving to the lowest point possible to add a button saying: "Show more" and then remove all PictureBoxes and show more pics from the beginning in the same panel.
EDIT: I did the above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900