Ejemplo n.º 1
0
void CClosableTabCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
	if (m_bCloseable)
	{
		int iTab = GetTabUnderPoint(point);
		if (iTab != -1)
		{
			CRect rcItem;
			GetItemRect(iTab, rcItem);
			rcItem.InflateRect(2, 2); // get the real tab item rect
			
			bool bVistaThemeActive = theApp.IsVistaThemeActive();
			CRect rcCloseButton;
			GetCloseButtonRect(iTab, rcItem, rcCloseButton, iTab == GetCurSel(), bVistaThemeActive);

			// The visible part of our close icon is one pixel less on each side
			if (!bVistaThemeActive) {
				rcCloseButton.top += 1;
				rcCloseButton.left += 1;
				rcCloseButton.right -= 1;
				rcCloseButton.bottom -= 1;
			}

			if (rcCloseButton.PtInRect(point)) {
				GetParent()->SendMessage(UM_CLOSETAB, (WPARAM)iTab);
				return;
			}
		}
	}
	
	CTabCtrl::OnLButtonUp(nFlags, point);
}
void CClosableTabCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
	if (m_bCloseable)
	{
		int iTabs = GetItemCount();
		for (int i = 0; i < iTabs; i++)
		{
			CRect rcItem;
			GetItemRect(i, rcItem);
			CRect rcCloseButton;
			GetCloseButtonRect(rcItem, rcCloseButton);
			rcCloseButton.top -= 2;
			rcCloseButton.left -= 4;
			rcCloseButton.right += 2;
			rcCloseButton.bottom += 4;
			if (rcCloseButton.PtInRect(point))
			{
				GetParent()->SendMessage(UM_CLOSETAB, (WPARAM)i);
				return;
			}
		}
	}
	
	CTabCtrl::OnLButtonUp(nFlags, point);
}
void CClosableTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CRect rect = lpDrawItemStruct->rcItem;
	int nTabIndex = lpDrawItemStruct->itemID;
	if (nTabIndex < 0)
		return;
	BOOL bSelected = (nTabIndex == GetCurSel());

	TCHAR szLabel[256];
	TC_ITEM tci;
	tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_STATE;
	tci.pszText = szLabel;
	tci.cchTextMax = ARRSIZE(szLabel);
	tci.dwStateMask = TCIS_HIGHLIGHTED;
	if (!GetItem(nTabIndex, &tci))
		return;

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	if (!pDC)
		return;

	int iOldBkMode = pDC->SetBkMode(TRANSPARENT);

	// Draw image on left side
	CImageList* piml = GetImageList();
	if (tci.iImage >= 0 && piml && piml->m_hImageList)
	{
		IMAGEINFO ii;
		piml->GetImageInfo(0, &ii);
		rect.left += bSelected ? 8 : 4;
		piml->Draw(pDC, tci.iImage, CPoint(rect.left, rect.top + 2), ILD_TRANSPARENT);
		rect.left += (ii.rcImage.right - ii.rcImage.left);
		if (!bSelected)
			rect.left += 4;
	}

	bool bCloseable = m_bCloseable;
	if (bCloseable && GetParent()->SendMessage(UM_QUERYTAB, nTabIndex))
		bCloseable = false;

	// Draw 'Close button' at right side
	if (bCloseable && m_ImgLstCloseButton.m_hImageList)
	{
		CRect rcCloseButton;
		GetCloseButtonRect(rect, rcCloseButton);
		m_ImgLstCloseButton.Draw(pDC, 0, rcCloseButton.TopLeft(), ILD_TRANSPARENT);
		rect.right = rcCloseButton.left - 2;
	}

	COLORREF crOldColor = RGB(0, 0, 0);
	if (tci.dwState & TCIS_HIGHLIGHTED)
		crOldColor = pDC->SetTextColor(RGB(192, 0, 0));

	rect.top += 4;
	pDC->DrawText(szLabel, rect, DT_SINGLELINE | DT_TOP | DT_CENTER | DT_NOPREFIX);

	if (tci.dwState & TCIS_HIGHLIGHTED)
		pDC->SetTextColor(crOldColor);
	pDC->SetBkMode(iOldBkMode);
}
Ejemplo n.º 4
0
  /* virtual methods from class Window */
  void OnCreate() override {
    SingleWindow::OnCreate();

#ifdef ENABLE_CLOSE_BUTTON
    close_button.Create(*this, *button_look, _T("Close"),
                        GetCloseButtonRect(GetClientRect()),
                        WindowStyle(),
                        *this, CLOSE);
#endif
  }
Ejemplo n.º 5
0
void CEGPaneBar::OnPaint()
{
	CPaintDC pdc(this);

	CRect rc;
	GetClientRect(rc);
	pdc.FillSolidRect(rc, GetSysColor(COLOR_3DFACE));
	if ( m_pszCaption ) {
		rc = GetCaptionRect();
		HFONT hOldFont = (HFONT) ::SelectObject( pdc.GetSafeHdc(), m_fntCaption );
		pdc.SetBkMode( TRANSPARENT );
		if ( m_bActive ) {
			pdc.FillSolidRect(rc, GetSysColor( COLOR_ACTIVECAPTION ));
			pdc.SetTextColor( GetSysColor( COLOR_CAPTIONTEXT ) );
		} else {
			CPen *pOldPen, pen(PS_SOLID,1,GetSysColor(COLOR_INACTIVECAPTION));
			pOldPen = pdc.SelectObject(&pen);

			pdc.MoveTo( rc.left + 1, rc.top );
			pdc.LineTo( rc.right - 1, rc.top );
			pdc.MoveTo( rc.right - 1, rc.top+1 );
			pdc.LineTo( rc.right - 1, rc.bottom - 1 );
			pdc.MoveTo( rc.right - 2, rc.bottom - 1 );
			pdc.LineTo( rc.left, rc.bottom - 1 );
			pdc.MoveTo( rc.left, rc.bottom - 2 );
			pdc.LineTo( rc.left, rc.top );

			pdc.SelectObject(pOldPen);

			pdc.SetTextColor( GetSysColor( COLOR_WINDOWTEXT ) );
		}
		rc.left += SPLITTER_SIZE;
		pdc.DrawText( m_pszCaption, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER );

		// X-button ( Marlett :: 0x72 )
		rc = GetCloseButtonRect();
		::SelectObject( pdc.GetSafeHdc(), m_fntXButton );
	    pdc.DrawText( _T("\x72"), &rc, DT_CENTER | DT_SINGLELINE | DT_VCENTER );
		
		if ( !m_bClosePressed && m_bCloseHover ) {
			pdc.DrawEdge( rc, BDR_RAISEDINNER , BF_RECT | BF_ADJUST  );
		} else if( m_bClosePressed && m_bCloseHover ) {
			pdc.DrawEdge( rc, BDR_SUNKENINNER , BF_RECT | BF_ADJUST  );
		} else if( m_bClosePressed && !m_bCloseHover ) { 
			pdc.DrawEdge( rc, BDR_RAISEDINNER , BF_RECT | BF_ADJUST  );
		}

		::SelectObject( pdc.GetSafeHdc(), hOldFont );
	}
}
Ejemplo n.º 6
0
UINT CCtrlMessageBar::DoNcHitTest(CPoint point, UINT nCode)
{
  if (nCode == HTNOWHERE || nCode == HTCAPTION)
  {
    // lets see if we really want to consider it as being in the message-bar
    CRect rc = GetRect(); // get rect in client co-ords
    CPoint pt(point);
    m_pCtrlMessageBarThis->ClientToScreen(&rc);
    CRect rcClose = GetCloseButtonRect(rc);
    if (rcClose.PtInRect(pt) && m_bMessageBarCloseButton)
      nCode = HTMESSAGEBARCLOSE;
    else if (rc.PtInRect(pt))
      nCode = HTMESSAGEBAR;
  }
  return nCode;
}
Ejemplo n.º 7
0
void CEGPaneBar::OnLButtonUp(UINT nFlags, CPoint point)
{
	if ( m_bDragging )
	{
		ReleaseCapture();
		OnInvertTracker(m_dragRect);
		DWORD dwStyle = GetBarStyle();

		CRect rcCaption = GetCaptionRect();
		int nMinHeight = rcCaption.Height() + SPLITTER_SIZE*2;
		int nMinWidth = nMinHeight*4;

		if( ( dwStyle & CBRS_TOP ) == CBRS_TOP ) {
			m_iSize = point.y > nMinHeight ? point.y : nMinHeight;
		} else if( ( dwStyle & CBRS_BOTTOM ) == CBRS_BOTTOM ) {
			m_iSize =  m_iSize - point.y;
			if ( m_iSize < nMinHeight )
				m_iSize = nMinHeight;
		} else if( ( dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) {
			m_iSize = m_iSize - point.x;
			if ( m_iSize < nMinWidth )
				m_iSize = nMinWidth;
		} else {
			m_iSize = point.x > nMinWidth ? point.x : nMinWidth;
		}
		GetParentFrame()->RecalcLayout();
	}
	m_bDragging = FALSE;
	BOOL bOldClosePressed = m_bClosePressed;
	m_bClosePressed = FALSE;
	if ( bOldClosePressed ) {
		ReleaseCapture();
		CRect rcCloseButton = GetCloseButtonRect();
		if ( rcCloseButton.PtInRect( point ) ) {
			HidePane( );
		} else {
			InvalidateCaption();
		}
	}

	CControlBar::OnLButtonUp(nFlags, point);
}
Ejemplo n.º 8
0
void CClosableTabCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
	if (m_bCloseable)
	{
		int iTab = GetTabUnderPoint(point);
		if (iTab != -1)
		{
			CRect rcItem;
			GetItemRect(iTab, rcItem);
			CRect rcCloseButton;
			GetCloseButtonRect(rcItem, rcCloseButton);
			rcCloseButton.top -= 2;
			rcCloseButton.left -= 4;
			rcCloseButton.right += 2;
			rcCloseButton.bottom += 4;
			if (rcCloseButton.PtInRect(point)) {
				GetParent()->SendMessage(UM_CLOSETAB, (WPARAM)iTab);
				return;
			}
		}
	}
	
	CTabCtrl::OnLButtonUp(nFlags, point);
}
Ejemplo n.º 9
0
void CClosableTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	CRect rect(lpDIS->rcItem);
	int nTabIndex = lpDIS->itemID;
	if (nTabIndex < 0)
		return;

	TCHAR szLabel[256];
	TC_ITEM tci;
	tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_STATE;
	tci.pszText = szLabel;
	tci.cchTextMax = _countof(szLabel);
	tci.dwStateMask = TCIS_HIGHLIGHTED;
	if (!GetItem(nTabIndex, &tci))
		return;
	//TRACE("CClosableTabCtrl::DrawItem: item=%u, state=%08x, color=%08x, rc=%3d,%3d,%3dx%3d\n", nTabIndex, tci.dwState, GetTextColor(lpDIS->hDC), lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right - lpDIS->rcItem.left, lpDIS->rcItem.bottom - lpDIS->rcItem.top);

	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	if (!pDC)
		return;

	CRect rcFullItem(lpDIS->rcItem);
	bool bSelected = (lpDIS->itemState & ODS_SELECTED) != 0;

	///////////////////////////////////////////////////////////////////////////////////////
	// Adding support for XP Styles (Vista Themes) for owner drawn tab controls simply
	// does *not* work under Vista. Maybe it works under XP (did not try), but that is
	// meaningless because under XP a owner drawn tab control is already rendered *with*
	// the proper XP Styles. So, for XP there is no need to care about the theme API at all.
	//
	// However, under Vista, a tab control which has the TCS_OWNERDRAWFIXED
	// style gets additional 3D-borders which are applied by Vista *after* WM_DRAWITEM
	// was processed. Thus, there is no known workaround available to prevent Vista from
	// adding those old fashioned 3D-borders. We can render the tab control items within
	// the WM_DRAWITEM handler in whatever style we want, but Vista will in each case
	// overwrite the borders of each tab control item with old fashioned 3D-borders...
	//
	// To complete this experience, tab controls also do not support NMCUSTOMDRAW. So, the
	// only known way to customize a tab control is by using TCS_OWNERDRAWFIXED which does
	// however not work properly under Vista.
	//
	// The "solution" which is currently implemented to prevent Vista from drawing those
	// 3D-borders is by using "ExcludeClipRect" to reduce the drawing area which is used
	// by Windows after WM_DRAWITEM was processed. This "solution" is very sensitive to
	// the used rectangles and offsets in general. Incrementing/Decrementing one of the
	// "rcItem", "rcFullItem", etc. rectangles makes the entire "solution" flawed again
	// because some borders would become visible again.
	//
	HTHEME hTheme = NULL;
	int iPartId = TABP_TABITEM;
	int iStateId = TIS_NORMAL;
	bool bVistaHotTracked = false;
	bool bVistaThemeActive = theApp.IsVistaThemeActive();
	if (bVistaThemeActive)
	{
		// To determine if the current item is in 'hot tracking' mode, we need to evaluate
		// the current foreground color - there is no flag which would indicate this state 
		// more safely. This applies only for Vista and for tab controls which have the
		// TCS_OWNERDRAWFIXED style.
		bVistaHotTracked = pDC->GetTextColor() == GetSysColor(COLOR_HOTLIGHT);

		hTheme = g_xpStyle.OpenThemeData(m_hWnd, L"TAB");
		if (hTheme)
		{
			if (bSelected) {
				// get the real tab item rect
				rcFullItem.left += 1;
				rcFullItem.right -= 1;
				rcFullItem.bottom -= 1;
			}
			else
				rcFullItem.InflateRect(2, 2); // get the real tab item rect

			CRect rcBk(rcFullItem);
			if (bSelected)
			{
				iStateId = TTIS_SELECTED;
				if (nTabIndex == 0) {
					// First item
					if (nTabIndex == GetItemCount() - 1)
						iPartId = TABP_TOPTABITEMBOTHEDGE; // First & Last item
					else
						iPartId = TABP_TOPTABITEMLEFTEDGE;
				}
				else if (nTabIndex == GetItemCount() - 1) {
					// Last item
					iPartId = TABP_TOPTABITEMRIGHTEDGE;
				}
				else {
					iPartId = TABP_TOPTABITEM;
				}
			}
			else
			{
				rcBk.top += 2;
				iStateId = bVistaHotTracked ? TIS_HOT : TIS_NORMAL;
				if (nTabIndex == 0) {
					// First item
					if (nTabIndex == GetItemCount() - 1)
						iPartId = TABP_TABITEMBOTHEDGE; // First & Last item
					else
						iPartId = TABP_TABITEMLEFTEDGE;
				}
				else if (nTabIndex == GetItemCount() - 1) {
					// Last item
					iPartId = TABP_TABITEMRIGHTEDGE;
				}
				else {
					iPartId = TABP_TABITEM;
				}
			}
			if (g_xpStyle.IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId))
				g_xpStyle.DrawThemeParentBackground(m_hWnd, *pDC, &rcFullItem);
			g_xpStyle.DrawThemeBackground(hTheme, *pDC, iPartId, iStateId, &rcBk, NULL);
		}
	}

	// Following background clearing is needed for:
	//	WinXP/Vista (when used without an application theme)
	//	Vista (when used with an application theme but without a theme for the tab control)
	if (   (!g_xpStyle.IsThemeActive() || !g_xpStyle.IsAppThemed())
		|| (hTheme == NULL && bVistaThemeActive) )
		pDC->FillSolidRect(&lpDIS->rcItem, GetSysColor(COLOR_BTNFACE));

	int iOldBkMode = pDC->SetBkMode(TRANSPARENT);

	// Draw image on left side
	CImageList *piml = GetImageList();
	if (tci.iImage >= 0 && piml && piml->m_hImageList)
	{
		IMAGEINFO ii;
		piml->GetImageInfo(0, &ii);
		rect.left += bSelected ? 8 : 4;
		piml->Draw(pDC, tci.iImage, CPoint(rect.left, rect.top + 2), ILD_TRANSPARENT);
		rect.left += (ii.rcImage.right - ii.rcImage.left);
		if (!bSelected)
			rect.left += 4;
	}

	bool bCloseable = m_bCloseable;
	if (bCloseable && GetParent()->SendMessage(UM_QUERYTAB, nTabIndex))
		bCloseable = false;

	// Draw 'Close button' at right side
	if (bCloseable && m_ImgLstCloseButton.m_hImageList)
	{
		CRect rcCloseButton;
		GetCloseButtonRect(nTabIndex, rect, rcCloseButton, bSelected, bVistaThemeActive);

		HTHEME hThemeNC = bVistaThemeActive ? g_xpStyle.OpenThemeData(m_hWnd, _T("WINDOW")) : NULL;
		if (hThemeNC) {
			// Possible "Close" parts: WP_CLOSEBUTTON, WP_SMALLCLOSEBUTTON, WP_MDICLOSEBUTTON
			int iPartId = WP_SMALLCLOSEBUTTON;
			int iStateId = (bSelected || bVistaHotTracked) ? CBS_NORMAL : CBS_DISABLED;
			if (g_xpStyle.IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId))
				g_xpStyle.DrawThemeParentBackground(m_hWnd, *pDC, &rcCloseButton);
			g_xpStyle.DrawThemeBackground(hThemeNC, *pDC, iPartId, iStateId, rcCloseButton, NULL);
			g_xpStyle.CloseThemeData(hThemeNC);
		}
		else {
			m_ImgLstCloseButton.Draw(pDC, (bSelected || bVistaHotTracked) ? 0 : 1, rcCloseButton.TopLeft(), ILD_TRANSPARENT);
		}

		rect.right = rcCloseButton.left - 2;
		if (bSelected)
			rect.left += hTheme ? 4 : 2;
	}

	COLORREF crOldColor = CLR_NONE;
	if (tci.dwState & TCIS_HIGHLIGHTED)
		crOldColor = pDC->SetTextColor(RGB(192, 0, 0));
	else if (bVistaHotTracked)
		crOldColor = pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));

	rect.top += bSelected ? 4 : 3;
	// Vista: Tab control has troubles with determining the width of a tab if the
	// label contains one '&' character. To get around this, we use the old code which
	// replaces one '&' character with two '&' characters and we do not specify DT_NOPREFIX
	// here when drawing the text.
	//
	// Vista: "DrawThemeText" can not be used in case we need a certain foreground color. Thus we always us
	// "DrawText" to always get the same font and metrics (just for safety).
	pDC->DrawText(szLabel, rect, DT_SINGLELINE | DT_TOP | DT_CENTER /*| DT_NOPREFIX*/);

	if (crOldColor != CLR_NONE)
		pDC->SetTextColor(crOldColor);
	pDC->SetBkMode(iOldBkMode);

	if (hTheme)
	{
		CRect rcClip(rcFullItem);
		if (bSelected) {
			rcClip.left -= 2 + 1;
			rcClip.right += 2 + 1;
		}
		else {
			rcClip.top += 2;
		}
		pDC->ExcludeClipRect(&rcClip);
		g_xpStyle.CloseThemeData(hTheme);
	}
}
Ejemplo n.º 10
0
void CCtrlMessageBar::DoNcPaint()
{
  if (m_pCtrlMessageBarThis == NULL)
    return;
  if (! m_bShowMessageBar && m_nMessageBarHeight > 0)
    m_pCtrlMessageBarThis->SetWindowPos(NULL, 0, 0, 0, 0, s_dwSWPFlags);
  if (! m_bShowMessageBar || m_sMessageBarText.IsEmpty() || m_nMessageBarHeight == 0)
    return;

  CDC* pDC = m_pCtrlMessageBarThis->GetWindowDC();

  COLORREF crBackground = m_bMouseHover ? (m_crBackgroundHilite == CLR_DEFAULT ? 
				GetSysColor(COLOR_HIGHLIGHT) : m_crBackgroundHilite) : 
			    (m_crBackgroundNormal == CLR_DEFAULT ? 
				GetSysColor(COLOR_INFOBK) : m_crBackgroundNormal);
  COLORREF crText = m_bMouseHover ? (m_crTextHilite == CLR_DEFAULT ? 
				GetSysColor(COLOR_HIGHLIGHTTEXT) : m_crTextHilite) : 
			    (m_crTextNormal == CLR_DEFAULT ? 
				GetSysColor(COLOR_INFOTEXT) : m_crTextNormal);

  if (pDC != NULL)
  {
    CRect rc = GetRect(TRUE); // get rect in window co-ords
    pDC->FillSolidRect(rc, crBackground);
    COLORREF crBkOld = pDC->SetBkColor(crBackground);
    COLORREF crTextOld = pDC->SetTextColor(crText);
	

    CFont* pFontOld = pDC->SelectObject(&font);
    rc.left += 2; // offset the text a little
    rc.right -= 1;

    if (m_nMessageBarImage != -1 && m_imlMessageBar.m_hImageList != NULL)
    {
      rc.top += 2;
      CPoint pt(rc.TopLeft());
      m_imlMessageBar.Draw(pDC, m_nMessageBarImage, pt, ILD_NORMAL);
      IMAGEINFO ii;
      m_imlMessageBar.GetImageInfo(m_nMessageBarImage, &ii);
      rc.left += abs(ii.rcImage.right - ii.rcImage.left) + 2;
    }

    if (m_bMessageBarCloseButton)
    {
      CRect rcClose = GetCloseButtonRect(rc);
      CFont font;
      font.CreatePointFont(CLOSE_BUTTON_FONT_SIZE, CLOSE_BUTTON_FONT, pDC);
      CFont* pFontOld2 = pDC->SelectObject(&font);
      pDC->DrawText(CLOSE_BUTTON_CHAR, rcClose, CLOSE_BUTTON_DRAW_FLAGS);
      pDC->SelectObject(pFontOld2);
    }

    CString sText(m_sMessageBarText);
    pDC->DrawText(sText.GetBuffer(sText.GetLength() + 4), -1, &rc, m_bWrapMessageBarText ? s_dwDrawTextFlagsWrap : s_dwDrawTextFlags | DT_MODIFYSTRING);
    sText.ReleaseBuffer();
    m_bTextTruncated = (sText != m_sMessageBarText);
    pDC->SetBkColor(crBkOld);
    pDC->SetTextColor(crTextOld);
    pDC->SelectObject(pFontOld);
    if (m_bTextTruncated)
    {
      // add tool-tip tool
      if (m_tipMessageBar.m_hWnd == NULL || ! ::IsWindow(m_tipMessageBar.m_hWnd))
	m_tipMessageBar.Create(m_pCtrlMessageBarThis);
      m_tipMessageBar.DelTool(m_pCtrlMessageBarThis, ID_TOOLTIP);
      m_tipMessageBar.AddTool(m_pCtrlMessageBarThis, m_sMessageBarText, GetRect(), ID_TOOLTIP);
    }
  }
}
Ejemplo n.º 11
0
LRESULT CEventInfoPopup::OnMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg) {
	case WM_CREATE:
		m_RichEditUtil.LoadRichEditLib();
		m_hwndEdit=::CreateWindowEx(0,m_RichEditUtil.GetWindowClassName(),TEXT(""),
			WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL | ES_NOHIDESEL,
			0,0,0,0,hwnd,(HMENU)1,m_hinst,NULL);
		SetWindowFont(m_hwndEdit,m_Font.GetHandle(),FALSE);
		::SendMessage(m_hwndEdit,EM_SETEVENTMASK,0,ENM_MOUSEEVENTS | ENM_LINK);
		::SendMessage(m_hwndEdit,EM_SETBKGNDCOLOR,0,m_BackColor);
		return 0;

	case WM_SIZE:
		CalcTitleHeight();
		::MoveWindow(m_hwndEdit,0,m_TitleHeight,
					 LOWORD(lParam),max(HIWORD(lParam)-m_TitleHeight,0),TRUE);
		return 0;

	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			RECT rc;
			HFONT hfontOld;
			int OldBkMode;
			COLORREF OldTextColor;

			::BeginPaint(hwnd,&ps);
			::GetClientRect(hwnd,&rc);
			rc.bottom=m_TitleHeight;
			Theme::FillGradient(ps.hdc,&rc,&m_TitleBackGradient);
			hfontOld=DrawUtil::SelectObject(ps.hdc,m_TitleFont);
			OldBkMode=::SetBkMode(ps.hdc,TRANSPARENT);
			OldTextColor=::SetTextColor(ps.hdc,m_TitleTextColor);
			TCHAR szText[EpgUtil::MAX_EVENT_TIME_LENGTH];
			int Length=EpgUtil::FormatEventTime(&m_EventInfo,szText,lengthof(szText),
												EpgUtil::EVENT_TIME_DATE | EpgUtil::EVENT_TIME_YEAR);
			if (Length>0)
				::TextOut(ps.hdc,0,0,szText,Length);
			rc.top+=m_TitleLineHeight;
			rc.right-=m_ButtonSize+m_ButtonMargin*2;
			DrawUtil::DrawWrapText(ps.hdc,m_EventInfo.GetEventName(),&rc,m_TitleLineHeight);
			::SelectObject(ps.hdc,hfontOld);
			::SetBkMode(ps.hdc,OldBkMode);
			::SetTextColor(ps.hdc,OldTextColor);
			GetCloseButtonRect(&rc);
			::DrawFrameControl(ps.hdc,&rc,DFC_CAPTION,DFCS_CAPTIONCLOSE | DFCS_MONO);
			::EndPaint(hwnd,&ps);
		}
		return 0;

	case WM_ACTIVATE:
		if (LOWORD(wParam)==WA_INACTIVE) {
			Hide();
		}
		return 0;

	case WM_ACTIVATEAPP:
		if (wParam==0) {
			Hide();
		}
		return 0;

	case WM_NCHITTEST:
		{
			POINT pt;
			RECT rc;

			pt.x=GET_X_LPARAM(lParam);
			pt.y=GET_Y_LPARAM(lParam);
			::ScreenToClient(hwnd,&pt);
			GetCloseButtonRect(&rc);
			if (::PtInRect(&rc,pt))
				return HTCLOSE;
			::GetClientRect(hwnd,&rc);
			rc.bottom=m_TitleHeight;
			if (::PtInRect(&rc,pt))
				return HTCAPTION;
		}
		break;

	case WM_NCLBUTTONDOWN:
		if (wParam==HTCLOSE) {
			::SendMessage(hwnd,WM_CLOSE,0,0);
			return 0;
		}
		break;

	case WM_NCRBUTTONDOWN:
		if (wParam==HTCAPTION) {
			POINT pt={GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)};
			HMENU hmenu=::CreatePopupMenu();

			::AppendMenu(hmenu,MF_STRING | MF_ENABLED,1,TEXT("番組名をコピー(&C)"));
			int Command=::TrackPopupMenu(hmenu,TPM_RIGHTBUTTON | TPM_RETURNCMD,pt.x,pt.y,0,hwnd,NULL);
			::DestroyMenu(hmenu);
			switch (Command) {
			case 1:
				CopyTextToClipboard(hwnd,m_EventInfo.GetEventName());
				break;
			}
			return 0;
		}
		break;

	case WM_MOUSEWHEEL:
		return ::SendMessage(m_hwndEdit,uMsg,wParam,lParam);

	case WM_NCMOUSEMOVE:
		{
			TRACKMOUSEEVENT tme;

			tme.cbSize=sizeof(TRACKMOUSEEVENT);
			tme.dwFlags=TME_LEAVE | TME_NONCLIENT;
			tme.hwndTrack=hwnd;
			::TrackMouseEvent(&tme);
		}
		return 0;

	case WM_NCMOUSELEAVE:
		{
			POINT pt;
			RECT rc;

			::GetCursorPos(&pt);
			::GetWindowRect(hwnd,&rc);
			if (!::PtInRect(&rc,pt))
				Hide();
		}
		return 0;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case EN_MSGFILTER:
			if (reinterpret_cast<MSGFILTER*>(lParam)->msg==WM_RBUTTONDOWN) {
				HMENU hmenu=::CreatePopupMenu();

				::AppendMenu(hmenu,MF_STRING | MF_ENABLED,1,TEXT("コピー(&C)"));
				::AppendMenu(hmenu,MF_STRING | MF_ENABLED,2,TEXT("すべて選択(&A)"));
				::AppendMenu(hmenu,MF_STRING | MF_ENABLED,3,TEXT("番組名をコピー(&E)"));
				if (m_pEventHandler!=NULL)
					m_pEventHandler->OnMenuPopup(hmenu);
				POINT pt;
				::GetCursorPos(&pt);
				int Command=::TrackPopupMenu(hmenu,TPM_RIGHTBUTTON | TPM_RETURNCMD,pt.x,pt.y,0,hwnd,NULL);
				::DestroyMenu(hmenu);
				switch (Command) {
				case 1:
					if (::SendMessage(m_hwndEdit,EM_SELECTIONTYPE,0,0)==SEL_EMPTY) {
						CRichEditUtil::CopyAllText(m_hwndEdit);
					} else {
						::SendMessage(m_hwndEdit,WM_COPY,0,0);
					}
					break;
				case 2:
					CRichEditUtil::SelectAll(m_hwndEdit);
					break;
				case 3:
					CopyTextToClipboard(hwnd,m_EventInfo.GetEventName());
					break;
				default:
					if (Command>=CEventHandler::COMMAND_FIRST)
						m_pEventHandler->OnMenuSelected(Command);
					break;
				}
			}
			return 0;

		case EN_LINK:
			{
				ENLINK *penl=reinterpret_cast<ENLINK*>(lParam);

				if (penl->msg==WM_LBUTTONUP)
					CRichEditUtil::HandleLinkClick(penl);
			}
			return 0;
		}
		break;

	case WM_CLOSE:
		Hide();
		return 0;
	}

	return ::DefWindowProc(hwnd,uMsg,wParam,lParam);
}