|
|
@@ -15,12 +15,22 @@ static char THIS_FILE[] = __FILE__;
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
// CWndEx
|
|
|
|
|
|
+#define CLOSE_WIDTH 12
|
|
|
+#define CLOSE_HEIGHT 11
|
|
|
+#define CLOSE_BORDER 2
|
|
|
+#define TIMER_AUTO_MAX 1
|
|
|
+#define TIMER_AUTO_MIN 2
|
|
|
+
|
|
|
CWndEx::CWndEx()
|
|
|
{
|
|
|
m_bResizable = true;
|
|
|
m_bMouseDownOnClose = false;
|
|
|
m_bMouseOverClose = false;
|
|
|
m_bMouseDownOnCaption = false;
|
|
|
+ m_bMouseOverMinimize = false;
|
|
|
+ m_bMouseDownOnMinimize = false;
|
|
|
+ m_bMinimized = false;
|
|
|
+ m_bMaxSetTimer = false;
|
|
|
|
|
|
SetCaptionColorActive(false);
|
|
|
}
|
|
|
@@ -34,6 +44,17 @@ void CWndEx::InvalidateNc()
|
|
|
::RedrawWindow( m_hWnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_NOINTERNALPAINT );
|
|
|
}
|
|
|
|
|
|
+void CWndEx::GetWindowRectEx(LPRECT lpRect)
|
|
|
+{
|
|
|
+ if(m_bMinimized)
|
|
|
+ {
|
|
|
+ lpRect = m_crFullSizeWindow;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ CWnd::GetWindowRect(lpRect);
|
|
|
+}
|
|
|
+
|
|
|
bool CWndEx::SetCaptionColors( COLORREF left, COLORREF right )
|
|
|
{
|
|
|
if( left == m_CaptionColorLeft || right == m_CaptionColorRight )
|
|
|
@@ -68,9 +89,12 @@ BEGIN_MESSAGE_MAP(CWndEx, CWnd)
|
|
|
ON_WM_NCMOUSEMOVE()
|
|
|
ON_WM_NCLBUTTONUP()
|
|
|
ON_WM_ERASEBKGND()
|
|
|
+ ON_WM_TIMER()
|
|
|
+ ON_WM_WINDOWPOSCHANGING()
|
|
|
//}}AFX_MSG_MAP
|
|
|
// ON_WM_NCLBUTTONDBLCLK()
|
|
|
// ON_WM_NCACTIVATE()
|
|
|
+ON_WM_SIZE()
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
@@ -107,10 +131,55 @@ int CWndEx::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
|
m_TitleFont.CreateFont(14,0,-900,0,400,FALSE,FALSE,0,ANSI_CHARSET,
|
|
|
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
|
|
|
DEFAULT_PITCH|FF_SWISS,"Arial");
|
|
|
+
|
|
|
+ m_HorFont.CreateFont(14,0,0,0,400,FALSE,FALSE,0,ANSI_CHARSET,
|
|
|
+ OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
|
|
|
+ DEFAULT_PITCH|FF_SWISS,"Arial");
|
|
|
+
|
|
|
+ SetCaptionOn(CGetSetOptions::GetCaptionPos(), true);
|
|
|
+ SetAutoHide(CGetSetOptions::GetAutoHide());
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+void CWndEx::SetAutoHide(BOOL bAutoHide)
|
|
|
+{
|
|
|
+ if(bAutoHide)
|
|
|
+ {
|
|
|
+ SetTimer(TIMER_AUTO_MIN, 500, NULL);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ KillTimer(TIMER_AUTO_MIN);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CWndEx::SetCaptionOn(int nPos, bool bOnstartup)
|
|
|
+{
|
|
|
+ m_lTopBorder = BORDER;
|
|
|
+ m_lRightBorder = BORDER;
|
|
|
+ m_lBottomBorder = BORDER;
|
|
|
+ m_lLeftBorder = BORDER;
|
|
|
+
|
|
|
+ if(nPos == CAPTION_RIGHT)
|
|
|
+ m_lRightBorder = CAPTION_BORDER;
|
|
|
+ if(nPos == CAPTION_BOTTOM)
|
|
|
+ m_lBottomBorder = CAPTION_BORDER;
|
|
|
+ if(nPos == CAPTION_LEFT)
|
|
|
+ m_lLeftBorder = CAPTION_BORDER;
|
|
|
+ if(nPos == CAPTION_TOP)
|
|
|
+ m_lTopBorder = CAPTION_BORDER;
|
|
|
+
|
|
|
+ SetRegion();
|
|
|
+
|
|
|
+ if(!bOnstartup)
|
|
|
+ {
|
|
|
+ SetWindowPos (NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
|
|
|
+ }
|
|
|
+
|
|
|
+ RedrawWindow();
|
|
|
+}
|
|
|
+
|
|
|
void CWndEx::OnNcPaint()
|
|
|
{
|
|
|
CWindowDC dc(this);
|
|
|
@@ -137,10 +206,69 @@ void CWndEx::OnNcPaint()
|
|
|
rcBorder.DeflateRect(1, 1, 1, 1);
|
|
|
dc.Draw3dRect(rcBorder, left, left);
|
|
|
|
|
|
- rcBorder.left = rcBorder.right - RIGHT_CAPTION - BORDER + 1;
|
|
|
- rcBorder.bottom += BORDER;
|
|
|
- rcBorder.top -= BORDER;
|
|
|
+ rcBorder.InflateRect(1, 1, 1, 1);
|
|
|
|
|
|
+ BOOL bVertical;
|
|
|
+ if(m_lRightBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ m_crCloseBT.SetRect(rcBorder.right - m_lRightBorder + 2,
|
|
|
+ 7,
|
|
|
+ rcBorder.right - m_lRightBorder + 14,
|
|
|
+ 18);
|
|
|
+
|
|
|
+ m_crMinimizeBT.SetRect(rcBorder.right - m_lRightBorder + 2,
|
|
|
+ rcBorder.bottom - 18,
|
|
|
+ rcBorder.right - m_lRightBorder + 14,
|
|
|
+ rcBorder.bottom - 7);
|
|
|
+
|
|
|
+ rcBorder.left = rcBorder.right - m_lRightBorder;
|
|
|
+ bVertical = TRUE;
|
|
|
+ }
|
|
|
+ else if(m_lLeftBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ m_crCloseBT.SetRect(2,
|
|
|
+ 7,
|
|
|
+ 2 + 12,
|
|
|
+ 7 + 11);
|
|
|
+
|
|
|
+ m_crMinimizeBT.SetRect(2,
|
|
|
+ rcBorder.bottom - 18,
|
|
|
+ 2 + 12,
|
|
|
+ rcBorder.bottom - 7);
|
|
|
+
|
|
|
+ rcBorder.right = rcBorder.left + m_lLeftBorder;
|
|
|
+ bVertical = TRUE;
|
|
|
+ }
|
|
|
+ else if(m_lTopBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ m_crCloseBT.SetRect(rcBorder.right - 18,
|
|
|
+ 3,
|
|
|
+ rcBorder.right - 6,
|
|
|
+ 3 + 11);
|
|
|
+
|
|
|
+ m_crMinimizeBT.SetRect(4,
|
|
|
+ 2,
|
|
|
+ 15,
|
|
|
+ 2 + 12);
|
|
|
+
|
|
|
+ rcBorder.bottom = rcBorder.top + m_lTopBorder;
|
|
|
+ bVertical = FALSE;
|
|
|
+ }
|
|
|
+ else if(m_lBottomBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ m_crCloseBT.SetRect(rcBorder.right - 18,
|
|
|
+ rcBorder.bottom - 13,
|
|
|
+ rcBorder.right - 6,
|
|
|
+ rcBorder.bottom - 2);
|
|
|
+
|
|
|
+ m_crMinimizeBT.SetRect(4,
|
|
|
+ rcBorder.bottom - 14,
|
|
|
+ 15,
|
|
|
+ rcBorder.bottom - 2);
|
|
|
+
|
|
|
+ rcBorder.top = rcBorder.bottom - m_lBottomBorder;
|
|
|
+ bVertical = FALSE;
|
|
|
+ }
|
|
|
float gR = 0;
|
|
|
float gG = 0;
|
|
|
float gB = 0;
|
|
|
@@ -154,20 +282,40 @@ void CWndEx::OnNcPaint()
|
|
|
float eB = GetBValue(right);
|
|
|
|
|
|
// calculate the slope for color gradient
|
|
|
- gR = (eR - sR) / rcBorder.Height();
|
|
|
- gG = (eG - sG) / rcBorder.Height();
|
|
|
- gB = (eB - sB) / rcBorder.Height();
|
|
|
+ if(bVertical)
|
|
|
+ {
|
|
|
+ gR = (eR - sR) / rcBorder.Height();
|
|
|
+ gG = (eG - sG) / rcBorder.Height();
|
|
|
+ gB = (eB - sB) / rcBorder.Height();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ gR = (eR - sR) / rcBorder.Width();
|
|
|
+ gG = (eG - sG) / rcBorder.Width();
|
|
|
+ gB = (eB - sB) / rcBorder.Width();
|
|
|
+ }
|
|
|
|
|
|
HBRUSH color;
|
|
|
|
|
|
long lHeight = rcBorder.Height();
|
|
|
CRect cr = rcBorder;
|
|
|
-
|
|
|
- for(int i = 0; i < lHeight; i++)
|
|
|
- {
|
|
|
- cr.top = i;
|
|
|
- cr.bottom = i + 1;
|
|
|
|
|
|
+ long lCount = rcBorder.Width();
|
|
|
+ if(bVertical)
|
|
|
+ lCount = lHeight;
|
|
|
+
|
|
|
+ for(int i = 0; i < lCount; i++)
|
|
|
+ {
|
|
|
+ if(bVertical)
|
|
|
+ {
|
|
|
+ cr.top = i;
|
|
|
+ cr.bottom = i + 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cr.left = i;
|
|
|
+ cr.right = i + 1;
|
|
|
+ }
|
|
|
color = CreateSolidBrush(RGB(int(gR * (float) i + gR),
|
|
|
int(gG * (float) i + sG),
|
|
|
int(gB * (float) i + sB)));
|
|
|
@@ -183,30 +331,53 @@ void CWndEx::OnNcPaint()
|
|
|
DeleteObject(color);
|
|
|
*/
|
|
|
|
|
|
+
|
|
|
int nOldBKMode = dc.SetBkMode(TRANSPARENT);
|
|
|
COLORREF oldColor = dc.SetTextColor(RGB(255, 255, 255));
|
|
|
- CFont* pOldFont=dc.SelectObject(&m_TitleFont);
|
|
|
+ CFont *pOldFont = NULL;
|
|
|
+ if(bVertical)
|
|
|
+ pOldFont=dc.SelectObject(&m_TitleFont);
|
|
|
+ else
|
|
|
+ pOldFont=dc.SelectObject(&m_HorFont);
|
|
|
|
|
|
CString csText;
|
|
|
GetWindowText(csText);
|
|
|
- dc.TextOut(rcBorder.right-1, 22, csText);
|
|
|
|
|
|
- DrawCloseBtn(dc, lWidth, left);
|
|
|
-
|
|
|
+ if(m_lRightBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ cr.SetRect(rcBorder.right-1, 20, rcBorder.right - 13, rcBorder.bottom - 20);
|
|
|
+ dc.DrawText(csText, cr, DT_SINGLELINE);
|
|
|
+ }
|
|
|
+ else if(m_lBottomBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ cr.SetRect(20, rcBorder.bottom - 15, rcBorder.right - 20, rcBorder.bottom - 1);
|
|
|
+ dc.DrawText(csText, cr, DT_SINGLELINE);
|
|
|
+ }
|
|
|
+ else if(m_lLeftBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ cr.SetRect(15, 20, 2, rcBorder.bottom - 20);
|
|
|
+ dc.DrawText(csText, cr, DT_SINGLELINE);
|
|
|
+ }
|
|
|
+ else if(m_lTopBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ cr.SetRect(20, 1, rcBorder.right - 20, 15);
|
|
|
+ dc.DrawText(csText, cr, DT_SINGLELINE);
|
|
|
+ }
|
|
|
+
|
|
|
+ DrawCloseBtn(dc, left);
|
|
|
+ DrawMinimizeBtn(dc, left);
|
|
|
+
|
|
|
dc.SelectObject(pOldFont);
|
|
|
dc.SetTextColor(oldColor);
|
|
|
dc.SetBkMode(nOldBKMode);
|
|
|
}
|
|
|
|
|
|
-void CWndEx::DrawCloseBtn(CWindowDC &dc, long lRight, COLORREF left)
|
|
|
+void CWndEx::DrawCloseBtn(CWindowDC &dc, COLORREF left)
|
|
|
{
|
|
|
- if(lRight == -1)
|
|
|
- {
|
|
|
- CRect cr;
|
|
|
- GetWindowRect(cr);
|
|
|
- lRight = cr.Width();
|
|
|
- }
|
|
|
-
|
|
|
if(left == 0)
|
|
|
left = GetSysColor(COLOR_ACTIVECAPTION);
|
|
|
|
|
|
@@ -220,8 +391,7 @@ void CWndEx::DrawCloseBtn(CWindowDC &dc, long lRight, COLORREF left)
|
|
|
1,1,0,0,1,1
|
|
|
};
|
|
|
|
|
|
- CPoint ptShift(lRight - 15, 7);
|
|
|
- m_crCloseBT.SetRect(ptShift, ptShift+CPoint(12, 11));
|
|
|
+ CPoint ptShift = m_crCloseBT.TopLeft();
|
|
|
ptShift.Offset(3, 3);
|
|
|
|
|
|
COLORREF shaddow = RGB(GetRValue(left) * 1.16,
|
|
|
@@ -243,16 +413,127 @@ void CWndEx::DrawCloseBtn(CWindowDC &dc, long lRight, COLORREF left)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void CWndEx::DrawMinimizeBtn(CWindowDC &dc, COLORREF left)
|
|
|
+{
|
|
|
+ if(left == 0)
|
|
|
+ left = GetSysColor(COLOR_ACTIVECAPTION);
|
|
|
+
|
|
|
+ bool bTopOrBottom = false;
|
|
|
+
|
|
|
+ int Points[5][8];
|
|
|
+ int Points2[8][5];
|
|
|
+ if(((m_lRightBorder == CAPTION_BORDER) && (m_bMinimized == false)) ||
|
|
|
+ ((m_lLeftBorder == CAPTION_BORDER) && (m_bMinimized)))
|
|
|
+ {
|
|
|
+ int nTemp[5][8] =
|
|
|
+ {
|
|
|
+ 1,1,0,0,1,1,0,0,
|
|
|
+ 0,1,1,0,0,1,1,0,
|
|
|
+ 0,0,1,1,0,0,1,1,
|
|
|
+ 0,1,1,0,0,1,1,0,
|
|
|
+ 1,1,0,0,1,1,0,0
|
|
|
+ };
|
|
|
+ memcpy(&Points, &nTemp, sizeof(nTemp));
|
|
|
+ }
|
|
|
+ else if(((m_lRightBorder == CAPTION_BORDER) && (m_bMinimized)) ||
|
|
|
+ ((m_lLeftBorder == CAPTION_BORDER) && (m_bMinimized == false)))
|
|
|
+ {
|
|
|
+ int nTemp[5][8] =
|
|
|
+ {
|
|
|
+ 0,0,1,1,0,0,1,1,
|
|
|
+ 0,1,1,0,0,1,1,0,
|
|
|
+ 1,1,0,0,1,1,0,0,
|
|
|
+ 0,1,1,0,0,1,1,0,
|
|
|
+ 0,0,1,1,0,0,1,1
|
|
|
+ };
|
|
|
+
|
|
|
+ memcpy(&Points, &nTemp, sizeof(nTemp));
|
|
|
+ }
|
|
|
+ else if(((m_lTopBorder == CAPTION_BORDER) && (m_bMinimized == false)) ||
|
|
|
+ ((m_lBottomBorder == CAPTION_BORDER) && (m_bMinimized)))
|
|
|
+ {
|
|
|
+ bTopOrBottom = true;
|
|
|
+
|
|
|
+ int nTemp[8][5] =
|
|
|
+ {
|
|
|
+ 0,0,1,0,0,
|
|
|
+ 0,1,1,1,0,
|
|
|
+ 1,1,0,1,1,
|
|
|
+ 1,0,0,0,1,
|
|
|
+ 0,0,1,0,0,
|
|
|
+ 0,1,1,1,0,
|
|
|
+ 1,1,0,1,1,
|
|
|
+ 1,0,0,0,1
|
|
|
+ };
|
|
|
+ memcpy(&Points2, &nTemp, sizeof(nTemp));
|
|
|
+ }
|
|
|
+ else if(((m_lTopBorder == CAPTION_BORDER) && (m_bMinimized)) ||
|
|
|
+ ((m_lBottomBorder == CAPTION_BORDER) && (m_bMinimized == false)))
|
|
|
+ {
|
|
|
+ bTopOrBottom = true;
|
|
|
+
|
|
|
+ int nTemp[8][5] =
|
|
|
+ {
|
|
|
+ 1,0,0,0,1,
|
|
|
+ 1,1,0,1,1,
|
|
|
+ 0,1,1,1,0,
|
|
|
+ 0,0,1,0,0,
|
|
|
+ 1,0,0,0,1,
|
|
|
+ 1,1,0,1,1,
|
|
|
+ 0,1,1,1,0,
|
|
|
+ 0,0,1,0,0
|
|
|
+ };
|
|
|
+ memcpy(&Points2, &nTemp, sizeof(nTemp));
|
|
|
+ }
|
|
|
+
|
|
|
+ COLORREF shaddow = RGB(GetRValue(left) * 1.16,
|
|
|
+ GetGValue(left) * 1.12,
|
|
|
+ GetBValue(left) * 1.12);
|
|
|
+
|
|
|
+ if(m_bMouseDownOnMinimize)
|
|
|
+ dc.Draw3dRect(m_crMinimizeBT, shaddow, RGB(255, 255, 255));
|
|
|
+ else if(m_bMouseOverMinimize)
|
|
|
+ dc.Draw3dRect(m_crMinimizeBT, RGB(255, 255, 255), shaddow);
|
|
|
+
|
|
|
+ if(bTopOrBottom == false)
|
|
|
+ {
|
|
|
+ CPoint ptShift = m_crMinimizeBT.TopLeft();
|
|
|
+ ptShift.Offset(2, 3);
|
|
|
+
|
|
|
+ for (int iRow = 0; iRow < 5; iRow++)
|
|
|
+ {
|
|
|
+ for (int iCol = 0; iCol < 8; iCol++)
|
|
|
+ {
|
|
|
+ if (Points[iRow][iCol] == 1)
|
|
|
+ dc.SetPixel(ptShift+CPoint(iCol, iRow), RGB(255, 255, 255));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CPoint ptShift = m_crMinimizeBT.TopLeft();
|
|
|
+ ptShift.Offset(3, 2);
|
|
|
+
|
|
|
+ for (int iRow = 0; iRow < 8; iRow++)
|
|
|
+ {
|
|
|
+ for (int iCol = 0; iCol < 5; iCol++)
|
|
|
+ {
|
|
|
+ if (Points2[iRow][iCol] == 1)
|
|
|
+ dc.SetPixel(ptShift+CPoint(iCol, iRow), RGB(255, 255, 255));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void CWndEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
|
|
|
{
|
|
|
CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
|
|
|
|
|
|
//Decrease the client area
|
|
|
- lpncsp->rgrc[0].left+= BORDER;
|
|
|
- lpncsp->rgrc[0].top+= BORDER;
|
|
|
- lpncsp->rgrc[0].right-= BORDER;
|
|
|
- lpncsp->rgrc[0].bottom-= BORDER;
|
|
|
- lpncsp->rgrc[0].right-= RIGHT_CAPTION;
|
|
|
+ lpncsp->rgrc[0].left+= m_lLeftBorder;
|
|
|
+ lpncsp->rgrc[0].top+= m_lTopBorder;
|
|
|
+ lpncsp->rgrc[0].right-= m_lRightBorder;
|
|
|
+ lpncsp->rgrc[0].bottom-= m_lBottomBorder;
|
|
|
}
|
|
|
|
|
|
UINT CWndEx::OnNcHitTest(CPoint point)
|
|
|
@@ -270,36 +551,77 @@ UINT CWndEx::OnNcHitTest(CPoint point)
|
|
|
CRect crWindow;
|
|
|
GetWindowRect(crWindow);
|
|
|
|
|
|
- if ((point.y < crWindow.top + BORDER * 2) &&
|
|
|
- (point.x < crWindow.left + BORDER * 2))
|
|
|
- return HTTOPLEFT;
|
|
|
- else if ((point.y < crWindow.top + BORDER * 2) &&
|
|
|
- (point.x > crWindow.right - RIGHT_CAPTION))
|
|
|
- return HTTOPRIGHT;
|
|
|
- else if ((point.y > crWindow.bottom - BORDER * 7) &&
|
|
|
- (point.x > crWindow.right - RIGHT_CAPTION))
|
|
|
- return HTBOTTOMRIGHT;
|
|
|
- else if ((point.y > crWindow.bottom - BORDER * 2) &&
|
|
|
- (point.x < crWindow.left + BORDER * 2))
|
|
|
- return HTBOTTOMLEFT;
|
|
|
- else if (point.y < crWindow.top + BORDER * 2)
|
|
|
- return HTTOP;
|
|
|
- else if (point.x > crWindow.right - BORDER * 2)
|
|
|
- return HTRIGHT;
|
|
|
- else if (point.x < crWindow.left + BORDER * 2)
|
|
|
- return HTLEFT;
|
|
|
- else if (point.y > crWindow.bottom - BORDER * 2)
|
|
|
- return HTBOTTOM;
|
|
|
- else if (point.x > crWindow.right - RIGHT_CAPTION)
|
|
|
- return HTCAPTION;
|
|
|
- else
|
|
|
- return CWnd::OnNcHitTest(point); // The default handler
|
|
|
+ if(crWindow.PtInRect(point) == false)
|
|
|
+ {
|
|
|
+ return CWnd::OnNcHitTest(point);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(m_bMinimized == false)
|
|
|
+ {
|
|
|
+ if ((point.y < crWindow.top + BORDER * 2) &&
|
|
|
+ (point.x < crWindow.left + BORDER * 2))
|
|
|
+ return HTTOPLEFT;
|
|
|
+ else if ((point.y < crWindow.top + BORDER * 2) &&
|
|
|
+ (point.x > crWindow.right - BORDER * 2))
|
|
|
+ return HTTOPRIGHT;
|
|
|
+ else if ((point.y > crWindow.bottom - BORDER * 2) &&
|
|
|
+ (point.x > crWindow.right - BORDER * 2))
|
|
|
+ return HTBOTTOMRIGHT;
|
|
|
+ else if ((point.y > crWindow.bottom - BORDER * 2) &&
|
|
|
+ (point.x < crWindow.left + BORDER * 2))
|
|
|
+ return HTBOTTOMLEFT;
|
|
|
+ }
|
|
|
+
|
|
|
+ if((((m_lTopBorder == CAPTION_BORDER) || (m_lBottomBorder == CAPTION_BORDER)) &&
|
|
|
+ (m_bMinimized)) == false)
|
|
|
+ {
|
|
|
+ if (point.y < crWindow.top + BORDER * 2)
|
|
|
+ return HTTOP;
|
|
|
+ if (point.y > crWindow.bottom - BORDER * 2)
|
|
|
+ return HTBOTTOM;
|
|
|
+ }
|
|
|
+
|
|
|
+ if((((m_lLeftBorder == CAPTION_BORDER) || (m_lRightBorder == CAPTION_BORDER)) &&
|
|
|
+ (m_bMinimized)) == false)
|
|
|
+ {
|
|
|
+ if (point.x > crWindow.right - BORDER * 2)
|
|
|
+ return HTRIGHT;
|
|
|
+ if (point.x < crWindow.left + BORDER * 2)
|
|
|
+ return HTLEFT;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(m_lRightBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if (point.x > crWindow.right - m_lRightBorder)
|
|
|
+ return HTCAPTION;
|
|
|
+ }
|
|
|
+ else if(m_lBottomBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if(point.y > crWindow.bottom - m_lBottomBorder)
|
|
|
+ return HTCAPTION;
|
|
|
+ }
|
|
|
+ else if(m_lLeftBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if (point.x < crWindow.left + m_lLeftBorder)
|
|
|
+ return HTCAPTION;
|
|
|
+ }
|
|
|
+ else if(m_lTopBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if (point.y < crWindow.top + m_lTopBorder)
|
|
|
+ return HTCAPTION;
|
|
|
+ }
|
|
|
+
|
|
|
+ return CWnd::OnNcHitTest(point); // The default handler
|
|
|
}
|
|
|
|
|
|
void CWndEx::OnNcLButtonDown(UINT nHitTest, CPoint point)
|
|
|
{
|
|
|
CPoint clPoint(point);
|
|
|
ScreenToClient(&clPoint);
|
|
|
+
|
|
|
+ clPoint.x += m_lLeftBorder;
|
|
|
+ clPoint.y += m_lTopBorder;
|
|
|
+
|
|
|
if(m_crCloseBT.PtInRect(clPoint))
|
|
|
{
|
|
|
SetCapture();
|
|
|
@@ -309,6 +631,13 @@ void CWndEx::OnNcLButtonDown(UINT nHitTest, CPoint point)
|
|
|
CWindowDC dc(this);
|
|
|
DrawCloseBtn(dc);
|
|
|
}
|
|
|
+ else if(m_crMinimizeBT.PtInRect(clPoint))
|
|
|
+ {
|
|
|
+ SetCapture();
|
|
|
+ m_bMouseDownOnMinimize = true;
|
|
|
+ CWindowDC dc(this);
|
|
|
+ DrawMinimizeBtn(dc);
|
|
|
+ }
|
|
|
|
|
|
CWnd::OnNcLButtonDown(nHitTest, point);
|
|
|
}
|
|
|
@@ -324,17 +653,144 @@ void CWndEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
|
|
|
OnNcPaint();
|
|
|
|
|
|
CPoint clPoint(point);
|
|
|
- if(m_crCloseBT.PtInRect(point))
|
|
|
+ clPoint.x += m_lLeftBorder;
|
|
|
+ clPoint.y += m_lTopBorder;
|
|
|
+ if(m_crCloseBT.PtInRect(clPoint))
|
|
|
SendMessage(WM_CLOSE, 0, 0);
|
|
|
}
|
|
|
+ else if(m_bMouseDownOnMinimize)
|
|
|
+ {
|
|
|
+ ReleaseCapture();
|
|
|
+ m_bMouseDownOnMinimize = false;
|
|
|
+ m_bMouseOverMinimize = false;
|
|
|
+
|
|
|
+ OnNcPaint();
|
|
|
+
|
|
|
+ CPoint clPoint(point);
|
|
|
+ clPoint.x += m_lLeftBorder;
|
|
|
+ clPoint.y += m_lTopBorder;
|
|
|
+ if(m_crMinimizeBT.PtInRect(clPoint))
|
|
|
+ {
|
|
|
+ MinMaxWindow();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
CWnd::OnNcLButtonUp(nHitTest, point);
|
|
|
}
|
|
|
|
|
|
+void CWndEx::MinMaxWindow(long lOption)
|
|
|
+{
|
|
|
+ if((m_bMinimized) && (lOption == FORCE_MIN))
|
|
|
+ return;
|
|
|
+
|
|
|
+ if((m_bMinimized == false) && (lOption == FORCE_MAX))
|
|
|
+ return;
|
|
|
+
|
|
|
+ if(m_lRightBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if(m_bMinimized == false)
|
|
|
+ {
|
|
|
+ GetWindowRect(m_crFullSizeWindow);
|
|
|
+ MoveWindow(m_crFullSizeWindow.right - CAPTION_BORDER,
|
|
|
+ m_crFullSizeWindow.top, CAPTION_BORDER,
|
|
|
+ m_crFullSizeWindow.Height());
|
|
|
+ m_bMinimized = true;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ GetWindowRect(cr);
|
|
|
+ MoveWindow(cr.right - m_crFullSizeWindow.Width(),
|
|
|
+ cr.top, m_crFullSizeWindow.Width(), cr.Height());
|
|
|
+
|
|
|
+ m_crFullSizeWindow.SetRectEmpty();
|
|
|
+ m_bMinimized = false;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(m_lLeftBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if(m_bMinimized == false)
|
|
|
+ {
|
|
|
+ GetWindowRect(m_crFullSizeWindow);
|
|
|
+ MoveWindow(m_crFullSizeWindow.left,
|
|
|
+ m_crFullSizeWindow.top, CAPTION_BORDER,
|
|
|
+ m_crFullSizeWindow.Height());
|
|
|
+ m_bMinimized = true;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ GetWindowRect(cr);
|
|
|
+ MoveWindow(cr.left, cr.top,
|
|
|
+ m_crFullSizeWindow.Width(), cr.Height());
|
|
|
+
|
|
|
+ m_crFullSizeWindow.SetRectEmpty();
|
|
|
+ m_bMinimized = false;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(m_lTopBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if(m_bMinimized == false)
|
|
|
+ {
|
|
|
+ GetWindowRect(m_crFullSizeWindow);
|
|
|
+ MoveWindow(m_crFullSizeWindow.left,
|
|
|
+ m_crFullSizeWindow.top,
|
|
|
+ m_crFullSizeWindow.Width(),
|
|
|
+ CAPTION_BORDER);
|
|
|
+ m_bMinimized = true;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ GetWindowRect(cr);
|
|
|
+ MoveWindow(cr.left, cr.top,
|
|
|
+ cr.Width(), m_crFullSizeWindow.Height());
|
|
|
+
|
|
|
+ m_crFullSizeWindow.SetRectEmpty();
|
|
|
+ m_bMinimized = false;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(m_lBottomBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ if(m_bMinimized == false)
|
|
|
+ {
|
|
|
+ GetWindowRect(m_crFullSizeWindow);
|
|
|
+ MoveWindow(m_crFullSizeWindow.left,
|
|
|
+ m_crFullSizeWindow.bottom - CAPTION_BORDER,
|
|
|
+ m_crFullSizeWindow.Width(),
|
|
|
+ CAPTION_BORDER);
|
|
|
+ m_bMinimized = true;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CRect cr;
|
|
|
+ GetWindowRect(cr);
|
|
|
+ MoveWindow(cr.left,
|
|
|
+ cr.bottom - m_crFullSizeWindow.Height(),
|
|
|
+ cr.Width(), m_crFullSizeWindow.Height());
|
|
|
+
|
|
|
+ m_crFullSizeWindow.SetRectEmpty();
|
|
|
+ m_bMinimized = false;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void CWndEx::OnNcMouseMove(UINT nHitTest, CPoint point)
|
|
|
{
|
|
|
CPoint clPoint(point);
|
|
|
ScreenToClient(&clPoint);
|
|
|
+
|
|
|
+ clPoint.x += m_lLeftBorder;
|
|
|
+ clPoint.y += m_lTopBorder;
|
|
|
+
|
|
|
if(m_crCloseBT.PtInRect(clPoint))
|
|
|
{
|
|
|
m_bMouseOverClose = true;
|
|
|
@@ -346,14 +802,34 @@ void CWndEx::OnNcMouseMove(UINT nHitTest, CPoint point)
|
|
|
m_bMouseOverClose = false;
|
|
|
OnNcPaint();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ if(m_crMinimizeBT.PtInRect(clPoint))
|
|
|
+ {
|
|
|
+ m_bMouseOverMinimize = true;
|
|
|
+ CWindowDC dc(this);
|
|
|
+ DrawMinimizeBtn(dc);
|
|
|
+ }
|
|
|
+ else if(m_bMouseOverMinimize)
|
|
|
+ {
|
|
|
+ m_bMouseOverMinimize = false;
|
|
|
+ OnNcPaint();
|
|
|
+ }
|
|
|
+
|
|
|
+ if((m_bMaxSetTimer == false) && m_bMinimized)
|
|
|
+ {
|
|
|
+ SetTimer(TIMER_AUTO_MAX, 1000, NULL);
|
|
|
+ m_bMaxSetTimer = true;
|
|
|
+ }
|
|
|
+
|
|
|
CWnd::OnNcMouseMove(nHitTest, point);
|
|
|
}
|
|
|
|
|
|
BOOL CWndEx::PreTranslateMessage(MSG* pMsg)
|
|
|
{
|
|
|
if (pMsg->message == WM_NCLBUTTONDOWN)
|
|
|
+ {
|
|
|
m_bMouseDownOnCaption = true;
|
|
|
+ }
|
|
|
|
|
|
if ((pMsg->message == WM_LBUTTONUP) && (m_bMouseDownOnCaption))
|
|
|
{
|
|
|
@@ -448,3 +924,133 @@ BOOL CWndEx::OnEraseBkgnd(CDC* pDC)
|
|
|
return CWnd::OnEraseBkgnd(pDC);
|
|
|
}
|
|
|
|
|
|
+void CWndEx::OnTimer(UINT nIDEvent)
|
|
|
+{
|
|
|
+ if(nIDEvent == TIMER_AUTO_MAX)
|
|
|
+ {
|
|
|
+ if(m_bMinimized)
|
|
|
+ {
|
|
|
+ CPoint cp;
|
|
|
+ GetCursorPos(&cp);
|
|
|
+
|
|
|
+ UINT nHitTest = OnNcHitTest(cp);
|
|
|
+
|
|
|
+ ScreenToClient(&cp);
|
|
|
+
|
|
|
+ if(nHitTest == HTCAPTION)
|
|
|
+ {
|
|
|
+ if(m_crCloseBT.PtInRect(cp) == false)
|
|
|
+ {
|
|
|
+ if(m_crMinimizeBT.PtInRect(cp) == false)
|
|
|
+ {
|
|
|
+ MinMaxWindow(FORCE_MAX);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ KillTimer(TIMER_AUTO_MAX);
|
|
|
+ m_bMaxSetTimer = false;
|
|
|
+ }
|
|
|
+ else if(nIDEvent == TIMER_AUTO_MIN)
|
|
|
+ {
|
|
|
+ if((m_bMinimized == false) && (g_Opt.m_bShowPersistent))
|
|
|
+ {
|
|
|
+ CPoint cp;
|
|
|
+ CRect cr;
|
|
|
+
|
|
|
+ GetCursorPos(&cp);
|
|
|
+ GetWindowRect(&cr);
|
|
|
+
|
|
|
+ if(cr.PtInRect(cp) == false)
|
|
|
+ {
|
|
|
+ if(GetFocus() == NULL)
|
|
|
+ {
|
|
|
+ MinMaxWindow(FORCE_MIN);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CWnd::OnTimer(nIDEvent);
|
|
|
+}
|
|
|
+
|
|
|
+void CWndEx::OnWindowPosChanging(WINDOWPOS* lpwndpos)
|
|
|
+{
|
|
|
+ CWnd::OnWindowPosChanging(lpwndpos);
|
|
|
+
|
|
|
+ if(m_bMaxSetTimer)
|
|
|
+ {
|
|
|
+ KillTimer(TIMER_AUTO_MAX);
|
|
|
+ m_bMaxSetTimer = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CWndEx::SetRegion()
|
|
|
+{
|
|
|
+ if((m_lRightBorder == CAPTION_BORDER) ||
|
|
|
+ (m_lTopBorder == CAPTION_BORDER))
|
|
|
+ {
|
|
|
+ //Create the region for drawing the rounded top edge
|
|
|
+ CRect rect;
|
|
|
+ GetWindowRect(rect);
|
|
|
+ CRgn rgnRect, rgnRect2, rgnRound, rgnFinalA, rgnFinalB;
|
|
|
+
|
|
|
+ rgnRect.CreateRectRgn(0, 0, rect.Width() - 7, rect.Height());
|
|
|
+ rgnRound.CreateRoundRectRgn(0, 0, rect.Width()+1, rect.Height(), 15, 15);
|
|
|
+
|
|
|
+ rgnFinalB.CreateRectRgn(0, 0, 0, 0);
|
|
|
+ rgnFinalB.CombineRgn(&rgnRect, &rgnRound, RGN_OR);
|
|
|
+
|
|
|
+ rgnRect2.CreateRectRgn(0, 7, rect.Width(), rect.Height());
|
|
|
+ rgnFinalA.CreateRectRgn(0, 0, 0, 0);
|
|
|
+ rgnFinalA.CombineRgn(&rgnRect2, &rgnFinalB, RGN_OR);
|
|
|
+
|
|
|
+ //Set the region
|
|
|
+ SetWindowRgn(rgnFinalA, TRUE);
|
|
|
+ }
|
|
|
+ else if(m_lLeftBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ CRect rect;
|
|
|
+ GetWindowRect(rect);
|
|
|
+ CRgn rgnRect, rgnRect2, rgnRound, rgnFinalA, rgnFinalB;
|
|
|
+
|
|
|
+ rgnRect.CreateRectRgn(0, 7, rect.Width(), rect.Height());
|
|
|
+ rgnRound.CreateRoundRectRgn(0, 0, rect.Width(), rect.Height(), 15, 15);
|
|
|
+
|
|
|
+ rgnFinalB.CreateRectRgn(0, 0, 0, 0);
|
|
|
+ rgnFinalB.CombineRgn(&rgnRect, &rgnRound, RGN_OR);
|
|
|
+
|
|
|
+ rgnRect2.CreateRectRgn(7, 0, rect.Width(), rect.Height());
|
|
|
+ rgnFinalA.CreateRectRgn(0, 0, 0, 0);
|
|
|
+ rgnFinalA.CombineRgn(&rgnRect2, &rgnFinalB, RGN_OR);
|
|
|
+
|
|
|
+ //Set the region
|
|
|
+ SetWindowRgn(rgnFinalA, TRUE);
|
|
|
+ }
|
|
|
+ else if(m_lBottomBorder == CAPTION_BORDER)
|
|
|
+ {
|
|
|
+ CRect rect;
|
|
|
+ GetWindowRect(rect);
|
|
|
+ CRgn rgnRect, rgnRect2, rgnRound, rgnFinalA, rgnFinalB;
|
|
|
+
|
|
|
+ rgnRect.CreateRectRgn(0, 0, rect.Width(), rect.Height()-7);
|
|
|
+ rgnRound.CreateRoundRectRgn(0, 0, rect.Width()+1, rect.Height()+1, 15, 15);
|
|
|
+
|
|
|
+ rgnFinalB.CreateRectRgn(0, 0, 0, 0);
|
|
|
+ rgnFinalB.CombineRgn(&rgnRect, &rgnRound, RGN_OR);
|
|
|
+
|
|
|
+ rgnRect2.CreateRectRgn(0, 0, rect.Width()-15, rect.Height());
|
|
|
+ rgnFinalA.CreateRectRgn(0, 0, 0, 0);
|
|
|
+ rgnFinalA.CombineRgn(&rgnRect2, &rgnFinalB, RGN_OR);
|
|
|
+
|
|
|
+ //Set the region
|
|
|
+ SetWindowRgn(rgnFinalA, TRUE);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CWndEx::OnSize(UINT nType, int cx, int cy)
|
|
|
+{
|
|
|
+ CWnd::OnSize(nType, cx, cy);
|
|
|
+
|
|
|
+ SetRegion();
|
|
|
+}
|