Skip to content

Commit

Permalink
Merged in PR #39 from the fenster repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbikker committed Dec 7, 2024
1 parent 20b15a9 commit c9ebf01
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions external/fenster.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ static LRESULT CALLBACK fenster_wndproc(HWND hwnd, UINT msg, WPARAM wParam,
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
HDC memdc = CreateCompatibleDC(hdc);
auto hbmp = CreateCompatibleBitmap(hdc, f->width, f->height);
auto oldbmp = SelectObject(memdc, hbmp);
HBITMAP hbmp = CreateCompatibleBitmap(hdc, f->width, f->height);
HBITMAP oldbmp = static_cast<HBITMAP>(SelectObject(memdc, hbmp));
BINFO bi = {{sizeof(bi), f->width, -f->height, 1, 32, BI_BITFIELDS}};
bi.bmiColors[0].rgbRed = 0xff;
bi.bmiColors[1].rgbGreen = 0xff;
Expand Down Expand Up @@ -249,10 +249,13 @@ FENSTER_API int fenster_open(struct fenster *f) {
wc.hInstance = hInstance;
wc.lpszClassName = f->title;
RegisterClassEx(&wc);
RECT desiredRect = {0, 0, f->width, f->height};
AdjustWindowRectEx(&desiredRect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_CLIENTEDGE);
int adjustedWidth = desiredRect.right - desiredRect.left;
int adjustedHeight = desiredRect.bottom - desiredRect.top;
f->hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, f->title, f->title,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
f->width, f->height, NULL, NULL, hInstance, NULL);

adjustedWidth, adjustedHeight, NULL, NULL, hInstance, NULL);
if (f->hwnd == NULL)
return -1;
SetWindowLongPtr(f->hwnd, GWLP_USERDATA, (LONG_PTR)f);
Expand All @@ -261,7 +264,10 @@ FENSTER_API int fenster_open(struct fenster *f) {
return 0;
}

FENSTER_API void fenster_close(struct fenster *f) { (void)f; }
FENSTER_API void fenster_close(struct fenster *f) {
PostMessage(f->hwnd, WM_CLOSE, 0, 0);
(void)f;
}

FENSTER_API int fenster_loop(struct fenster *f) {
MSG msg;
Expand Down

0 comments on commit c9ebf01

Please sign in to comment.