Use GDI + Interface graphic usage GDI It is much simpler and easier to meet user needs. GDI + Provides many practical features, such as smooth lines, graphic translation, rotation, scaling, and so on.
1. UseGDI +Draw a straight line
1)Create paint brush
Pen (color (255, 0, 0, 0), 2.0f );
2)Create a graphic object
CDC * PDC = getdc ();
Graphics graphics (PDC-> m_hdc)
3)Draw a straight line
Graphics. drawline (& pen, 0, 0,100,100 );
4)ReleaseDC
Releasedc (PDC );
2. Parameter settings
1)Set paint brush Parameters
Pen (color (255, 0, 0, 0), 2.0f);
Pen. setstartcap (linecapround );//Modify the start line header type. Here is the circle header.
Pen. setendcap (linecapround );//Modify the end line header type. Here is the Arrow
Pen. setdashstyle (dashstyledot );//Modify the line format. Here is the dot line.
2)Set graphic Object Attributes
Graphics. setsmoothingmode (smoothingmodeantialias );//Anti-aliasing
3) Draw a straight line
Graphics. drawline (& pen, 10, 10,110,110 );
The preceding two steps show thatGDI +Drawing is very simple, and through simple parameters
You can easily draw the desired image.