Explorar o código

view caption on all sides and roll up window -- SAB

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@32 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden %!s(int64=22) %!d(string=hai) anos
pai
achega
004f01b5d0
Modificáronse 12 ficheiros con 881 adicións e 106 borrados
  1. 17 0
      CP_Main.rc
  2. 5 0
      Changes.txt
  3. 4 0
      Misc.cpp
  4. 11 0
      Misc.h
  5. 11 6
      QListCtrl.cpp
  6. 2 0
      QListCtrl.h
  7. 93 20
      QPasteWnd.cpp
  8. 9 0
      QPasteWnd.h
  9. 5 0
      QuickPaste.cpp
  10. 32 22
      Resource.h
  11. 662 56
      WndEx.cpp
  12. 30 2
      WndEx.h

+ 17 - 0
CP_Main.rc

@@ -193,6 +193,23 @@ BEGIN
             MENUITEM "Show Hot Key Text",           ID_MENU_FIRSTTENHOTKEYS_SHOWHOTKEYTEXT
 
         END
+        POPUP "View Caption Bar On"
+        BEGIN
+            MENUITEM "Top",                         ID_VIEWCAPTIONBARON_TOP
+            MENUITEM "Right",                       ID_VIEWCAPTIONBARON_RIGHT
+
+            MENUITEM "Bottom",                      ID_VIEWCAPTIONBARON_BOTTOM
+
+            MENUITEM "Left",                        ID_VIEWCAPTIONBARON_LEFT
+        END
+        POPUP "Sort"
+        BEGIN
+            MENUITEM "Ascending (Latest on the Top)", ID_SORT_ASCENDING
+            MENUITEM "Descending (Latest on the Bottom", ID_SORT_DESCENDING
+        END
+        MENUITEM "Allways on Top\tCtrl-Spce",   ID_MENU_ALLWAYSONTOP
+        MENUITEM "Auto Roolup",                 ID_MENU_AUTOHIDE
+        MENUITEM "View Full Description\tF3",   ID_MENU_VIEWFULLDESCRIPTION
         MENUITEM "Reconnect To Clipboard Chain", 
                                                 ID_MENU_RECONNECTTOCLIPBOARDCHAIN
 

+ 5 - 0
Changes.txt

@@ -1,3 +1,8 @@
+03 Sept 14
+----------
++ View caption on all sides(top, right, bottom, left)
++ Roll up window by button on caption or by auto roll up(looses focus then it will rool up)
+
 03 Sept 10
 ----------
 + HistoryStartTop - History can be shown top-down or bottom-up

+ 4 - 0
Misc.cpp

@@ -896,7 +896,11 @@ BOOL CGetSetOptions::GetShowTextForFirstTenHotKeys()			{	return GetProfileLong("
 void CGetSetOptions::SetMainHWND(long lhWnd)	{	SetProfileLong("MainhWnd", lhWnd);		}
 BOOL CGetSetOptions::GetMainHWND()				{	return GetProfileLong("MainhWnd", 0);	}
 
+void CGetSetOptions::SetCaptionPos(long lPos)	{	SetProfileLong("CaptionPos", lPos);					}
+long CGetSetOptions::GetCaptionPos()			{	return GetProfileLong("CaptionPos", CAPTION_RIGHT);	}
 
+void CGetSetOptions::SetAutoHide(BOOL bAutoHide){	SetProfileLong("AutoHide", bAutoHide);					}
+BOOL CGetSetOptions::GetAutoHide()				{	return GetProfileLong("AutoHide", FALSE);				}
 
 /*------------------------------------------------------------------*\
 	CHotKey - a single system-wide hotkey

+ 11 - 0
Misc.h

@@ -78,6 +78,11 @@ CString GetFilePath(CString csFullPath);
 #define POS_AT_CURSOR	2
 #define POS_AT_PREVIOUS	3
 
+#define CAPTION_RIGHT	1
+#define CAPTION_BOTTOM	2
+#define CAPTION_LEFT	3
+#define CAPTION_TOP		4
+
 //Message to the main window to show icon or not
 #define WM_SHOW_TRAY_ICON		WM_USER + 200
 #define WM_CV_RECONNECT			WM_USER + 201
@@ -213,6 +218,12 @@ public:
 	static void		SetMainHWND(long lhWnd);
 	static BOOL		GetMainHWND();
 
+	static void		SetCaptionPos(long lPos);
+	static long		GetCaptionPos();
+
+	static void		SetAutoHide(BOOL bAutoHide);
+	static BOOL		GetAutoHide();
+
 	/*
 	BOOL IsAutoRun();
 	void SetAutoRun(BOOL bRun);

+ 11 - 6
QListCtrl.cpp

@@ -645,12 +645,7 @@ BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
 
 		case VK_F3:
 			{
-				int nItem = GetCaret();
-				CRect rc;
-				GetItemRect(nItem, rc, LVIR_BOUNDS);
-				ClientToScreen(rc);
-				m_Popup.m_Pos = CPoint(rc.left, rc.bottom);
-				m_Popup.Show( GetToolTipText(nItem) );
+				ShowFullDescription();
 			
 				break;
 			}
@@ -662,6 +657,16 @@ BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
 	return CListCtrl::PreTranslateMessage(pMsg);
 }
 
+void CQListCtrl::ShowFullDescription()
+{
+	int nItem = GetCaret();
+	CRect rc;
+	GetItemRect(nItem, rc, LVIR_BOUNDS);
+	ClientToScreen(rc);
+	m_Popup.m_Pos = CPoint(rc.left, rc.bottom);
+	m_Popup.Show( GetToolTipText(nItem) );
+}
+
 CString CQListCtrl::GetToolTipText(int nItem)
 {
 	CString cs;

+ 2 - 0
QListCtrl.h

@@ -88,6 +88,8 @@ public:
 
 	void DestroyAndCreateAccelerator(BOOL bCreate);
 
+	void ShowFullDescription();
+
 protected:
 	void SendSelection(int nItem);;
 	void SendSelection(ARRAY &arrItems);

+ 93 - 20
QPasteWnd.cpp

@@ -88,6 +88,15 @@ BEGIN_MESSAGE_MAP(CQPasteWnd, CWndEx)
 	ON_MESSAGE(WM_REFRESH_VIEW, OnRefreshView)
 	ON_WM_NCLBUTTONDBLCLK()
 	ON_WM_WINDOWPOSCHANGING()
+	ON_COMMAND(ID_VIEWCAPTIONBARON_RIGHT, OnViewcaptionbaronRight)
+	ON_COMMAND(ID_VIEWCAPTIONBARON_BOTTOM, OnViewcaptionbaronBottom)
+	ON_COMMAND(ID_VIEWCAPTIONBARON_LEFT, OnViewcaptionbaronLeft)
+	ON_COMMAND(ID_VIEWCAPTIONBARON_TOP, OnViewcaptionbaronTop)
+	ON_COMMAND(ID_MENU_AUTOHIDE, OnMenuAutohide)
+	ON_COMMAND(ID_MENU_VIEWFULLDESCRIPTION, OnMenuViewfulldescription)
+	ON_COMMAND(ID_MENU_ALLWAYSONTOP, OnMenuAllwaysontop)
+	ON_COMMAND(ID_SORT_ASCENDING, OnSortAscending)
+	ON_COMMAND(ID_SORT_DESCENDING, OnSortDescending)
 END_MESSAGE_MAP()
 
 
@@ -162,24 +171,6 @@ void CQPasteWnd::OnSize(UINT nType, int cx, int cy)
 	if(!IsWindow(m_lstHeader.m_hWnd))
 		return;
 
-	//Create the region for drawing the rounded top edge
-	CRect rect;
-	GetWindowRect(rect);
-	CRgn rgnRect, rgnRect2, rgnRound, rgnFinalA, rgnFinalB;
-
-	rgnRect.CreateRectRgn(0, 0, 20, rect.Height());
-	rgnRound.CreateRoundRectRgn(0, 0, rect.Width(), rect.Height()+1, 15, 15);
-
-	rgnFinalB.CreateRectRgn(0, 0, 0, 0);
-	rgnFinalB.CombineRgn(&rgnRect, &rgnRound, RGN_OR);
-
-	rgnRect2.CreateRectRgn(0, 20, rect.Width()-1, rect.Height());
-	rgnFinalA.CreateRectRgn(0, 0, 0, 0);
-	rgnFinalA.CombineRgn(&rgnRect2, &rgnFinalB, RGN_OR);
-
-	//Set the region
-	SetWindowRgn(rgnFinalA, TRUE);
-
 	MoveControls();
 }
 
@@ -212,7 +203,8 @@ void CQPasteWnd::OnSetFocus(CWnd* pOldWnd)
 	CWndEx::OnSetFocus(pOldWnd);
 
 	// Set the focus to the list control
-	m_lstHeader.SetFocus();
+	if(::IsWindow(m_lstHeader.m_hWnd))
+		m_lstHeader.SetFocus();
 }
 
 void CQPasteWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
@@ -249,7 +241,7 @@ BOOL CQPasteWnd::HideQPasteWindow()
 
 	//Save the size
 	CRect rect;
-	GetWindowRect(rect);
+	GetWindowRectEx(rect);
 	CGetSetOptions::SetQuickPasteSize(rect.Size());
 	CGetSetOptions::SetQuickPastePoint(rect.TopLeft());
 
@@ -608,6 +600,33 @@ void CQPasteWnd::SetMenuChecks(CMenu *pMenu)
 
 	if(CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys())
 		pMenu->CheckMenuItem(ID_MENU_FIRSTTENHOTKEYS_USECTRLNUM, MF_CHECKED);
+
+	if(g_Opt.m_bShowPersistent)
+		pMenu->CheckMenuItem(ID_MENU_ALLWAYSONTOP, MF_CHECKED);
+
+	if(CGetSetOptions::GetAutoHide())
+		pMenu->CheckMenuItem(ID_MENU_AUTOHIDE, MF_CHECKED);
+
+	if(g_Opt.m_bHistoryStartTop)
+		pMenu->CheckMenuItem(ID_SORT_ASCENDING, MF_CHECKED);
+	else
+		pMenu->CheckMenuItem(ID_SORT_DESCENDING, MF_CHECKED);
+
+	switch(CGetSetOptions::GetCaptionPos())
+	{
+	case 1:
+		pMenu->CheckMenuItem(ID_VIEWCAPTIONBARON_RIGHT, MF_CHECKED);
+		break;
+	case 2:
+		pMenu->CheckMenuItem(ID_VIEWCAPTIONBARON_BOTTOM, MF_CHECKED);
+		break;
+	case 3:
+		pMenu->CheckMenuItem(ID_VIEWCAPTIONBARON_LEFT, MF_CHECKED);
+		break;
+	case 4:
+		pMenu->CheckMenuItem(ID_VIEWCAPTIONBARON_TOP, MF_CHECKED);
+		break;
+	}
 }
 
 LRESULT CQPasteWnd::OnSearch(WPARAM wParam, LPARAM lParam)
@@ -775,6 +794,60 @@ void CQPasteWnd::OnMenuFirsttenhotkeysShowhotkeytext()
 	m_lstHeader.RefreshVisibleRows();
 }
 
+void CQPasteWnd::OnViewcaptionbaronRight()
+{
+	SetCaptionOn(CAPTION_RIGHT);
+	CGetSetOptions::SetCaptionPos(CAPTION_RIGHT);
+}
+
+void CQPasteWnd::OnViewcaptionbaronBottom()
+{
+	SetCaptionOn(CAPTION_BOTTOM);
+	CGetSetOptions::SetCaptionPos(CAPTION_BOTTOM);
+}
+
+void CQPasteWnd::OnViewcaptionbaronLeft()
+{
+	SetCaptionOn(CAPTION_LEFT);
+	CGetSetOptions::SetCaptionPos(CAPTION_LEFT);
+}
+
+void CQPasteWnd::OnViewcaptionbaronTop()
+{
+	SetCaptionOn(CAPTION_TOP);
+	CGetSetOptions::SetCaptionPos(CAPTION_TOP);
+}
+
+void CQPasteWnd::OnMenuAutohide()
+{
+	bool bAutoHide = !CGetSetOptions::GetAutoHide();
+	CGetSetOptions::SetAutoHide(bAutoHide);
+	SetAutoHide(bAutoHide);
+}
+
+void CQPasteWnd::OnMenuViewfulldescription()
+{
+	m_lstHeader.ShowFullDescription();	
+}
+
+void CQPasteWnd::OnMenuAllwaysontop()
+{
+	theApp.ShowPersistent( !g_Opt.m_bShowPersistent );
+}
+
+void CQPasteWnd::OnSortAscending()
+{
+	g_Opt.SetHistoryStartTop(TRUE);
+	FillList();
+}
+
+void CQPasteWnd::OnSortDescending()
+{
+	g_Opt.SetHistoryStartTop(FALSE);
+	FillList();
+}
+
+
 ///////////////////////////////////////////////////////////////////////
 //END END Menu Stuff
 ///////////////////////////////////////////////////////////////////////

+ 9 - 0
QPasteWnd.h

@@ -132,6 +132,15 @@ protected:
 public:
 	afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
 	afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
+	afx_msg void OnViewcaptionbaronRight();
+	afx_msg void OnViewcaptionbaronBottom();
+	afx_msg void OnViewcaptionbaronLeft();
+	afx_msg void OnViewcaptionbaronTop();
+	afx_msg void OnMenuAutohide();
+	afx_msg void OnMenuViewfulldescription();
+	afx_msg void OnMenuAllwaysontop();
+	afx_msg void OnSortAscending();
+	afx_msg void OnSortDescending();
 };
 
 

+ 5 - 0
QuickPaste.cpp

@@ -73,7 +73,10 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, BOOL bAtPrevPos)
 		if((theApp.m_bShowingQuickPaste) || (theApp.m_bShowingOptions))
 		{
 			if( g_Opt.m_bShowPersistent )
+			{
+				m_pwndPaste->MinMaxWindow(FORCE_MAX);
 				m_pwndPaste->SetForegroundWindow();
+			}
 			return;
 		}
 	}
@@ -128,6 +131,8 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, BOOL bAtPrevPos)
 		VERIFY( m_pwndPaste->Create(point, pParent) );
 	}
 
+	m_pwndPaste->MinMaxWindow(FORCE_MAX);
+
 	if((nPosition == POS_AT_CARET) ||
 		(nPosition == POS_AT_CURSOR) ||
 		(bAtPrevPos))

+ 32 - 22
Resource.h

@@ -85,27 +85,37 @@
 #define ID_FIRST_RECONNECTTOCLIPBOARDCHAIN 32774
 #define ID_MENU_RECONNECTTOCLIPBOARDCHAIN 32775
 #define ID_MENU_PROPERTIES              32776
-#define ID_MENU_FIRSTTENHOTKEYS_USECTRLNUM 32778
-#define ID_MENU_FIRSTTENHOTKEYS_SHOWHOTKEYTEXT 32779
-#define ID_MENU_LINESPERROW_1           32786
-#define ID_MENU_LINESPERROW_2           32787
-#define ID_MENU_LINESPERROW_3           32788
-#define ID_MENU_LINESPERROW_4           32789
-#define ID_MENU_LINESPERROW_5           32790
-#define ID_MENU_TRANSPARENCY_5          32791
+#define ID_MENU_FIRSTTENHOTKEYS_USECTRLNUM 32777
+#define ID_MENU_FIRSTTENHOTKEYS_SHOWHOTKEYTEXT 32778
+#define ID_MENU_VIEWCAPTIONBARON        32779
+#define ID_VIEWCAPTIONBARON_RIGHT       32780
+#define ID_VIEWCAPTIONBARON_BOTTOM      32781
+#define ID_VIEWCAPTIONBARON_LEFT        32782
+#define ID_VIEWCAPTIONBARON_TOP         32783
+#define ID_MENU_ALLWAYSONTOP            32784
+#define ID_MENU_LINESPERROW_2           32786
+#define ID_MENU_LINESPERROW_3           32787
+#define ID_MENU_LINESPERROW_4           32788
+#define ID_MENU_LINESPERROW_5           32789
+#define ID_MENU_TRANSPARENCY_40         32790
+#define ID_MENU_AUTOHIDE                32791
 #define ID_MENU_TRANSPARENCY_10         32792
-#define ID_MENU_TRANSPARENCY_15         32793
-#define ID_MENU_TRANSPARENCY_20         32794
-#define ID_MENU_TRANSPARENCY_25         32795
-#define ID_MENU_TRANSPARENCY_30         32796
-#define ID_MENU_TRANSPARENCY_40         32806
-#define ID_MENU_TRANSPARENCY_NONE       32807
-#define ID_MENU_DELETE                  32810
-#define ID_MENU_POSITIONING_ATCARET     32811
-#define ID_MENU_POSITIONING_ATCURSOR    32812
-#define ID_MENU_POSITIONING_ATPREVIOUSPOSITION 32813
-#define ID_MENU_OPTIONS                 32814
-#define ID_MENU_EXITPROGRAM             32816
+#define ID_MENU_VIEWFULLDESCRIPTION     32793
+#define ID_MENU_TRANSPARENCY_15         32794
+#define ID_SORT_ASCENDING               32795
+#define ID_MENU_TRANSPARENCY_20         32796
+#define ID_SORT_DESCENDING              32797
+#define ID_MENU_TRANSPARENCY_25         32798
+#define ID_MENU_TRANSPARENCY_30         32799
+#define ID_MENU_TRANSPARENCY_NONE       32800
+#define ID_MENU_DELETE                  32801
+#define ID_MENU_POSITIONING_ATCARET     32802
+#define ID_MENU_POSITIONING_ATCURSOR    32803
+#define ID_MENU_POSITIONING_ATPREVIOUSPOSITION 32804
+#define ID_MENU_OPTIONS                 32805
+#define ID_MENU_EXITPROGRAM             32806
+#define ID_MENU_LINESPERROW_1           32807
+#define ID_MENU_TRANSPARENCY_5          32808
 
 // Next default values for new objects
 // 
@@ -113,8 +123,8 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        138
-#define _APS_NEXT_COMMAND_VALUE         32780
-#define _APS_NEXT_CONTROL_VALUE         1043
+#define _APS_NEXT_COMMAND_VALUE         32809
+#define _APS_NEXT_CONTROL_VALUE         2020
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

+ 662 - 56
WndEx.cpp

@@ -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();
+}

+ 30 - 2
WndEx.h

@@ -7,9 +7,13 @@
 // WndEx.h : header file
 //
 
-#define RIGHT_CAPTION			15
+#define	CAPTION_BORDER			16
 #define BORDER					2
 
+#define	SWAP_MIN_MAX			1
+#define FORCE_MIN				2
+#define FORCE_MAX				3
+
 class CWndEx : public CWnd
 {
 // Construction
@@ -41,15 +45,36 @@ public:
 
 	void	InvalidateNc();
 
+	void	SetCaptionOn(int nPos, bool bOnstartup = false);
+	void	SetAutoHide(BOOL bAutoHide);
+	void	MinMaxWindow(long lOption = SWAP_MIN_MAX);
+	void	GetWindowRectEx(LPRECT lpRect);
+
 protected:
 	CFont			m_TitleFont;
+	CFont			m_HorFont;
 	bool			m_bResizable;
 	CRect			m_crCloseBT;
+	CRect			m_crMinimizeBT;
 	bool			m_bMouseOverClose;
 	bool			m_bMouseDownOnClose;
 	bool			m_bMouseDownOnCaption;
+	bool			m_bMouseOverMinimize;
+	bool			m_bMouseDownOnMinimize;
+
+	long			m_lTopBorder;
+	long			m_lRightBorder;
+	long			m_lBottomBorder;
+	long			m_lLeftBorder;
+
+	CRect			m_crFullSizeWindow;
+
+	bool			m_bMinimized;
+	bool			m_bMaxSetTimer;
 	
-	void			DrawCloseBtn(CWindowDC &dc, long lRight = -1, COLORREF left = 0);
+	void			DrawCloseBtn(CWindowDC &dc, COLORREF left = 0);
+	void			DrawMinimizeBtn(CWindowDC &dc, COLORREF left = 0);
+	void			SetRegion();
 
 // Implementation
 public:
@@ -66,11 +91,14 @@ protected:
 	afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
 	afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
 	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+	afx_msg void OnTimer(UINT nIDEvent);
+	afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 public:
 //	afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
 //	afx_msg BOOL OnNcActivate(BOOL bActive);
+	afx_msg void OnSize(UINT nType, int cx, int cy);
 };
 
 /////////////////////////////////////////////////////////////////////////////