The results of the operation of this example are shown below
I. Function and principle
Learning VC also not long, will I do this gadget and share with you. Its main function is to be able to customize the formation of official seal graphics and save for BMP pictures, I hope to be a bit of use for everyone. The following methods are implemented:
Step one: Generate dialog project, and add the corresponding control, the picture display using the pictures control;
Step two: Define the parameters needed to generate the graph;
Step three: Through the parameter definition, generate the corresponding bitmap, and then display the bitmap in the picture control, see the source program.
Step four: Save the generated bitmap as a bitmap file.
Second, the key point of the realization of the program
(i), need to understand logfont, logpen and logbrush structure, and flexible application, especially in the process of arranging fonts, the rotation angle of the font and positioning point settings.
//绘制图章基本图形
void CMakeSealDlg::DrawSeal(CDC * MemDC)
{
int cx = 100;
int cy = 100;
POINT point;
point.x = point.y = 5;
LOGPEN logPen;
logPen.lopnColor = ChooseColor(&m_nRadioColor);
//绘制背景
logPen.lopnStyle = PS_NULL;
logPen.lopnWidth = point;
(*MemDC).SelectObject(CreatePenIndirect(&logPen));
(*MemDC).Rectangle(0,0,200,200);
//设置绘笔
logPen.lopnStyle = PS_SOLID;
(*MemDC).SelectObject(CreatePenIndirect(&logPen));
//设置填充
LOGBRUSH logBrush;
logBrush.lbStyle = BS_HOLLOW;
logBrush.lbColor = RGB(255, 0, 0);
(*MemDC).SelectObject(CreateBrushIndirect(&logBrush));
//绘制外圆
(*MemDC).Ellipse(cx - m_nRadius, cy - m_nRadius, cx + m_nRadius, cy + m_nRadius);
}