foobar2000 SDK  2015-08-03
Functions
misc.cpp File Reference

Go to the source code of this file.

Functions

void PaintSeparatorControl (CWindow wnd)
 

Function Documentation

void PaintSeparatorControl ( CWindow  wnd)

Definition at line 3 of file misc.cpp.

3  {
4  CPaintDC dc(wnd);
5  TCHAR buffer[512] = {};
6  wnd.GetWindowText(buffer, _countof(buffer));
7  const int txLen = pfc::strlen_max_t(buffer, _countof(buffer));
8  CRect contentRect;
9  WIN32_OP_D( wnd.GetClientRect(contentRect) );
10 
11  dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
12  dc.SetBkMode(TRANSPARENT);
13 
14  {
15  CBrushHandle brush = (HBRUSH) wnd.GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM) (HDC) dc, (LPARAM) wnd.m_hWnd);
16  if (brush != NULL) dc.FillRect(contentRect, brush);
17  }
18  SelectObjectScope scopeFont(dc, wnd.GetFont());
19 
20  if (txLen > 0) {
21  CRect rcText(contentRect);
22  WIN32_OP_D( dc.DrawText(buffer,txLen,rcText,DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER | DT_LEFT ) > 0);
23  }
24 
25  SIZE txSize, probeSize;
26  const TCHAR probe[] = _T("#");
27  if (dc.GetTextExtent(buffer,txLen,&txSize) && dc.GetTextExtent(probe, _countof(probe), &probeSize)) {
28  int spacing = txSize.cx > 0 ? (probeSize.cx / 4) : 0;
29  if (txSize.cx + spacing < contentRect.Width()) {
30  const CPoint center = contentRect.CenterPoint();
31  CRect rcEdge(contentRect.left + txSize.cx + spacing, center.y, contentRect.right, contentRect.bottom);
32  WIN32_OP_D( dc.DrawEdge(rcEdge, EDGE_ETCHED, BF_TOP) );
33  }
34  }
35 }
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84