Derived classes a button CMyButton, response WM_NCHITTEST message
LRESULT CMyButton: : OnNcHitTest (CPoint point)
{
,,,,,,,,
if (! The rect. PtInRect (pt))
{
If (pt) x & lt;=nFrame & amp; & Pt. Y & gt;=the rect. Bottom - nFrame)
{
Return HTBOTTOMLEFT;
}
Else if (pt. X & lt;=nFrame & amp; & Pt. Y & lt;=nFrame)
{
Return HTTOPLEFT;
}
Else if (pt. X & gt;=the rect. Right - nFrame & amp; & Pt. Y & lt;=nFrame)
{
Return HTTOPRIGHT;
}
Else if (pt. X & gt;=the rect. Right - nFrame & amp; & Pt. Y & gt;=the rect. Bottom - nFrame)
{
Return HTBOTTOMRIGHT;
}
Else if (pt. X & lt;=nFrame)
{
Return HTLEFT;
}
Else if (pt. Y & lt;=nFrame)
{
Return HTTOP;
}
Else if (pt. Y & gt;=the rect. Bottom - nFrame)
{
Return HTBOTTOM;
}
Else if (pt. X & gt;=the rect. Right - nFrame)
{
Return HTRIGHT;
}
}
The else
{
Return HTCAPTION;
}
}
The idea is effective for the button control, the listbox control effectively, can change the location and size
Have no effect on picture controls, both neither can change position, also can't change the size, please BBS halves pointed out that the reason
Or can provide other methods can use the mouse to change the size and location of the picture control
CodePudding user response:
That picture control CStatic open Notify propertiesCodePudding user response:
Hook on the Notify attribute, or can't move can't adjust the sizeCodePudding user response:
Void CMyStatic1: : onm ouseMove (UINT nFlags, CPoint point){
//TODO: Add your message handler code here and/or call the default
The static CPoint ptLast;
If (MK_LBUTTON==nFlags)
{
CRect rc;
GetWindowRect (& amp; Rc);
The ScreenToClient (& amp; Rc);
MapWindowPoints (GetParent (), & amp; Rc);
MoveWindow (rc) left + point. X-ray ptLast. (x), rc. The top + point. Y - ptLast. (y), rc. The Width (), rc, Height ());
}
The else
{
PtLast=point;
CStatic: onm ouseMove (nFlags, point);
}
Invalidate ().
//
//CStatic: : onm ouseMove (nFlags, point);
}
CodePudding user response:
To change the size by CRectTracker, such as:The class CMyButton: public CButton, public CRectTracker
CodePudding user response:
The border style to choose even?Also note, it is from the CStatic derived subclass
And picture controls have modify its ID and map to the derived subclass?