?
Solved

Problems with WS_THICKFRAME

Posted on 2001-08-21
2
Medium Priority
?
688 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 800 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

752 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