Solved

Problems with WS_THICKFRAME

Posted on 2001-08-21
2
682 Views
Last Modified: 2013-11-20
Hi!
I want to show a small window in my CView derived window in order to let the user to move and resize it. What I did was to derive a class from CWnd (CSelectWnd) and then I handled WM_LBUTTONDOWN/WM_LBUTTONUP AND WM_MOUSEMOVE.
The code I used is the following:
void CSelectWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
     SetCapture();
     m_bCaptured = true;
     CWnd::OnLButtonDown(nFlags, point);
}

void CSelectWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
     ReleaseCapture();
        m_bCaptured = false;
     CWnd::OnLButtonUp(nFlags, point);
}
void CSelectWnd::OnMouseMove(UINT nFlags, CPoint point)
{
     if (m_bCaptured)
     {
          CWnd* pParent = GetParent();
         
          //Retrieve the old postion (in parent client coordinates)
          CRect oldPos;
          GetClientRect(&oldPos);
          ClientToScreen(oldPos);
          pParent->ScreenToClient(&oldPos);
         
          //Work out the new position (in parent client coordinates)
          CRect newPos(point.x - m_nDragOffset.x, point.y - m_nDragOffset.y,
               point.x - m_nDragOffset.x + oldPos.Width(), point.y  - m_nDragOffset.y + oldPos.Height());
          ClientToScreen(&newPos);
          pParent->ScreenToClient(&newPos);
         
          //Only move the window if it is inside the client rect of the parent window
          CRect clientRect;
          pParent->GetClientRect(&clientRect);
          if (newPos.left >= clientRect.left && newPos.top >= clientRect.top &&
               newPos.right < clientRect.right && newPos.bottom < clientRect.bottom)
          {
               newPos.InflateRect(3,3);
               MoveWindow(newPos, FALSE);
               oldPos.InflateRect(3,3);
               pParent->InvalidateRect(oldPos, FALSE);
               Invalidate(TRUE);
               CWnd::OnMouseMove(nFlags, point);
          }


     }
     else
          CWnd::OnMouseMove(nFlags, point);
}

Then in my view class I create an instance of this class as follows:

int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     if (CView::OnCreate(lpCreateStruct) == -1)
          return -1;

     CRect rect(100,100,500,500);
     
     m_Select.Create(NULL, "TestClass", WS_VISIBLE|WS_CHILD|WS_THICKFRAME   , rect, this, 0xFFFF);


     return 0;
}

The window is correctly creatly but when I move the CSelectWnd derived window, it is not properly repainted. However it is correctly repainted if I remove thw WS_THICKFRAME style.
Any solution?

Thanks
Carlos

0
Comment
Question by:qocarlos
[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
2 Comments
 
LVL 9

Accepted Solution

by:
Pacman earned 200 total points
ID: 6412346
in your mousemove function you use GetClientRect().
This function gives you the coordinates of the client-area of the window. Use GetWindowRect() to get the exterior rectangle of the window.
PS: GetWindowRect() comes already with screen coordinates so you don't have to call ClientToScreen().

Pacman
0
 
LVL 3

Author Comment

by:qocarlos
ID: 6413858
Thanks Pacman,
GetWindowRect can do the job. I will try it out and let you know if it works.

Carlos
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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