We should use the real ClientArea!
Use for a test {{0.49,CLR_GRAY,CLR_WHITE},{0.02,CLR_BLACK,CLR_BLACK},{0.49,CLR_WHITE,CLR_GRAY}} as gradient. The black line should located in the middle (V or H) from window/dialog
- Code: Select all Expand view
METHOD Gradient( aGradColors ) CLASS TWindow
local hDC, hBmp, hBmpOld, aClient := GetClientRect(::hWnd), nHeight := aClient[3]-aClient[1], nWidth := aClient[4]-aClient[2]
DEFAULT aGradColors := ::aGradColors
if aGradColors == nil
return nil
endif
hDC = CreateCompatibleDC( ::GetDC() )
hBmp = CreateCompatibleBitMap( ::hDC, nWidth, nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, nHeight, nWidth, aGradColors )
if ::oBrush != nil
::oBrush:End()
endif
::oBrush = TBrush():New()
::oBrush:hBitmap = hBmp
::oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
::ReleaseDC()
return nil