Beispiel #1
0
void mew::theme::TabDrawItem(HDC hDC, RECT bounds, PCWSTR text, DWORD status, HFONT hFontNormal, HFONT hFontBold, COLORREF clrActiveTab, COLORREF clrActiveText, COLORREF clrInactiveText)
{
	DCHandle dc(hDC);
	if(status & CHECKED)
	{
		bounds.right  -= 1;
		bounds.bottom += 1;

		dc.FillSolidRect(&bounds, clrActiveTab);

		Pen penHilight(::GetSysColor(COLOR_BTNHIGHLIGHT));
		Pen penText(clrActiveText);
		dc.DrawLine(penHilight, bounds.left, bounds.top, bounds.left, bounds.bottom);
		dc.DrawLine(penText, bounds.right, bounds.top, bounds.right, bounds.bottom-2);
	}
	else
	{
		Pen pen(::GetSysColor(COLOR_BTNSHADOW));
		if(false)//(bHasBottomStyle)
			dc.DrawLine(pen, bounds.right-1, bounds.top + 3, bounds.right-1, bounds.bottom - 1);
		else
			dc.DrawLine(pen, bounds.right-1, bounds.top + 2, bounds.right-1, bounds.bottom - 2);
	}
	CFontHandle font;
	if(status & FOCUSED)
	{
		if(status & ENABLED)
			dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));
		else
			dc.SetTextColor(RGB(255,0,0));
		font = hFontBold;
	}
	else
	{
		if(status & ENABLED)
			dc.SetTextColor(clrInactiveText);
		else
			dc.SetTextColor(RGB(255,0,0));
		font = hFontNormal;
	}
	if(status & HOT)
	{
		LOGFONT info;
		font.GetLogFont(&info);
		info.lfUnderline = true;
		CFont fontUL;
		fontUL.CreateFontIndirect(&info);
		dc.DrawText(fontUL, text, &bounds, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
	}
	else
	{
		dc.DrawText(font, text, &bounds, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
	}
}
Beispiel #2
0
void CMediaInfoDlg::GetMediaInfo(LPCTSTR filename)
{
	MediaInfoLib::MediaInfo MI;
	CString info, line, str;

	m_wndListCtrl.DeleteAllItems();

	if (MI.Open(filename)) {
		MI.Option(_T("Complete"));
		info = MI.Inform().c_str();

		int index = 0;
		while(true) {
			index = info.Find(_T("\n"));
			if(index < 0)
				break;

			line = info.Left(index);
			info.Delete(0, index+1);

			line.Trim();
			if(line.IsEmpty())
				continue;

			index = line.Find(_T(" : "));
			if(index <= 0) {
				int nItem = m_wndListCtrl.AddItem(line);

				LOGFONT lf;
				CFontHandle font = m_wndListCtrl.GetItemFont(nItem, 0);
				font.GetLogFont(lf);
				lf.lfWeight = FW_BOLD;
				HFONT hfont = CreateFontIndirect(&lf);
				m_wndListCtrl.SetItemFont(nItem, 0, hfont);

			} else {
				int nItem = m_wndListCtrl.AddItem(_T(""));

				str = line.Left(index);
				line.Delete(0, index+3);

				str.Trim();
				line.Trim();

				m_wndListCtrl.SetItemText(nItem, 1, str);
				m_wndListCtrl.SetItemText(nItem, 2, line);
			}
		}

		MI.Close();
	}
}
Beispiel #3
0
void
CNdasMenuBitmapHandler::
OnDrawStatusText(
	LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDCHandle dc = lpDrawItemStruct->hDC;
	CRect rect(&lpDrawItemStruct->rcItem);
	rect.bottom -= 2;

	COLORREF oldBkColor = dc.SetBkColor(RGB(255,255,225));

	CBrush brush = ::CreateSolidBrush(RGB(255,255,225));
	
	CPen pen = ::CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DDKSHADOW)); 

	HBRUSH hOldBrush = dc.SelectBrush(brush);
	HPEN hOldPen = dc.SelectPen(pen);

//	dc.Rectangle(rect);

	dc.RoundRect(rect,CPoint(rect.Height() /4, rect.Height() / 4));

	(void) dc.SelectPen(hOldPen);
	(void) dc.SelectBrush(hOldBrush);

	CRect rectText(rect);
	rectText.left += GetSystemMetrics(SM_CXMENUCHECK) + 2;

	CString strStatus;
	ATLVERIFY(strStatus.LoadString(static_cast<UINT>(lpDrawItemStruct->itemData)));

	CFontHandle curFont = dc.GetCurrentFont();
	LOGFONT logFont;
	curFont.GetLogFont(&logFont);
	logFont.lfWeight = FW_BOLD;
	CFont newFont = ::CreateFontIndirect(&logFont);
	CFontHandle oldFont = dc.SelectFont(newFont);

//	COLORREF oldTextColor = dc.SetTextColor(RGB(40,40,233));

	dc.DrawText(
		strStatus,
		strStatus.GetLength(),
		&rectText,
		DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_NOPREFIX | 
		DT_VCENTER);

	dc.SelectFont(oldFont);
//	dc.SetTextColor(oldTextColor);
	dc.SetBkColor(oldBkColor);
}
Beispiel #4
0
void CMediaInfoDlg::loadInfoFile(LPCTSTR filename)
{
	CAtlStdioFile file;
	CString str, str1;

	m_wndListCtrl.DeleteAllItems();
	
	if(SUCCEEDED(file.Create(filename, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING))) {
		while(file.ReadLineC(str, codepage)) {
			int index = str.Find(_T(",_,"));
			if(index <= 0)
				continue;
			str1 = str.Left(index);
			int nItem = m_wndListCtrl.AddItem(str1);

			str.Delete(0, index + 3);

			index = str.Find(_T(",_,"));
			if(index <= 0)
				continue;

			LOGFONT lf;
			CFontHandle font = m_wndListCtrl.GetItemFont(nItem, 0);
			font.GetLogFont(lf);
			lf.lfWeight = FW_BOLD;
			HFONT hfont = CreateFontIndirect(&lf);
			m_wndListCtrl.SetItemFont(nItem, 0, hfont);

			str1 = str.Left(index);
			str.Delete(0, index + 3);

			m_wndListCtrl.SetItemText(nItem, 1, str1);
			m_wndListCtrl.SetItemText(nItem, 2, str);
		}
		file.Close();
	}

	DeleteFile(filename);
}
BOOL CMailAlert::OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
{
    CAlertDialog::OnInitDialog(wndFocus, lInitParam);
    m_message = GetDlgItem(IDC_STATIC_MSG2);
    m_ctrlFrom.SubclassWindow(GetDlgItem(IDC_STATIC_FROM));
    m_ctrlTitle.SubclassWindow(GetDlgItem(IDC_STATIC_TITLE));
    m_ctrlIcon.SubclassWindow(GetDlgItem(IDC_STATIC_ICON));
    m_btnFlag.SubclassWindow(GetDlgItem(IDC_BUTTON_FLAG));
    m_btnDelete.SubclassWindow(GetDlgItem(IDC_BUTTON_DELETE));
    m_btnClose.SubclassWindow(GetDlgItem((IDCANCEL)));
    m_ctrlContent.SubclassWindow(GetDlgItem(IDC_STATIC_CONTENT));

    LOGFONT lf;
    CFontHandle f = m_ctrlFrom.GetFont();
    f.GetLogFont(&lf);
    lf.lfWeight = FW_BOLD;

    m_fontFrom.CreateFontIndirect (&lf);
    m_ctrlFrom.SetFont(m_fontFrom);

    m_ctrlFrom.SetWindowText(_T("Marius Bancila"));
    m_ctrlTitle.SetWindowText(_T("This is a test mail"));
    m_ctrlContent.SetWindowText(_T("This is a notification window that should apear on top of the tray window."));

    m_ctrlIcon.SetIcon(IDI_MAIL, 32, 32);
    m_ctrlIcon.SetTransparentColor(RGB(0,0,0));

    m_btnFlag.SetBitmap(IDB_BITMAP_FLAG);
    m_btnFlag.SetTransparentColor(RGB(192,192,192));
    m_btnFlag.SetHighlightColor(RGB(200, 200, 100));

    m_btnDelete.SetBitmap(IDB_BITMAP_DELETE);
    m_btnDelete.SetTransparentColor(RGB(192,192,192));
    m_btnDelete.SetHighlightBackground(FALSE);

    return true;
}
LRESULT 
CNdasDevicePropGeneralPage::OnInitDialog(HWND hwndFocus, LPARAM lParam)
{
	ATLASSERT(m_pDevice != 0);

	m_hCursor = AtlLoadSysCursor(IDC_ARROW);

	m_wndDeviceName.Attach(GetDlgItem(IDC_DEVICE_NAME));
	m_wndDeviceId.Attach(GetDlgItem(IDC_DEVICE_ID));
	m_wndDeviceStatus.Attach(GetDlgItem(IDC_DEVICE_STATUS));
	m_wndDeviceWriteKey.Attach(GetDlgItem(IDC_DEVICE_WRITE_KEY));
	m_wndAddRemoveWriteKey.Attach(GetDlgItem(IDC_ADD_WRITE_KEY));

	m_wndUnitDeviceGroup.Attach(GetDlgItem(IDC_UNITDEVICE_GROUP));
	m_wndUnitDeviceIcon.Attach(GetDlgItem(IDC_UNITDEVICE_TYPE_ICON));
	m_wndUnitDeviceType.Attach(GetDlgItem(IDC_UNITDEVICE_TYPE));
	m_wndUnitDeviceStatus.Attach(GetDlgItem(IDC_UNITDEVICE_STATUS));
	m_wndUnitDeviceCapacity.Attach(GetDlgItem(IDC_UNITDEVICE_CAPACITY));
	m_wndUnitDeviceROHosts.Attach(GetDlgItem(IDC_UNITDEVICE_RO_HOSTS));
	m_wndUnitDeviceRWHosts.Attach(GetDlgItem(IDC_UNITDEVICE_RW_HOSTS));
	m_wndLogDeviceTree.Attach(GetDlgItem(IDC_LOGDEV_TREE));

	m_wndUnitDeviceList = GetDlgItem(IDC_UNITDEVICE_LIST);

	// Temporary edit control to get an effective password character
	{
		CEdit wndPassword;
		wndPassword.Create(m_hWnd, NULL, NULL, WS_CHILD | ES_PASSWORD);
		m_chConcealed = wndPassword.GetPasswordChar();
		wndPassword.DestroyWindow();
	}

	BOOL fSuccess = m_imageList.CreateFromImage(
		IDB_UNITDEVICES, 
		32, 
		1, 
		CLR_DEFAULT, 
		IMAGE_BITMAP,
		LR_CREATEDIBSECTION | LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
	ATLASSERT(fSuccess && "Loading IDB_UNITDEVICES failed");

	_GrabUnitDeviceControls();

	// get the bold font
	CFontHandle boldFont;
	{
		CFontHandle dlgFont = GetFont();
		LOGFONT logFont;
		dlgFont.GetLogFont(&logFont);
		logFont.lfWeight = FW_BOLD;
		ATLVERIFY(boldFont.CreateFontIndirect(&logFont));
	}

	m_wndUnitDeviceType.SetFont(boldFont);

	// Cover up control, be sure to create this after FillUnitDeviceControls()
	{
		CRect rect;
		m_wndUnitDeviceGroup.GetClientRect(&rect);
		::MapWindowPoints(m_wndUnitDeviceGroup, HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2);
		::MapWindowPoints(HWND_DESKTOP, m_hWnd, reinterpret_cast<LPPOINT>(&rect), 2);
		rect.DeflateRect(10,50,10,10);
		m_wndNA.Create(m_hWnd, rect, NULL, WS_CHILD | SS_CENTER);
		CString str = MAKEINTRESOURCE(IDS_UNITDEVICE_NONE);
		ATLTRACE("NA: %ws\n", str);
		m_wndNA.SetWindowText(str);
		m_wndNA.SetFont(GetFont());
		m_wndNA.EnableWindow(FALSE);
	}
	{
		CRect rect;
		m_wndLogDeviceTree.GetWindowRect(&rect);
		::MapWindowPoints(HWND_DESKTOP, m_hWnd, reinterpret_cast<LPPOINT>(&rect), 2);
		// rect.DeflateRect(10,10,10,10);
		CString str = MAKEINTRESOURCE(IDS_LOGDEV_INFO_UNAVAILABLE);
		m_wndLogDeviceNA.Create(m_hWnd, rect, str, 
			WS_CHILD | WS_DISABLED | 
			BS_FLAT | BS_CENTER | BS_VCENTER | BS_TEXT);
		// m_wndLogDeviceNA.Create( Create(m_hWnd, rect, NULL, WS_CHILD | SS_CENTER, WS_EX_TRANSPARENT);
		ATLTRACE(_T("LogDevice N/A: %s"), str);
		// m_wndLogDeviceNA.SetWindowText(str);
		m_wndLogDeviceNA.SetFont(GetFont());
		m_wndLogDeviceNA.EnableWindow(FALSE);
	}

	_InitData();

	// Support F5 to refresh
	ACCEL accel = {0};
	accel.fVirt = FVIRTKEY;
	accel.key = VK_F5;
	accel.cmd = IDC_REFRESH_HOST;

	m_hAccel = ::CreateAcceleratorTable(&accel, 1);
	ATLASSERT(NULL != m_hAccel);

	return 0;
}
Beispiel #7
0
void 
CNBTreeListView::DrawTreeItem(LPNMTVCUSTOMDRAW lptvcd, UINT iState, const RECT& rcItem)
{
	CDCHandle dc = lptvcd->nmcd.hdc;
	HTREEITEM hItem = (HTREEITEM) lptvcd->nmcd.dwItemSpec;

	tMapItem* pVal = m_mapItems.Lookup(hItem);
	if( pVal == NULL ) return;

	// NOTE: Having an ImageList attached to the TreeView control seems
	//       to produce some extra WM_ERASEBKGND msgs, which we can use to
	//       optimize the painting...
	CImageList il = m_ctrlTree.GetImageList(TVSIL_NORMAL);

	// If the item had focus then draw it
	// NOTE: Only when images are used (see note above)
	// FIX-BY-PATRIA: DrawFocusRect should be done later
	//if( (iState & CDIS_FOCUS) != 0 && !il.IsNull() ) {
	//	RECT rcFocus = rcItem;
	//	rcFocus.left = 1;
	//	dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));
	//	dc.DrawFocusRect(&rcFocus);
	//}

	// If it's selected, paint the selection background
	if( iState & CDIS_SELECTED  && iState & CDIS_FOCUS) {
		RECT rcHigh = rcItem;
		dc.FillSolidRect(&rcHigh, ::GetSysColor(COLOR_HIGHLIGHT));
	}
	else if( il.IsNull() ) {
		RECT rcHigh = rcItem;
		dc.FillSolidRect(&rcHigh, lptvcd->clrTextBk);
	}

	// Always write text with background
	dc.SetBkMode(OPAQUE);
	dc.SetBkColor(::GetSysColor((iState & CDIS_SELECTED) != 0 ? COLOR_HIGHLIGHT : COLOR_WINDOW));

	// Draw all columns of the item
	RECT rc = rcItem;
	int cnt = pVal->GetSize();
	for( int i = 0; i < cnt; i++ ) {
		LPTLVITEM pItem = (*pVal)[i];
		ATLASSERT(pItem);

		if( i != 0 ) rc.left = m_rcColumns[i].left;
		rc.right = m_rcColumns[i].right;

		if( pItem->mask & TLVIF_IMAGE ) {
			ATLASSERT(!il.IsNull());
			int cx, cy;
			il.GetIconSize(cx, cy);
			il.DrawEx(
				pItem->iImage, 
				dc, 
				rc.left, rc.top, 
				MIN(cx, rc.right - rc.left), cy,
				CLR_NONE, CLR_NONE,
				ILD_TRANSPARENT);
			rc.left += cx;
		}

		if( pItem->mask & TLVIF_TEXT ) {

			rc.left += 2;

			COLORREF clrText = lptvcd->clrText;
			if( pItem->mask & TLVIF_TEXTCOLOR ) clrText = pItem->clrText;
			if( iState & CDIS_SELECTED ) clrText = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
			dc.SetTextColor(clrText);

			CFont font;
			HFONT hOldFont = NULL;
			if( pItem->mask & TLVIF_STATE ) {
				LOGFONT lf;
				::GetObject(m_ctrlTree.GetFont(), sizeof(LOGFONT), &lf);
				if( pItem->state & TLVIS_BOLD ) lf.lfWeight += FW_BOLD - FW_NORMAL;
				if( pItem->state & TLVIS_ITALIC ) lf.lfItalic = TRUE;
				if( pItem->state & TLVIS_UNDERLINE ) lf.lfUnderline = TRUE;
				if( pItem->state & TLVIS_STRIKEOUT ) lf.lfStrikeOut = TRUE;
				font.CreateFontIndirect(&lf);
				ATLASSERT(!font.IsNull());
				hOldFont = dc.SelectFont(font);
			}

			UINT format = pItem->mask & TLVIF_FORMAT ? pItem->format : 0;

			if (0 == i)
			{
				CNBDevice* pDevice = (CNBDevice*) m_ctrlTree.GetItemData(hItem);
				if (NULL != pDevice && pDevice->GetIDString(_T('*')).GetLength() > 0)
				{
					CString strBottom = pDevice->GetIDString(m_chHidden);

					CRect rcTop = rc; rcTop.DeflateRect(0, 0, 0, rcTop.Height() / 2);
					CRect rcBottom = rc; rcBottom.top = rcTop.bottom;
					
					dc.FillSolidRect(&rc, lptvcd->clrTextBk);

					LOGFONT lf;
					CFontHandle fontHandle = dc.GetCurrentFont();
					fontHandle.GetLogFont(&lf);
					lf.lfWeight = FW_BOLD;
					CFont font; 
					font.CreateFontIndirect(&lf);
					ATLASSERT(!font.IsNull());

					HFONT hOldFont = dc.SelectFont(font);
					dc.DrawText(pItem->pszText, -1, &rcTop, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
					dc.SelectFont(hOldFont);

					COLORREF clrText = dc.GetTextColor();
					clrText = RGB(
						(GetRValue(clrText) + 0x40) & 0xFF, 
						(GetGValue(clrText) + 0x40) & 0xFF,
						(GetBValue(clrText) + 0x40) & 0xFF);
					clrText = dc.SetTextColor(clrText);
					dc.DrawText(strBottom, -1, &rcBottom, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
					dc.SetTextColor(clrText);
				}
				else
				{
					dc.FillSolidRect(&rc, lptvcd->clrTextBk);

					LOGFONT lf;
					CFontHandle fontHandle = dc.GetCurrentFont();
					fontHandle.GetLogFont(&lf);
					lf.lfWeight = FW_BOLD;
					CFont font; 
					font.CreateFontIndirect(&lf);
					ATLASSERT(!font.IsNull());
					HFONT hOldFont = dc.SelectFont(font);
					dc.DrawText(pItem->pszText, 
						-1, 
						&rc, 
						DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
					dc.SelectFont(hOldFont);
				}
			}
			else
			{
				dc.DrawText(pItem->pszText, 
					-1, 
					&rc, 
					DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format);
			}

			if( pItem->mask & TLVIF_STATE ) dc.SelectFont(hOldFont);
		}
	}
	// FIX-BY-PATRIA: DrawFocusRect should be done here
	if( (iState & CDIS_FOCUS) != 0 && !il.IsNull() ) {
		RECT rcFocus = rcItem;
		rcFocus.left = 1;
		dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));
		dc.DrawFocusRect(&rcFocus);
	}

}
Beispiel #8
0
void CSkinHyperLink::Draw(HDC hDC)
{
	if (m_bTransparent)
		DrawParentWndBg(hDC);

	CRect rtClient;
	GetClientRect(&rtClient);

	int nTextLen = GetWindowTextLength();
	if (nTextLen > 0)
	{
		CString strText;
		GetWindowText(strText);

		HFONT hNormalFont = NULL, hHoverFont = NULL, hVisitedFont = NULL;
		HFONT hFont, hOldFont;
		COLORREF clrText;

		hNormalFont = m_hNormalFont;
		if (NULL == hNormalFont)
			hNormalFont = (HFONT)::SendMessage(m_hWnd, WM_GETFONT, 0, 0L);

		if (m_bHover)	// 鼠标悬停状态
		{
			hHoverFont = m_hHoverFont;
			if (NULL == hHoverFont)
			{
				CFontHandle font = hNormalFont;
				LOGFONT lf = {0};
				font.GetLogFont(&lf);

				lf.lfUnderline = TRUE;

				hHoverFont = ::CreateFontIndirect(&lf);
			}
			hFont = hHoverFont;

			clrText = m_clrHover;
		}
		else if (m_bVisited)
		{
			hVisitedFont = m_hVisitedFont;
			if (NULL == hVisitedFont)
				hVisitedFont = hNormalFont;
			hFont = hVisitedFont;
			clrText = m_clrVisited;
		}
		else	// 普通状态
		{
			hFont = hNormalFont;
			clrText = m_clrLink;
		}

		int nMode = ::SetBkMode(hDC, TRANSPARENT);

		::SetTextColor(hDC, clrText);

		hOldFont = (HFONT)::SelectObject(hDC, hFont);
		::DrawText(hDC, strText, nTextLen, &rtClient, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
		::SelectObject(hDC, hOldFont);

		::SetBkMode(hDC, nMode);

		if (hHoverFont != NULL && hHoverFont != m_hHoverFont)
		{
			::DeleteObject(hHoverFont);
			hHoverFont = NULL;
		}
	}
}