资源描述:
《vc++编程实验》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#includelongWINAPIWndProc(HWNDhWnd,UINTiMessage,UINTwParam,LONGlParam);BOOLInitWindowsClass(HINSTANCEhInstance);BOOLInitWindows(HINSTANCEhInstance,intnCmdShow);intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine
2、,intnCmdShow){ MSGMessage; if(!InitWindowsClass(hInstance)) returnFALSE; if(!InitWindows(hInstance,nCmdShow)) returnFALSE; while(GetMessage(&Message,0,0,0)) { TranslateMessage(&Message); DispatchMessage(&Message); } returnMessage.wParam;}longWINAPIWndProc(HWNDhWnd,UINTiMessage,UI
3、NTwParam,LONGlParam){ HDChDC; HBRUSHhBrush; HPENhPen; PAINTSTRUCTPtStr; switch(iMessage) { caseWM_PAINT: hDC=BeginPaint(hWnd,&PtStr); SetMapMode(hDC,MM_ANISOTROPIC); hPen=(HPEN)CreatePen(PS_INSIDEFRAME,1,RGB(255,0,0)); SelectObject(hDC,hPen); Rectangle(hDC,50,50,210,210); DeleteO
4、bject(hPen); hBrush=(HBRUSH)GetStockObject(BLACK_BRUSH); SelectObject(hDC,hBrush); POINTp[3]; p[0].x=50;p[0].y=50;p[1].x=130;p[1].y=130;p[2].x=210;p[2].y=50; Polygon(hDC,p,3); DeleteObject(hBrush); hBrush=(HBRUSH)GetStockObject(DKGRAY_BRUSH); SelectObject(hDC,hBrush);
5、 p[0].x=50;p[0].y=50;p[1].x=130;p[1].y=130;p[2].x=50;p[2].y=210; Polygon(hDC,p,3); hBrush=CreateSolidBrush(RGB(255,0,255)); SelectObject(hDC,hBrush); p[0].x=210;p[0].y=210;p[1].x=130;p[1].y=130;p[2].x=210;p[2].y=50; Polygon(hDC,p,3); hBrush=(HBRUSH)GetStockObject(LTGRAY_BRUSH
6、); SelectObject(hDC,hBrush); p[0].x=210;p[0].y=210;p[1].x=130;p[1].y=130;p[2].x=50;p[2].y=210; Polygon(hDC,p,3); hPen=(HPEN)CreatePen(PS_INSIDEFRAME,1,RGB(0,0,255)); SelectObject(hDC,hPen); MoveToEx(hDC,50,50,NULL); LineTo(hDC,210,210); DeleteObject(hPen); hPen=(HPEN)
7、CreatePen(PS_INSIDEFRAME,1,RGB(0,255,0)); SelectObject(hDC,hPen); MoveToEx(hDC,50,210,NULL); LineTo(hDC,210,50); EndPaint(hWnd,&PtStr); return0; caseWM_DESTROY: PostQuitMessage(0); return0; default: return(DefWindowProc(hWnd,iMessage,wParam,lParam)); }}BOOLInitWindows(HINST
8、ANCEhInstance,intnCmdShow){ HWNDhWnd; hW