TPanel with User Color Setting

TPanel with User Color Setting

Postby Patrick Mast » Mon Sep 15, 2008 9:13 am

Antonio,

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

Code: Select all  Expand view
//----------------------------------------------------------------------------//

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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby James Bott » Mon Sep 15, 2008 3: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.

Code: Select all  Expand view
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Patrick Mast » Mon Sep 15, 2008 3: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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby James Bott » Mon Sep 15, 2008 3: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Silvio » Mon Sep 15, 2008 4:38 pm

Patrik, James
I pubblish a TPanel with colors and scrollbar
http://forums.fivetechsoft.com/viewtopi ... ght=tpanel
Best Regards, Saludos

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

Postby James Bott » Mon Sep 15, 2008 4:54 pm

Silvio,

>I pubblish a TPanel with colors

As I said, setColors() has always worked.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Silvio » Tue Sep 16, 2008 7:03 am

james but the scrollbar not run good
Best Regards, Saludos

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: No registered users and 81 guests