Page 1 of 1

to fill a rect

Posted: Sun Jan 29, 2006 6:00 pm
by Silvio
I must refill a rect :

Code: Select all

METHOD Rectang( nTop, nLeft, nBottom, nRight, oPen ,nRecord) CLASS XXXXXXX

   local hPen := if( oPen = nil, 0, oPen:hPen )
   Local nX := oPen:nWidth / 2
   IIF( nRecord == nil , nRecord := 0  , )
   ::GetDC()
   MoveTo( ::hDC, nLeft, nTop )
   LineTo( ::hDC, nRight, nBottom, hPen )
   FillRect( nTop, nLeft, nBottom, nRight, nColor )  ?? it make me error 
   ::ReleaseDC()
 
return nil

Someone can help me please

Regards

Re: to fill a rect

Posted: Sun Jan 29, 2006 6:39 pm
by Enrico Maria Giordano
This is a working sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrush

    DEFINE BRUSH oBrush COLOR CLR_RED

    DEFINE DIALOG oDlg

    @ 3, 1 BUTTON "&Close" ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             ON PAINT FILLRECT( hDC, { 10, 10, 100, 300 }, oBrush:hBrush );
             CENTER

    RELEASE BRUSH oBrush

    RETURN NIL
EMG

Posted: Sun Jan 29, 2006 10:21 pm
by Silvio
thanks EMG

but I must give to my func ncolor variable
it create a rect with

Code: Select all

Rectang( nTop, nLeft, nBottom, nRight, oPen ,nRecord)
from this command I can create a brush with the ncolor of the open I give to it

can I found the color of the open and insert to brush ?

Posted: Sun Jan 29, 2006 10:33 pm
by Silvio
to understand well I explain you
in a program I run this function

Code: Select all

    oGraficos:Rectang( nLinea+nVertic+4, nColumnaInicio+nHoriz, nLinea+nVertic+10, nColumnaFinal+nHoriz ,oPen5,dati->(Recno()) )
           
oGraficos is a object of a class

and into class there is this method :

Code: Select all

METHOD Rectang( nTop, nLeft, nBottom, nRight, oPen ,nRecord) CLASS XXXXXX

   local hPen := if( oPen = nil, 0, oPen:hPen )
   Local nX := oPen:nWidth / 2
   IIF( nRecord == nil , nRecord := 0  , )
   ::GetDC()
   *Rectangle( ::hDC, nTop, nLeft, nBottom, nRight, hPen )
    MoveTo( ::hDC, nLeft, nTop )
   LineTo( ::hDC, nRight, nBottom, hPen )

   PPP

   ::ReleaseDC()
 if nRecord > 0
      aadd(::aItems,{nTop-nX,nLeft-nX,nBottom+nX,nRight+nX,nRecord})
   endif

return nil
But it create a line as a pen and I want to show a rectangule filled of the color hpen

where I insert the word "PPP" i must insert the _fillrect method but it want a brush

Code: Select all

METHOD _FillRect( nTop, nLeft, nBottom, nRight, nColor ) CLASS XXXX

   LOCAL oBrush, hBru, hOld

   hBru := CreateSolidBrush( nColor )
   hPen := CreatePen( nColor )
   hOld := SelectObject( ::hDC, hBru )
   MoveTo( ::hDC, nLeft, nTop )
   LineTo( ::hDC, nRight, nBottom, hPen )
   FillRect( ::hDC, { nTop, nLeft, nBottom, nRight }, hBru )
   SelectObject( ::hDC, hOld )
   DeleteObject( hBru )

   RETURN (Nil)
I hope you understand now well my work

Regards

Posted: Sun Jan 29, 2006 10:37 pm
by Silvio
OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK


I resolve IT

NOw RUn OKKKKKKKK

thanks to all

Falconi Silvio