@@ -12359,10 +12359,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1235912359
1236012360 // Old C WebView2 handler code removed - now using C++ API
1236112361
12362+ // Available since Windows 8. May be missing in old MinGW headers.
12363+ #ifndef WS_EX_NOREDIRECTIONBITMAP
12364+ #define WS_EX_NOREDIRECTIONBITMAP 0x00200000L
12365+ #endif
12366+
1236212367 LRESULT CALLBACK WndProc (HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam ) {
1236312368
12364- if (uMsg == WM_CREATE ) {
12365- // Set win ptr
12369+ if (uMsg == WM_NCCREATE || uMsg == WM_CREATE ) {
1236612370 CREATESTRUCT * pCreate = (CREATESTRUCT * )lParam ;
1236712371 void * userData = pCreate -> lpCreateParams ;
1236812372 SetWindowLongPtr (hwnd , GWLP_USERDATA , (LONG_PTR )userData );
@@ -12373,12 +12377,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1237312377 _webui_window_t * win = _webui_dereference_win_ptr (ptr );
1237412378
1237512379 switch (uMsg ) {
12376- case WM_CREATE : {
12377- if (win ) {
12378- if (win -> transparent ) {
12379- // New layer for background transparency
12380- SetWindowLong (hwnd , GWL_EXSTYLE , GetWindowLong (hwnd , GWL_EXSTYLE ) | WS_EX_LAYERED );
12381- }
12380+ case WM_NCCALCSIZE : {
12381+ if (win && win -> frameless && wParam == TRUE && !IsZoomed (hwnd )) {
12382+ NCCALCSIZE_PARAMS * params = (NCCALCSIZE_PARAMS * )lParam ;
12383+ LONG originalTop = params -> rgrc [0 ].top ;
12384+ LRESULT result = DefWindowProc (hwnd , WM_NCCALCSIZE , wParam , lParam );
12385+ if (result != 0 )
12386+ return result ;
12387+ params -> rgrc [0 ].top = originalTop ;
12388+ return 0 ;
1238212389 }
1238312390 break ;
1238412391 }
@@ -12766,8 +12773,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1276612773 }
1276712774 }
1276812775
12776+ // Set extended window style based on transparent flag
12777+ DWORD exStyle = 0 ;
12778+ if (win -> transparent ) {
12779+ exStyle |= WS_EX_NOREDIRECTIONBITMAP ;
12780+ }
12781+
1276912782 HWND hwnd = CreateWindowExA (
12770- 0 , wvClass , "" , style ,
12783+ exStyle , wvClass , "" , style ,
1277112784 x , y , width , height ,
1277212785 NULL , NULL , GetModuleHandle (NULL ), (LPVOID )win
1277312786 );
@@ -12779,6 +12792,26 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1277912792 WEBUI_THREAD_RETURN
1278012793 }
1278112794
12795+ if (win -> frameless ) {
12796+ HMODULE dwmapi = LoadLibraryA ("dwmapi.dll" );
12797+ if (dwmapi ) {
12798+ typedef HRESULT (WINAPI * DwmSetWindowAttributeFunc )(HWND , DWORD , LPCVOID , DWORD );
12799+ DwmSetWindowAttributeFunc setWindowAttribute =
12800+ (DwmSetWindowAttributeFunc )GetProcAddress (dwmapi , "DwmSetWindowAttribute" );
12801+ if (setWindowAttribute ) {
12802+ COLORREF borderColor = 0xFFFFFFFE ;
12803+ setWindowAttribute (hwnd , 34 , & borderColor , sizeof (borderColor ));
12804+ DWORD cornerPreference = 1 ;
12805+ setWindowAttribute (hwnd , 33 , & cornerPreference , sizeof (cornerPreference ));
12806+ }
12807+ }
12808+ SetWindowPos (
12809+ hwnd , NULL , 0 , 0 , 0 , 0 ,
12810+ SWP_FRAMECHANGED | SWP_NOMOVE |
12811+ SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE
12812+ );
12813+ }
12814+
1278212815 // Set HWND in C++ handle
1278312816 _webui_win32_wv2_set_hwnd (win -> webView -> cpp_handle , hwnd );
1278412817
0 commit comments