LRESULT CALLBACK WndProc_Draw(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc, hdcSource, hdcMemory;
	HBITMAP hBitmap, hBitmapOld;
	HWND hWndDraw;

	switch (message)
	{
	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);

		hdcSource = GetDC(NULL);
		hdcMemory = CreateCompatibleDC(hdcSource);

		RECT rect; int w, h;
		if (GetWindowRect(hWnd, &rect))
		{
			w = rect.right - rect.left;
			h = rect.bottom - rect.top;
		}

		hBitmap = CreateCompatibleBitmap(hdcSource, w, h);
		hBitmapOld = (HBITMAP)SelectObject(hdcMemory, hBitmap);

		BitBlt(hdc, 0, 0, w, h, hdcSource, 0, 23, SRCCOPY);
		hBitmap = (HBITMAP)SelectObject(hdcMemory, hBitmapOld);

		DeleteDC(hdcSource);
		DeleteDC(hdcMemory);

		EndPaint(hWnd, &ps);
		break;
	case WM_LBUTTONDOWN:
		paint = TRUE;

		px1 = px2 = GET_X_LPARAM(lParam);
		py1 = py2 = GET_Y_LPARAM(lParam);

		break;
	case WM_MOUSEMOVE:
		if (!paint)
			break;
		hdc = GetDC(hWnd);
		px2 = GET_X_LPARAM(lParam);
		py2 = GET_Y_LPARAM(lParam);

		HPEN hPen;
		hPen = CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
		SelectObject(hdc, hPen);

		MoveToEx(hdc, px1, py1, NULL);
		LineTo(hdc, px2, py2);

		px1 = px2;
		py1 = py2;

		ReleaseDC(hWnd, hdc);
		break;
	case WM_LBUTTONUP:
		paint = FALSE;
		break;
	case WM_DESTROY:
		draw = FALSE;
		UpdateDraw();
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Beispiel #2
0
void SummaryWindow::PeriodChanged(Draw *draw, PeriodType period) {
	UpdateDraw(draw);
}
Beispiel #3
0
void SummaryWindow::DoubleCursorChanged(DrawsController *draws_controller) {
	for (size_t i = 0; i < draws_controller->GetDrawsCount(); i++)
		UpdateDraw(draws_controller->GetDraw(i));
}
Beispiel #4
0
void SummaryWindow::AverageValueCalculationMethodChanged(Draw *draw) {
	UpdateDraw(draw);
}
Beispiel #5
0
void SummaryWindow::StatsChanged(Draw *draw) {
	UpdateDraw(draw);
}