Solved

Problems with WS_THICKFRAME

Posted on 2001-08-21
2
655 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
2 Comments
 
LVL 9

Accepted Solution

by:
Pacman earned 200 total points
Comment Utility
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
Comment Utility
Thanks Pacman,
GetWindowRect can do the job. I will try it out and let you know if it works.

Carlos
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 98
modThree challenge 4 64
abstract class with all non abstract mentods 6 71
sumHeights2  challenge 7 75
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

7 Experts available now in Live!

Get 1:1 Help Now