-
I have a program that has many forms with heavy graphics and controls. I wanted to preload all the forms in the memory but I found that the GDI resource is not enough and hang my PC. Is there actually a way to allocate more resource for this without adding new hardware ?
What hardware that affect this ? RAM, Video RAM, Processor ..
Thanks
-
One of the main problems is running out of GDI handles. There's really no way round it other than rethinking how you put your form together. However, if you use dynamic allocation of things like that, you can often extend the limit.
-
Try to avoid using too many controls and objects, if you spend much on the interface you could just draw directly on the form instead.
-
When possible, try to use Image's instead of PictureBox's.
-
In other words, if you just need the image for interace you use image control. If you need to access the DC and drawing Vb methods use picturebox.
-
If you're going to draw it on the DC, you'll need a PictureBox anyway so I don't think it will do much, unless you have to draw the same picture multiple times.
-
Thank you.. but the problem is that I wanted to load all my forms during startup ( about 30 of them).. so, I guess there is no fix for this unless reduce the preload form.
-
Why do you need 30 forms?
Do you need them to be displayed all at the same time?
-
And why do people add apostrophes where they do not belong:
Quote:
Picturebox's
Image's
?
One of those high-ranking questions alongside why dogs smell after having a shower.
-
It's probably only my apostrophes out there, i can't help them
-
no lah.. is just that I want the form to instant popup when call.. since my form use heavy graphics, the form loading take about 1-2 seconds.. which is not nice..
-
You can use the GdiFlush API to improve performace slightly.
-
If you need 30 forms, what are they for? If most of them are closely related, I suggest making a Subroutine for loading the form with different functions. For example, if it was a dialog, you could try this:
Code:
---form1---
Sub myMessage(Choice1 as String, Choice2 as String, C1Funct as String, C2Funct As String, Message as String)
frmDialog.Text1.Text = Message
frmDialog.Cmd1.Caption = Choice1
frmDialog.Cmd2.Caption = Choice2
'declare C1F and C2F as strings in a module
C1F = C1Funct
C2F = C2Funct
End Sub
---mod1.bas---
Option Explicit
Public C1F As String
Public C2F As String
---frmdialog---
Private Sub Cmd1_Click()
CallByName C1F
End Sub
Private Sub Cmd2_Click()
CallByName C2F
End Sub
I haven't checked the code but it'll probably work.