BOOL SMaskEdit::CopyToClipboard(const SStringT& strText) { if (!OpenClipboard(NULL)) return FALSE; ::EmptyClipboard(); int nLen = (strText.GetLength() + 1) * sizeof(TCHAR); HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, nLen); if (hglbCopy == NULL) { ::CloseClipboard(); return FALSE; } LPTSTR lptstrCopy = (TCHAR*)GlobalLock(hglbCopy); _tcscpy_s(lptstrCopy, strText.GetLength() + 1, (LPCTSTR)strText); GlobalUnlock(hglbCopy); #ifndef _UNICODE ::SetClipboardData(CF_TEXT, hglbCopy); #else ::SetClipboardData(CF_UNICODETEXT, hglbCopy); #endif if (!::CloseClipboard()) return FALSE; return TRUE; }
void SProgress::OnPaint(IRenderTarget *pRT) { SPainter painter; BeforePaint(pRT, painter); SASSERT(m_pSkinBg && m_pSkinPos); CRect rcClient; GetClientRect(&rcClient); m_pSkinBg->Draw(pRT, rcClient, WndState_Normal); CRect rcValue=rcClient; if(IsVertical()) { rcValue.bottom=rcValue.top+(int)(((__int64)rcValue.Height())*(m_nValue-m_nMinValue)/(__int64)(m_nMaxValue-m_nMinValue)); } else { rcValue.right=rcValue.left+(int)(((__int64)rcValue.Width())*(m_nValue-m_nMinValue)/(__int64)(m_nMaxValue-m_nMinValue)); } if(m_nValue>m_nMinValue) { m_pSkinPos->Draw(pRT, rcValue, WndState_Normal); } if (m_bShowPercent && !IsVertical()) { SStringT strPercent; strPercent.Format(_T("%d%%"), (int)((m_nValue-m_nMinValue) * 100/(m_nMaxValue-m_nMinValue))); pRT->DrawText(strPercent, strPercent.GetLength(), GetWindowRect(), DT_SINGLELINE | DT_CENTER | DT_VCENTER); } AfterPaint(pRT, painter); }
void SPropertyItemColor::DrawItem( IRenderTarget *pRT,CRect rc ) { CRect rcColor = rc; rcColor.right = rcColor.left + KColorWidth; rcColor.DeflateRect(2,2); //画一个代表透明的网格背景 pRT->PushClipRect(&rcColor); bool bDrawY=true; for(int y=rcColor.top;y<rcColor.bottom;y+=KTransGridSize) { bool bDraw= bDrawY; for(int x=rcColor.left;x<rcColor.right;x+=KTransGridSize) { if(bDraw) pRT->FillSolidRect(CRect(CPoint(x,y),CSize(KTransGridSize,KTransGridSize)),RGBA(0xcc,0xcc,0xcc,0xff)); bDraw=!bDraw; } bDrawY=!bDrawY; } pRT->PopClip(); pRT->FillSolidRect(&rcColor,m_crValue); pRT->DrawRectangle(&rcColor); CRect rcValue = rc; rcValue.left += KColorWidth; SStringT strValue = GetString(); pRT->DrawText(strValue,strValue.GetLength(),&rcValue,DT_SINGLELINE|DT_VCENTER); }
BOOL SMaskEdit::IsPromptPos(const SStringT& strLiteral, int nPos) const { return (nPos >= 0 && nPos < strLiteral.GetLength()) && (strLiteral[nPos] == m_chPrompt); }