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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pls Help : Limitation on # of Edit Controls in VC++

Status
Not open for further replies.

cdgios

Technical User
Jul 17, 2002
40
US
Hello, I am creating a dialog box with a bunch of edit controls on it in Visual C++. I have added a few (about 200 of them ) and i need to add more. But visual C++ ins't allowing me to add any more. Is there some limitation on the # of edit controls that can be added?. If not, what could be the possible reason as to why VC++ wouldn't allow me a to add more edit controls.

Your help is greatly appreciated
Thanks
Best Regards
Chandra
 
Aren't you talking about the limit of 255 controls on a dialog template? That is a Windows 9x/ME limit.

MSDN says about it: Windows 95/98/Me: The system can support a maximum of 255 controls per dialog box template. To place more than 255 controls in a dialog box, create the controls in the WM_INITDIALOG message handler rather than placing them in the template.

Did you consider changing the design of the program? I would not like filling in about 200 edit boxes myself.
Marcel
 
Hello Mkuiper, Thanks for your reply. I am a very new Visual C++ Programmer.

I am trying to display the register contents of a device that has eleven 24 bit registers, in the binary format. I am defining an edit control for each of the bits of the registers (24 * 11 + 11 = 275 in total) to be displayed. Can you suggest other methods (some other control's or other ways) through which i could acheive my objective (To display binary values of 11 24-bit registers adn their hex values) without having to fill 275 edit control's?.

Thanks
Best Regards
Chandra
 
Hi

You can use a list control with eleven rows, each rows containing 24 colums.
It's faster and much more memory efficient.

Thierry
 
Hello TGM, Thanks for your reply. Is the "List Control" part of the core win32 API?. I can't find documentation/examples for using the List Control. The documentation i find in MSDN, Visual C++ Reference, Platform SDK, etc. is based on MFC. Could you [please point me to where i could find a good discussion on this.

Thanks
Best Regards
Chandra
 
Hi

Ok, I guessed you are using MFC ... so look at CListCtrl and you'll find how to do it.

However I give you below some clue to do it.
To use this code, add a CListCtrl control to your dialog box and set its style 'View' as report. Use ClassWizard and call it m_RegList (for example)

Add the following code (I stopped at 7 colums ...) typically in the OnInitDialog

m_RegList.InsertColumn( 0, "0", LVCFMT_LEFT, 10, -1);
m_RegList.InsertColumn( 1, "1", LVCFMT_LEFT, 10, -1);
m_RegList.InsertColumn( 2, "2", LVCFMT_LEFT, 10, -1);
m_RegList.InsertColumn( 3, "3", LVCFMT_LEFT, 10, -1);
m_RegList.InsertColumn( 4, "4", LVCFMT_LEFT, 10, -1);
m_RegList.InsertColumn( 5, "5", LVCFMT_LEFT, 10, -1);

Use the following code to fill it:

char szBuffer[100];
LV_ITEM lvitem;
int nNdx;

for ( int nReg = 0; nReg < 11; nReg++)
{
// Add Data to List Control

lvitem.mask = LVIF_TEXT;
lvitem.iItem = 0;
lvitem.iSubItem = 0;
wsprintf( szBuffer, &quot;%d&quot;, 0);
lvitem.pszText = szBuffer;

nNdx = m_RegList.InsertItem( &lvitem);

for ( int nBit = 1; nBit < 5; nBit++)
{
lvitem.iItem = nNdx;
lvitem.iSubItem = nBit;
wsprintf( szBuffer, &quot;%d&quot;, nBit % 2);
lvitem.pszText = szBuffer;
m_RegList.SetItem( &lvitem);
}
}

Use these line to ensure correct column sizing:

m_RegList.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER);
m_RegList.SetColumnWidth( 1, LVSCW_AUTOSIZE_USEHEADER);
m_RegList.SetColumnWidth( 2, LVSCW_AUTOSIZE_USEHEADER);
m_RegList.SetColumnWidth( 3, LVSCW_AUTOSIZE_USEHEADER);
m_RegList.SetColumnWidth( 4, LVSCW_AUTOSIZE_USEHEADER);
m_RegList.SetColumnWidth( 5, LVSCW_AUTOSIZE_USEHEADER);

HTH

Thierry
EMail: Thierry.Marneffe@skynet.be
 
Hello TGM, Thanks for your reply. I was looking for equivalent win32 API functions to accomplish the same but couldn't find them. Could you please point me if you could to the win32 API functions for &quot;List Control&quot;?.

Thanks
Best Regards
Chandra
 
Hello Brother C, Thanks for the link. All the examples etc. listed there use MFC. Could you please point me to a place with examples etc. using Win32 API calls for List Control?. I couldn't find any win32 API functions etc. for &quot;List Control&quot;. Are there any ? or Am i forced to use MFC for List Control?.

Thanks
Best Regards
Chandra
 
Hello Chandra,

I think you should have a look at functions CreateWindow and CreateWindowEx in the platform SDK.

Using these functions I think you have 100 % control of what's going on ... (I wouldn't program it though, since you have to deal with a lot of nasty details ... and code).

How about a combination of a spinbutton and an editcontrol :
Use the spinbutton to select the Register to operate on, and 1 (or 24) editcontrol(s) to display/edit the register-content ?

/JOlesen
 
Hello again,

Sorry I didn't read all the postings or I would have known you were not looking for MFC controls.

The CListCtrl is an MFC class. The Microsoft Foundation Class Library (MFC) framework is based largely on a few major classes and several Visual C++ tools. Some of the classes encapsulate a large portion of the Win32 application programming interface (API). If MFC encapsulates the Win32 API there must be calls for you to use but I've never tried and have yet to see any info on how to.

That's the beauty of MFC, you don't need to know how to. MFC does the work for you. I would suggest using MFC if you can.

Brother C
 
If you have installed the MSDN library, choose the page &quot;Index&quot; and type &quot;Listview_&quot; (without the quotes, of course). Now you find all the macros and functions you need.
Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top