Around 500 controls in a Dialog
-
Hi, how can i place around 500 controls simultaneously on a single Dialog? Any idea? Thanks in advance. Anish.
you can, but you won't be able to place all of them at design, because the editor is limiting you. add the additionnal controls it at runtime...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -
Hi, how can i place around 500 controls simultaneously on a single Dialog? Any idea? Thanks in advance. Anish.
AnsGe wrote:
500 controls simultaneously on a single Dialog?
OMG, I hope that I will never use your application. but on a more serious note, explain what you want to do, maybe there are better ways that we could suggest.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
Hi, how can i place around 500 controls simultaneously on a single Dialog? Any idea? Thanks in advance. Anish.
-
Hi, how can i place around 500 controls simultaneously on a single Dialog? Any idea? Thanks in advance. Anish.
go windowless and draw the controls yourself My blogs: http://blog.joycode.com/jiangsheng http://blog.csdn.net/jiangsheng http://bloglines.com/public/jiangsheng Command what is yours Conquer what is not ---Kane
-
AnsGe wrote:
500 controls simultaneously on a single Dialog?
OMG, I hope that I will never use your application. but on a more serious note, explain what you want to do, maybe there are better ways that we could suggest.
Maximilien Lincourt Your Head A Splode - Strong Bad
Maximilien wrote:
OMG, I hope that I will never use your application.
LMAO :D You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.
-
Hi, how can i place around 500 controls simultaneously on a single Dialog? Any idea? Thanks in advance. Anish.
AnsGe wrote:
how can i place around 500 controls simultaneously on a single Dialog?
IMHO, Putting 500 control on single dialog is not part of good design, better try breaking them into diffrent property sheets! if you still insist on putting 500 control on single dialog... htne dynamically generating control will better option
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
I think you could: 1- Create the controls dynamically with pre-defined ID's. 2- Create a few child dialogs, each having a couple hundred controls. 3- Edit the .RC file, and add them manually. 4- Some other way. Why? this is this.
Here's a fragment of code from a dialog I wrote earlier: Declare some controls CStatic m_txtLabelIn [ 500 ]; And create them with any arbitrary size for now for (i = 0; i < sizeof(m_txtLabelIn) / sizeof(m_txtLabelIn[0]); i++) m_txtLabelIn[i].Create("", SS_LEFTNOWORDWRAP, rect, this); and then do a SetWindowPosition on each one to put them where you want them. (You ARE sure they will all fit the space available?) Shraddhan
-
Here's a fragment of code from a dialog I wrote earlier: Declare some controls CStatic m_txtLabelIn [ 500 ]; And create them with any arbitrary size for now for (i = 0; i < sizeof(m_txtLabelIn) / sizeof(m_txtLabelIn[0]); i++) m_txtLabelIn[i].Create("", SS_LEFTNOWORDWRAP, rect, this); and then do a SetWindowPosition on each one to put them where you want them. (You ARE sure they will all fit the space available?) Shraddhan
No I am not sure that they all will fit on one dialog. If you are using it maximized with screen resolutions 1024 x 768, then maybe it is possible. Actually it all depends on the size of individual controls, and what you choose to put in them, like text, icons, images etc. Suggestion: You should rather use a property sheet with a few property pages in it. That way, you can put fewer controls on each page, and it would be easier to create and use, and would fit in a smaller screen area. Now about your code:
CStatic m_Static[500];// is not a very good idea. //You should rather use: CStatic* m_pStatic; m_pStatic = new CStatic[500];// etc
However, I strongly recommend using property sheet and pages. this is this. -
No I am not sure that they all will fit on one dialog. If you are using it maximized with screen resolutions 1024 x 768, then maybe it is possible. Actually it all depends on the size of individual controls, and what you choose to put in them, like text, icons, images etc. Suggestion: You should rather use a property sheet with a few property pages in it. That way, you can put fewer controls on each page, and it would be easier to create and use, and would fit in a smaller screen area. Now about your code:
CStatic m_Static[500];// is not a very good idea. //You should rather use: CStatic* m_pStatic; m_pStatic = new CStatic[500];// etc
However, I strongly recommend using property sheet and pages. this is this.Whether or not 500 controls will fit on a mere 1024 x 768 display surely depends on how big they are and what they do. I don't know what the original questioner had in mind. I know that I have a dialog that will hold up to 120 CEdit controls and about a dozen others, and the property sheet technique will not help as they all need to be visible at the same time. However, as my screen resolution is a pleasant 2304 x 864, this is perfectly OK. I note with interest your comment on my code smippet that CStatic m_Static[500]; is not a very good idea. Please tell me why not? As the array is a member of a class (a CDialog), I don't need to worry about deleting it. So in what way is using new better? Shraddhan
-
Whether or not 500 controls will fit on a mere 1024 x 768 display surely depends on how big they are and what they do. I don't know what the original questioner had in mind. I know that I have a dialog that will hold up to 120 CEdit controls and about a dozen others, and the property sheet technique will not help as they all need to be visible at the same time. However, as my screen resolution is a pleasant 2304 x 864, this is perfectly OK. I note with interest your comment on my code smippet that CStatic m_Static[500]; is not a very good idea. Please tell me why not? As the array is a member of a class (a CDialog), I don't need to worry about deleting it. So in what way is using new better? Shraddhan
Statically creating so many controls will take more memory out of the stack space for the thread. If you have a large amount of code with that, then the stack might even get corrupted. I tried once with about 16 objects of CView, with a lot of other code and controls, and the program simply crashed on some machines without showing any error at all. So, it would be wiser to allocate so many controls on the heap. this is this.
-
Statically creating so many controls will take more memory out of the stack space for the thread. If you have a large amount of code with that, then the stack might even get corrupted. I tried once with about 16 objects of CView, with a lot of other code and controls, and the program simply crashed on some machines without showing any error at all. So, it would be wiser to allocate so many controls on the heap. this is this.
khan++ wrote:
then the stack might even get corrupted
Didn't I say that the array of CEdit controls was a member of the window class, a CDialog? I assumed that the controls would be allocated memory anywhere but the heap, and being created by the class's constructor, if this failed the dialog would surely not open. Or am I missing something here? Shraddhan
-
khan++ wrote:
then the stack might even get corrupted
Didn't I say that the array of CEdit controls was a member of the window class, a CDialog? I assumed that the controls would be allocated memory anywhere but the heap, and being created by the class's constructor, if this failed the dialog would surely not open. Or am I missing something here? Shraddhan
Well, if it works, then you don't need to worry. What I actually meant was that when you have lots of controls and lots of code, then it is
safer
to allocate them using new instead of statically. But if it works, then who cares where and how they are created. ;) this is this.