Windows 10 and window shadows

Windows specific questions.
geminis4941
Posts: 40
Joined: Jul 15, 2009 12:41

Windows 10 and window shadows

Postby geminis4941 » Aug 12, 2017 18:37

I have instaled Windows 10 and I saw that windows displayed have a nice shadow around all the rectangle.

When I run my win32 freebasic program the window with DROP_SHADOW class have a shadow on right and bottom borders
like in XP and Windows 7. Anyone knows how can obtain the shadow around all the window? Is there a new API ?

Thanks in advanced.
St_W
Posts: 932
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Windows 10 and window shadows

Postby St_W » Aug 12, 2017 22:05

Maybe post a screenshot to explicitly mark what you mean, but I see such a shadow for every window with a border by default, without specifying anything. Additionally, the CS_DROPSHADOW seems to only work correctly for borderless windows (like WS_POPUP). Here's some code for experiments:

Code: Select all

#include "windows.bi"

'LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
declare function WndProc (hwnd as HWND, message as UINT , wParam as WPARAM , lParam as LPARAM ) as LRESULT


'int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
dim msg as MSG
dim wc as WNDCLASS
dim hInstance as HINSTANCE

hInstance = GetModuleHandle(NULL)

wc.lpfnWndProc   = @WndProc
wc.hInstance     = hInstance
wc.hbrBackground = cast(HBRUSH, COLOR_BACKGROUND)
wc.lpszClassName = strptr("minwindowsapp")
'wc.style = CS_DROPSHADOW

if RegisterClass(@wc) = 0 then print "error 1" : end(1)


if CreateWindow(@"minwindowsapp", @"Windows Application", _
             WS_VISIBLE or WS_OVERLAPPEDWINDOW, _  ' WS_OVERLAPPEDWINDOW or WS_POPUP
            20,20,640,480,0,0,hInstance,NULL) = 0 then
   print "error 2"; GetLastError()
   end(2)
EndIf

while GetMessage( @msg, NULL, 0, 0 ) > 0
   DispatchMessage( @msg )
Wend



function WndProc (hwnd as HWND, message as UINT , wParam as WPARAM , lParam as LPARAM ) as LRESULT

   select case message
   
      case WM_CLOSE:
         PostQuitMessage(0)

      case WM_KEYUP:
         PostQuitMessage(0)
         
      case else:
         return DefWindowProc(hWnd, message, wParam, lParam)
   
   End Select

 return 0

end function
Change the window style and the window class styles and try different combinations.
geminis4941
Posts: 40
Joined: Jul 15, 2009 12:41

Re: Windows 10 and window shadows

Postby geminis4941 » Aug 13, 2017 11:52

I modified the code to show what I say . It happens with WS_POPUPWINDOW.

Code: Select all

#include "windows.bi"

'LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
declare function WndProc (hwnd as HWND, message as UINT , wParam as WPARAM , lParam as LPARAM ) as LRESULT


'int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Dim hwnd As HWND
dim msg as MSG
dim wc as WNDCLASS
dim hInstance as HINSTANCE

hInstance = GetModuleHandle(NULL)

wc.lpfnWndProc   = @WndProc
wc.hInstance     = hInstance
wc.hbrBackground = cast(HBRUSH, COLOR_BACKGROUND)
wc.lpszClassName = strptr("minwindowsapp")
wc.style = CS_DROPSHADOW

if RegisterClass(@wc) = 0 then print "error 1" : end(1)


hwnd = CreateWindow(@"minwindowsapp", @"Windows Application", _
             WS_VISIBLE Or WS_BORDER Or WS_POPUP, _  ' WS_OVERLAPPEDWINDOW or WS_POPUP
            20,20,640,480,0,0,hInstance,NULL)
           
If hwnd = 0 Then
   print "error 2"; GetLastError()
   end(2)
EndIf
'SetWindowLong(hWnd, GWL_STYLE, 0) ' remove all window styles, check MSDN for details

while GetMessage( @msg, NULL, 0, 0 ) > 0
   DispatchMessage( @msg )
Wend
St_W
Posts: 932
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Windows 10 and window shadows

Postby St_W » Aug 13, 2017 15:07

For me the shadow is automatically shown when using the WS_THICKFRAME window style - otherwise it is not.

But there seems to be an API for that too. See
https://stackoverflow.com/questions/327 ... windows-10

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests