to fill a rect

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

to fill a rect

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: to fill a rect

Post 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
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post 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 ?
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post 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
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK


I resolve IT

NOw RUn OKKKKKKKK

thanks to all

Falconi Silvio
Post Reply