Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

WxWidgets lesson 13 wxMemoryDC uses cached DC rendering

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Description

Using wxMemoryDC rendering, you can reduce flicker, and when the rendering is complete, paste the content onto the target DC, where wxBitmap is needed as the canvas. The effect is equivalent to using wxBufferedPaintDC, but wxBufferedPaintDC is limited to use in OnPaint functions

Code

WxRect rect = GetClientRect ()

Int width = rect.GetWidth ()

Int height = rect.GetHeight ()

WxMemoryDC memDC

WxBitmap bitmap (width, height)

MemDC.SelectObject (bitmap)

MemDC.SetBackground (* wxWHITE_BRUSH)

MemDC.Clear ()

MemDC.SetPen (* wxRED_PEN)

MemDC.SetBrush (* wxRED_BRUSH)

MemDC.DrawRectangle ((wxRect (0,10, width, 100))

WxClientDC destDC (this)

DestDC.Blit (0,0

Bitmap.GetWidth (), bitmap.GetHeight ()

& memDC

0, 0

WxCOPY

True)

MemDC.SelectObject (wxNullBitmap)

A reminder

By default, the memDC background is black

WxScreenDC screen device environment

Description

WxScreenDC supports drawing graphics outside the program window and rendering in other DC, aiming at the client area of the program, not the screen. In order to map points to the screen, you need to use the ClientToScreen function to convert coordinates.

Code

WxPoint pt = ClientToScreen (GetPosition ())

Pt.x = pt.x + GetSize () .GetWidth ()

Pt.y = pt.y + GetSize () .GetHeight ()

WxSize size (100,100)

WxRect rect (pt, size)

WxScreenDC dc

Dc.SetPen (wxPen (* wxLIGHT_GREY, 2, wxSOLID))

/ / dc.SetBrush (* wxTRANSPARENT_BRUSH)

Dc.SetBrush (wxBrush (* wxBLACK))

Dc.DrawRectangle (rect)

WxClientDC wxPaintDC

Description

WxClientDC allows access to the device environment handle in the client area outside the OnPaint event, and you can see from the erase background event that wxPaintDC is in the OnPaint event

Device environment handle for internal access to the client area

Here we need to explain the client area: for a control, the size of the client area is the size of the control itself. If you customize the OnPaint event, it is only rendered within the control area. For windows, the client area does not include the title bar, menu bar, status bar and toolbars, and certainly does not include borders (this is important for dragging borders to zoom in at any time)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report