FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Error on SetCoors()
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Error on SetCoors()
Posted: Thu Oct 16, 2025 08:34 AM



Antonio,

When calling SetCoors() on a TPanel (or any class derived from TControl),

FWH raises:

Error BASE/1004 No exported method: nTop


because TPanel does not export the variables nTop, nLeft, nBottom, nRight

โ€” they exist only in TWindow and its descendants.

So SetCoors() works for TWindow, TDialog, TMDIChild, etc.,

but not for TPanel (or derived classes such as our custom canvas).

โœ… Using Move(top,left,width,height) instead of SetCoors() works perfectly in all cases.


Please try this sample
#include "FiveWin.ch"

FUNCTION Main()
   LOCAL oWnd, oPan, oBr
   DEFINE BRUSH oBr COLOR CLR_RED
   DEFINE WINDOW oWnd TITLE "SetCoors() vs TPanel test"


   // Create a plain TPanel used as a custom canvas
   // NOTE: TPanel():New usually expects (top, left, bottom, right, owner) in older FWH;
   // we pass small initial coords and resize it right after.
   oPan := TPanel():New( 0, 0, 100, 100, oWnd )

   // Make sure the panel paints white so we can see it clearly
  *
   oPan:SetBrush( oBr )

   // Resize handler
  oWnd:bResized := { || FitPanel( oWnd, oPan ) }

   ACTIVATE WINDOW oWnd
RETURN NIL

FUNCTION FitPanel( oWnd, oPan )
   LOCAL aCli, nTop, nLeft, nBottom, nRight

   aCli    := GetClientRect( oWnd:hWnd )   // { top, left, bottom, right }
   nTop    := 0
   nLeft   := 0
   nBottom := aCli[3]
   nRight  := aCli[4]

   // ---- This call raises a runtime error with TPanel ----
   // Error BASE/1004  No exported method: nTop
   // oPan:SetCoors( nTop, nLeft, nBottom, nRight )

   // ---- This call works fine with TPanel (width/height) ----
   oPan:Move( nTop, nLeft, nRight - nLeft, nBottom - nTop )

   InvalidateRect( oPan:hWnd, 0, .T. )
   UpdateWindow( oPan:hWnd )
RETURN NIL
// ---- This call raises a runtime error with TPanel ----
// Error BASE/1004 No exported method: nTop
oPan:SetCoors( nTop, nLeft, nBottom, nRight ) this not run

// ---- This call works fine with TPanel (width/height) ----
oPan:Move( nTop, nLeft, nRight - nLeft, nBottom - nTop ) This run
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: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Error on SetCoors()
Posted: Thu Oct 16, 2025 12:39 PM

Dear Silvio,

Method SetCoors( oRect ) expects a Class TRect object:

oPan:SetCoors( TRect():New( nTop, nLeft, nBottom, nRight ) )

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion