




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、面向對象編程技術實驗五實驗報告班級:學號:姓名:時間:2013-12-011實驗要求1A、基本功能要求1B、高級要求12實驗過程及結果12.1 交互式繪制圖形12.2 繪制直線12.3 繪制矩形22.4 繪制橢圓32.5 輸入文本42.6 文本保存62.7 文本讀取73實驗總結8附錄關鍵代碼8一、主CPP8二、附CPP22三、頭文件281實驗要求A、基本功能要求1 .交互式繪制圖形(至少包括線、矩形和文本),繪制完成的圖形能夠正確地重現(xiàn)2 .繪制結果可以正確持久化(存儲到文件、從文件中讀出)3 .最終交付的工程中至少包含兩個源文件(.cpp文件,即除主程序外,將部分函數(shù)分離到單獨的源文件卜一個
2、rc文件B、高級要求用“橢圓”1 .線、矩形、文本的顏色(線色和填充色)、文本字體可調。繪制2 .能夠通過鼠標點擊選中圖形,并進行屬性的修改,修改的內容可包括:位置大小顏色線型字體(對應文本圖元而言)3 .能夠刪除選中的圖形2實驗過程及結果2.1 交互式繪制圖形此次繪制圖形的程序和例程中EasyDraw不同,相比后者,本程序的繪制是建立在結構體數(shù)組的基礎上的。繪制結果完全可以滿足實驗要求。效果圖如下:2.2 繪制直線首先定義一個直線的結構體數(shù)組structMySaveLine/直線保存POINTptS;POINTptE;COLORREFcolor;intpenWidth;intpenStyle
3、;繪制直線的函數(shù)如下:voidDrawMyLine(HDChdc)/繪制直線HPENhPen;HPENhPenOld;intj;for(j=0;j<MAX;j+)hPen=CreatePen(SaveLinej.penStyle,SaveLinej.penWidth,SaveLinej.color);hPenOld=(HPEN)SelectObject(hdc,hPen);MoveToEx(hdc,SaveLinej.ptS.x,SaveLinej.ptS.y,NULL);LineTo(hdc,SaveLinej.ptE.x,SaveLinej.ptE.y);SelectObject(h
4、dc,hPenOld);DeleteObject(hPen);2.3 繪制矩形首先定義一個矩形的結構體數(shù)組structMySaveRectangle/矩形保存POINTptS;POINTptE;COLORREFcolor;HBRUSHhNewBrush;intbrushColor;intpenWidth;intpenStyle;繪制矩形的函數(shù)如下:voidDrawMyRectangle(HDChdc)/繪制矩形intj;HBRUSHhOldBrush;HPENhPen;HPENhPenOld;for(j=0;j<MAX;j+)hPen=CreatePen(SaveRectanglej.p
5、enStyle,SaveRectanglej.penWidth,SaveRectanglej.color);hPenOld=(HPEN)SelectObject(hdc,hPen);switch(pDrawData->iSelectionBrush)caseIDM_BRUSH_WHITE:caseIDM_BRUSH_LTGRAY:hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(SaveRectanglej.brushColor);break;caseIDM_BRUSH_COLORSOLID:caseIDM_BRUSH_CROSS:hOl
6、dBrush=(HBRUSH)SelectObject(hdc,SaveRectanglej.hNewBrush);break;Rectangle(hdc,SaveRectanglej.ptS.x,SaveRectanglej.ptS.y,SaveRectanglej.ptE.x,SaveRectanglej.ptE.y);SelectObject(hdc,hPenOld);DeleteObject(hPen);SelectObject(hdc,hOldBrush);2.4 繪制橢圓首先定義一個橢圓的結構體數(shù)組structMySaveEllipse/橢圓保存POINTptS;POINTptE;
7、COLORREFcolor;HBRUSHhNewBrush;intbrushColor;intpenWidth;intpenStyle;繪制橢圓的函數(shù)如下:voidDrawMyEllipse(HDChdc)/繪制橢圓intj;HBRUSHhOldBrush;HPENhPen;HPENhPenOld;for(j=0;j<MAX;j+)hPen=CreatePen(SaveEllipsej.penStyle,SaveEllipsej.penWidth,SaveEllipsej.color);hPenOld=(HPEN)SelectObject(hdc,hPen);switch(pDrawDa
8、ta->iSelectionBrush)caseIDM_BRUSH_WHITE:caseIDM_BRUSH_LTGRAY:hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(SaveEllipsej.brushColor)break;caseIDM_BRUSH_COLORSOLID:caseIDM_BRUSH_CROSS:hOldBrush=(HBRUSH)SelectObject(hdc,SaveEllipsej.hNewBrush);break;Ellipse(hdc,SaveEllipsej.ptS.x,SaveEllipsej.pt
9、S.y,SaveEllipsej.ptE.x,SaveEllipsej.ptE.y);SelectObject(hdc,hPenOld);DeleteObject(hPen);SelectObject(hdc,hOldBrush);2.5 輸入文本輸入文本前可以選擇文本的字體、顏色,然后點擊鼠標左鍵在該處輸入文本。先定義一個文本的結構體數(shù)組structMySaveText/文本保存POINTpt;charg_EditInput1024;COLORREFcrText;HFONThFont;選擇字體的函數(shù)如下:voidChooseFont(HWNDhwnd)staticLOGFONTlogfont
10、;staticCHOOSEFONTcf;staticHFONThFont;GetObject(GetStockObject(SYSTEM_FONT),sizeof(LOGFONT),cf.lStructSize=sizeof(CHOOSEFONT);cf.hwndOwner=hwnd;cf.hDC=NULL;cf.lpLogFont=&logfont;cf.iPointSize=0;cf.Flags=CF_INITTOLOGFONTSTRUCT|CF_SCREENFONTS|(PTSTR) &logfont);初始化結構logfontCF_EFFECTS;cf.rgbColor
11、s=0;cf.lCustData=0;cf.lpfnHook=NULL;cf.lpTemplateName=NULL;cf.hInstance=NULL;cf.lpszStyle=NULL;cf.nFontType=0;cf.nSizeMin=0;cf.nSizeMax=0;if(ChooseFont(&cf)if(SaveTextq.hFont)DeleteObject(SaveTextq.hFont);SaveTextq.hFont=CreateFontIndirect(&logfont);InvalidateRect(hwnd,NULL,TRUE);選擇顏色的函數(shù)如下:v
12、oidChooseColor(HWNDhwnd)crCustomC010rs16;crText = RGB (0, 0, 0);staticCHOOSECOLORcc;staticCOLORREFstaticCOLORREF初始化結構cccc.lStructSize cc.hwndOwner cc.hInstance cc.rgbResult cc.lpCustC010rs cc.Flags cc.lCustData cc.lpfnHook=sizeof(CHOOSECOLOR);=hwnd;=NULL;=RGB(0,0,0);=crCustomColors;=CC_RGBINIT|CC_FU
13、LLOPEN;=0;=NULL;cc.lpTemplateName=NULL;if(ChooseColor(&cc)SaveTextq.crText=crCustomColors0;InvalidateRect(hwnd,NULL,TRUE);輸出函數(shù)的文本如下:voidDrawMyText(HDChdc)intj;for(j=0;j<MAX;j+)if(SaveTextj.hFont)SelectObject(hdc,SaveTextj.hFont);/選用邏輯字體SetTextColor(hdc,SaveTextj.crText);TextOut(hdc,SaveTextj.
14、pt.x,SaveTextj.pt.y,SaveTextj.g_EditInput,strlen(SaveTextj.g_EditInput);SelectObject(hdc,GetStockObject(SYSTEM_FONT);/還原邏輯字體.2.6 文本保存代碼如下voidSaveMyData(structMySaveLine*SaveLine,intLineCount,structMySaveRectangle*SaveRectangle,intRectangleCount,structMySaveEllipse*SaveEllipse,intEllipseCount,structM
15、ySaveText*SaveText,intTextCount)staticHANDLEhFile;hFile=CreateFile("e:abc.f",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);if(hFile!=INVALID_HANDLE_VALUE)DWORDdwByte1=0;DWORDdwByte2=0;DWORDdwByte3=0;DWORDdwByte4=0;WriteFile(hFile,&LineCount,sizeof(int),&dwByte1,NULL);WriteFile(hFile,&
16、amp;RectangleCount,sizeof(int),&dwByte2,NULL);WriteFile(hFile,&EllipseCount,sizeof(int),&dwByte3,NULL);WriteFile(hFile,&TextCount,sizeof(int),&dwByte4,NULL);WriteFile(hFile,SaveLine,LineCount*sizeof(MySaveLine),&dwByte1,NULL);WriteFile(hFile,SaveRectangle,RectangleCount*sizeo
17、f(MySaveRectangle),&dwByte2,NULL);WriteFile(hFile,SaveEllipse,EllipseCount*sizeof(MySaveEllipse),&dwByte3,NULL);WriteFile(hFile,SaveText,TextCount*sizeof(MySaveText),&dwByte4,NULL);CloseHandle(hFile);2.7 文本讀取代碼如下:voidLoadMyData(structMySaveLine*SaveLine,intLineCount,structMySaveRectangle
18、*SaveRectangle,intRectangleCount,structMySaveEllipse*SaveEllipse,intEllipseCount,structMySaveText*SaveText,intTextCount)staticHANDLEhFile;hFile=CreateFile("e:abc.f",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);if(hFile!=INVALID_HANDLE_VALUE)DWORDdwByte1=0;DWORDdwByte2=0;DWORDdwB
19、yte3=0;DWORDdwByte4=0;ReadFile(hFile,&LineCount,sizeof(int),&dwByte1,NULL);ReadFile(hFile,&RectangleCount,sizeof(int),&dwByte2,NULL);ReadFile(hFile,&EllipseCount,sizeof(int),&dwByte3,NULL);ReadFile(hFile,&TextCount,sizeof(int),&dwByte4,NULL);ReadFile(hFile,SaveLine,Li
20、neCount*sizeof(MySaveLine),&dwByte1,NULL);ReadFile(hFile,SaveRectangle,RectangleCount*sizeof(MySaveRectangle),&dwByte2,NULL);ReadFile(hFile,SaveEllipse,EllipseCount*sizeof(MySaveEllipse),&dwByte3,NULL);ReadFile(hFile,SaveText,TextCount*sizeof(MySaveText),&dwByte4,NULL);CloseHandle(hF
21、ile);3實驗總結本實驗最大的特點是使用結構體數(shù)組,這也是我第一次使用結構體數(shù)組,從不使用結構體到使用結構體指針最后升級到結構體數(shù)組是一個循序漸進的過程,在這個過程中我越來越感覺到結構體在管理數(shù)據(jù)方面的優(yōu)勢。我的感覺是在主CPP文件中代碼應該是越少越好,很多地方只要調用函數(shù)就可以了,然后在另外的CPP中寫函數(shù)。這樣的程序給人的感覺是分層做的比較好,調理比較清晰。附錄關鍵代碼一、主CPP/*程序:Paint文件:Paint.cpp功能:簡易的圖像編輯器*/#include"draw.h"#defineMAX100TCHARszAppName口;structMySaveLin
22、eSaveLineMAX;structMySaveRectangleSaveRectangleMAX;structMySaveEllipseSaveEllipseMAX;structMySaveTextSaveTextMAX;intlineCount;intrectangleCount;intellipseCount;inttextCount;DRAWDATA*pDrawData;HACCELhAccel;HDChdc;inti,m,n,p,q;BOOLInitWindow(HINSTANCEhInstance,intnCmdShow);LRESULTCALLBACKWinProc(HWNDh
23、Wnd,UINTmessage,WPARAMwParam,LPARAMlParam);/*函數(shù):WinMain()功能:Win32應用程序入口函數(shù)。創(chuàng)建主窗口,處理消息循環(huán)*/intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,PSTRszCmdLine,intiCmdShow)當前實例句柄前一個實例句柄/命令行字符/窗口顯示方式MSGmsg;char*p;創(chuàng)建主窗口if(!InitWindow(hInstance,iCmdShow)returnFALSE;p=0;/進入消息循環(huán):從該應用程序的消息隊列中檢取消息,/送到消息處理
24、過程,當檢取到WM_QUIT消息時,退出消息循環(huán)。while(GetMessage(&msg,NULL,0,0)TranslateMessage(&msg);DispatchMessage(&msg);returnmsg.wParam;/*函數(shù):InitWindow()功能:創(chuàng)建窗口。*/staticBOOLInitWindow(HINSTANCEhInstance,intiCmdShow)HWNDhwnd;窗口句柄WNDCLASSwcMainWnd;窗口類結構ATOMa;填充窗口類結構wcMainWnd.style=CS_VREDRAW|CS_HREDRAW;wcMa
25、inWnd.lpfnWndProc=WinProc;wcMainWnd.cbClsExtra=0;wcMainWnd.cbWndExtra=0;wcMainWnd.hInstance=hInstance;wcMainWnd.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1);wcMainWnd.hCursor=LoadCursor(NULL,IDC_ARROW);wcMainWnd.hbrBackground=(structHBRUSH_*)GetStockObject(WHITE_BRUSH);wcMainWnd.lpszMenuName=
26、(LPSTR)IDR_MENU1;wcMainWnd.lpszClassName=szAppName;LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR1);hAccel=LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCELERATOR1);注冊窗口類a=RegisterClass(&wcMainWnd);if(!a)MessageBox(NULL,TEXT("注冊窗口類失敗!"),szAppName,MB_ICONERROR);return0;創(chuàng)建
27、主窗口窗口類名稱hwnd=CreateWindow(szAppName,窗口風格窗口位置的x坐標窗口位置的y坐標窗口的寬度窗口的高度父窗口句柄菜單句柄應用程序實例句柄窗口創(chuàng)建數(shù)據(jù)指針TEXT("簡易的圖形編輯器作者:婁通)窗口標題WS_OVERLAPPEDWINDOW,200,200,800,450,NULL,NULL,hInstance,NULL);if(!hwnd)returnFALSE;顯示并更新窗口ShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);returnTRUE;/*函數(shù):WinProc()功能:處理主窗口消息*/LRESULTC
28、ALLBACKWinProc(HWNDhWnd,UINTmessage,WPARAMwParam,LPARAMIParam)PAINTSTRUCTps;RECTrect;HMENUhMenu;bDrawing=FALSE,Line=FALSE,staticBOOLRectangle=FALSE,Ellipse=FALSE,Text=FALSE;staticHMENUhPopMenu;POINTpt;inthNewPenStyle,hNewPenWidth;intBrushColor;COLORREFhNewPenColor;staticintx,y;staticchara100;HBRUSHh
29、NewBrush;staticintk=1;staticHWNDhWndEdit;static LOGFONT static CHOOSEFONT static HFONTstatic CHOOSECOLOR static COLORREF static COLORREF static HANDLE switch (message) logfont;cf;hFont;cc;crCustomC010rs16;crText = RGB (0, 0, 0);hFile;caseWMCREATE:創(chuàng)建消息pDrawData=newDRAWDATA;pDrawData->iSelectionFun
30、c=IDM_FUNC_LINETO;pDrawData->iSelectionPenColor=IDM_PEN_BLACK;pDrawData->iSelectionPenStyle=IDM_PEN_SOLID;pDrawData->iSelectionPenWidth=IDM_PEN_WIDTH1;if(pDrawData)SetWindowLong(hWnd,0,(LONG)pDrawData);初始化結構cfGetObject(GetStockObject(SYSTEM_FONT),sizeof(LOGFONT),(PTSTR)&logfont);初始化結構lo
31、gfontcf.lStructSize=sizeof(CHOOSEFONT);cf.hwndOwner=hWnd;cf.hDC=NULL;cf.lpLogFont=&logfont;cf.iPointSize=:0;cf.Flags=CF_INITTOLOGFONTSTRUCTCF_EFFECTS;cf.rgbColors=0;cf.lCustData=0;cf.lpfnHook=NULL;cf.lpTemplateName=NULL;cf.hInstance=NULL;cf.lpszStyle=NULL;cf.nFontType=0;cf.nSizeMin=0;cf.nSizeMax
32、=0;初始化結構cccc.lStructSize=:sizeof(CHOOSECOLOR);cc.hwndOwner=hWnd;cc.hInstance=NULL;cc.rgbResult=RGB(0,0,0);cc.lpCustColors=crCustomColors;cc.Flags=CC_RGBINIT|CC_FULLOPEN;cc.lCustData=0;cc.lpfnHook=NULL;|CF_SCREENFONTS|cc.lpTemplateName=NULL;/顯不'窗口標題hPopMenu=LoadMenu(LPCREATESTRUCT)lParam)->hIn
33、stance,MAKEINTRESOURCE(IDR_MENU1);hPopMenu=GetSubMenu(hPopMenu,2);return0;caseWM_COMMAND:hMenu=GetMenu(hWnd);switch(LOWORD(wParam)caseIDM_FILE_EXIT:SendMessage(hWnd,WM_CLOSE,0,0);return0;caseIDM_FILE_SAVE:SaveMyData(SaveLine,lineCount,SaveRectangle,rectangleCount,SaveEllipse,ellipseCount,SaveText,te
34、xtCount);InvalidateRect(hWnd,NULL,TRUE);return0;caseIDM_FILE_OPEN:LoadMyData(SaveLine,lineCount,SaveRectangle,rectangleCount,SaveEllipse,ellipseCount,SaveText,textCount);InvalidateRect(hWnd,NULL,TRUE);return0;caseIDM_FUNC_ELLIPSE:CheckMenuItem(hMenu,pDrawData->iSelectionFunc,MF_UNCHECKED);pDrawDa
35、ta->iSelectionFunc=LOWORD(wParam);CheckMenuItem(hMenu,pDrawData->iSelectionFunc,MF_CHECKED);Line=FALSE;Rectangle=FALSE;Ellipse=TRUE;Text=FALSE;return0;caseIDM_FUNC_RECTANGLE:CheckMenuItem(hMenu,pDrawData->iSelectionFunc,MF_UNCHECKED);pDrawData->iSelectionFunc=LOWORD(wParam);CheckMenuItem
36、(hMenu,pDrawData->iSelectionFunc,MF_CHECKED);Line=FALSE;Rectangle=TRUE;Ellipse=FALSE;Text=FALSE;return0;caseIDM_FUNC_LINETO:CheckMenuItem(hMenu,pDrawData->iSelectionFunc,MF_UNCHECKED);pDrawData->iSelectionFunc=LOWORD(wParam);CheckMenuItem(hMenu,pDrawData->iSelectionFunc,MF_CHECKED);Line=
37、TRUE;Rectangle=FALSE;Ellipse=FALSE;Text=FALSE;return0;caseIDM_TEXT_INPUT:Text=TRUE;Line=FALSE;Rectangle=FALSE;Ellipse=FALSE;InvalidateRect(hWnd,NULL,FALSE);return0;caseIDM_TEXT_FONT:ChooseFont(hWnd);return0;caseIDM_TEXT_COLOR:ChooseColor(hWnd);return0;caseIDM_PEN_BLACK:caseIDM_PEN_RED:caseIDM_PEN_BL
38、UE:CheckMenuItem(hMenu,pDrawData->iSelectionPenColor,MF_UNCHECKED);pDrawData->iSelectionPenColor=LOWORD(wParam);CheckMenuItem(hMenu,pDrawData->iSelectionPenColor,MF_CHECKED);InvalidateRect(hWnd,NULL,TRUE);return0;caseIDM_PEN_SOLID:caseIDM_PEN_DASHDOT:CheckMenuItem(hMenu,pDrawData->iSelec
39、tionPenStyle,MF_UNCHECKED);pDrawData->iSelectionPenStyle=LOWORD(wParam);CheckMenuItem(hMenu,pDrawData->iSelectionPenStyle,MF_CHECKED);InvalidateRect(hWnd,NULL,TRUE);return0;caseIDM_PEN_WIDTH1:caseIDM_PEN_WIDTH2:caseIDM_PEN_WIDTH3:CheckMenuItem(hMenu,pDrawData->iSelectionPenWidth,MF_UNCHECKE
40、D);pDrawData->iSelectionPenWidth=LOWORD(wParam);CheckMenuItem(hMenu,pDrawData->iSelectionPenWidth,MF_CHECKED);InvalidateRect(hWnd,NULL,TRUE);return0;caseIDM_BRUSH_WHITE:caseIDM_BRUSH_LTGRAY:caseIDM_BRUSH_COLORSOLID:caseIDM_BRUSH_CROSS:CheckMenuItem(hMenu,pDrawData->iSelectionBrush,MF_UNCHEC
41、KED);pDrawData->iSelectionBrush=LOWORD(wParam);CheckMenuItem(hMenu,pDrawData->iSelectionBrush,MF_CHECKED);return0;return0;caseWM_RBUTTONDOWN:/鼠標消息if(LOWORD(lParam)>240)&&(LOWORD(lParam)<480)&&(HIWORD(lParam)>120)&&(HIWORD(lParam)<150)if(ChooseFont(&cf)if
42、(hFont)DeleteObject(hFont);hFont=CreateFontIndirect(&logfont);InvalidateRect(hWnd,NULL,TRUE);elsept.x=LOWORD(lParam);pt.y=HIWORD(lParam);ClientToScreen(hWnd,&pt);TrackPopupMenu(hPopMenu,TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON,pt.x,pt.y,0,hWnd,NULL);return0;caseWM_LBUTTONDOWN:if(!bDrawing)S
43、etCapture(hWnd);if(Line)設置繪圖的起始、終止點SaveLinei.ptS.x=LOWORD(IParam);SaveLinei.ptS.y=HIWORD(lParam);SaveLinei.ptE.x=LOWORD(lParam);SaveLinei.ptE.y=HIWORD(lParam);if(Rectangle)SaveRectanglem.ptS.x=LOWORD(lParam);SaveRectanglem.ptS.y=HIWORD(lParam);SaveRectanglem.ptE.x=LOWORD(lParam);SaveRectanglem.ptE.y
44、=HIWORD(lParam);if(Ellipse)SaveEllipsen.ptS.x=LOWORD(lParam);SaveEllipsen.ptS.y=HIWORD(lParam);SaveEllipsen.ptE.x=LOWORD(lParam);SaveEllipsen.ptE.y=HIWORD(lParam);if(Text)SaveTextq.pt.x=LOWORD(lParam);SaveTextq.pt.y=HIWORD(lParam);if(LOWORD(lParam)>240)&&(LOWORD(lParam)<480)&&(
45、HIWORD(lParam)>120)&&(HIWORD(lParam)<150)if(ChooseColor(&cc)crText=crCustomColors0;InvalidateRect(hWnd,NULL,TRUE);elseif(Text)if(DialogBox(HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE),MAKEINTRESOURCE(IDD_DIALOG1),hWnd,InputDlgProc)=IDOK)DrawMyText(hdc);q+;textCount+;x=GET_X_LPARAM(l
46、Param);y=GET_Y_LPARAM(lParam);wsprintf(a,"鼠標位置x=%d,y=%d",x,y);DrawText(hdc,a,-1,&rect,DT_RIGHT);DrawText(hdc,TEXT("請在空白處單擊鼠標左鍵輸入文本"),-1,&rect,DT_RIGHT|DT_BOTTOM);InvalidateRect(hWnd,NULL,FALSE);bDrawing=TRUE;return0;caseWM_LBUTTONUP:if(bDrawing)SetCapture(NULL);if(Line)Sa
47、veLinei.ptE.x=(short)LOWORD(lParam);SaveLinei+.ptE.y=(short)HIWORD(lParam);lineCount+;if(Rectangle)SaveRectanglem.ptE.x=(short)LOWORD(lParam);SaveRectanglem+.ptE.y=(short)HIWORD(lParam);rectangleCount+;if(Ellipse)SaveEllipsen.ptE.x=(short)LOWORD(lParam);SaveEllipsen+.ptE.y=(short)HIWORD(lParam);elli
48、pseCount+;bDrawing=FALSE;return0;caseWM_MOUSEMOVE:if(!bDrawing)return0;hdc=GetDC(hWnd);switch(pDrawData->iSelectionPenColor)caseIDM_PEN_BLACK:hNewPenColor=RGB(0,0,0);break;caseIDM_PEN_RED:hNewPenColor=RGB(255,0,0);break;caseIDM_PEN_BLUE:hNewPenColor=RGB(0,0,255);break;switch(pDrawData->iSelect
49、ionPenStyle)caseIDM_PEN_SOLID:hNewPenStyle=PS_SOLID;break;caseIDM_PEN_DASHDOT:hNewPenStyle=PS_DASHDOT;break;switch(pDrawData->iSelectionPenWidth)caseIDM_PEN_WIDTH1:hNewPenWidth=1;break;caseIDM_PEN_WIDTH2:hNewPenWidth=2;break;caseIDM_PEN_WIDTH3:hNewPenWidth=3;break;switch(pDrawData->iSelectionB
50、rush)caseIDM_BRUSH_WHITE:BrushColor=WHITE_BRUSH;break;caseIDM_BRUSH_LTGRAY:BrushColor=LTGRAY_BRUSH;break;caseIDM_BRUSH_COLORSOLID:創(chuàng)建并選擇彩色實體畫刷hNewBrush=(HBRUSH)CreateSolidBrush(RGB(0,255,255);break;caseIDM_BRUSH_CROSS:創(chuàng)建并選擇綠色十字影線畫刷hNewBrush=CreateHatchBrush(HS_CROSS,RGB(0,255,0);break;if(Line)SaveLin
51、ei.penStyle=hNewPenStyle;SaveLinei.penWidth=hNewPenWidth;SaveLinei.color=hNewPenColor;if(Rectangle)SaveRectanglem.penStyle=hNewPenStyle;SaveRectanglem.penWidth=hNewPenWidth;SaveRectanglem.color=hNewPenColor;SaveRectanglem.brushColor=BrushColor;SaveRectanglem.hNewBrush=hNewBrush;if(Ellipse)SaveEllips
52、en.penStyle=hNewPenStyle;SaveEllipsen.penWidth=hNewPenWidth;SaveEllipsen.color=hNewPenColor;SaveEllipsen.brushColor=BrushColor;SaveEllipsen.hNewBrush=hNewBrush;清除原繪圖軌跡SetROP2(hdc,R2_WHITE);switch(pDrawData->iSelectionFunc)caseIDM_FUNC_LINETO:DrawMyLine(hdc);break;caseIDM_FUNC_RECTANGLE:DrawMyRect
53、angle(hdc);break;caseIDM_FUNC_ELLIPSE:DrawMyEllipse(hdc);break;if(Line)SaveLinei.ptE.x=(short)LOWORD(IParam);SaveLinei.ptE.y=(short)HIWORD(lParam);if(Rectangle)SaveRectanglem.ptE.x=(short)LOWORD(lParam);SaveRectanglem.ptE.y=(short)HIWORD(lParam);if(Ellipse)SaveEllipsen.ptE.x=(short)LOWORD(lParam);SaveEllipsen.ptE.y=(short)HIWORD(lP
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年小學英語能力測試試題及答案
- 2025年糧食安全與農業(yè)發(fā)展考試試題及答案
- 2025年國家安全法相關知識測試卷及答案
- 2025年公共英語等級考試試卷及答案
- 2025年供應鏈金融理論與實踐考試試題及答案
- 物資管理計劃管理制度
- 物資驗收安全管理制度
- 特殊員工工時管理制度
- 特殊學生安全管理制度
- 特殊氣體存放管理制度
- 企業(yè)標準化體系建立課件
- 醫(yī)院護士辭職申請書集合六篇(護士崗位辭職申請書)
- 靜脈注射 Microsoft PowerPoint 演示文稿課件
- 同濟大學論文答辯通用PPT模板
- AFC檢測技術規(guī)程
- 部編人教版二年級下學期數(shù)學期末學業(yè)質量監(jiān)測復習課堂知識練習題
- 餐飲行業(yè)抖音代運營方案
- 《聰明人和傻子和奴才》 課件
- Fleischner指南解讀
- 建筑工地安全生產百日攻堅行動實施方案
- 電廠度電機維修技術規(guī)范書正式
評論
0/150
提交評論