Creating a windows with WS_POPUP style

I'm implementing a simple program displaying an image on the screen using `GDI+` `WinAPI`.

Here is the code I have so far:

#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>

using namespace Gdiplus;
#pragma comment (lib, "Gdiplus.lib")

void Example_DrawImage9(HDC hdc) {
Graphics graphics(hdc);
Image image(L"C:/test.bmp");
graphics.DrawImage(&image, 0, 0);
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pCmdLine, int nCmdShow) {
ULONG_PTR token;
GdiplusStartupInput input = { 0 };
input.GdiplusVersion = 1;
GdiplusStartup(&token, &input, NULL);
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = {};
wc.lpfnWndProc = &WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);

HWND hwnd = CreateWindowEx(0, CLASS_NAME, L"Learn to Program Windows", WS_POPUP, 0, 0, 190, 110, NULL, NULL, hInstance, NULL);

if (hwnd != NULL) {
ShowWindow(hwnd, nCmdShow);

MSG msg;
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

GdiplusShutdown(token);
return 0;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;

case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1));
Example_DrawImage9(hdc);
EndPaint(hwnd, &ps);
return 0;
}
}

return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

Because I'd like to show only the image itself (no Non-Client-Area) i'm using the `WS_POPUP` style for the created window.
But there is apparently sth. wrong with the window - when i move the mouse over the app window i get "loading/busy" (animating blue circle). Moreover i cant' move the window. When i change the style to for example `WS_CAPTION` all is OK - the mouse cursor is "normal" (just arrow as usually) and i can move/drag the window. How can i use the `WS_POPUP` style without this bizarre side effects I've described?
Registered users can post here. Sign in or register to post.