Page 1 of 1

help for Gdiplus Brush class

Posted: Wed Mar 22, 2023 12:03 pm
by Silvio.Falconi
is it possible to draw with tGDIPlus a rectangle ( drawrect) with a gradient brush having a style like diagonal lines, around a Get or another control ?


I made a test but not work

Code: Select all | Expand


Function test()
local oDlg
local oGet,oSay
local cGet:= space(10)
nColor1:= RGB( 245,245,235)
nColor2:=RGB(250,250,245)



DEFINE DIALOG oDlg SIZE 400,100

@ 12,10 SAY  oSay PROMPT "TEST SAY" SIZE 80,12 PIXEL of oDlg
@ 12,90 GET  oGet VAR cGEt SIZE 100,12 PIXEL of oDlg



  oDlg:bPainted := < |hDC|
  TestBrush(hDC,oGet,nColor1,nColor2,oSay:nLeft, oSay:nTop, oSAy:nWidth, oSay:nHeight)
  TestBrush(hDC,oSay,nColor1,nColor2,oGEt:nLeft, oGet:nTop, oGet:nWidth, oGet:nHeight)

 * DRAWBORDER ( hDC, oSay:nLeft, oSay:nTop, oSay:nWidth, oSay:nHeight,0 , 1, nColor1, .t. )

 *DRAWBORDER ( hDC, oGEt:nLeft, oGEt:nTop, oGEt:nWidth, oGet:nHeight,0 , 1, nColor1, .t. )

  RETURN NIL
>

ACTIVATE DIALOG oDlg ;
on init oGet:disable()
          return nil



Function TestBrush(hDC,oControl,nColor1,nColor2, nLeft, nTop, nWidth, nHeight )
local oGraphics := Graphics():New( hDC )

local nRed1 := nRGBRed( nColor1 )
local nGreen1 := nRGBGreen( nColor1 )
local nBlue1 := nRGBBlue( nColor1 )

local nRed2 := nRGBRed( nColor2 )
local nGreen2 := nRGBGreen( nColor2 )
local nBlue2 := nRGBBlue( nColor2 )


local oBrush

local oPen ,nPen:=1


oPen := Pen():New( 255, nRed1, nGreen1, nBlue1, nPen )

oBrush :=  Brush():NewGradientBrush( nTop, nLeft, nWidth, nHeight, 3,;
                         180, nRed1, nGreen1, nBlue1,;
                         180, nRed2, nGreen2, nBlue2)

oGraphics:DrawRect( , oBrush, nLeft, nTop, nWidth, nHeight )

return nil
 

Re: help for Gdiplus Brush class

Posted: Wed Mar 22, 2023 3:40 pm
by cnavarro

Re: help for Gdiplus Brush class

Posted: Thu Mar 23, 2023 9:28 am
by Silvio.Falconi

Progetto: TESTGDI, Ambiente: bcc7Harbor:
[1]:Harbour.Exe TESTGDI.prg /m /n0 /gc1 /w0 /es2 /a /iC:\Work\fwh\include /iC:\work\HARBOUR\Include /jC:\Work\errori\BUTTON~1\I18n\Main.hil /iinclude;c:\work\fwh\include;C:\work\HARBOUR\include /oObj\TESTGDI.c
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Compiling 'TESTGDI.prg'...
Lines 5658, Functions/Procedures 14
Generating C source output to 'Obj\TESTGDI.c'... Done.
[1]:Bcc32.Exe -M -c -DHB_OS_WIN_32 -DHB_FM_STATISTICS_OFF -DHB_NO_DEFAULT_API_MACROS -DHB_NO_DEFAULT_STACK_MACROS -IC:\Work\fwh\include -IC:\work\bcc7\Include\windows\sdk\;C:\work\HARBOUR\Include -nC:\Work\errori\BUTTON~1\Obj TESTGDI.c
Embarcadero C++ 7.30 for Win32 Copyright (c) 1993-2017 Embarcadero Technologies, Inc.
TESTGDI.c:
[1]:iLink32.Exe -Gn -aa -Tpe -s -v @TESTGDI.bcl
Turbo Incremental Link 6.80 Copyright (c) 1997-2017 Embarcadero Technologies, Inc.
Error: Unresolved external '_HB_FUN_TESTWRAPMODE' referenced from C:\WORK\ERRORI\BUTTON_PIENO_VUOTO\OBJ\TESTGDI.OBJ
Error: Unable to perform link

Re: help for Gdiplus Brush class

Posted: Thu Mar 30, 2023 4:23 am
by albeiroval
+1

Re: help for Gdiplus Brush class

Posted: Thu Mar 30, 2023 12:12 pm
by cnavarro
Dear Silvio, remove call to function TESTWRAPMODE
It was just a test function