Solved

MoveWindow() of a groupbox overtop another groupbox

Posted on 1998-08-29
4
592 Views
Last Modified: 2008-02-01
I am performing a MoveWindow on a groupbox within a dialog such that I want one groupbox to overlay another groupbox. Both groupboxes are defined on the dialog with the exact same dimensions. However, when I perform the MoveWindow() command, the groupbox I wish to move actually appears about 1/4 inch below the groupbox I am trying to overlay.

Here is the code I am using:

m_wndGroupToOverlay = a CButton assigned control to the groupbox. (I don't know why ClassWizard only gave me this choice for a member variable assignment...but...)

m_wndOtherGroupBox = another groupbox member variable for a groupbox defined elsewhere in the dialog.

In OnInitDialog():
(..after calling the default ::OnInitDialog)
m_wndGroupToOverlay.GetWindowRect(&m_rectGroupToOverlay);

In SomeOtherFunction:
m_wndOtherGroupBox.MoveWindow(&m_rectGroupToOverlay);

This results in the offset groupbox, when I was expecting it would be covering the original groubox completely.

Any thoughts?

Thanks
0
Comment
Question by:rascal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1171556
answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1171557
Its a matter of  coordinate systems. GetWindowRect() returns the window's coordinates relative to the top left corner of the screen.  MoveWindow() takes coordinates that are relative to the top-left corner of the window's parent window's client area.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1171558
The following code should fix the problem, or at least be close, I may not have the math perfect.

 m_wndGroupToOverlay.GetWindowRect(&m_rectGroupToOverlay);
CWnd *ParWndPtr = GetParent();
POINT Pnt = {0,0};
ParWndPtr->ClientToScreen(0,0);
m_rectGroupToOverlay.Left -= Pnt.x;
m_rectGroupToOverlay.Right -= Pnt.x;
m_rectGroupToOverlay.Top -= Pnt.y;
m_rectGroupToOverlay.Bottom -= Pnt.y;

let me know if you have questions.
0
 
LVL 1

Author Comment

by:rascal
ID: 1171559
Thanks, I used ScreenToClient to change the coordinates and it worked as intended.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question