@@ -405,16 +405,6 @@ INT_PTR MainWindow::InitializeMainDialog()
405405 DefWindowProc (hwnd_, WM_SETICON, ICON_BIG, LPARAM (LoadIcon (Application::g_hModule, MAKEINTRESOURCE (1 ))));
406406 SetWindowText (hwnd_, BUILD_TITLE_STRING);
407407
408- #if 0 // todo::: delete
409- SetWindowStyleEx(g_mainHwnd, GetWindowLong(g_mainHwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
410- SetLayeredWindowAttributes(
411- g_mainHwnd,
412- 0,
413- 128,
414- LWA_ALPHA
415- );
416- #endif
417-
418408 Edit_LimitText (GetWindowFromId (hwnd_, IdcLog), 1048576 );
419409
420410 // Subclass the values edit box for a few reasons.
@@ -2099,6 +2089,30 @@ HRESULT MainWindow::ExportFontGlyphData()
20992089}
21002090
21012091
2092+ void MainWindow::SetWindowTranslucency (uint32_t alpha)
2093+ {
2094+ #ifndef SetWindowExStyle
2095+ #define SetWindowExStyle (hwnd, value ) ((DWORD)SetWindowLong(hwnd, GWL_EXSTYLE, value))
2096+ #endif
2097+
2098+ uint32_t previousExStyle = GetWindowExStyle (hwnd_);
2099+ if (alpha >= 255 ) // Opaque.
2100+ {
2101+ SetWindowExStyle (hwnd_, previousExStyle & ~WS_EX_LAYERED);
2102+ }
2103+ else // Translucent.
2104+ {
2105+ SetWindowExStyle (hwnd_, previousExStyle | WS_EX_LAYERED);
2106+ SetLayeredWindowAttributes (
2107+ hwnd_,
2108+ 0 ,
2109+ alpha,
2110+ LWA_ALPHA
2111+ );
2112+ }
2113+ }
2114+
2115+
21022116HRESULT MainWindow::AutofitDrawableObjects (bool useMaximumWidth, bool useMaximumHeight)
21032117{
21042118 // Autofit all the selected objects to their actual contents, looping through and asking each
@@ -3008,7 +3022,10 @@ void MainWindow::OnAssortedActions(HWND anchorControl)
30083022 {0 , u" -" },
30093023 {IdcAutofitDrawableObjects, u" Autofit drawable objects" },
30103024 {IdcAutofitDrawableObjectsUniformly, u" Autofit drawable objects uniformly" },
3011- {IdcSetNoLineWrapOnDrawableObjects, u" Reduce drawable objects size with no wrap" }
3025+ {IdcSetNoLineWrapOnDrawableObjects, u" Reduce drawable objects size with no wrap" },
3026+ {0 , u" -" },
3027+ {IdcSetWindowTranslucent, u" Make window translucent" },
3028+ {IdcSetWindowOpaque, u" Make window opaque" },
30123029 };
30133030
30143031 int menuId = TrackPopupMenu (make_array_ref (items, countof (items)), anchorControl, hwnd_);
@@ -3024,6 +3041,8 @@ void MainWindow::OnAssortedActions(HWND anchorControl)
30243041 case IdcAutofitDrawableObjects: AutofitDrawableObjects (/* useMaximumWidth*/ false , /* useMaximumHeight*/ false ); break ;
30253042 case IdcAutofitDrawableObjectsUniformly: AutofitDrawableObjects (/* useMaximumWidth*/ true , /* useMaximumHeight*/ true ); break ;
30263043 case IdcSetNoLineWrapOnDrawableObjects: SetNoLineWrapOnDrawableObjects (); break ;
3044+ case IdcSetWindowTranslucent: SetWindowTranslucency (128 ); break ;
3045+ case IdcSetWindowOpaque: SetWindowTranslucency (255 ); break ;
30273046 }
30283047}
30293048
0 commit comments