In experiments and production, we often need to monitor the monitored objects in real time, for example, to collect real-time data for environmental factors such as the site temperature, and then transmit the data to the master control computer, it is displayed in a dynamic curve to facilitate people's understanding and control of the site.2. There are four ways to draw dynamic curves using Visual C ++. (1) Use deactivating. (2) Use redrawing. Based on different principles, repainting is divided
curve through parameters to scale the font freely.
8.2.2 class related to GDI in MFC
To support GDI plotting, MFC provides two important classes: the device context class, which is used to set drawing properties and Drawing Graphics. The drawing object class encapsulates various GDI drawing objects, includes paint brush, brush, Font, bitmap, color palette, and area.
Device context
The device context class includes the CDC and Its Derived classes ccli
///using HDC drawing // HDC HDC; Hdc=::getdc (m_hwnd); Movetoex (Hdc,m_ptorigin.x,m_ptorigin.y,null); LineTo (HDC,POINT.X,POINT.Y); :: ReleaseDC (M_HWND,HDC); *///All window-related operations are encapsulated in the CWnd class //All drawing-related operations are encapsulated in the CDC class //using CDC drawing // CDC *PDC=CWND::GETDC (); // The GetDC of th
Show pictures in a resource(1) Loading bitmaps from resourcesDefines a Bitmap object data member CBitmap M_bitmap;Call the CBitmap member function LoadBitmap (), such as M_bitmap.loadbitmap (IDB_BITMAP1);The arguments passed in LoadBitmap are the identifiers that are given when the bitmap is generated in the graphics editor or when it is introduced from a bitmap file.(2) Generating a memory device context object associated with a bitmapCDC MEMDC;Memdc.createcompatibledc (NULL);Memdc.selectobject
A few days ago due to the need for programming. To do a static control with a border, so in the trace of other people do the basis of 3DBar, oneself made a C3dbar class, now dedicate it to everyone. Here's how to use C3dbar.
The use of this class is simple, with a total of 7 public functions in 3DBbar. respectively:
void SetBarColour(COLORREF cr); void DrawHorizontal(CDC* pDC, CRect BarRect); //画水平bar void DrawVertical(
configuration objects that are published to other business systems
Other application objects
Object partitioning:
Database account
Linked server
Instance-level triggers
Homework
System parameters
Maintenance plan
Cdc
Bi-related
Synonyms
Assembly
Mail
Operator
Read-only library indexes, views, and other objects
Wait, wait.
Test process Build test environmentAll upgrades, high-a
The big difference between the first call to Cdialog::onpaint () and the Last Call to Cdialog::onpaint () in the OnPaint () function is that if you do not pay attention to this problem there will be an unreasonable drawing problem-the effect is not coming out! After two hours of torture, the problem lies in the following lessons:the Cdialog::onpaint () function is called first in the OnPaint () function:[CPP]View PlainCopy
Add a bitmap background to the main form client area
void Cbackimag
alternately in a short period of time, making the display window appear flashing. If you set the background to null, the duplicate drawing will not flash. Of course, this will make the display of the window messy, because during the re-painting, there is no background color to clear the original drawing, and a new image is superimposed. Some people may say that the blinking is caused by the drawing speed being too slow or the display graphics being too complex. In fact, this is not true. The in
side to draw and display, so when displaying a frame of graphics, the slowdown is less flickering, so as to achieve smooth animation; and, graphics are directly displayed in the memory to the current form, so the speed is also very fast, so as to achieve high-speed animation. The following describes how to implement these technologies:1,Start VC ++ and create a single-document application supported by MFC.2,Select the menu item inertnew class to create a class inherited from the cbitmap class,
limit to the above approach, because not all parent windows can accept this special WM_PAINT message feature, but MSDN mentions that most controls have this feature, and you should be careful to read its document content.Third: If the above methods are not, then the most stupid way, the GDI function to brush the background of the child window, but you need to know the parent window background color, background bitmap and other information. For example, to fill the background of a child window w
users often ask: "Why can't the WM_ERASEBKGND message in the dialog box be found in class wizard? Is this message unavailable in the dialog box "? In fact, the dialog box is also a window, and it also contains the WM_ERASEBKGND message, but it is filtered out by the dialog filter used by the MFC class wizard (only in the display of the message window, does not really do not respond to this message), in order to highlight the exclusive message and control events in the dialog box during code wri
First load an image with ID idb_bitmap2
In testdlg. h:
Cbrush m_brbk; // defined in public
In testdlg. cpp:
Add the following to the oninitdialog () initialization function:
Bool ctestdlg: oninitdialog ()
{
Cdialog: oninitdialog ();
Cbitmap BMP;
BMP. loadbitmap (idb_bitmap2 );
M_brbk.createpatternbrush ( BMP );
BMP. deleteobject ();
Return true; // return true unless you set the focus to a control
}
Open the Class Wizard and find the wm_ctlcolor message. The onctlcolor () function is reloaded
content, in this way, the background color and the display image appear alternately in a short period of time, making the display window appear flashing. If you set the background to null, the duplicate drawing will not flash. Of course, this will make the display of the window messy, because during the re-painting, there is no background color to clear the original drawing, and a new image is superimposed. Some people may say that the blinking is caused by the drawing speed being too slow or t
, the duplicate drawing will not flash.Of course, this will make the display of the window messy, because there is no background color for the originalThe drawn image is cleared, and the new image is superimposed.Some people may say that flashing is caused by the drawing speed being too slow or the graphics displayed are too complex,In fact, this is not true. The influence of the display speed of the drawing on the flicker is not fundamental.For example, in ondraw (
wm_erasebkgnd in the message list of the dialog box.
Figure 2 modify a message Filter
Now you can use Class Wizard to add the message response function of wm_erasebkgnd and modify this function as follows:
Bool ccustdlgdlg: onerasebkgnd (CDC * PDC)
{
Crect rcclient;
Getclientrect ( rcclient );
PDC-> fillrect ( rcclient, m_brbkgnd );
Return true;
// Return cdialog: onerasebkgnd (PDC );}
M_brbkgnd is a cbrush, which has been initializ
For more information about how to use VC to open the mo extension symbol library, see the article "Custom symbol method (for Mo) in VC.
The key code is as follows:Public:Cpen g_hpen;// IcustomlineStdmethod (setupdc) (long HDC, double DPI, idispatch * pbasesym){CDC * pcdc = CDC: fromhandle (HDC );
// Cpen * g_hpen = createpen (pbasesym-> style, pbasesym-> size, pbasesym-> color );
Dispid;Dispparams dispparam
1.Picking handle
CDC problems:1. cdc dc; DC. lineto (point); cannot run
2. CDC * Dc = getdc (); DC-> lineto (point );There are a large number of handle packaging classes in MFC. As the name suggests, the so-called handle packaging class refers to these classes encapsulate the handles of System Objects (hwnd, HDC, hbitmap, etc.), and provides a group of functi
To modify the background color and text color of the CButton class button, you must redraw the button using a self-drawing method. This can be accomplished by defining a new button class that is based on the CButton class. The following is a concrete implementation method:method One:Add a new class, class name: Cbuttonex, base class: CButton.Add the following variables and function definitions to the header file CButtonEx.h:Privateint M_style; Button shape (0-Normal, 1-current, 2-pressed, 3-lock
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.