FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Rectangle
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Rectangle
Posted: Wed Feb 26, 2025 08: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 ?

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Rectangle
Posted: Wed Feb 26, 2025 10:16 AM
Natter wrote: 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
#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
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Rectangle
Posted: Wed Feb 26, 2025 12:52 PM

Thanks, I'll give it a try !

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Rectangle
Posted: Wed Feb 26, 2025 01:41 PM
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
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Rectangle
Posted: Wed Feb 26, 2025 06:23 PM

Thanks Rao, good solution !

Continue the discussion