Code:
HDC hMemDC;
HBITMAP hBmp, hBmpOrig;
HBITMAP hOldBmp;
HWND hwnd;
HDC hdc;
// Function to draw the line
void DrawWithPen()
{ // PAINTSTRUCT pntS;
HPEN pen, oldPen;
hwnd = GetFrameWindow();
// hdc = BeginPaint(hwnd, &pntS);
hdc = GetDC(hwnd);
pen = CreatePen(PS_SOLID, 2, RGB(255, 255, 0));
oldPen = (HPEN)SelectObject(hdc, pen);
MoveToEx(hdc, 150, 150, NULL);
LineTo(hdc, 150, 200);
SelectObject(hdc, oldPen);
DeleteObject(pen);
// EndPaint(hwnd, &pntS);
}
// DrawARectangle - draws a red rectangle with a green border
// No return value.
// hdc - handle to the device context
void DrawARectangle()
{HPEN hpen, hpenOld;
HBRUSH hbrush, hbrushOld;
PAINTSTRUCT pntS;
hwnd = GetFrameWindow(); // Retrieve the frame handle
hdc = BeginPaint(hwnd, &pntS); // Prepare the specified window for painting
hpen = CreatePen(PS_SOLID, 10, RGB(0, 255, 0));
// Create a red brush.
hbrush = CreateSolidBrush(RGB(255, 0, 0));
// Select the new pen and brush, and then draw.
hpenOld = SelectObject(hdc, hpen);
hbrushOld = SelectObject(hdc, hbrush);
Rectangle(hdc, 100,100, 200,200);
// Do not forget to clean up.
SelectObject(hdc, hpenOld);
DeleteObject(hpen);
SelectObject(hdc, hbrushOld);
DeleteObject(hbrush);
EndPaint(hwnd, &pntS);
}
// CALL FUNCTION
DrawWithPen();
//DrawARectangle();