Page 1 of 1

Fixed Brush

Posted: Tue Dec 24, 2019 1:20 am
by ctoas
Friends.

I need to make a solid color brush that has a fixed size in the footer no matter the size of the window, is this possible?

Thanks

Re: Fixed Brush

Posted: Tue Dec 24, 2019 2:06 am
by nageswaragunupudi

Code: Select all

#include "fivewin.ch"

function Main()

   local oWnd
   local nBrushHt    := 80
   local nBrushClr   := CLR_HGRAY

   DEFINE WINDOW oWnd TITLE "FOOTER BRUSH"

   oWnd:bPainted := <|hDC|
      local aRect    := GetClientRect( oWnd:hWnd )
      local hBrush   := CreateSolidBrush( nBrushClr )

      aRect[ 1 ] := aRect[ 3 ] - nBrushHt
      FillRect( hDC, aRect, hBrush )
      DeleteObject( hBrush )

      return nil
      >

   ACTIVATE WINDOW oWnd

return nil
 

Re: Fixed Brush

Posted: Tue Dec 24, 2019 4:14 am
by ctoas
Thanks for answering.

It worked perfectly, but there was a flaw in translating my message that made window instead of dialog.

Tried to do in a dialog, but generate several errors.

If you can help, I appreciate it.

Re: Fixed Brush

Posted: Tue Dec 24, 2019 4:35 am
by nageswaragunupudi
Are you using a very very old version of FWH?

Re: Fixed Brush

Posted: Tue Dec 24, 2019 4:44 am
by ctoas
Resolved with tPanel

Thank you for your help

Re: Fixed Brush

Posted: Tue Dec 24, 2019 7:30 am
by nageswaragunupudi
ctoas wrote:Resolved with tPanel

Thank you for your help
No need for workarounds and make the code complex.
We can do it directly with Dialog.

Code: Select all

   local oDlg, aRect, oFooterBrush, nBrushHt := 80

   DEFINE BRUSH oFooterBrush COLOR CLR_HGREEN
   DEFINE DIALOG oDlg SIZE 500,400 PIXEL
   ACTIVATE DIALOG oDlg CENTERED ON PAINT ;
      (  aRect := GetClientRect( oDlg:hWnd ), ;
         aRect[ 1 ] := aRect[ 3 ] - nBrushHt, ;
         FillRect( hDC, aRect, oFooterBrush:hBrush ) ;
      )
   RELEASE BRUSH oFooterBrush
 
When you put a question, we request you to indicate the version of FWH you are using. That makes it easy for us to suggest a solution that works with your version. If not we suggest what works with the latest versions.

Re: Fixed Brush

Posted: Thu Dec 26, 2019 6:46 pm
by ctoas
Hello, I hope you had a great Christmas!

Sorry, I know the version rule, but when I saw your message I had already found the tPanel class, but I didn't get to test it for what I wanted.

What I want to do would be custom warning, error and etc messages like this in the image, in this case I tested the know example but where the brush does not accept anything over transparent.

Image

Re: Fixed Brush

Posted: Thu Dec 26, 2019 9:17 pm
by ukoenig
You can use TTitle
What I want to do would be custom warning, error and etc messages
like this in the image,
in this case I tested the know example but where the brush
does not accept anything over transparent.
use windows or dialog
transparent- or brushed title
brushed 3D-text
defined border with pensize and transparent-level
or NO border

I added another test to sample < Testtitle.prg >

Image

Code: Select all

...
...
    @ 250, 150 TITLE oTitle3 size 460, 60 of oWnd TRANSPARENT NOBORDER 
    @   8,  100 TITLETEXT OF oTitle3 TEXT FWVERSION FONT oFont1 brush oBrush4 3D SHADOW TOPRIGHT
    @   2,  30 TITLEIMG OF oTitle3 BITMAP "..\bitmaps\32X32\keys.bmp" SIZE 50, 50 REFLEX TRANSPARENT ;
    ACTION MsgInfo( "Keys" )

oWnd:bPainted := < |hDC|
    DRAWBORDER( oWnd, oTitle3 )
RETURN NIL
>
...
...
// -----------

FUNCTION DRAWBORDER( oWnd, oTitle3 )
LOCAL oGraphics := Graphics():New( oWnd:hDC ) 
LOCAL nRed      := nRGBRed( 255 ) // red
LOCAL nGreen    := nRGBGreen( 255 )
LOCAL nBlue     := nRGBBlue( 255 )
LOCAL oPen      := Pen():New( 255, nRed, nGreen, nBlue, 5, .T.) // nTransparency, nRed, nGreen, nBlue

oGraphics:DrawRoundRect( oPen, , oTitle3:nLeft, oTitle3:nTop, oTitle3:nWidth, oTitle3:nHeight, 30 ) 

oGraphics:Destroy()
oPen:Destroy()

RETURN NIL
 

Re: Fixed Brush

Posted: Thu Dec 26, 2019 9:43 pm
by nageswaragunupudi
Is this what you want?
Image

Re: Fixed Brush

Posted: Thu Dec 26, 2019 9:46 pm
by nageswaragunupudi

Code: Select all

#include "fivewin.ch"

function Main()

   local oDlg, oFont, oSay, oBtn
   local cMsg  := "Message"
   local aColor   := { 0x91ffff, 0x4bb7fe }

   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-30
   DEFINE DIALOG oDlg SIZE 500,200 PIXEL TRUEPIXEL COLOR CLR_WHITE, 1 STYLE WS_POPUP
   oDlg:nSeeThroClr  := 1

   @ 00,120 SAY oSay PROMPT cMsg SIZE 350,100 PIXEL OF oDlg CENTER VCENTER ;
      FONT oFont COLOR CLR_HRED, aColor[ 1 ]

   @ 140,350 BTNBMP oBtn BITMAP "c:\fwh\bitmaps\32x32\yes.bmp" SIZE 40,40 PIXEL ;
      OF oDlg FLAT NOBORDER ACTION oDlg:End()
   oBtn:bClrGrad  := { || { { 1, aColor[ 2 ], aColor[ 2 ] } } }

   ACTIVATE DIALOG oDlg CENTERED ON PAINT DlgPaint( hDC, oDlg, aColor )
   RELEASE FONT oFont

return nil

static function DlgPaint( hDC, oDlg, aColor )

   local hWnd     := oDlg:hWnd
   local aRect    := GetClientRect( hWnd )
   local nTop     := aRect[ 1 ]
   local nBottom  := aRect[ 3 ]
   local nHt      := 80
   local hRgn     := CreateRoundRectRgn( aRect, 80, 80 )

   local hBrush

   SelectClipRgn( hDC, hRgn )
   hBrush         := CreateSolidBrush( aColor[ 1 ] )
   aRect[ 3 ]     := nBottom - nHt
   FillRect( hDC, aRect, hBrush )
   DeleteObject( hBrush )

   hBrush         := CreateSolidBrush( aColor[ 2 ] )
   aRect[ 1 ]     := aRect[ 3 ]
   aRect[ 3 ]     := nBottom

   FillRect( hDC, aRect, hBrush )
   DeleteObject( hBrush )
   SelectClipRgn( hDC )
   DeleteObject( hRgn )

   FW_DrawImage( hDC, "c:\fwh\bitmaps\alphabmp\ichat.bmp", { 90,50,154,114 } )

return nil
 

Re: Fixed Brush

Posted: Fri Dec 27, 2019 2:07 am
by ctoas
nageswaragunupudi wrote:Is this what you want?
Image
Perfect, that's what I was looking for.

Thanks!

Image

Re: Fixed Brush

Posted: Fri Dec 27, 2019 11:36 am
by ukoenig
Added brushed text with 3D look,
gradient base,
and border with possible transparent-level,
possible to move the dialog,
mixing my sample from above with Mr. Rao's solution

Image

regards
Uwe :D