Solved

Problems with WS_THICKFRAME

Posted on 2001-08-21
2
664 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Looking for a specific application/software 2 110
Problem to event 3 96
Updating statistics with error notification email in SQL server 4 95
Increment column based of a FK 8 21
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

772 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