コード例 #1
0
void CTabItem_MainTabBn::DrawHover(CDC* pDC, const CRect &rect)
{
	CRect	rtFrm;
	CRect	rtFace;

	rtFrm = rect;
	rtFace = rect;

	{
		CPenDC	penOutSide(pDC->GetSafeHdc(), RGB(126, 165, 250));

		rtFace.top += 3;
		Draw2GradLayerRect(pDC->GetSafeHdc(), rtFace, RGB(255, 255, 255), RGB(228, 236, 254), RGB(205, 221, 253), RGB(240, 246, 255), 62);
		DrawRound(pDC->GetSafeHdc(), rtFrm, 3);
	}

	{
		CPenDC	penInSide(pDC->GetSafeHdc(), RGB(255, 255, 255), 2);

		rtFrm.left += 2;
		rtFrm.top += 2;
		rtFrm.right -= 1;
		rtFrm.bottom -= 2;

		DrawRound(pDC->GetSafeHdc(), rtFrm, 3);
	}
}
コード例 #2
0
void CTabItem_MainTabBn::DrawInactiveBk(CDC* pDC, const CRect &rect)
{
	CRect	rtFrm;
	CRect	rtFace;

	rtFrm = rect;
	rtFace = rect;

	{
		CPenDC	penOutSide(pDC->GetSafeHdc(), RGB(171, 164, 150));

		rtFace.top += 3;
		Draw2GradLayerRect(pDC->GetSafeHdc(), rtFace, RGB(255, 255, 255), RGB(239, 238, 234), RGB(226, 223, 215), RGB(242, 241, 235), 62);
		DrawRound(pDC->GetSafeHdc(), rtFrm, 3);
	}

	{
		CPenDC	penInSide(pDC->GetSafeHdc(), RGB(255, 255, 255), 2);

		rtFrm.left += 2;
		rtFrm.top += 2;
		rtFrm.right -= 1;
		rtFrm.bottom -= 2;

		DrawRound(pDC->GetSafeHdc(), rtFrm, 3);
	}
}
コード例 #3
0
void CTabItem_MainTabBn::DrawActiveBk(CDC* pDC, const CRect &rect)
{
	CRect	rtFrm;
	CRect	rtFace;

	rtFrm = rect;
	rtFace = rect;

	{
		CPenDC	penOutSide(pDC->GetSafeHdc(), RGB(110, 150, 199));

		rtFace.top += 3;
		Draw2GradLayerRect(pDC->GetSafeHdc(), rtFace, RGB(239, 243, 249), RGB(220, 229, 241), RGB(187, 206, 229), RGB(255, 255, 255), 62);
		DrawRound(pDC->GetSafeHdc(), rtFrm, 3);
	}

	{
		CPenDC	penInSide(pDC->GetSafeHdc(), RGB(255, 255, 255), 2);

		rtFrm.left += 2;
		rtFrm.top += 2;
		rtFrm.right -= 1;
		rtFrm.bottom -= 2;

		DrawRound(pDC->GetSafeHdc(), rtFrm, 3);
	}
}
コード例 #4
0
ファイル: Scene3D.c プロジェクト: JingoC/LCD_DISPLAY
void Draw3DAxes(void)
{
	Round rCenter;
	Line l;
	
	//center axes
	
	rCenter.Center.X = OFFSET_X_CENTER;
	rCenter.Center.Y = OFFSET_Y_CENTER;
	rCenter.R = 5;
	
	DrawRound(&rCenter, &cCenter, 0);
	
	// y
	l.Start.X = 0;
	l.Start.Y = 0;
	l.Start.Z = 0;
	l.Stop.X = 0;
	l.Stop.Y = 250;
	l.Stop.Z = 0;
	
	DrawVector(&l, &cYLine, 0);
	
	//x
	l.Start.X = 0;
	l.Start.Y = 0;
	l.Start.Z = 0;
	l.Stop.X = 250;
	l.Stop.Y = 0;
	l.Stop.Z = 0;
	
	DrawVector(&l, &cXLine, 0);
	
	//z
	l.Start.X = 0;
	l.Start.Y = 0;
	l.Start.Z = 0;
	l.Stop.X = 0;
	l.Stop.Y = 0;
	l.Stop.Z = 250;
	
	DrawVector(&l, &cZLine, 0);
}
コード例 #5
0
ファイル: Win32Project1.cpp プロジェクト: laphuynh915/projet
VOID				DrawRoundProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	RECT windowRect;
	switch (message)
	{
	case WM_LBUTTONDOWN:
	{
		p1.x = GET_X_LPARAM(lParam);
		p1.y = GET_Y_LPARAM(lParam);
		//p2_ancien = p2 = p1;
		enTrainDessin = TRUE;
		break;
	}
	case WM_MOUSEMOVE:
	{
		if (wParam&MK_LBUTTON)
		{
			p2.x = GET_X_LPARAM(lParam);
			p2.y = GET_Y_LPARAM(lParam);
			GetWindowRect(hWnd, &windowRect);
			InvalidateRect(hWnd, &windowRect, FALSE);
			UpdateWindow(hWnd);
		}
		break;
	}
	case WM_LBUTTONUP:

		//Tiến hành cho vẽ lên bitmap
		HDC hdc = GetDC(hWnd);
		HDC memDC = CreateCompatibleDC(hdc);
		SelectObject(memDC, hBitmap);
		DrawRound(memDC);
		DeleteObject(memDC);
		ReleaseDC(hWnd, hdc);

		enTrainDessin = FALSE;
		break;
	}
}
コード例 #6
0
ファイル: Scene3D.c プロジェクト: JingoC/LCD_DISPLAY
void DrawProjection2DAxes(void)
{
	Round rCenter;
	Line l;
	
	// projection AXES
	
	// Axes XY
	rCenter.Center.X = OFFSET_X_XY_CENTER;
	rCenter.Center.Y = OFFSET_Y_XY_CENTER;
	rCenter.R = 5;
	
	DrawRound(&rCenter, &cCenter, 0);
	
	l.Start.X = OFFSET_X_XY_CENTER;
	l.Start.Y = OFFSET_Y_XY_CENTER;
	l.Stop.X	= OFFSET_X_XY_CENTER;
	l.Stop.Y	= OFFSET_Y_XY_CENTER - 120;
	
	DrawLine(&l, &cYLine);
	
	l.Start.X = OFFSET_X_XY_CENTER;
	l.Start.Y = OFFSET_Y_XY_CENTER;
	l.Stop.X	= OFFSET_X_XY_CENTER + 120;
	l.Stop.Y	= OFFSET_Y_XY_CENTER;
	
	DrawLine(&l, &cXLine);
	// Axes YZ
	
	rCenter.Center.X = OFFSET_X_YZ_CENTER;
	rCenter.Center.Y = OFFSET_Y_YZ_CENTER;
	rCenter.R = 5;
	
	DrawRound(&rCenter, &cCenter, 0);
	
	l.Start.X = OFFSET_X_YZ_CENTER;
	l.Start.Y = OFFSET_Y_YZ_CENTER;
	l.Stop.X	= OFFSET_X_YZ_CENTER;
	l.Stop.Y	= OFFSET_Y_YZ_CENTER - 120;
	
	DrawLine(&l, &cYLine);
	
	l.Start.X = OFFSET_X_YZ_CENTER;
	l.Start.Y = OFFSET_Y_YZ_CENTER;
	l.Stop.X	= OFFSET_X_YZ_CENTER + 120;
	l.Stop.Y	= OFFSET_Y_YZ_CENTER;
	
	DrawLine(&l, &cZLine);
	// Axes XZ
	
	rCenter.Center.X = OFFSET_X_XZ_CENTER;
	rCenter.Center.Y = OFFSET_Y_XZ_CENTER;
	rCenter.R = 5;
	
	DrawRound(&rCenter, &cCenter, 0);
	
	l.Start.X = OFFSET_X_XZ_CENTER;
	l.Start.Y = OFFSET_Y_XZ_CENTER;
	l.Stop.X	= OFFSET_X_XZ_CENTER;
	l.Stop.Y	= OFFSET_Y_XZ_CENTER - 120;
	
	DrawLine(&l, &cXLine);
	
	l.Start.X = OFFSET_X_XZ_CENTER;
	l.Start.Y = OFFSET_Y_XZ_CENTER;
	l.Stop.X	= OFFSET_X_XZ_CENTER + 120;
	l.Stop.Y	= OFFSET_Y_XZ_CENTER;
	
	DrawLine(&l, &cZLine);
}
コード例 #7
0
void CTabItem_Normal::DrawItem(CDC* pDC, const CRect &rect, COLORREF clrFrmOutside, COLORREF clrFrmInside, COLORREF clrLayers[4])
{
	CRect	rtFrm;
	CRect	rtFace;

	rtFrm = rect;
	rtFace = rect;

	switch (GetBarPos())
	{
	case TBP_TOP:
	default:
		rtFace.top += 2;
		Draw2GradLayerRect(pDC->GetSafeHdc(), rtFace, clrLayers[0], clrLayers[1], clrLayers[2], clrLayers[3], 62);
		break;
	case TBP_BOTTOM:
		rtFace.bottom -= 2;
		Draw2GradLayerRect(pDC->GetSafeHdc(), rtFace, clrLayers[0], clrLayers[1], clrLayers[2], clrLayers[3], 62);
		break;
	}



	{
		CPenDC	penInSide(pDC->GetSafeHdc(), clrFrmInside, 1);

		switch (GetBarPos())
		{
		case TBP_TOP:
		default:
			rtFrm.left += 1;
			rtFrm.right -= 1;
			rtFrm.top += 1;

			DrawRound(pDC->GetSafeHdc(), rtFrm, 3, 2);
			//Draw3Borders(pDC->GetSafeHdc(), rtFrm, 3);
			break;
		case TBP_BOTTOM:
			rtFrm.left += 1;
			rtFrm.right -= 1;
			rtFrm.bottom -= 1;
			DrawRound(pDC->GetSafeHdc(), rtFrm, 1, 2);
			//Draw3Borders(pDC->GetSafeHdc(), rtFrm, 1);
			break;
		}
	}

	{
		CPenDC	penOutSide(pDC->GetSafeHdc(), clrFrmOutside);

		switch (GetBarPos())
		{
		case TBP_TOP:
		default:
			DrawRound(pDC->GetSafeHdc(), rect, 3, 3);
			//Draw3Borders(pDC->GetSafeHdc(), rtFrm, 3);
			break;
		case TBP_BOTTOM:
			DrawRound(pDC->GetSafeHdc(), rect, 1, 3);
			//Draw3Borders(pDC->GetSafeHdc(), rect, 1);
			break;
		}
	}

}
コード例 #8
0
ファイル: Win32Project1.cpp プロジェクト: laphuynh915/projet
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc = GetDC(hWnd);
	switch (mode)
	{
	case 0:
		FreeDrawProc(hWnd, message, wParam, lParam);
		break;
	case 1:
		DrawLineProc(hWnd, message, wParam, lParam);
	case 2:
		DrawEllipseProc(hWnd, message, wParam, lParam);
	case 3:
		DrawRoundProc(hWnd, message, wParam, lParam);
	case 4:
		DrawSquareProc(hWnd, message, wParam, lParam);
	case 5:
		DrawRectangleProc(hWnd, message, wParam, lParam);
	}
	
	switch (message)
    {
	case WM_CREATE:
	{
		p1.x = p1.y = 0;
		p2 = p1;
		mode = 1;
		enTrainDessin = FALSE;

		//Tạo bitmap
	
		RECT rect;
		GetClientRect(hWnd, &rect);
		//Tạo ra một bitmap tương thích với DC màn hình
		hBitmap = CreateCompatibleBitmap(hdc, rect.right - rect.left, rect.bottom - rect.top);
		
		//Tô background cho bitmap
		//Tạo memory dc để tương tác với Bitmap
		HDC memDC = CreateCompatibleDC(hdc);
		SelectObject(memDC, hBitmap);
		HBRUSH hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
		FillRect(memDC, &rect, hBrush);
		DeleteObject(hBrush);
		DeleteDC(memDC);
		ReleaseDC(hWnd, hdc);
		break;
	}
    case WM_COMMAND:
        {
			
            int wmId = LOWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
			case ID_LINE_STRAIGHTLINE:
				mode = 1;
			break;
			case ID_LINE_FREESTYLE:
				mode = 0;
				break;
			
			case ID_SHAPE_ELLIPSE:
				mode = 2;
				break;
			
			case ID_SHAPE_ROUND:
				mode = 3;
				break;
			
			case ID_SHAPE_SQUARE:
				mode = 4;
				break;
			
			case ID_SHAPE_RECTANGLE:
				mode = 5;
				break;

			case ID_DRAW_WIDTH:
				DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG2), hWnd, AboutBox);
				break;

			case ID_COLOR_RED:
				R = 255;
				G = 0;
				B = 0;
					break;

			case ID_COLOR_GREEN:
				R = 0;
				G = 255;
				B = 0;
					break;


			case ID_COLOR_BLUE:
				R = 0;
				G = 0;
				B = 255;
					break;

			case ID_FORMAT_COLOR:
				doChooseColor(hEdit);

				break;
            
			case ID_FILE_OPEN:

				OPENFILENAME ofn;
				TCHAR szFile[260];
				ZeroMemory(&ofn, sizeof(ofn));
				ofn.lStructSize = sizeof(ofn);
				ofn.hwndOwner = hWnd;
				ofn.lpstrFile = szFile;
				ofn.lpstrFile[0] = '\0';
				ofn.nMaxFile = sizeof(szFile);
				ofn.lpstrFilter = _T("All Files *.*\0*.*\0Text Files *.txt\0*.TXT\0 Doc Files\0*.TXT;*.DOC;*.BAK\0");
				ofn.nFilterIndex = 1;
				ofn.lpstrInitialDir = _T("C:\\");
				ofn.lpstrTitle = _T("My Application - Open file");
				ofn.lpstrDefExt = _T("txt");
				ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

				// Display the Open dialog box. 
				if (GetOpenFileName(&ofn) == TRUE) {
					PAINTSTRUCT ps;
					HDC hdc = GetDC(hWnd);
					//			HDC hdcDestination;
					HBITMAP hbitmap = (HBITMAP)::LoadImage(NULL, ofn.lpstrFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
					//	MessageBox(NULL, ofn.lpstrFile, _T("Selected file"), MB_OK);
					//hdc = getOb
					HDC memDC = CreateCompatibleDC(hdc);
					SelectObject(memDC, hbitmap);
					RECT rect;
					GetClientRect(hWnd, &rect);
					BitBlt(hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top, memDC, 0, 0, SRCCOPY);
				}

				break;
			case ID_FILE_SAVE:
			{
				OPENFILENAME ofn;
				ZeroMemory(&ofn, sizeof(ofn));
				char szFileName[MAX_LOADSTRING];
				ZeroMemory(szFileName, MAX_LOADSTRING);
				ofn.lStructSize = sizeof(ofn);
				ofn.hwndOwner = NULL;
				ofn.lpstrFilter = _T("All Files(*.*)\0 * .*\0Bmp Files(*.bmp)\0 * .bmp\0Text Files(*.txt)\0 * .txt\0");
				ofn.lpstrFile = (LPWSTR)szFileName;
				ofn.nMaxFile = MAX_LOADSTRING;
				ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
				ofn.lpstrDefExt = (LPCWSTR)L"bmp";
				GetSaveFileName(&ofn);
				PBITMAPINFO PBi = CreateBitmapInfoStruct(hWnd, hBitmap);
				CreateBMPFile(hWnd, ofn.lpstrFile, PBi, hBitmap, hdc);
				/*save = 1;*/
			}
				break;
			case ID_FILE_EXIT:
				DestroyWindow(hWnd);
				break;
			default:
				return DefWindowProc(hWnd, message, wParam, lParam);
            }
        }
        break;


    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            
            // TODO: Add any drawing code that uses hdc here...
			HDC hdc = BeginPaint(hWnd, &ps);
			//Vẽ bitmap ra màn hình trước
			HDC memDC = CreateCompatibleDC(hdc);
			SelectObject(memDC, hBitmap);
			RECT rect;
			GetClientRect(hWnd, &rect);
			BitBlt(hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top, memDC, 0, 0, SRCCOPY);
				switch (mode)
				{
				case 0:
					//Vẽ tự do thì ta vẽ luôn trên màn hình và bitmap
					FreeDraw(memDC);
					FreeDraw(hdc);
					break;
				case 1:
					//Vẽ đường thẳng thì ta chỉ vẽ lên màn hình
					DrawLine(hdc);
					break;
				case 2:
					
					DrawEllipse(hdc);
					break;
				case 3:

					DrawRound(hdc);
					break;
				case 4:

					DrawSquare(hdc);
					break;
				case 5:
					//DrawRectangle(memDC);
					DrawRectangle(hdc);
					break;
				}
				
				DeleteObject(memDC);
			//SelectObject(hdc, oldPen);
			
            EndPaint(hWnd, &ps);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}