Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Major Trouble - reached Control creation LIMIT

Status
Not open for further replies.

mushin

Programmer
Oct 4, 2000
49
I have created an Activex data entry application the utilizes tabstrip control to manipulated 12 picturebox objects, each with label and text boxes on them......
I have gotton thru 5 pages and about 250 label/text box objects and I can CREATE NO MORE ?????

ERROR states: "Reached Limit:cannot create any more controls on this form "

I need about 450 textboxes and an equal number of labels
.IS there a way to increase this limit, or am I doomed to wander the earth as a homeless spirit for all eternity ???

Anyone who can , please assist or I will have to start dissassembling this into 12 seperate activeX controls.......

Argggghhhhhh !!!!!
 
First off, you need to rethink your design just a bit. 900 controls (about 450 textboxes and an equal number of labels) on any one form is going to have terrible performance. It is, however, good that you are breaking up the data using the Tab control . . . that way, you won't overwhelm the user, but you still have far too many controls on one form. When placing controls on a form, remember that each control is actually a seperate window with its own window handle (hWnd) and its own message queue in the OS. Having 900 of these for a single form is a huge resource drain and will quickly overwhelm the system which is why there is an upper limit.
Now, having said that, here are a few ways to get around the problem . . .

1) The simplest solution would be to create different forms and only show the form that the user needs at any given time. Each of these forms would only have a small number of controls on them. I worked for an insurance comapny and we did this . . . the end result was over 200 forms, but the application behaved very well.

2) IF the multiple forms idea is not possible then consider using a grid control (Sheridan make a good one) rather than using labels and textboxes.


3) DO NOT USE THE PICTUREBOX CONTROL AS A CONTAINER JUST TO STORE CONTROLS. USE THE FRAME CONTROL . . . LESS OVERHEAD.



--> sorry to shout, but I wanted to make a point :) !



This would be the method that I would choose.

4) Finally, remember that the user will not be able to see all of the controls on all of the tabs at any given moment. THIS IS IMPORTANT! There is no need for you to load all of the controls on all of the tabs. Simply Load those controls dynamically at runtime that are needed for the current visible tab. When the user changes tabs, remove the old controls and load those controls appropriate for the new tab. With this method, you can keep the total number on controls to a minimum, you will use less memory, you form will load faster, and YOUR APPLICATION WILL PERFORM BETTER! Sorry . . . just trying to make a point again.


If you would like to see an example of how to do this, just let me know and I will write a quick EXE and post it on my WebSite. I have written apps like this before and they usually run very well.
- Jeff Marler
(please note, that the page is under construction)
 
Not to question your solution Jeff, as your solution seems the way to go to me, but could you reduce the number of controls that count against the limit by using control arrays?

Rich
 
Even with a control array, you each control is still technically a window and each window must be registered with the system and a message queue has to be created. So no, I don't think that a control array would help by itself. However, to use the 3 option that I provided, you need to have control arrays set up (this allows you to dynamically load and unload controls as needed). The main idea is to only have thosee controls that are visible loaded into memory at any given time. The other option, is of course, to break the single form into several smaller forms, but I don't know if that was an option for Mushin.
I am writing a small demo program to demonstrate the 3rd option. I will post the EXE and source code in here when it is ready. - Jeff Marler
(please note, that the page is under construction)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top