Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB9.0
this is my code
 
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 28-Aug-12 1:16am
Comments
Wes Aday at 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.
TechXSoftware at 28-Aug-12 6:59am
   
if you could find a better way to do this it would be very appreciated
Wes Aday at 28-Aug-12 7:07am
   
A better way to do what? How does anyone know what it is that you are trying to do?
TechXSoftware at 28-Aug-12 7:11am
   
well if you read the question, it says, make a 2d destructible environment
Wes Aday at 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.
TechXSoftware at 29-Aug-12 18:24pm
   
how dose makeing 10000 pictureboxes make no sense? it should be stright foward. Its making a picurebox 10000 times.
Wes Aday at 29-Aug-12 18:29pm
   
How exactly does it make any sense at all? There is no reason in the world to create 10000 picture boxes for anything. No reason at all. 1 picture box should be enough to do whatever it is that you are doing. 0 picture boxes is even better.
TechXSoftware at 29-Aug-12 23:07pm
   
if there is a better way please tell me. And yes my reason to make that meny is so i can use an ( if missile.contains(picurebox1){then delete the picurebox} ) something like thatand i can do that will a for each code that will idenerfiy all the picureboxes the missile touches and it will remove them, and yes i would very much like to do it will less picureboxes, but i can;'t find a way and i don't know WAY

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  

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

  Print Answers RSS
0 BillWoodruff 330
1 Mathew Soji 309
2 Maciej Los 295
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 217
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,025


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100