|
-
April 5th, 2006, 07:00 AM
#1
MOving a group of buttons in MFC
Hi all,
I need to move a group of buttons.I tried with group box and frames but only the frame or group box is moving and not the buttons placed in it.
Plz help regarding this.
-
April 5th, 2006, 07:53 AM
#2
Re: MOving a group of buttons in MFC
Hi!
There is no magic, you have to move each button individually.
Regards / Z
-
April 5th, 2006, 08:23 AM
#3
Re: MOving a group of buttons in MFC
where u want to move the group of button?? at the time when application is running or in resource editor?
-
April 5th, 2006, 08:46 AM
#4
Re: MOving a group of buttons in MFC
If it is in resource editor, u can select multple objects using the CTRL key
or draw a window around all the items to select. Then MOVE
Cheers
-
April 5th, 2006, 08:52 AM
#5
Re: MOving a group of buttons in MFC
By the way, in resource editor (VS 6.0) it seems impossible to move controls in steps of just one pixel. They always move two pixels. That sucks
Is there a fix?
-
April 5th, 2006, 09:06 AM
#6
Re: MOving a group of buttons in MFC
check it out again. they move in steps of one pixel.
-
April 5th, 2006, 09:24 AM
#7
Re: MOving a group of buttons in MFC
Originally posted by zerver By the way, in resource editor (VS 6.0) it seems impossible to move controls in steps of just one pixel. They always move two pixels. That sucks
Is there a fix?
Try to move by using the keyboard arrows and not by using mouse
If there is no love sun won't shine
-
April 5th, 2006, 09:48 AM
#8
Re: MOving a group of buttons in MFC
Not always. I just tried moving a checkbox three times using the right arrow key.
The first time it moved two pixels, then one, then two.
(I pasted a screenshot from the resource editor in Paint Shop Pro after each move to confirm this)
Annoyances galore. I have VS 6.0 SP5.
-
April 5th, 2006, 09:55 AM
#9
Re: MOving a group of buttons in MFC
 Originally Posted by zerver
Not always. I just tried moving a checkbox three times using the right arrow key.
The first time it moved two pixels, then one, then two.
(I pasted a screenshot from the resource editor in Paint Shop Pro after each move to confirm this)
Annoyances galore. I have VS 6.0 SP5.
This is weird i also using VC6 and i didn’t face this problem; it always moves one pixel with arrow keys. 
PS: Unless you hold the key down of course 
Cheers
-
April 5th, 2006, 10:27 AM
#10
Re: MOving a group of buttons in MFC
OK, I have confirmed now that exactly every second move is two pixels long.
I also tried switching from Metric to U.S. measurement system in Regional Options but that did not help...
-
April 6th, 2006, 12:44 AM
#11
Re: MOving a group of buttons in MFC
Hi all,
I want to move the buttons while application is running and not in resource editor.
Thank u.
-
April 6th, 2006, 01:11 AM
#12
Re: MOving a group of buttons in MFC
get the handle of all the buttons u want to move and call MoveWindow() for each button at the event when u want to move thosse buttons
-
April 6th, 2006, 02:26 AM
#13
Re: MOving a group of buttons in MFC
 Originally Posted by harshandu
Hi all,
I want to move the buttons while application is running and not in resource editor.
Thank u.
Also look at ::SetWindowPos().
Cheers
-
April 6th, 2006, 04:41 AM
#14
Re: MOving a group of buttons in MFC
Hello,
When you add controls from resource editor, it is added on the dialog window and not in group box, though you place it in the group box. Hence moving group box does not result in moving the control.
But one can attach the group box as parent to the control you want to move together using CWnd::SetParent function. Moving group box will move the control also. Best place to set the parent is in CDialog::OnInitDialog function. There will be movement in control position when you attach another parent to it, which is the offset of the new parent with respect to the old one.
Here is a code snippet to be included in OnInitDialog function of the parent dialog class, which moves a control (ID = IDC_BUTTON) from parent dialog to a group box (ID = IDC_GROUP), retaining its original position. Once this is included in OnInitDialog function, moving the groupbox will result in moving the control as well.
Code:
// Calculates offset of group box to the parent window
CRect Rect;
GetDlgItem(IDC_GROUP)->GetWindowRect(Rect);
ScreenToClient(Rect);
int X = Rect.left, Y = Rect.top;
// Sets group box as parent to the control
GetDlgItem(IDC_BUTTON)->SetParent(GetDlgItem(IDC_GROUP));
// Retains original position by offsetting control
GetDlgItem(IDC_GROUP)->GetDlgItem(IDC_BUTTON)->GetWindowRect(Rect);
GetDlgItem(IDC_GROUP)->ScreenToClient(Rect);
Rect.OffsetRect(-X, -Y);
GetDlgItem(IDC_GROUP)->GetDlgItem(IDC_BUTTON)->MoveWindow(Rect);
Regards.
Pravin.
Last edited by Pravin Kumar; April 6th, 2006 at 04:45 AM.
-
October 17th, 2006, 04:29 AM
#15
Re: MOving a group of buttons in MFC
 Originally Posted by zerver
OK, I have confirmed now that exactly every second move is two pixels long.
I also tried switching from Metric to U.S. measurement system in Regional Options but that did not help...
Apart from this, when I click on a button in resource editor it says in the left corner that the size is 51x14, but when I make a screen shot and measure the pixel size it is 77x23. So, I can confirm again that there is definitely something fishy about the resource editor units in VS 6.0.
If someone knows what is going on, plz tell. Thx.
Nobody cares how it works as long as it works
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|