Solved

MoveWindow() of a groupbox overtop another groupbox

Posted on 1998-08-29
4
579 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now