Re: CSpinButtonCtrl does not follow CEdit when moving
- From: "Victor" <nijegorodov.otpusk@xxxxxxxxxx>
- Date: Tue, 3 Jul 2007 21:03:47 +0200
SetBuddy does work OK!
However, there is an interesting "problem" with edit control "window rect":
this rect deflates after each SetBuddy call!
So if someone wanted to use this way, he/she would need to save the initial
edit control size to "correct" the rect dimensions returned by
m_cEdit.GetWindowRect.
In this case, I think, Joe's way would me more simple and more obvious!
Regards,
Victor
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:la8j8394ig6q5scsnqe23g7bjgjnnqdl5u@xxxxxxxxxx
Presumably the buddy has already been set, so how is it that this will
change anything?
joe
On Mon, 2 Jul 2007 22:45:29 +0200, "Victor"
<nijegorodov.otpusk@xxxxxxxxxx> wrote:
Well, how about using CSpinButtonCtrl::SetBuddy after edit control hasJoseph M. Newcomer [MVP]
been
moved?
Something like:
CRect newRect(...);
....
m_cEdit.MoveWindow(newRect);
m_cSpin.SetBuddy(&m_cEdit);
Victor
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:a09e83hloeior9lpmcun2g6iij3ctekjpa@xxxxxxxxxx
The alignment requirement in no way makes the two controls be coupled at
runtime; it
applies cosmetics at design time. If you want the control to move at
runtime, you have to
move both controls, no other choice.
I would do something of the following
void CMyClass::MoveEditControl(CEdit & ctrl, CPoint pt)
{
CRect editRect;
ctrl.GetWindowRect(&editRect);
ScreenToClient(&editRect);
CWnd * spin = ctrl.GetWindow(GW_HWNDNEXT);
CRect spinRect;
spin->GetWIndowRect(&spinRect);
ScreenToClient(&spinRect);
CSize offset(spinRect.left - editRect.left, spinRect.top -
editRect.top);
ctrl.MoveWindow(NULL, pt.x, pt.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
spin->MoveWindow(NULL, pt.x + offset.cx, pt.y + offset.cy, 0, 0,
SWP_NOSIZE |
SWP_NOZORDER);
}
joe
On Fri, 29 Jun 2007 14:07:43 -0000, alexandre.asas@xxxxxxxxx wrote:
Hi there!Joseph M. Newcomer [MVP]
I have a problem that seams to be very common, but I still didn't find
a nice solution.
My subclasses:
- CMyEdit : CEdit;
- CMySpinButtonCtrl : CSpinButtonCtrl.
Behavior:
- The SpinButton is aligned as UDS_ALIGNRIGHT;
- When I move the Edit (using CWnd::MoveWindow), the SpinButton is
not moved and stay away from the Edit control.
It's a common problem or I forgot important overrides in my
subclasses?
I'd really appreciate any help.
Best regards,
Alexandre Alves
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: CSpinButtonCtrl does not follow CEdit when moving
- From: Joseph M . Newcomer
- Re: CSpinButtonCtrl does not follow CEdit when moving
- References:
- Re: CSpinButtonCtrl does not follow CEdit when moving
- From: Joseph M . Newcomer
- Re: CSpinButtonCtrl does not follow CEdit when moving
- From: Victor
- Re: CSpinButtonCtrl does not follow CEdit when moving
- From: Joseph M . Newcomer
- Re: CSpinButtonCtrl does not follow CEdit when moving
- Prev by Date: Re: WaitForSingleObject() will not deadlock
- Next by Date: Re: WaitForSingleObject() will not deadlock
- Previous by thread: Re: CSpinButtonCtrl does not follow CEdit when moving
- Next by thread: Re: CSpinButtonCtrl does not follow CEdit when moving
- Index(es):