Page 1 of 1

make a rectangule with a brush

PostPosted: Thu Mar 23, 2023 11:58 am
by Silvio.Falconi
could someone help me in making a rectangle with a specific brush ( borland bdiagonal) ?

I tried with
Code: Select all  Expand view

 hLite   := CreatePen( PS_SOLID, 1, ::nClrLite )
   hDark   := CreatePen( PS_SOLID, 1, ::nClrDark )
   hBack   := CreatePen( PS_SOLID, 1, ::oWnd:nClrPane )

    DEFINE BRUSH hBrush    STYLE BDIAGONAL COLOR  Rgb(195,195,185)
     hOldBru := SelectObject( ::hDC, hBrush )

         Rectangle( ::hDC, aRect[ 1 ] + 1 , aRect[ 2 ] + 1, aRect[ 3 ], aRect[ 4 ], hLite )
         Rectangle( ::hDC, aRect[ 1 ], aRect[ 2 ], aRect[ 3 ] - 1, aRect[ 4 ] - 1, hDark )
         MoveTo( ::hDC, aRect[ 2 ] + 1, aRect[ 3 ] - 3 )
         LineTo( ::hDC, aRect[ 2 ] + 1, aRect[ 1 ] + 1, hLite )
         LineTo( ::hDC, aRect[ 4 ] - 2, aRect[ 1 ] + 1, hLite )

        FillRect( ::hDC, { aRect[ 1 ] + 1 , aRect[ 2 ] + 1, aRect[ 3 ], aRect[ 4 ] }, hBrush )


it draw the rectangule without the brush

Image

but not run ok

Re: make a rectangule with a brush

PostPosted: Mon Mar 27, 2023 2:32 am
by nageswaragunupudi
Code: Select all  Expand view
   DEFINE BRUSH hBrush    STYLE BDIAGONAL COLOR  Rgb(195,195,185)
     hOldBru := SelectObject( ::hDC, hBrush )
 


should be

Code: Select all  Expand view
   DEFINE BRUSH oBrush    STYLE BDIAGONAL COLOR  Rgb(195,195,185)
     hOldBru := SelectObject( ::hDC, oBrush:hBrush )
 

Re: make a rectangule with a brush

PostPosted: Mon Mar 27, 2023 2:58 am
by nageswaragunupudi
Or we can also do this with minimal code like this:

Code: Select all  Expand view
   DEFINE BRUSH oBrush STYLE BDIAGONAL COLOR CLR_GREEN
   oDlg:bPainted := { || oDlg:Box( 100,100,200,300, { CLR_HRED, 2 }, oBrush, "TEXT" ) }
 


Image

Re: make a rectangule with a brush

PostPosted: Mon Mar 27, 2023 6:50 am
by Silvio.Falconi
nageswaragunupudi wrote:Or we can also do this with minimal code like this:

Code: Select all  Expand view
   DEFINE BRUSH oBrush STYLE BDIAGONAL COLOR CLR_GREEN
   oDlg:bPainted := { || oDlg:Box( 100,100,200,300, { CLR_HRED, 2 }, oBrush, "TEXT" ) }
 


Image


Thanks Rao , But I need it to replace a btnbmp when it's disabled, the problem is that a btnbmp when disabled looks ugly and behaves differently from a get or a say

Re: make a rectangule with a brush

PostPosted: Mon Mar 27, 2023 8:46 am
by nageswaragunupudi
the problem is that a btnbmp when disabled looks ugly


Depends on the program.

Re: make a rectangule with a brush

PostPosted: Thu Mar 30, 2023 11:33 am
by nageswaragunupudi
Code: Select all  Expand view
function test()

   local oDlg, oBtn, hBmp := LinesBmp()
   local lEnabled := .t.

   DEFINE DIALOG oDlg SIZE 200,200 PIXEL TRUEPIXEL

   @  40,60 BTNBMP oBtn ;
      FILE "..\bitmaps\pngs\image1.png", "", hBmp, "" ;
      SIZE 64,64 PIXEL FLAT GDIP WHEN lEnabled OF oDlg

   @ 130,60 CHECKBOX lEnabled PROMPT "ENABLED" ;
      SIZE 80,20 PIXEL OF oDlg


   ACTIVATE DIALOG oDlg CENTERED

return nil

//----------------------------------------------------------------------------//

static function LinesBmp()

   local hBmp, oBrush

   DEFINE BRUSH oBrush STYLE BDIAGONAL COLOR CLR_GRAY
   hBmp  := FW_MakeYourBitmap( 96,96, <|hDC,w,h|
            FillRect( hDC, { 0,0,95,95 }, oBrush:hBrush )
            return nil
            > )
   RELEASE BRUSH oBrush

return hBmp
 


Image

Re: make a rectangule with a brush

PostPosted: Thu Mar 30, 2023 11:57 am
by Silvio.Falconi
nageswaragunupudi wrote:
Code: Select all  Expand view
function test()

   local oDlg, oBtn, hBmp := LinesBmp()
   local lEnabled := .t.

   DEFINE DIALOG oDlg SIZE 200,200 PIXEL TRUEPIXEL

   @  40,60 BTNBMP oBtn ;
      FILE "..\bitmaps\pngs\image1.png", "", hBmp, "" ;
      SIZE 64,64 PIXEL FLAT GDIP WHEN lEnabled OF oDlg

   @ 130,60 CHECKBOX lEnabled PROMPT "ENABLED" ;
      SIZE 80,20 PIXEL OF oDlg


   ACTIVATE DIALOG oDlg CENTERED

return nil

//----------------------------------------------------------------------------//

static function LinesBmp()

   local hBmp, oBrush

   DEFINE BRUSH oBrush STYLE BDIAGONAL COLOR CLR_GRAY
   hBmp  := FW_MakeYourBitmap( 96,96, <|hDC,w,h|
            FillRect( hDC, { 0,0,95,95 }, oBrush:hBrush )
            return nil
            > )
   RELEASE BRUSH oBrush

return hBmp
 


Image


Good Mr Rao ....and the Border of Btbnbmp ? it is allways black
oBtn:nClrBorder := RGB( 245,245,235)
on init go ok then I wish modify it

Re: make a rectangule with a brush

PostPosted: Thu Mar 30, 2023 12:26 pm
by Silvio.Falconi
Rao,
I modify your test inserting the gradient I use and the color of border

Code: Select all  Expand view
#include "fivewin.ch"



function test()

   local oDlg, oBtn, hBmp := LinesBmp()
   local lEnabled := .t.




   DEFINE DIALOG oDlg SIZE 200,200 PIXEL TRUEPIXEL

   @  40,60 BTNBMP oBtn ;
      FILE "C:\WORK\FWH\bitmaps\pngs\image1.png", "", hBmp, "" ;
      SIZE 64,64 PIXEL FLAT NOROUND GDIP WHEN lEnabled OF oDlg

   oBtn:nClrBorder := RGB(195,195,185)

    oBtn:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 0.25, RGB( 245,245,235),  RGB(250,250,245) },;
                      { 0.75,  RGB(250,250,245), RGB( 245,245,235) } },;
                    { { 0.25,  RGB(250,250,245), RGB( 245,245,235) }, ;
                      { 0.75, RGB( 245,245,235),  RGB(250,250,245) } } ) }




   @ 130,60 CHECKBOX lEnabled PROMPT "ENABLED" ;
      SIZE 80,20 PIXEL OF oDlg


   ACTIVATE DIALOG oDlg CENTERED

return nil

//----------------------------------------------------------------------------//

static function LinesBmp()

   local hBmp, oBrush

   DEFINE BRUSH oBrush STYLE BDIAGONAL COLOR CLR_GRAY
   hBmp  := FW_MakeYourBitmap( 96,96, <|hDC,w,h|
            FillRect( hDC, { 0,0,95,95 }, oBrush:hBrush )
            return nil
            > )

   RELEASE BRUSH oBrush

return hBmp


 



Image


if you enlarge the button with a zoom you will see that there are problems which I've been asking for a long time
i.e. both the gradient and the oblique lines come out of the edge of the button
if you want to change the border online it is not possible because it is always black

Re: make a rectangule with a brush

PostPosted: Thu Mar 30, 2023 1:13 pm
by nageswaragunupudi
Enlarge?
Pls provide an example.

Re: make a rectangule with a brush

PostPosted: Thu Mar 30, 2023 3:59 pm
by Silvio.Falconi
Mr. Rao,
I meant that if you see well the button has problems when using the gradient or the brush with diagonal lines, in both cases they come out of the border when they shouldn't.

Re: make a rectangule with a brush

PostPosted: Tue Apr 04, 2023 6:01 am
by nageswaragunupudi
Silvio.Falconi wrote:Mr. Rao,
I meant that if you see well the button has problems when using the gradient or the brush with diagonal lines, in both cases they come out of the border when they shouldn't.


I see your point.
We will look into this.