当前位置: 首页>>代码示例>>C++>>正文


C++ Draw::Distance方法代码示例

本文整理汇总了C++中Draw::Distance方法的典型用法代码示例。如果您正苦于以下问题:C++ Draw::Distance方法的具体用法?C++ Draw::Distance怎么用?C++ Draw::Distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Draw的用法示例。


在下文中一共展示了Draw::Distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WndProc

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	Draw Ahmed;
	switch (message)
	{
		case WM_LBUTTONDOWN: 
			if(!isSecond) 
				X1 = LOWORD(lParam), Y1 = HIWORD(lParam) , isSecond = true;
			else 
				X2 = LOWORD(lParam) , Y2 = HIWORD(lParam) , InvalidateRect(hWnd, NULL, false);
		break;
		case WM_COMMAND:
			wmId = LOWORD(wParam) , wmEvent = HIWORD(wParam);
			// Parse the menu selections:
			switch (wmId){
				case IDM_S:
					ss.open("input.in") , tmp.clear() , tmp = var;
					while(var.size())
						ss << var.front().x1 << " " << var.front().y1 << " " << var.front().x2 << " " << 
							var.front().y2 << " " << var.front().P <<"\n" , var.pop_front();
					var = tmp , ss.close();
				break;
				case IDM_O:
					clr() , OT = true;
					InvalidateRect(hWnd, NULL, true); // draw only a line on the screen
				break;
				case IDM_DDA_LINE:
					clr() , BDDA = 1;
				break;
				case IDM_MP_LINE:
					clr() , BMP = true;
				break;
					case IDM_MP_CIRCULE:
					clr() , MPC = true;
				break;
				case IDM_CIRC_CART:
					clr() , cartizen = true;
				break;
				case IDM_RES:
					RES = true;
					isSecond  = false;
					InvalidateRect(hWnd, NULL, true); // draw only a line on the screen
				break;
				case IDM_R:
					clr() ,  R = true , InvalidateRect(hWnd , 0 , false);
				break;
				case IDM_U:
					clr() ,  U = true , InvalidateRect(hWnd , 0 , false);
				break;
				case IDM_COL:
					memset(&color,0,sizeof(color));
					color.lStructSize=sizeof(CHOOSECOLOR);
					color.hwndOwner=hWnd;
					color.lpCustColors=ccref;
					color.rgbResult=selcolor;
					color.Flags=CC_RGBINIT;
					if(ChooseColor(&color))
						selcolor=color.rgbResult;
					isSecond = false;
				break;
				case IDM_ABOUT:
					DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
					break;
				case IDM_EXIT:
					DestroyWindow(hWnd);
					break;
				default:
					return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
			case WM_PAINT:
				hdc = BeginPaint(hWnd, &ps);
				Ahmed.ps = ps ;
				if(OT == true){
					ss.open("input.in");
					PT tmst;
					while(!ss.eof()){
						ss >> tmst.x1 >> tmst.y1 >> tmst.x2 >> tmst.y2 >> tmst.P;			
						if (tmst.P == 'D')
							Ahmed.DDA(tmst.x1 , tmst.y1 , tmst.x2 , tmst.y2 , selcolor);
						if (tmst.P == 'M')
							Ahmed.MidPoint(tmst.x1 , tmst.y1 , tmst.x2 , tmst.y2 , selcolor);
						if (tmst.P == 'C')
							Ahmed.drawCircle(tmst.x1 , tmst.y1 , Ahmed.Distance(tmst.x1 , tmst.y1 , tmst.x2 , tmst.y2), selcolor);
						if(tmst.P == 'Z')
							Ahmed.MIDPOINT_CARTISIEAN(tmst.x1, tmst.y1 , Ahmed.Distance(tmst.x1 , tmst.y1 , tmst.x2 , tmst.y2), selcolor);
					}
					ss.close();
					clr() , BDDA = true , X1 = X2 = Y1 = Y2 = 0;
					EndPaint(hWnd, &ps);
					break;
				}
				if(U == true){
					if(var.size() != 0){
						PT t = var.back();
						var.pop_back() , var.push_front(t) ;
						if (t.P == 'D')
							Ahmed.DDA(t.x1 , t.y1 , t.x2 , t.y2 , RGB(250,250,250));
//.........这里部分代码省略.........
开发者ID:sngvahmed,项目名称:Graphics,代码行数:101,代码来源:graphics.cpp


注:本文中的Draw::Distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。