Click here to Skip to main content
15,886,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code

VB
Dim b As Integer = 100
Dim i As Integer
Dim u As Integer

Dim h As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    While i < 10000
        i = i + 1

        h = h + 1
        Dim pic As New PictureBox
        If i = b Then
            u = u + 1
            b = b + 100
            h = 0
        End If

        pic.BackColor = Color.Red
        pic.Size = New Size(1, 1)
        pic.Location = New Point(h, u)
        Me.Controls.Add(pic)
    End While

End Sub



its meant to create picureboxes in massive quonitys and think of it like drawing a simple 500x500 solid box but that will take like 1000x1000 pictureboxes, there reason im trying to make this work is that I can make a really easy distributable 2d environment by just using contains and bounds.

the code works very well when it can create like 500 picureboxes though, but i want to be able to make more without it crashing i think

this is my error
Error creating window handle.

can some plz help me fix this?
Posted
Comments
[no name] 28-Aug-12 6:54am    
Fix what? 10000 picture boxes? There is no fix for that. Rethink what it is that you are trying to do and redesign your application is the fix.
[no name] 28-Aug-12 6:59am    
if you could find a better way to do this it would be very appreciated
[no name] 28-Aug-12 7:07am    
A better way to do what? How does anyone know what it is that you are trying to do?
[no name] 28-Aug-12 7:11am    
well if you read the question, it says, make a 2d destructible environment
[no name] 28-Aug-12 7:26am    
Oh I read your question. That description makes no sense at all. Just like creating 10000 picture boxes makes no sense at all.

1 solution

According to this article it is to do with the number of controls that you are adding to your form

The "Error creating window handle" exception and the Desktop Heap[^]
 
Share this answer
 

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