#include <windows.h>
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
// ...
while ((retval = GetMessage(&msg, NULL, 0, 0)) != FALSE)
{
if (retval < 0)
break; // erreur
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT WINAPI WindowProcedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_MOVING:
{
// rend la fenêtre transparente lors du déplacement
LONG_PTR exstyles = GetWindowLongPtr(g_WindowHandle, GWL_EXSTYLE);
if (!(exstyles & WS_EX_LAYERED))
SetWindowLongPtr(g_WindowHandle, GWL_EXSTYLE, exstyles | WS_EX_LAYERED);
SetLayeredWindowAttributes(g_WindowHandle, 0, 175, LWA_ALPHA);
}
break;
case WM_EXITSIZEMOVE:
{
// rend la fenêtre opaque après déplacement
LONG_PTR exstyles = GetWindowLongPtr(g_WindowHandle, GWL_EXSTYLE);
if ((exstyles & WS_EX_LAYERED))
SetWindowLongPtr(g_WindowHandle, GWL_EXSTYLE, exstyles & ~WS_EX_LAYERED);
}
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}