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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| LRESULT CALLBACK privateEvent(HWND _handle, UINT _message, WPARAM _wParam, LPARAM _lParam)
{
return DefWindowProc(_handle, _message, _wParam, _lParam);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND handle = 0;
HINSTANCE instance = GetModuleHandle(NULL);
WNDCLASSEX l_windowClass;
l_windowClass.cbSize = sizeof(WNDCLASSEX);
l_windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Move, And Own DC For Window
l_windowClass.lpfnWndProc = privateEvent;
l_windowClass.cbClsExtra = 0;
l_windowClass.cbWndExtra = 0;
l_windowClass.hInstance = instance;
l_windowClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); //IDI_APPLICATION
l_windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
l_windowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
l_windowClass.lpszMenuName = NULL;
l_windowClass.lpszClassName = "Render2D";
l_windowClass.hIconSm=LoadIcon(NULL, IDI_APPLICATION);
if (RegisterClassEx(&l_windowClass))
{
DWORD l_windowStyle = WS_OVERLAPPEDWINDOW;
DWORD l_windowExtendedStyle = WS_EX_APPWINDOW;
l_windowStyle = WS_POPUP; // Set The WindowStyle To WS_POPUP (Popup Window)
l_windowExtendedStyle = WS_EX_APPWINDOW; // Set The Extended Window Style To WS_EX_TOPMOST
RECT l_windowRect;
l_windowRect.top = 0;
l_windowRect.left = 0;
l_windowRect.right = 800;
l_windowRect.bottom = 600;
AdjustWindowRectEx(&l_windowRect, l_windowStyle, 0, l_windowExtendedStyle);
handle = CreateWindowEx(
l_windowExtendedStyle,
"Render2D",
"test",
l_windowStyle | WS_CLIPCHILDREN | WS_VISIBLE,
0, 0,
l_windowRect.right - l_windowRect.left,
l_windowRect.bottom - l_windowRect.top,
NULL, NULL,
l_windowClass.hInstance,
NULL
);
}
HDC dc = GetDC(handle); //BeginPaint(handle, &ps);
HPEN winPen;
HBRUSH winBrush;
HRGN l_region;
while(true)
{
static MSG l_message;
if (PeekMessage(&l_message, NULL, 0, 0, PM_REMOVE))
{
if (l_message.message == WM_QUIT) break;
// Deal With Window Messages
TranslateMessage(&l_message); // Translate The Message
DispatchMessage(&l_message); // Dispatch The Message
}
winPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
winBrush = CreateSolidBrush(RGB(0, 255, 0));
SelectObject(dc, winPen);
static RECT l_rect;
l_rect.left = 0;
l_rect.right = 800;
l_rect.top = 0;
l_rect.bottom = 600;
l_region = CreateRectRgn(0, 0, 800, 600);
SelectClipRgn(dc, l_region);
FillRect(dc, &l_rect, winBrush);
}
DeleteObject(winBrush);
DeleteObject(winPen);
// etc...
return 0;
} |
Partager