Painting problem in the New Sample GradBrus.Prg

Re: Painting problem in the New Sample GradBrus.Prg

Postby byte-one » Thu Feb 26, 2009 1: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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Painting problem in the New Sample GradBrus.Prg

Postby Antonio Linares » Thu Feb 26, 2009 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Painting problem in the New Sample GradBrus.Prg

Postby byte-one » 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: Select all  Expand view
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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Painting problem in the New Sample GradBrus.Prg

Postby Antonio Linares » Fri Feb 27, 2009 1:02 pm

Günther,

Excellent! :-)

Many thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Painting problem in the New Sample GradBrus.Prg

Postby James Bott » Fri Feb 27, 2009 2:13 pm

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

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Painting problem in the New Sample GradBrus.Prg

Postby Dietmar Jahnel » 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: Select all  Expand view
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
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Re: Painting problem in the New Sample GradBrus.Prg

Postby ukoenig » Sun May 17, 2009 1: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: Select all  Expand view


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 :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Painting problem in the New Sample GradBrus.Prg

Postby FranciscoA » Wed May 20, 2009 3: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
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Painting problem in the New Sample GradBrus.Prg

Postby FranciscoA » Wed May 20, 2009 1: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
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 96 guests