用C++画五角星
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SetTextColor(hDC,RGB(0,0,0));
HF_big=CreateFont(
nCharHeight,
0,
900-150*i,
0,
FW_HEAVY,
0,
0,
0,
GB2312_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_SCRIPT,
"粗体字"
);
SelectObject(hDC,HF_big);
TextOut(hDC,X,Y,&lpsz_1[2*i],2);
}
EndPaint(hWnd,&PtStr);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
MoveToEx(hDC,402,235,NULL);
LineTo(hDC,474,290);
MoveToEx(hDC,498,235,NULL);
LineTo(hDC,402,235);
MoveToEx(hDC,498,235,NULL);
LineTo(hDC,421,290);
DeleteObject(hPen2);
DeleteObject(hPen1);
SetTextColor(hDC,RGB(0,0,0));
GetTextMetrics(hDC,&tm);
TextOut(hDC,412,320,lpsz_2,strlen(lpsz_2));
X=425+tm.tmAveCharWidth;
Y=330+tm.tmHeight+tm.tmExternalLeading;
default:
return (DefWindowProc(hWnd,iMessage,wParam,lParam));
}
}
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hWnd;
hWnd=CreateWindow(
"stamp",
"图章工具",
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG Message;
if(!InitWindowsClass(hInstance))
return FALSE;
char lpsz_2[]="自动化系";
char lpsz_3[]="10级";
int nCharlen=strlen(lpsz_1)/2;
int nCharHeight;
int X=0,Y=0,i;
SIZE size;
switch(iMessage)
{
case WM_PAINT:
hDC=BeginPaint(hWnd,&PtStr);
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
TextOut(hDC,X,Y,lpsz_3,strlen(lpsz_3));
for(i=0;i<nCharlen;i++)
{
nCharHeight=25;
X=(int)(450-125*cos(-Pi/(nCharlen)*i));
Y=(int)(250+125*sin(-Pi/(nCharlen)*i));
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
while(GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,"END");
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName="stamp";
SetMapMode(hDC,MM_ANISOTROPIC);
hPen1=(HPEN)GetStockObject(BLACK_PEN);
SelectObject(hDC,hPen1);
Ellipse(hDC,lCenterX-lRidous,lCenterY-lRidous,lCenterX+lRidous,lCenterY+lRidous);
hPen2=CreatePen(PS_SOLID,1,RGB(255,0,0));
SelectObject(hDC,h450,200,NULL);
LineTo(hDC,421,290);
MoveToEx(hDC,474,290,NULL);
LineTo(hDC,450,200);
#include<windows.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#define Pi 3.1415926
int lCenterX=450,lCenterY=250,lRidous=135;
}
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam)
{
HDC hDC;
HPEN hPen1,hPen2;
HFONT HF_big,HF_small;
PAINTSTRUCT PtStr;
TEXTMETRIC tm;
char lpsz_1[]="内蒙古大学电子信息工程学院";
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW|CS_VREDRAW;
return RegisterClass(&WndClass);
}
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL
);
if(!hWnd)
return FALSE;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
HF_big=CreateFont(
nCharHeight,
0,
900-150*i,
0,
FW_HEAVY,
0,
0,
0,
GB2312_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_SCRIPT,
"粗体字"
);
SelectObject(hDC,HF_big);
TextOut(hDC,X,Y,&lpsz_1[2*i],2);
}
EndPaint(hWnd,&PtStr);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
MoveToEx(hDC,402,235,NULL);
LineTo(hDC,474,290);
MoveToEx(hDC,498,235,NULL);
LineTo(hDC,402,235);
MoveToEx(hDC,498,235,NULL);
LineTo(hDC,421,290);
DeleteObject(hPen2);
DeleteObject(hPen1);
SetTextColor(hDC,RGB(0,0,0));
GetTextMetrics(hDC,&tm);
TextOut(hDC,412,320,lpsz_2,strlen(lpsz_2));
X=425+tm.tmAveCharWidth;
Y=330+tm.tmHeight+tm.tmExternalLeading;
default:
return (DefWindowProc(hWnd,iMessage,wParam,lParam));
}
}
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
HWND hWnd;
hWnd=CreateWindow(
"stamp",
"图章工具",
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG Message;
if(!InitWindowsClass(hInstance))
return FALSE;
char lpsz_2[]="自动化系";
char lpsz_3[]="10级";
int nCharlen=strlen(lpsz_1)/2;
int nCharHeight;
int X=0,Y=0,i;
SIZE size;
switch(iMessage)
{
case WM_PAINT:
hDC=BeginPaint(hWnd,&PtStr);
}
BOOL InitWindowsClass(HINSTANCE hInstance)
{
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
TextOut(hDC,X,Y,lpsz_3,strlen(lpsz_3));
for(i=0;i<nCharlen;i++)
{
nCharHeight=25;
X=(int)(450-125*cos(-Pi/(nCharlen)*i));
Y=(int)(250+125*sin(-Pi/(nCharlen)*i));
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
while(GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,"END");
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName="stamp";
SetMapMode(hDC,MM_ANISOTROPIC);
hPen1=(HPEN)GetStockObject(BLACK_PEN);
SelectObject(hDC,hPen1);
Ellipse(hDC,lCenterX-lRidous,lCenterY-lRidous,lCenterX+lRidous,lCenterY+lRidous);
hPen2=CreatePen(PS_SOLID,1,RGB(255,0,0));
SelectObject(hDC,h450,200,NULL);
LineTo(hDC,421,290);
MoveToEx(hDC,474,290,NULL);
LineTo(hDC,450,200);
#include<windows.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#define Pi 3.1415926
int lCenterX=450,lCenterY=250,lRidous=135;
}
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam)
{
HDC hDC;
HPEN hPen1,hPen2;
HFONT HF_big,HF_small;
PAINTSTRUCT PtStr;
TEXTMETRIC tm;
char lpsz_1[]="内蒙古大学电子信息工程学院";
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW|CS_VREDRAW;
return RegisterClass(&WndClass);
}
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL
);
if(!hWnd)
return FALSE;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;