00001
00002
00003
00004
00005 #include "stdafx.h"
00006 #include "FdmApp.h"
00007 #include "PlugFrame.h"
00008 #include "misc.h"
00009
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015
00016 CPlugFrame::CPlugFrame()
00017 {
00018 m_dyCaption = 25;
00019 m_wndPlugin = NULL;
00020 m_clrBkCaption = RGB (170, 170, 170);
00021 m_clrCaptionText = RGB (255, 255, 255);
00022
00023 m_font.CreateFont (20, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, "Arial");
00024 }
00025
00026 CPlugFrame::~CPlugFrame()
00027 {
00028 }
00029
00030 BEGIN_MESSAGE_MAP(CPlugFrame, CWnd)
00031
00032 ON_WM_PAINT()
00033 ON_WM_SIZE()
00034 ON_WM_SETFOCUS()
00035
00036 END_MESSAGE_MAP()
00037
00038 BOOL CPlugFrame::Create(CWnd *pParent)
00039 {
00040 CRect rc (0, 0, 100, 50);
00041
00042 if (FALSE == CWnd::Create (AfxRegisterWndClass (CS_DBLCLKS, LoadCursor (NULL, IDC_ARROW),
00043 (HBRUSH) (COLOR_3DFACE+1), NULL), NULL, WS_CHILD | WS_VISIBLE, rc, pParent, 0x111))
00044 return FALSE;
00045
00046 return TRUE;
00047 }
00048
00049 void CPlugFrame::OnPaint()
00050 {
00051 CPaintDC dc(this);
00052
00053 dc.SetTextColor (m_clrCaptionText);
00054 CBrush br (m_clrBkCaption);
00055
00056 CBrush *oldBr = dc.SelectObject (&br);
00057 CFont *oldFont = dc.SelectObject (&m_font);
00058 CPen pen (PS_SOLID, 1, m_clrBkCaption),
00059 penBorder (PS_SOLID, 2, GetSysColor (COLOR_3DDKSHADOW));
00060
00061 CRect rcCaption;
00062 GetClientRect (&rcCaption);
00063 rcCaption.bottom = m_dyCaption - 3;
00064
00065 CPen *oldPen = dc.SelectObject (&pen);
00066
00067
00068 dc.Rectangle (&rcCaption);
00069
00070 dc.SetBkMode (TRANSPARENT);
00071 rcCaption.left = 10;
00072
00073
00074 dc.DrawText (m_strFrameName, &rcCaption, DT_SINGLELINE | DT_VCENTER);
00075
00076
00077
00078 CPen penShadow (PS_SOLID, 1, GetSysColor (COLOR_3DSHADOW));
00079 dc.SelectObject (&penShadow);
00080 dc.MoveTo (0, m_dyCaption - 1);
00081 dc.LineTo (rcCaption.right, m_dyCaption - 1);
00082
00083 dc.SelectObject (oldBr);
00084 dc.SelectObject (oldFont);
00085 dc.SelectObject (oldPen);
00086
00087
00088 }
00089
00090 void CPlugFrame::SetFrameName(LPCTSTR pszName)
00091 {
00092 m_strFrameName = pszName;
00093 Invalidate (FALSE);
00094 }
00095
00096 void CPlugFrame::SetPluginWindow(HWND hWnd)
00097 {
00098 m_wndPlugin = hWnd;
00099 SetupPluginRect ();
00100 }
00101
00102 void CPlugFrame::OnSize(UINT , int , int )
00103 {
00104 if (m_wndPlugin)
00105 SetupPluginRect ();
00106
00107 Invalidate (FALSE);
00108 }
00109
00110 void CPlugFrame::SetupPluginRect()
00111 {
00112 RECT rcThis;
00113
00114 GetClientRect (&rcThis);
00115
00116 rcThis.top += m_dyCaption;
00117
00118 ::MoveWindow (m_wndPlugin, rcThis.left, rcThis.top, rcThis.right - rcThis.left,
00119 rcThis.bottom - rcThis.top, TRUE);
00120 }
00121
00122 void CPlugFrame::OnSetFocus(CWnd* pOldWnd)
00123 {
00124 CWnd::OnSetFocus(pOldWnd);
00125 ::SetFocus (m_wndPlugin);
00126 }