?
Solved

MoveWindow() of a groupbox overtop another groupbox

Posted on 1998-08-29
4
Medium Priority
?
593 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 200 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

770 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