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 11 Custom Control rendering

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

Share

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

Description

Implement custom window drawing

Examples

# include "wx/event.h"

# include "wx/dcclient.h"

Void OnPaint (wxPaintEvent& event)

EVT_PAINT (CFlightInstrumentPanel::OnPaint)

Void CFlightInstrumentPanel::OnPaint (wxPaintEvent& event)

{

WxClientDC dc (this)

Dc.SetBackground (* wxWHITE_BRUSH); / / clear the background color

Dc.Clear ()

WxPen pen (* wxRED,1)

Dc.SetPen (pen)

Dc.DrawRectangle (0,0,200,300)

Dc.SetPen (wxNullPen)

}

EVT_NC_PAINT description

NC means non client. The non-client area mainly includes the title bar, status bar, toolbar, border and other areas. At present, wxwidgets only provides events in the non-client area of EVT_NC_PAINT. In MFC, it also provides event operations such as WM_NCLBUTTONDOWN WM_NCLBUTTONUP WM_NCMOUSEMOVE. If you need to associate these events, you must filter the events or implement such events in the source code. Currently, this can be done by overriding the MSWWindowProc function of the parent class.

At present, when you need to drag the border, the customer area remains the same, but the border becomes larger. When the border is dragged to the right place, the mouse pops up and the customer area is redrawn. At this time, will the redraw interface in the WM_NCLBUTTONUP message avoid flickering!

Note 1: for graphics that cannot be rendered accurately, use images instead

Description

For example, render text (flip.) In fact, the last symbol should be at the top, not at the bottom, but the tab does not have a dot at the top, which is the key problem. It is difficult to solve this problem by using DrawLabel or DrawText, but it can be solved easily if pictures are introduced. This method, especially when applied to irregular graphics rendering, reduces a lot of workload.

Note 2: the control flashes near the window frame

When the control is placed near the border of the window, drag the border of the window to stretch, it is very obvious to see that the upper half of the control is close to the border, flicker will occur, and you will see the dislocation of the image, and occasionally there will be discordant blocks of color. these phenomena occur only where the control is close to the border. When the border is stretched, the border is redrawn, and then the control is re-rendered, and the border has a width range, not a straight line, so the part of the control near the border is first obscured, redrawn, and then the control is refreshed again. You see the flashing problem. The solution is to say that the position of the control deviates slightly from the border.

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