Jump to content

How to disable window shadow? (GUICreate, $WS_POPUP, only one window, looking for every possible way)


Recommended Posts

Posted

Hello everyone!!!

How to disable shadow on window but keep rounded edges? (Windows 11)

Basically I'm ready to do anything, just to turn off the shadow... leaving only the beautiful rounded edges..

Sorry for my English

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>
#include <GDIPlus.au3>
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPISysWin.au3>
#include <Misc.au3>

$hGUI = GUICreate('MAIN WINDOW', 580, 580, 400, 200, $WS_POPUP, $WS_EX_COMPOSITED)
GUISetBkColor($COLOR_GREEN, $hGUI)
GUISetState(@SW_SHOW, $hGUI)

DllCall('dwmapi.dll', _  ;maybe there is a function to disable the shadow?
        'long', 'DwmSetWindowAttribute', _
        'hwnd', $hGUI, _
        'dword', 33, _
        'dword*', 2, _
        'dword', 4)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

 

Posted
2 minutes ago, Nine said:

I do not have Win11, so I won't be able to test, nevertheless you could use my Round Corner GUI UDF

I saw your library, but how to make smooth corners? The corners are a bit "sharp", I would like more smoothness..

Posted
4 minutes ago, SEKOMD said:

The corners are a bit "sharp", I would like more smoothness.

True.  I did not use a GDI+ smooth enhancement.  I wanted to keep it simple.  But I suppose there is examples of GDI+ doing this in here.

Posted
2 minutes ago, Nine said:

True.  I did not use a GDI+ smooth enhancement.  I wanted to keep it simple.  But I suppose there is examples of GDI+ doing this in here.

yes i found an example from UEZ, it has nice rounded edges

i would like to make a frame based on this example, then apply it to your library on top, you can make nice rounded edges..

Example from UEZ:

#include <WindowsConstants.au3>
#include <WinApi.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()
; Create GUI
Local $hGUI = GUICreate('Test', 500, 300, -1,-1,$WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
Local $idPic = GUICtrlCreatePic('', 0, 0, 500, 300)
Local $hPic = GUICtrlGetHandle($idPic)
Local $hGDIBmp = _GDIPlus_CreateBitmapRoundCornerRect()
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, $IMAGE_BITMAP, $hGDIBmp))
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3
_WinAPI_DeleteObject($hGDIBmp)
_GDIPlus_Shutdown()

Func _GDIPlus_CreateBitmapRoundCornerRect($iW = 500, $iH = 300, $iColorBg = 0xFF505050, $iColorBorder = 0xFF505050, $iRadius = 15, $bGDIBmp = 1)
    Local Const $iX = 0, $iY = 0, $iPenSize = 1
    Local Const $iWidth = $iW - $iPenSize, $iHeight = $iH - $iPenSize
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
    Local Const $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY, $iRadius * 2, $iRadius * 2, 270, 90)
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90)
    _GDIPlus_PathAddArc($hPath,  $iX, $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90)
    _GDIPlus_PathAddArc($hPath,  $iX, $iY, $iRadius * 2, $iRadius * 2, 180, 90)
    _GDIPlus_PathCloseFigure($hPath)

    Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColorBg)
    _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush)
    Local Const $hPen = _GDIPlus_PenCreate($iColorBorder, $iPenSize)
    _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen)

    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hCtxt)
    If $bGDIBmp Then
        Local $hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hGDIBmp
    EndIf
    Return $hBitmap
EndFunc

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...