Alaska Software Inc. - Re: Change Background Color
Username: Password:
AuthorTopic: Re: Change Background Color
Andreas Gehrs-Pahl

View the complete thread for this message in:

Re: Change Background Color
on Thu, 04 Jun 2015 16:29:48 -0400
Salvatore,

>As can I change background color of my forms without to use setcolorBG 
>for all forms?

Xbase++ uses the Windows default colors when creating Dialogs, so the user's 
Windows settings are respected by default. If you want to use a different 
color scheme than the user's active Windows default settings, you must 
explicitly set those colors in your code.

One way to do this would be to create your own class and use that class in 
your code. In that class, you can use SetColorBG() to define your Dialog's 
DrawingArea's background color. Here is a small demo for a such a class:

#include "AppEvent.CH"
#include "Gra.ch"
#include "Xbp.ch"

Procedure Main()
LOCAL nEvent  := xbeP_None, mp1, mp2, oXbp
LOCAL oDialog := ColorDialog():New(AppDeskTop(), , {200, 200}, {600, 400})
   oDialog:Title    := 'Testing Default Background Colors...'
   oDialog:TaskList := .t.
*  oDialog:BGColor  := GRA_CLR_BLUE     Override new default Color (Red)
   oDialog:Create()
   SetAppfocus(oDialog)
   while .t.
      nEvent := AppEvent(@mp1, @mp2, @oXbp)
      oXbp:HandleEvent(nEvent, mp1, mp2)
      if nEvent == xbeP_Close .or. nEvent == xbeP_Quit .or. ;
        (nEvent == xbeP_Keyboard .and. mp1 == xbeK_ESC)
         exit
      endif
   enddo
return

Class ColorDialog from XbpDialog
   EXPORTED
   Var BGColor

   Inline Method Init(oParent, oOwner, aPos, aSize, aPP, lVisible)
      ::BGColor := GRA_CLR_RED
   return (::XbpDialog:Init(oParent, oOwner, aPos, aSize, aPP, lVisible))

   Inline Method Create(oParent, oOwner, aPos, aSize, aPP, lVisible)
      ::XbpDialog:Create(oParent, oOwner, aPos, aSize, aPP, lVisible)
      ::DrawingArea:SetColorBG(::BGColor)
   return (Self)

   Inline Method Configure(oParent, oOwner, aPos, aSize, aPP, lVisible)
      ::XbpDialog:Configure(oParent, oOwner, aPos, aSize, aPP, lVisible)
      ::DrawingArea:SetColorBG(::BGColor)
   return (Self)
EndClass

Procedure AppSys()
return

Procedure DbeSys()
return

You could also edit the XbpDialog Class implementation in the XbParts.prg 
file and create your own custom XppDUI.dll, but that would be much more 
cumbersome and you will have to re-do that after each update from Alaska.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas.GP@Charter.net
web:   http://www.Aerospace-History.net