to fill a rect

to fill a rect

Postby Silvio » Sun Jan 29, 2006 6:00 pm

I must refill a rect :

Code: Select all  Expand view
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
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: to fill a rect

Postby Enrico Maria Giordano » Sun Jan 29, 2006 6:39 pm

This is a working sample:

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Silvio » Sun Jan 29, 2006 10:21 pm

thanks EMG

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

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

Postby Silvio » Sun Jan 29, 2006 10:33 pm

to understand well I explain you
in a program I run this function

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

Postby Silvio » Sun Jan 29, 2006 10:37 pm

OKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK


I resolve IT

NOw RUn OKKKKKKKK

thanks to all

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 74 guests