1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <windows.h>
#include "main.h"
using namespace std;
HDC hdcBuffer;
int Initialize()
{
hdcBuffer = CreateCompatibleDC(NULL);
hdc = GetDC(hwnd);
}
int drawCircle(int X, int Y, int R, int Pen, int Fill)
{
HPEN hNPen=CreatePen(PS_SOLID, 1,Pen);
HPEN hOPen=(HPEN)SelectObject(hdcBuffer, hNPen);
HBRUSH hOldBrush;
HBRUSH hNewBrush;
if(Fill){
hNewBrush=CreateSolidBrush(Pen);
hOldBrush=(HBRUSH)SelectObject(hdcBuffer, hNewBrush);
} else {
hNewBrush=(HBRUSH)GetStockObject(NULL_BRUSH);
hOldBrush=(HBRUSH)SelectObject(hdcBuffer, hNewBrush);
}
Ellipse(hdcBuffer, X-R, Y+R, X+R, Y-R);
DeleteObject(SelectObject(hdcBuffer, hOPen));
DeleteObject(SelectObject(hdcBuffer, hOldBrush));
return 0;
}
int HDCClear()
{
int Color = RGB(255, 255, 255);
HPEN hNPen = CreatePen(PS_SOLID, 1, Color);
HPEN hOPen = (HPEN)SelectObject(hdcBuffer, hNPen);
HBRUSH hOldBrush;
HBRUSH hNewBrush;
hNewBrush=CreateSolidBrush(Color);
hOldBrush=(HBRUSH)SelectObject(hdcBuffer, hNewBrush);
Rectangle(hdcBuffer, 0, 0, planeWidth, planeHeight);
DeleteObject(SelectObject(hdcBuffer, hOPen));
DeleteObject(SelectObject(hdcBuffer, hOldBrush));
return 0;
}
int HDCUpdate()
{
BitBlt(hdc, 0, 0, planeWidth, planeHeight, hdcBuffer, 0, 0, SRCCOPY);
ReleaseDC(hwnd,hdc);
}
|