FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TPanel with User Color Setting
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
TPanel with User Color Setting
Posted: Mon Sep 15, 2008 09:13 AM
Antonio,

Can you change the TPanel class so it has a user definable color. I did it like this:

//----------------------------------------------------------------------------//

CLASS TPanel FROM TControl

   METHOD New( nTop, nLeft, nBottom, nRight, oWnd, nClrPane ) CONSTRUCTOR  //PM (Added nClrPane)

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nTop, nLeft, nBottom, nRight, oWnd, nClrPane ) CLASS TPanel //PM (Added nClrPane)

   DEFAULT nTop := 0, nLeft := 0, nBottom := 100, nRight := 100,;
           oWnd := GetWndDefault()
   
   DEFAULT nClrPane := GetSysColor( COLOR_BTNFACE ) //PM

   ::nTop    = nTop
   ::nLeft   = nLeft
   ::nBottom = nBottom
   ::nRight  = nRight
   ::oWnd    = oWnd
   ::nStyle  = nOr( WS_CHILD, WS_VISIBLE )
   ::lDrag   = .f.
   ::nClrPane = nClrPane //PM

   #ifdef __XPP__
      DEFAULT ::lRegistered := .f.
   #endif

   ::Register()

   if ! Empty( ::oWnd:hWnd )
      ::Create()
      ::oWnd:AddControl( Self )
   else
      ::oWnd:DefControl( Self )
   endif

return Self


Look for the //PM code for the changes I made.

Tx!

Patrick
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
TPanel with User Color Setting
Posted: Mon Sep 15, 2008 03:28 PM
Patrick,

Of course you can always set the color using setColor().

If we are going to add color to the parameters I suggest we add both foreground and background colors to be consistant with other classes.

METHOD New( nTop, nLeft, nBottom, nRight, oWnd, nClrText, nClrPane ) CLASS TPanel

   DEFAULT nTop := 0, nLeft := 0, nBottom := 100, nRight := 100,; 
           oWnd := GetWndDefault() 
    
   DEFAULT nClrText := GetSysColor( COLOR_WINDOWTEXT ) ;
      nClrPane := GetSysColor( COLOR_BTNFACE )
   ...
   ::nClrText := nClrText
   ::nClrPane := nClrPane


Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
TPanel with User Color Setting
Posted: Mon Sep 15, 2008 03:35 PM
Hello James,
Of course you can always set the color using setColor().
The SetColor() did not work with me.

If we are going to add color to the parameters I suggest we add both foreground and background colors to be consistant with other classes.
Can a Panel have text on it? If not, there is no usage for a TextColor. :-)

Patrick
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
TPanel with User Color Setting
Posted: Mon Sep 15, 2008 03:40 PM

Patrick,

>The SetColor() did not work with me.

I have been using it for years.

>Can a Panel have text on it? If not, there is no usage for a TextColor.

Of course; you can put any control on a panel that you can put on a window. TPanel is a subclass of TControl which is a subclass of TWindow.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
TPanel with User Color Setting
Posted: Mon Sep 15, 2008 04:38 PM

Patrik, James
I pubblish a TPanel with colors and scrollbar

http://forums.fivetechsoft.com/viewtopi ... ght=tpanel

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
TPanel with User Color Setting
Posted: Mon Sep 15, 2008 04:54 PM

Silvio,

>I pubblish a TPanel with colors

As I said, setColors() has always worked.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
TPanel with User Color Setting
Posted: Tue Sep 16, 2008 07:03 AM

james but the scrollbar not run good

Best Regards, Saludos



Falconi Silvio

Continue the discussion