Painting problem in the New Sample GradBrus.Prg
Re: Painting problem in the New Sample GradBrus.Prg
Antonio, and thats the problem! If we use many dialogs (also dialogs without Gradientbrush() or other brushes) then we must use for any dialog another brush-color to have no side-effects. And then the reuse is not given. So i delete only then a brush from aBrushes, if a hBitmap (from GradientBrush()) is defined and the brush comes not from a resource or from a file.
Another point for my solution is, that no extra brush-call for this dialog and no caution is required !
Another point for my solution is, that no extra brush-call for this dialog and no caution is required !
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: Painting problem in the New Sample GradBrus.Prg
Günther,
yes, you are right. I see your solution now and it is a very good one!
It is working nicely. Many thanks!
yes, you are right. I see your solution now and it is a very good one!

It is working nicely. Many thanks!
Re: Painting problem in the New Sample GradBrus.Prg
Antonio, please look at this.
A new version from Gradientbrush(). With lDir = .F. the gradient is horizontal. The bitmap are now only one pixel in height or width == good for GDI consumation.
A new version from Gradientbrush(). With lDir = .F. the gradient is horizontal. The bitmap are now only one pixel in height or width == good for GDI consumation.
Code: Select all | Expand
function GradientBrush( oDlg, aColors , lDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight
DEFAULT lDir := .T.
if Empty( oDlg:oBrush:hBitmap )
nHeight := if(lDir,oDlg:nHeight,1)
nWidth := if(lDir,1,oDlg:nWidth)
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, nHeight, nWidth, aColors,lDir )
DeleteObject( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlg:ReleaseDC()
endif
return nil
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Painting problem in the New Sample GradBrus.Prg
May I suggest changing lDir to lVertical--it will be more obvious what it means.
Regards,
James
Regards,
James
- Dietmar Jahnel
- Posts: 83
- Joined: Mon Oct 17, 2005 10:33 am
- Location: Austria
- Contact:
Re: Painting problem in the New Sample GradBrus.Prg
I found this thread. The solution is working fine in dialogs.
But how do I apply the gradient brush to FOLDERS in a DIALOG?
This fills the Dialog with color but not the folders
Any suggestions?
Thanks,
Dietmar
But how do I apply the gradient brush to FOLDERS in a DIALOG?
This fills the Dialog with color but not the folders
Code: Select all | Expand
ACTIVATE DIALOG eFenst CENTERED;
ON INIT (GradientBrush( eFenst, { { 0.4, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) },;
{ 0.6, nRGB( 24, 61, 118 ), nRGB( 50, 95, 158 ) } }) ,;
GradientBrush( eFolder:aDialogs[1], { { 0.4, nRGB( 75, 144, 223 ), nRGB( 41, 85, 145 ) },;
{ 0.6, nRGB( 24, 61, 118 ), nRGB( 50, 95, 158 ) } } ))
Any suggestions?
Thanks,
Dietmar
Re: Painting problem in the New Sample GradBrus.Prg
Hello Dietmar,
using Günther's Function for Folders
DlgGrad( hDC, oDlg ) = the old Dialog-Gradient-Style ( can replaced with Günther's Function )
FolderGrad() = using Günther's Function
All together with < disable Exit-Button > :
Regards
Uwe
using Günther's Function for Folders
DlgGrad( hDC, oDlg ) = the old Dialog-Gradient-Style ( can replaced with Günther's Function )
FolderGrad() = using Günther's Function
All together with < disable Exit-Button > :
Code: Select all | Expand
ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
ON INIT ( oDlg:Move( 30 , 10, oDlg:nWidth, oDlg1:nHeight, .f. ), DisableX(oDlg, .T.), ;
SetImages( oDlg ) ) ;
ON PAINT ( DlgGrad( hDC, oDlg ), FolderGrad() )
RETURN ( NIL )
//--------------- Images on Folder-Pages ---------------//
FUNCTION SetImages( oDlg )
local oImageList
DEFINE IMAGELIST oImageList SIZE 16, 16
oImageList:AddMasked( TBitmap():Define( "head",, oDlg1 ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "foot",, oDlg1 ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "menue",, oDlg1 ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "zoom",, oDlg1 ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "image",, oDlg1 ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "project",, oDlg1 ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "index",, oDlg1 ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "gradient",, oDlg1 ), nRGB( 255, 0, 255 ) )
oFld:SetImageList( oImageList )
RETURN NIL
// ---------- Dialog - Gradient -------------------------------------
static func DlgGrad( hDC, oDlg )
local aGrad
aGrad := { { 0.50, 16054371, 8388608 },{ 0.50, 8388608, 16054371 } }
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, .T. )
RETURN NIL
// --------- Folder - Gradient -------------------
FUNCTION FolderGrad()
local n, oDlg
for n = 1 to Len( oFld:aDialogs )
oDlg = oFld:aDialogs[ n ]
// Cyan and Red
oDlg:bPainted = { || GradientBrush( oDlg, oDlg:bPainted = { || GradientBrush( oDlg, ;
{ { 0.50, 16054371, 8388608 },{ 0.50, 8388608, 16054371 } }, .T.) }
next
RETURN NIL
// ------- Günther's Function ----------------------
FUNCTION GradientBrush( oDlg, aColors , lDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight
DEFAULT lDir := .T.
if Empty( oDlg:oBrush:hBitmap )
nHeight := if(lDir,oDlg:nHeight,1)
nWidth := if(lDir,1,oDlg:nWidth)
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, nHeight, nWidth, aColors,lDir )
DeleteObject( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlg:ReleaseDC()
endif
return nil
// --------------------- Disable EXIT - BUTTON -----------------
FUNCTION DisableX(oDlg, lDisable)
LOCAL hMenu := 0
LOCAL nCount := 0
IF lDisable
hMenu = GetSystemMenu(oDlg:hWnd, .F.)
nCount = GetMItemCount(hMenu)
IF oDlg:ClassName() = "TDIALOG"
RemoveMenu(hMenu, 1, nOR( 1024, 2) )
ELSE
RemoveMenu(hMenu, nCount - 1, nOR( 1024, 2) )
RemoveMenu(hMenu, nCount - 2, nOR( 1024, 2) )
ENDIF
DrawMenuBar( oDlg:hWnd )
ELSE
GetSystemMenu( oDlg:hWnd, .T. )
DrawMenuBar( oDlg:hWnd )
ENDIF
RETURN nil
Regards
Uwe

Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- FranciscoA
- Posts: 2163
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: Painting problem in the New Sample GradBrus.Prg
Dears friends:
I've done some testing with the GradientBrush Gunther' s Function and got the following results:
Maybe this was already resolved.
Using dialogues in resources:
On bmps, Works well.
On Says, works well.
On normal Gets, works well.
On Gets read-only, does not work properly (the bottom of gets is not covered)
If you use the PAINT ON clause, not working properly (you have to use ON INIT)
Excuse my english, please.
Greetings
I've done some testing with the GradientBrush Gunther' s Function and got the following results:
Maybe this was already resolved.
Using dialogues in resources:
On bmps, Works well.
On Says, works well.
On normal Gets, works well.
On Gets read-only, does not work properly (the bottom of gets is not covered)
If you use the PAINT ON clause, not working properly (you have to use ON INIT)
Excuse my english, please.
Greetings
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh-MySql-TMySql
Chinandega, Nicaragua.
Fwxh-MySql-TMySql
- FranciscoA
- Posts: 2163
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: Painting problem in the New Sample GradBrus.Prg
Something more I have observed:
If you use lTransparent:=.t., it seems work fine, but if you put the mouse pointer over the get, the get's container dissapears. If you move the dialog out of the main window, his container shows again. (PAINT)
REDEFINE GET oCtaRetALC Var cCtaRetALC ID 140 OF oDlg PICTURE "@!" READONLY
oCtaRetAlc:lTransparent:=.t.
The solution is to use SAY instead GET READONLY
REDEFINE SAY oCtaRetALC Var cCtaRetALC ID 140 OF oDlg PICTURE "@!"
Regards
If you use lTransparent:=.t., it seems work fine, but if you put the mouse pointer over the get, the get's container dissapears. If you move the dialog out of the main window, his container shows again. (PAINT)
REDEFINE GET oCtaRetALC Var cCtaRetALC ID 140 OF oDlg PICTURE "@!" READONLY
oCtaRetAlc:lTransparent:=.t.
The solution is to use SAY instead GET READONLY
REDEFINE SAY oCtaRetALC Var cCtaRetALC ID 140 OF oDlg PICTURE "@!"
Regards
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh-MySql-TMySql
Chinandega, Nicaragua.
Fwxh-MySql-TMySql