Code:
#include "stdafx.h"
#include "Painter.h"
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
DisableThreadLibraryCalls(hModule);
return true;
}
class BackgroundPainter : public Painter
{
private:
HBRUSH brush;
HPEN pen;
HFONT font;
public:
virtual void Paint(HDC hdc, int horizonOffsetY, int viewOffsetX, int viewOffsetY, int viewWidth, int viewHeight, int x, int y, int width, int height)
{
SelectObject(hdc, pen);
SelectObject(hdc, font);
SetTextColor(hdc, RGB(0, 0, 0));
SetBkMode(hdc, TRANSPARENT);
RECT rc = { x, y, x + width, y + height };
FillRect(hdc, &rc, brush);
//como não tem nenhum tratamento especial, apenas soma os dois
viewOffsetY += horizonOffsetY;
MoveToEx(hdc, viewOffsetX, viewHeight + viewOffsetY, 0);
LineTo(hdc, viewOffsetX + 300, viewHeight + viewOffsetY - 300);
LineTo(hdc, viewOffsetX + 600, viewHeight + viewOffsetY);
LineTo(hdc, viewOffsetX + 900, viewHeight + viewOffsetY - 300);
LineTo(hdc, viewOffsetX + 1200, viewHeight + viewOffsetY);
SetTextAlign(hdc, TA_LEFT);
TextOut(hdc, 0, 0, TEXT("Eu sou o topo!"), 14);
TextOut(hdc, viewOffsetX, viewHeight + viewOffsetY - 20, TEXT("Eu sou o baseline!"), 18);
SetTextAlign(hdc, TA_RIGHT);
TextOut(hdc, viewWidth, viewHeight + viewOffsetY - 20, TEXT("Eu sou o baseline no canto!"), 27);
}
virtual BOOL Initialize()
{
brush = CreateSolidBrush(RGB(255, 117, 24));
pen = CreatePen(PS_SOLID, 2, RGB(255, 201, 14));
font = (HFONT)GetStockObject(ANSI_VAR_FONT);
return true;
}
virtual void Terminate()
{
DeleteObject((HGDIOBJ)brush);
DeleteObject((HGDIOBJ)pen);
delete this;
}
};
__declspec(dllexport) Painter* __stdcall CreateBackgroundPainter()
{
return new BackgroundPainter();
}