Hi Everyone!!:
Mica Demo for Harbour/HMG — Bringing Windows 11 Materials to Win32 GUI Apps
What is Mica?
Mica is a Windows 11 material introduced with the Fluent design language.
It's an opaque dynamic material: the Desktop Window Manager (DWM) samples the user's desktop wallpaper and theme color once,
and paints the window's background with a subtle, tinted version of it. Unlike Acrylic (which is a translucent, real-time blur of whatever is currently behind the window),
Mica doesn't blur live content — it's cheaper to render, avoids the blur-behind-window overhead, and gives apps a "rooted in the desktop" feel while keeping window content perfectly readable on top.
Windows 11 exposes these system materials to regular Win32 apps through a single attribute:
DwmSetWindowAttribute(hWnd, DWMWA_SYSTEMBACKDROP_TYPE /* 38 */, &value, sizeof(value));
// value: 1 = None, 2 = Mica (main window), 3 = Acrylic (transient window), 4 = Mica Alt (tabbed)
The catch: making it actually show up
Setting the attribute alone does nothing visible for a classic GDI application, because your window paints an opaque background over the material. Two tricks make it work:
1. Extend the DWM frame across the entire client area:
MARGINS mar = { -1, -1, -1, -1 };
DwmExtendFrameIntoClientArea(hWnd, &mar);
With the sheet-of-glass frame covering the whole client, any pixel your app paints with plain GDI ends up with alpha 0 — invisible. Pixels painted black become fully transparent and let the system material show through. So the window background is simply FillRect(..., BLACK_BRUSH).
2. Alpha-corrected drawing for everything else. Since GDI never writes the alpha channel, text and colored fills drawn with TextOut/FillRect vanish over the material. The fix: render into a 32-bpp DIB, fix/premultiply the alpha channel by hand, and blit with AlphaBlend (which respects per-pixel alpha):
BlitFillAlpha() — solid fill with alpha 255 for borders, hover states and button highlights.
DrawTextAlpha() — draws white text into a DIB, uses per-pixel luminance as the alpha mask, premultiplies with the target color, then AlphaBlends it. Result: crisp antialiased text visible over Mica.
What this example does
The demo (C and Harbour/HMG versions) is a live playground for these techniques:
Switch None / Mica / Acrylic at runtime.
Toggle immersive dark mode (DWMWA_USE_IMMERSIVE_DARK_MODE) for dark/light title bars.
Custom title bar on a caption-less window: centered caption, Segoe MDL2 Assets glyphs for minimize/close (\uE921 / \uE8BB), red hover on close, dragging via WM_NCHITTEST → HTCAPTION, double-click to maximize, resize via kept WS_THICKFRAME, rounded corners via DWMWA_WINDOW_CORNER_PREFERENCE.
Owner-drawn buttons whose text survives the material thanks to the alpha helpers.
The Harbour/HMG port
The HMG version proves the pattern drops into an existing Win32 framework without replacing it:
The .prg defines a plain HMG MAIN NOCAPTION window.
A small C bridge (MicaBridge.c) subclasses the HMG window with SetWindowSubclass — the same pattern used by our Flyout engine — and takes over WM_ERASEBKGND (black), WM_PAINT (custom title bar), WM_NCHITTEST, hover tracking, and button creation/drawing.
Buttons report clicks back to Harbour through a codeblock: Mica_SetOnCommand( {|nId| ...} ).
Two practical gotchas worth documenting for the forum:
WM_DRAWITEM passes the DRAWITEMSTRUCT* in lParam, not wParam (wParam is the control's HWND). Casting wParam silently reads garbage — and crashes (0xC000041D) once you actually use it.
Create the subclass before the child buttons, or their first WM_DRAWITEM goes to the original window procedure and they never paint.
The golden rule this demo establishes: over a system material, anything drawn with plain GDI is invisible — only alpha-corrected blits are visible, and black means "let the material through".
Source :
Mica DWM Microsoft
Moderator: Rathinagiri
- danielmaximiliano
- Posts: 2763
- Joined: Fri Apr 09, 2010 4:53 pm
- DBs Used: DBF
- Location: Argentina
- Contact:
Mica DWM Microsoft
- Attachments
-
- MicaDemoHB.rar
- (9.55 KiB) Downloaded 20 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace
- danielmaximiliano
- Posts: 2763
- Joined: Fri Apr 09, 2010 4:53 pm
- DBs Used: DBF
- Location: Argentina
- Contact:
Re: Mica DWM Microsoft
ScreenShot :
- Attachments
-
- Captura de pantalla 2026-09-04 171604.png (50.83 KiB) Viewed 69 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace