DWM for windows Vista and PB
Posted: Sun Jan 28, 2007 3:21 pm
Finally got the new Vista Desktop Window Manager (DWM) to work in PureBasic. I know a lot of you might not have Vista right now, but some of you will soon. So...heres a working example for DWM in Vista and PureBasic. It enables the Vista Glass effect for a window;
(This only works on Vista)
(This only works on Vista)
Code: Select all
#DWM_BB_ENABLE = 1
#DWM_BB_BLURREGION = 2
#DWM_BB_TRANSITIONONMAXIMIZED = 4
Structure DWM_BLURBEHIND
dwFlags.l
fEnable.b
hRgnBlur.l
fTransitionOnMaximized.b
EndStructure
Procedure EnableBlurBehindWindow(hWnd.l, enable.b = #True, region.l = 0, transitionOnMaximized.b = #False)
blurBehind.DWM_BLURBEHIND
blurBehind\dwFlags = #DWM_BB_ENABLE | #DWM_BB_TRANSITIONONMAXIMIZED
;blurBehind\dwFlags = #DWM_BB_ENABLE
blurBehind\fEnable = enable
blurBehind\fTransitionOnMaximized = transitionOnMaximized
Lib = LoadLibrary_("dwmapi.dll") ; load the library
If Lib
If (enable And 0) <> region
blurBehind\dwFlags = #DWM_BB_BLURREGION
blurBehind\hRgnBlur = region
EndIf
*pAfunc = GetProcAddress_(Lib, "DwmEnableBlurBehindWindow") ; get pointer to function
CallFunctionFast(*pAfunc, hWnd, @blurBehind) ; call the function
MessageRequester("Information", "Blur Behind is enabled", #PB_MessageRequester_Ok)
FreeLibrary_(Lib) ; free up the library
EndIf
ProcedureReturn ; returns 1 if function called sucessfully
EndProcedure
hWnd.l = OpenWindow(0,100,100,300,300, "Test_V_DWM", #PB_Window_SystemMenu)
Color = RGB(000, 000, 000)
SetWindowColor(0, Color)
;will not see DWM blur glass effect in PB windows unless we
;change the client area color to something less 'white' (opaque).
;We need to paint our own color for windows here. don't use white
;(255,255,255) or similar as will not see blur effect very well
;some colors look a whole lot better. Vista DWM uses ARGB
;I just do a simple quick set window color here for demo purposes
EnableBlurBehindWindow(hWnd.l)
Repeat
Event = WindowEvent()
If Event ; event in queue then process
Else
Delay(1) ; No queue event, CPU time for something else
EndIf
Until Event = #PB_Event_CloseWindow