Page 1 of 1
Borderless window with drop shadow?
Posted: Tue Jul 22, 2014 10:50 pm
by Samuel
Does anyone know how to create a borderless window that still keeps the drop shadow?
I'm assuming this has to be done through API which is fine, but my knowledge is pretty limited on this subject.
Any tips or examples well be very much appreciated.
Re: Borderless window with drop shadow?
Posted: Tue Jul 22, 2014 11:31 pm
by STARGĂ…TE
Code: Select all
Enumeration
#Window
EndEnumeration
OpenWindow(#Window, 0, 0, 200, 150, "WindowTitle", #PB_Window_BorderLess|#PB_Window_ScreenCentered|#PB_Window_Invisible)
SetClassLongPtr_(WindowID(#Window), #GCL_STYLE, $00020000)
HideWindow(#Window, #False)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: Borderless window with drop shadow?
Posted: Tue Jul 22, 2014 11:39 pm
by hallodri
Code: Select all
Import ""
GetProcAddress(hMod, Name.p-ascii)
EndImport
#DWMWA_NCRENDERING_POLICY = 2
#DWMNCRP_ENABLED = 2
Structure Margin
cxLeftWidth.l
cxRightWidth.l
cyTopHeight.l
cyBottomHeight.l
EndStructure
Procedure DwmSetWindowAttribute(hWnd, attr, attrValue)
Static hMod
Static Func
Protected Value.integer\i = attrValue
If Not hMod And Not Func
hMod = GetModuleHandle_("dwmapi")
Func = GetProcAddress(hMod, "DwmSetWindowAttribute")
EndIf
If Func
ProcedureReturn CallFunctionFast(Func, hWnd, attr, Value, SizeOf(Value))
EndIf
ProcedureReturn -1
EndProcedure
Procedure DwmExtendFrameIntoClientArea(hWnd, Top, Left, Right, Bottom)
Static hMod
Static Func
Protected Margin.Margin
Margin\cxLeftWidth = Left
Margin\cxRightWidth = Right
Margin\cyTopHeight = Top
Margin\cyBottomHeight = Bottom
If Not hMod And Not Func
hMod = GetModuleHandle_("dwmapi")
Func = GetProcAddress(hMod, "DwmExtendFrameIntoClientArea")
EndIf
If Func
ProcedureReturn CallFunctionFast(Func, hWnd, Margin)
EndIf
ProcedureReturn -1
EndProcedure
Procedure Main()
Protected Window.i
Window = OpenWindow(#PB_Any, 150, 150, 200, 200, "Shadow Test", #PB_Window_BorderLess)
If Window
DwmSetWindowAttribute(WindowID(Window), #DWMWA_NCRENDERING_POLICY, #DWMNCRP_ENABLED)
DwmExtendFrameIntoClientArea(WindowID(Window), 1, 1, 1, 1)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndProcedure: End Main()
Re: Borderless window with drop shadow?
Posted: Wed Jul 23, 2014 12:10 am
by Samuel
Well, that was quick.
Thank you both for the wonderful examples.
Re: Borderless window with drop shadow?
Posted: Thu Aug 20, 2015 4:18 pm
by HanPBF
Hello hallodri,
how can the shadow width and form be changed?
thanks!