FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Painting problem in the New Sample GradBrus.Prg
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Thu Feb 26, 2009 01:54 PM

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 !

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Thu Feb 26, 2009 07:59 PM

Günther,

yes, you are right. I see your solution now and it is a very good one! :-)

It is working nicely. Many thanks!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Fri Feb 27, 2009 11:20 AM
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.

Code (fw): Select all Collapse
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
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Fri Feb 27, 2009 01:02 PM

Günther,

Excellent! :-)

Many thanks,

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Fri Feb 27, 2009 02:13 PM

May I suggest changing lDir to lVertical--it will be more obvious what it means.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 83
Joined: Mon Oct 17, 2005 10:33 AM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Sun May 17, 2009 12:22 PM
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

Code (fw): Select all Collapse
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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Sun May 17, 2009 01:31 PM
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 > :

Code (fw): Select all Collapse
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.
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Wed May 20, 2009 03:52 AM

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

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Painting problem in the New Sample GradBrus.Prg
Posted: Wed May 20, 2009 01:19 PM

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

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql

Continue the discussion