本文整理汇总了C++中RestoreDC函数的典型用法代码示例。如果您正苦于以下问题:C++ RestoreDC函数的具体用法?C++ RestoreDC怎么用?C++ RestoreDC使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RestoreDC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveDC
void CFlexWnd::RenderInto(HDC hDC, int x, int y)
{
if (hDC == NULL)
return;
int sdc = SaveDC(hDC);
{
OffsetViewportOrgEx(hDC, x, y, NULL);
SIZE size = GetClientSize();
IntersectClipRect(hDC, 0, 0, size.cx, size.cy);
m_hRenderInto = hDC;
int sdc2 = SaveDC(hDC);
{
EnumChildWindows/*ZDown*/(m_hWnd, ::RenderIntoClipChild, (LPARAM)(PVOID)this);
EnumSiblingsAbove(m_hWnd, ::RenderIntoClipChild, (LPARAM)(PVOID)this);
DoOnPaint(hDC);
}
if (sdc2)
RestoreDC(hDC, sdc2);
EnumChildWindows/*ZDown*/(m_hWnd, ::RenderIntoRenderChild, (LPARAM)(PVOID)this);
m_hRenderInto = NULL;
}
if (sdc)
RestoreDC(hDC, sdc);
}
示例2: dc
bool GlyphPage::fill(UChar* buffer, unsigned bufferLength, const Font* fontData)
{
// bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs.
// We won't support this for now.
if (bufferLength > GlyphPage::size)
return false;
bool haveGlyphs = false;
HWndDC dc(0);
SaveDC(dc);
SelectObject(dc, fontData->platformData().hfont());
WORD localGlyphBuffer[GlyphPage::size * 2];
DWORD result = GetGlyphIndices(dc, buffer, bufferLength, localGlyphBuffer, GGI_MARK_NONEXISTING_GLYPHS);
bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength;
if (success) {
for (unsigned i = 0; i < GlyphPage::size; i++) {
Glyph glyph = localGlyphBuffer[i];
if (glyph == 0xffff)
setGlyphForIndex(i, 0);
else {
setGlyphForIndex(i, glyph);
haveGlyphs = true;
}
}
}
RestoreDC(dc, -1);
return haveGlyphs;
}
示例3: Draw3DBorder
//give some 3D
void Draw3DBorder(HDC hDC,RECT rRect,COLORREF clrDrawingColor,bool bSinked)
{
HPEN hPenHilight,hPenShadow;
int iSaveDCState;
iSaveDCState=SaveDC(hDC);
if (!bSinked)
{
hPenHilight=CreatePen(PS_SOLID,1,ColorAdjustLuma(clrDrawingColor,400));
hPenShadow=CreatePen(PS_SOLID,1,ColorAdjustLuma(clrDrawingColor,-400));
}
else
{
hPenHilight=CreatePen(PS_SOLID,1,ColorAdjustLuma(clrDrawingColor,-400));
hPenShadow=CreatePen(PS_SOLID,1,ColorAdjustLuma(clrDrawingColor,400));
}
MoveToEx(hDC,rRect.left,rRect.bottom,NULL);
SelectObject(hDC,hPenHilight);
LineTo(hDC,rRect.left,rRect.top);
LineTo(hDC,rRect.right,rRect.top);
SelectObject(hDC,hPenShadow);
LineTo(hDC,rRect.right,rRect.bottom);
LineTo(hDC,rRect.left,rRect.bottom);
DeleteObject(hPenHilight);
DeleteObject(hPenShadow);
//clean up and return
RestoreDC(hDC,iSaveDCState);
}
示例4: GetDC
bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
{
// bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs.
// We won't support this for now.
if (bufferLength > length)
return false;
bool haveGlyphs = false;
HDC dc = GetDC((HWND)0);
SaveDC(dc);
SelectObject(dc, fontData->platformData().hfont());
TEXTMETRIC tm;
GetTextMetrics(dc, &tm);
WORD localGlyphBuffer[GlyphPage::size * 2];
DWORD result = GetGlyphIndices(dc, buffer, bufferLength, localGlyphBuffer, 0);
bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength;
if (success) {
for (unsigned i = 0; i < length; i++) {
Glyph glyph = localGlyphBuffer[i];
if (!glyph)
setGlyphDataForIndex(offset + i, 0, 0);
else {
setGlyphDataForIndex(offset + i, glyph, fontData);
haveGlyphs = true;
}
}
}
RestoreDC(dc, -1);
ReleaseDC(0, dc);
return haveGlyphs;
}
示例5: SaveDC
void CKey::Repaint()
{
int dcant = SaveDC(memdc);
SelectObject(memdc,bmp);
BitBlt(dc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, memdc, value?chave_h:0, chave_v * index, SRCCOPY);
RestoreDC(memdc,dcant);
}
示例6: m_font
FontPlatformData::FontPlatformData(GDIObject<HFONT> font, float size, bool bold, bool oblique, bool useGDI)
: m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
, m_size(size)
, m_orientation(Horizontal)
, m_widthVariant(RegularWidth)
, m_isColorBitmapFont(false)
, m_syntheticBold(bold)
, m_syntheticOblique(oblique)
, m_useGDI(useGDI)
{
HWndDC hdc(0);
SaveDC(hdc);
::SelectObject(hdc, m_font->get());
UINT bufferSize = GetOutlineTextMetrics(hdc, 0, NULL);
ASSERT_WITH_MESSAGE(bufferSize, "Bitmap fonts not supported with CoreGraphics.");
if (bufferSize) {
OUTLINETEXTMETRICW* metrics = (OUTLINETEXTMETRICW*)malloc(bufferSize);
GetOutlineTextMetricsW(hdc, bufferSize, metrics);
WCHAR* faceName = (WCHAR*)((uintptr_t)metrics + (uintptr_t)metrics->otmpFaceName);
platformDataInit(m_font->get(), size, hdc, faceName);
free(metrics);
}
RestoreDC(hdc, -1);
}
示例7: PageGDICalls
void PageGDICalls (HDC hdcPrn, int cxPage, int cyPage)
{
static TCHAR szTextStr[] = TEXT ("Hello, Printer!") ;
Rectangle (hdcPrn, 0, 0, cxPage, cyPage) ;
MoveToEx (hdcPrn, 0, 0, NULL) ;
LineTo (hdcPrn, cxPage, cyPage) ;
MoveToEx (hdcPrn, cxPage, 0, NULL) ;
LineTo (hdcPrn, 0, cyPage) ;
SaveDC (hdcPrn) ;
SetMapMode (hdcPrn, MM_ISOTROPIC) ;
SetWindowExtEx (hdcPrn, 1000, 1000, NULL) ;
SetViewportExtEx (hdcPrn, cxPage / 2, -cyPage / 2, NULL) ;
SetViewportOrgEx (hdcPrn, cxPage / 2, cyPage / 2, NULL) ;
Ellipse (hdcPrn, -500, 500, 500, -500) ;
SetTextAlign (hdcPrn, TA_BASELINE | TA_CENTER) ;
TextOut (hdcPrn, 0, 0, szTextStr, lstrlen (szTextStr)) ;
RestoreDC (hdcPrn, -1) ;
}
示例8: RestoreDC
void plDynSurfaceWriter::plWinSurface::Release( void )
{
if( fBitmap != nil )
sNumBitmapsAllocated--;
if( fDC != nil )
sNumDCsAllocated--;
if( fSaveNum != 0 )
RestoreDC( fDC, fSaveNum );
fSaveNum = 0;
DeleteObject( fBitmap );
DeleteDC( fDC );
fDC = nil;
fBitmap = nil;
fFont = nil;
fBits = nil;
fWidth = fHeight = 0;
delete [] fFontFace;
fFontFace = nil;
fFontSize = 0;
fFontFlags = 0;
fFontAntiAliasRGB = false;
fFontBlockedRGB = false;
}
示例9: rcClip
BOOL CShadeWnd::CreateShadow(HDC hdc,CSize szWindow,CRect rcMargin)
{
HDC hdcMask = ::CreateCompatibleDC(hdc);
HBITMAP hBmpMask = ::CreateCompatibleBitmap( hdc, szWindow.cx,szWindow.cy );
HGDIOBJ hBmpOldMask = ( HBITMAP )::SelectObject( hdcMask, hBmpMask );
if(hdcMask && hBmpMask)
{
CRect rcClip(rcMargin.left,rcMargin.top,szWindow.cx - rcMargin.right,szWindow.cy - rcMargin.bottom);
int nSave = SaveDC(hdc);
HRGN hRgn = ::CreateRectRgnIndirect( &rcClip );
::ExtSelectClipRgn( hdc, hRgn ,RGN_DIFF);
::DeleteObject(hRgn);
HBRUSH hbrush = CreateSolidBrush(RGB(0,0,0));
FillRect(hdc,CRect(0,0,szWindow.cx,szWindow.cy),hbrush);
DeleteObject(hbrush);
RestoreDC( hdc,nSave );
//½«ÒõӰͼƬ»æÖƵ½hdcMask
m_pMask->Draw(hdcMask,CRect(0,0,szWindow.cx,szWindow.cy));
BLENDFUNCTION bf = {AC_SRC_OVER,0,255,AC_SRC_ALPHA};
::AlphaBlend(hdc,0,0,szWindow.cx,szWindow.cy,hdcMask,0,0,szWindow.cx,szWindow.cy,bf);
::SelectObject( hdcMask, hBmpOldMask );
::DeleteObject( hBmpMask );
::DeleteDC( hdcMask );
return TRUE;
}
return FALSE;
}
示例10: BitBlt
//+------------------------------------------------------------------------
//
// Member: COffScreenContext::ReleaseDC
//
// Synopsis: If painting offscreen, blt the bits to the screen.
//
//-------------------------------------------------------------------------
HDC COffScreenContext::ReleaseDC(HWND hwnd, BOOL fDraw/*=TRUE*/)
{
if(_fOffScreen)
{
if(fDraw)
{
if(_fCaret)
{
::HideCaret(hwnd);
}
BitBlt(_hdcWnd,
_rc.left, _rc.top,
_rc.right-_rc.left,
_rc.bottom-_rc.top,
_hdcMem,
_rc.left, _rc.top,
SRCCOPY);
if(_fCaret)
{
::ShowCaret(hwnd);
}
}
if(_nSavedDC)
{
Verify(RestoreDC(_hdcMem, _nSavedDC));
_nSavedDC = 0;
}
}
return _hdcWnd;
}
示例11: SetLLTextW
static void SetLLTextW(HWND hwnd, wchar_t * lpText){
wchar_t * pText;
SIZE sz;
HDC hdc;
int state;
HFONT hFont;
RECT rc;
GetWindowRect(hwnd, &rc);
MapWindowPoints(HWND_DESKTOP, GetParent(hwnd), (LPPOINT)&rc, 2);
pText = (wchar_t *)GetWindowLongPtrW(hwnd, 0);
if(pText)
free(pText);
pText = (wchar_t *)calloc(wcslen(lpText) + 2, sizeof(wchar_t));
wcscpy(pText, lpText);
SetWindowLongPtrW(hwnd, 0, (LONG_PTR)pText);
hdc = GetDC(hwnd);
state = SaveDC(hdc);
hFont = CreateFontIndirectW((LPLOGFONTW)GetWindowLongPtrW(hwnd, 4));
SelectFont(hdc, hFont);
GetTextExtentPoint32W(hdc, lpText, wcslen(lpText) + 1, &sz);
RestoreDC(hdc, state);
ReleaseDC(hwnd, hdc);
DeleteFont(hFont);
if(GetPropW(hwnd, LL_ALIGNW))
SetWindowPos(hwnd, 0, rc.right - sz.cx, rc.top, sz.cx, sz.cy, SWP_SHOWWINDOW);
else
SetWindowPos(hwnd, 0, 0, 0, sz.cx, sz.cy, SWP_NOMOVE | SWP_SHOWWINDOW);
}
示例12: UpdatePreviewArea
void UpdatePreviewArea(HWND hwndDlg,HDC hDC,int ControlID,COLORREF clrDrawingColor)
{
RECT rRect;HBRUSH hBrush;int iSaveDCState; HPEN hPen;
iSaveDCState=SaveDC(hDC);
GetWindowRect(GetDlgItem(hwndDlg,ControlID),&rRect);
hBrush=CreateSolidBrush(clrDrawingColor);
SelectObject(hDC,hBrush);
hPen=CreatePen(PS_SOLID,1,ColorAdjustLuma(clrDrawingColor,-400));
SelectObject(hDC,hPen);
MapWindowPoints(NULL,hwndDlg,(POINT*)&rRect,2);
Rectangle(hDC,rRect.left,rRect.top,rRect.right+1,rRect.bottom+1);
//give some 3D look for the thumb
DeleteObject(hPen);
hPen=CreatePen(PS_SOLID,1,ColorAdjustLuma(clrDrawingColor,400));
SelectObject(hDC,hPen);
MoveToEx(hDC,rRect.left,rRect.bottom-1,NULL);
LineTo(hDC,rRect.left,rRect.top);
LineTo(hDC,rRect.right,rRect.top);
//clean up and return
RestoreDC(hDC,iSaveDCState);
DeleteObject(hPen);
DeleteObject(hBrush);
}
示例13: m_font
FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI)
: m_font(RefCountedGDIHandle<HFONT>::create(font))
, m_size(size)
#if PLATFORM(CG)
, m_cgFont(0)
#elif PLATFORM(CAIRO)
, m_fontFace(0)
, m_scaledFont(0)
#endif
, m_syntheticBold(bold)
, m_syntheticOblique(oblique)
, m_useGDI(useGDI)
{
HDC hdc = GetDC(0);
SaveDC(hdc);
SelectObject(hdc, font);
UINT bufferSize = GetOutlineTextMetrics(hdc, 0, NULL);
ASSERT_WITH_MESSAGE(bufferSize, "Bitmap fonts not supported with CoreGraphics.");
if (bufferSize) {
OUTLINETEXTMETRICW* metrics = (OUTLINETEXTMETRICW*)malloc(bufferSize);
GetOutlineTextMetricsW(hdc, bufferSize, metrics);
WCHAR* faceName = (WCHAR*)((uintptr_t)metrics + (uintptr_t)metrics->otmpFaceName);
platformDataInit(font, size, hdc, faceName);
free(metrics);
}
RestoreDC(hdc, -1);
ReleaseDC(0, hdc);
}
示例14: PluginDraw
static void
PluginDraw(InstanceData* id)
{
NPP npp = id->npp;
HDC hdc = (HDC) id->window.window;
int savedDCID = SaveDC(hdc);
const RECT fill = { id->window.x, id->window.y, id->window.x + id->window.width, id->window.y + id->window.height };
SetBkMode(hdc, TRANSPARENT);
HBRUSH brush = ::CreateSolidBrush(RGB(192, 120, 50));
FillRect(hdc, &fill, brush);
DeleteObject(brush);
if (id->window.width > 2 && id->window.height > 2) {
brush = CreateSolidBrush(RGB(212, 192, 150));
const RECT inset = { id->window.x + 1, id->window.y + 1, id->window.x + id->window.width - 1, id->window.y + id->window.height - 1 };
FillRect(hdc, &inset, brush);
DeleteObject(brush);
}
if (id->window.width > 6 && id->window.height > 6) {
HFONT font = CreateFont(20, 0, 0, 0, 400, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, 5, DEFAULT_PITCH, L"Arial");
SelectObject(hdc, font);
RECT inset = { id->window.x + 3, id->window.y + 3, id->window.x + id->window.width - 3, id->window.y + id->window.height - 3 };
DrawText(hdc, L"Hello, world.", -1, &inset, DT_LEFT | DT_TOP | DT_NOPREFIX | DT_WORDBREAK);
DeleteObject(font);
}
RestoreDC(hdc, savedDCID);
}
示例15: DrawRect
void CStatusBar::Draw()
{
const int& cx = m_mdc.cx;
const int& cy = m_mdc.cy;
// Draw background
if (m_bBackgrWinDefault)
{
DrawRect(m_mdc, 0, 0, cx, 1, GetSysColor(COLOR_3DSHADOW));
DrawRect(m_mdc, 0, 1, cx, 1, GetSysColor(COLOR_3DHIGHLIGHT));
DrawRect(m_mdc, 0, 2, cx, cy - 2, GetSysColor(COLOR_3DFACE));
}
else
{
DrawRectGradientV(m_mdc, 0, 0, cx, cy, m_clrBackgrT, m_clrBackgrB);
DrawRect(m_mdc, 0, 0, cx, SCY(1), m_clrBackgrLine);
}
// Draw status text
int nSavedDC = SaveDC(m_mdc);
SetTextColor(m_mdc, m_clrText);
SelectObject(m_mdc, m_font);
TextOut(m_mdc, SCX(4), SCY(4), GetText());
RestoreDC(m_mdc, nSavedDC);
Invalidate(m_hWnd);
PostMessage(m_hWnd, WM_PAINT);
}