make a rectangule with a brush

make a rectangule with a brush

Postby Silvio.Falconi » Thu Mar 23, 2023 11:58 am

could someone help me in making a rectangle with a specific brush ( borland bdiagonal) ?

I tried with
Code: Select all  Expand view  RUN

 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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: make a rectangule with a brush

Postby nageswaragunupudi » Mon Mar 27, 2023 2:32 am

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


should be

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: make a rectangule with a brush

Postby nageswaragunupudi » Mon Mar 27, 2023 2:58 am

Or we can also do this with minimal code like this:

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


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: make a rectangule with a brush

Postby Silvio.Falconi » Mon Mar 27, 2023 6:50 am

nageswaragunupudi wrote:Or we can also do this with minimal code like this:

Code: Select all  Expand view  RUN
   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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: make a rectangule with a brush

Postby nageswaragunupudi » Mon Mar 27, 2023 8:46 am

the problem is that a btnbmp when disabled looks ugly


Depends on the program.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: make a rectangule with a brush

Postby nageswaragunupudi » Thu Mar 30, 2023 11:33 am

Code: Select all  Expand view  RUN
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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: make a rectangule with a brush

Postby Silvio.Falconi » Thu Mar 30, 2023 11:57 am

nageswaragunupudi wrote:
Code: Select all  Expand view  RUN
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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: make a rectangule with a brush

Postby Silvio.Falconi » Thu Mar 30, 2023 12:26 pm

Rao,
I modify your test inserting the gradient I use and the color of border

Code: Select all  Expand view  RUN
#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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: make a rectangule with a brush

Postby nageswaragunupudi » Thu Mar 30, 2023 1:13 pm

Enlarge?
Pls provide an example.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: make a rectangule with a brush

Postby Silvio.Falconi » Thu Mar 30, 2023 3:59 pm

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.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: make a rectangule with a brush

Postby nageswaragunupudi » Tue Apr 04, 2023 6:01 am

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests