Grouping Controls using Group Box control
-
I have created a SDI application with CFormView in VS 2005, vc++, MFC. I placed listctrl, a group box, and a couple of buttons and textboxes in the group box. I am setting the list ctrl and group box posisions at runtime using SetWindowPos(). The list control and the group box sets as per my x,y values. But the control which i have palced in the group box are not set with the group box. They are there, where i have placed them statically. I want all the control placed in the group box to be set as i change the pos of the group box. Is it possible. If yes where am i doing wrong. Thank you.
Saadhinchaali
-
I have created a SDI application with CFormView in VS 2005, vc++, MFC. I placed listctrl, a group box, and a couple of buttons and textboxes in the group box. I am setting the list ctrl and group box posisions at runtime using SetWindowPos(). The list control and the group box sets as per my x,y values. But the control which i have palced in the group box are not set with the group box. They are there, where i have placed them statically. I want all the control placed in the group box to be set as i change the pos of the group box. Is it possible. If yes where am i doing wrong. Thank you.
Saadhinchaali
A groupbox is just a control like any other (with a big hole in it). Just because you place controls inside of it in the dialog editor it won't be the parent of those controls. So as far as i know you can't move the controls visibly inside the gorup box by just moving the group box itself, you have to move the controls individually inside the group box. You could try doing 4 things i think: 1. Move the controls individually - not too nice but works 2. Put the controls which are inside of the groupbox on some custom-made panel and move that one around, so you only have to move the groupbox and the panel representing its inside. - a bit complicated, not too nice, but works 3. Put the groupbox and the controls visually inside it onto a panel (like a child dialog for exmaple) and move that one around - a bit less complicated than 2. but still not nice 4. Write some helper class that walks thorough the controls which are inside the gorup box and moves them around, maybe a class inherited from the groupbox class. - I'd chose this one, you are still moving around the controls individually but you get a reusable way to do so. You would need for example an array into which you'd place the controls that need to be moved simulteniously, you could also make a method for it that collects the controls inside the group box by checking their positions. I hope this all helps, good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
-
A groupbox is just a control like any other (with a big hole in it). Just because you place controls inside of it in the dialog editor it won't be the parent of those controls. So as far as i know you can't move the controls visibly inside the gorup box by just moving the group box itself, you have to move the controls individually inside the group box. You could try doing 4 things i think: 1. Move the controls individually - not too nice but works 2. Put the controls which are inside of the groupbox on some custom-made panel and move that one around, so you only have to move the groupbox and the panel representing its inside. - a bit complicated, not too nice, but works 3. Put the groupbox and the controls visually inside it onto a panel (like a child dialog for exmaple) and move that one around - a bit less complicated than 2. but still not nice 4. Write some helper class that walks thorough the controls which are inside the gorup box and moves them around, maybe a class inherited from the groupbox class. - I'd chose this one, you are still moving around the controls individually but you get a reusable way to do so. You would need for example an array into which you'd place the controls that need to be moved simulteniously, you could also make a method for it that collects the controls inside the group box by checking their positions. I hope this all helps, good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
Thank you. I just tried to place a tab control and put some controls on it. Even the tab control is not controling the controls. When i am moving the tabcontrol the controls placed on it are not moving. I tried cut paste on tab control also. Can u help me in this!
Saadhinchaali
-
Thank you. I just tried to place a tab control and put some controls on it. Even the tab control is not controling the controls. When i am moving the tabcontrol the controls placed on it are not moving. I tried cut paste on tab control also. Can u help me in this!
Saadhinchaali
The tab control is the same as the group box regarding this issue. If you want to change tabs you will either have to write yourself your own tabpage-changing mechanism or look for one, i am sure there are such already written and useable solutions for that here (or just use google).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <