Rectangle

Post Reply
Natter
Posts: 1243
Joined: Mon May 14, 2007 9:49 am

Rectangle

Post by Natter »

Hi,

I need to draw a rectangle on a window with an outline of a certain color and thickness. How to do it ?
User avatar
Silvio.Falconi
Posts: 7151
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Rectangle

Post by Silvio.Falconi »

Natter wrote: Wed Feb 26, 2025 8:29 am Hi,

I need to draw a rectangle on a window with an outline of a certain color and thickness. How to do it ?

Try this but I not test it

Code: Select all | Expand

#include "fivewin.ch"

function Main()
    local oWnd

    // Define the window
    DEFINE WINDOW oWnd TITLE "Rectangle Example" SIZE 640, 480

    // Set the pen color and thickness for the rectangle border
    oWnd: SetPen( RGB(255, 0, 0), 3 )  // Red color, 3 pixels thickness

    // Set the brush color for the rectangle fill (optional)
    oWnd: SetBrush( RGB(0, 255, 0) )   // Green fill (you can also use a transparent fill)

    // Draw the rectangle with specific coordinates
    oWnd: DrawRect( 100, 100, 500, 300 ) // x1, y1, x2, y2

    // Show and activate the window
    ACTIVATE WINDOW oWnd

return
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 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
Natter
Posts: 1243
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle

Post by Natter »

Thanks, I'll give it a try !
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Rectangle

Post by nageswaragunupudi »

Code: Select all | Expand

function TestBox()

   local oWnd
   local aRect       := { 60,100,300,400 }
   local nBrdThick   := 2
   local nBrdColor   := CLR_HRED
   local nRectFill   := CLR_YELLOW

   DEFINE WINDOW oWnd SIZE 600, 500 PIXEL

   oWnd:bPainted := { || FW_Box( oWnd, aRect, { nBrdColor, nBrdThick }, nRectFill ) }

   ACTIVATE WINDOW oWnd CENTERED


return nil
Regards

G. N. Rao.
Hyderabad, India
Post Reply