Link to home
Start Free TrialLog in
Avatar of rickatseasoft
rickatseasoft

asked on

Max controls per dialog AND do large numbers of controls impact overall system

Today I doscovered, the hard way, that VC++ has a hard limitation of 255 controls per dialog.  Actually, I think this is the editor as opposed to the language or the OS.  Reviewing the topic here, I discovered a lot of opinions, and counter opinions about effects on system performance, use of resources, programming style, etc.

My dialog has, you guessed it, 255 controls on it, and a need for a few more.  I realize that this dialog begs for a grid control, and, it will get one eventually.  For now though, absent some overriding consideration, I'll stick to dialogs and normal controls.

Fully 150 of the controls are CText, 7 are CComboBoxes, a few are Group Boxes, there are a few buttons, and about 80 CEdits.  By the way, I can easily remove about 10-20 controls that aren't absolutely necessary, and complete the project.

My questions are:
   1.  Am I creating overall system performance issues.
   2.  If I am, is there a way to place text on a dialog without using a control.

I know that I can create CText, or for that matter, any other control on the fly, but I am only interested in this if it somehow helps with system performance.

Thanks, Rick
Avatar of rickatseasoft
rickatseasoft

ASKER

One thing that I could do is take a row of data that is currently in colums by virtue of aligning the CTexts, and use one long CText to do the work of 6.  The question is how would I align the data within the control.  In other words, instead of indivicual controls as in

CText      CText       CText          CText        CText

A single control that had tabs or something in it to align the test
XXXX      XXXX     XXXX     XXXX        XXXX

Thanks, Rick
>>Today I doscovered, the hard way, that VC++ has a hard limitation of 255 controls per dialog.

Note :
Only dialog box 'template' support a maximum of 255 controls.

But If you want to create more than 255 controls in a dialog box, you may add the controls dynamically from within the OnInitDialog() function. Here you can put any number within reason.

-MAHESH
So 255 is limitation of template ie resource editor.

But if you have so many controls on a dialog I will suggest you to rethink about your design. You may also use tabs CPropertyPage,CPropertySheet  etc,that way for each "screen" you could have multiple lines with one or two controls.

-MAHESH
Avatar of AndyAinscow
You can use the OnPaint to draw text into the DC (so no static/text controls would be required).

You could create child dialogs and place these onto the dialog (runtime creation).

Is the dialog usable with so many controls?  How about splitting it into a tabbed dialog (property sheet/pages) ?
As I said you may split your controls using tabs, CPropertyPage,CPropertySheet  etc,that way for each screen you have fewer controls comapred to previous.

You may also activate this tabs automatically if you need to redirect user to input specific data.

-MAHESH
Thanks To All!

I take it, from the answers, that there is NOT a resource problem nor is there a system performance problem.  Do a quick search on this topic here on ee, and you will find dire warnings of system crashes, etc. all caused by the large complicated dialog.  This was my biggest concern.

mahesh1402:  I am aware of the ability to create controls at runtime, but, I didn't want to do that if there would be some sort of system performance penalty.  

Andy:  Under normal cirumstances, I would agree with you about the complexity of the dialog.  In this case,  I believe that it is justified. Thank for the tip about OnPaint(), I'll consider how to use that.
 
I'll let this sit for a couple of days to see if anyone raises any legitimate performance/resource issues, but, barring that, I believe that these two answers will suffice.

Thanks again, This site is priceless,  Rick
@ mahesh - oops, sorry for repeating the tab/property sheet suggestion.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial