Page 1 of 3

Change BACKCOLOR of SPLITCHILD Window

Posted: Fri May 31, 2013 6:23 pm
by serge_girard
Hello All,


Is it possible to change the background color of a SPLITCHILD Window?


Grtz & Thx,


Serge

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Fri May 31, 2013 7:44 pm
by Pablo César
Hi Serge,

I found a midle of way to solve your problem (sorry, today I'm not so shining... :lol: )

But with this Guru example of Dr. Soto, I found something... look at this:

Code: Select all

* PROGRAMA: Demo ON PAINT event
* LENGUAJE: HMG
* FECHA:    Setiembre 2012
* AUTOR:    Dr. CLAUDIO SOTO
* PAIS:     URUGUAY
* E-MAIL:   srvet@adinet.com.uy
* BLOG:     http://srvet.blogspot.com
*******************************************************************************


#include "hmg.ch"
#include "hfcl.ch"


FUNCTION MAIN

PRIVATE cont := 1 

   DEFINE WINDOW Win1;
       AT 0,0;
       WIDTH  600;
       HEIGHT 600;
       TITLE "Demo2: DrawGradientFill and DrawText";
       MAIN;
       ON PAINT Proc_ON_PAINT ()

       DEFINE MAIN MENU
           DEFINE POPUP "File"
                  MENUITEM "Exit" ACTION Win1.Release
           END POPUP
       END MENU

        @  330, 300 BUTTON Button_1 CAPTION "Maximize" ACTION Win1.Maximize      
        @  330, 100 BUTTON Button_2 CAPTION "Click"    ACTION MsgInfo ("Hello")
        @  400, 200 BUTTON Button_3 CAPTION "Change"   ACTION {|| cont++, BT_ClientAreaInvalidateAll ("Win1")}

        
		DEFINE SPLITBOX 
		
		DEFINE GRID Grid_1
				WIDTH 300 
				HEIGHT 200
				HEADERS {'Last Name','First Name'} 
				WIDTHS {180,180}
				ITEMS { {'Simpson','Homer'} , {'Mulder','Fox'} } 
				VALUE 1 
				TOOLTIP 'Grid Control'
        END GRID
						
		DEFINE WINDOW SplitChild_1 ; 
				WIDTH 200 ;
				HEIGHT 200 ;
				VIRTUAL WIDTH 400 ;
				VIRTUAL HEIGHT 400 ;
				SPLITCHILD NOCAPTION ;

				DEFINE LABEL Label_1
					ROW	55
					COL	30
					VALUE 'Label !!!' 
					WIDTH 100 
					HEIGHT 27 
				END LABEL

				DEFINE CHECKBOX Check_1
					ROW	80
					COL	30
					CAPTION 'Check 1' 
					VALUE .T. 
					TOOLTIP 'CheckBox' 
				END CHECKBOX
			
				DEFINE SLIDER Slider_1
					ROW 115
					COL 30
					RANGEMIN 1
					RANGEMAX 10 
					VALUE 5 
					TOOLTIP 'Slider' 
				END SLIDER
				
				DEFINE FRAME Frame_1
					ROW	45
					COL	170
					WIDTH 85
					HEIGHT 110
				END FRAME

				DEFINE RADIOGROUP Radio_1
					ROW	50
					COL	180
					OPTIONS { 'One' , 'Two' , 'Three', 'Four' } 
					VALUE 1 
					WIDTH 70 
					TOOLTIP 'RadioGroup' 
				END RADIOGROUP

			END WINDOW
		    END SPLITBOX
			
			
   END WINDOW

   CENTER WINDOW Win1
   ACTIVATE WINDOW Win1

RETURN Nil



PROCEDURE Proc_ON_PAINT
LOCAL Width  := BT_ClientAreaWidth  ("Win1")
LOCAL Height := BT_ClientAreaHeight ("Win1")  
LOCAL hDC, BTstruct

  hDC = BT_CreateDC ("Win1", BT_HDC_INVALIDCLIENTAREA, @BTstruct)
  
    IF cont > 6
       cont = 1
    ENDIF

    DO CASE
       CASE cont = 1
            BT_DrawGradientFillHorizontal (hDC, 0,       0, Width/2, Height, BLACK, BLUE)
            BT_DrawGradientFillHorizontal (hDC, 0, Width/2, Width/2, Height, BLUE,  BLACK)

       CASE cont = 2
            BT_DrawGradientFillVertical (hDC,        0,   0, Width, Height/2, BLACK, RED)
            BT_DrawGradientFillVertical (hDC, Height/2,   0, Width, Height/2, RED,   BLACK)

       CASE cont = 3
            BT_DrawGradientFillVertical (hDC,        0,   0, Width, Height/2, RED,   GREEN)
            BT_DrawGradientFillVertical (hDC, Height/2,   0, Width, Height/2, GREEN, BLUE)
       
       CASE cont = 4
            BT_DrawGradientFillHorizontal (hDC, 0,       0, Width/2, Height, GREEN, BLUE)
            BT_DrawGradientFillHorizontal (hDC, 0, Width/2, Width/2, Height, BLUE,  RED)
           
      CASE cont = 5 
           BT_DrawGradientFillVertical   (hDC,   0,       0,  Width,  Height, WHITE, BLACK)                 

      CASE cont = 6            
           BT_DrawGradientFillHorizontal (hDC,   0,       0,  Width,  Height, {100,0,123}, BLACK)      
     
    END CASE
    
    nTypeText  := BT_TEXT_TRANSPARENT + BT_TEXT_BOLD + BT_TEXT_ITALIC + BT_TEXT_UNDERLINE    
    nAlingText := BT_TEXT_CENTER + BT_TEXT_BASELINE  
    BT_DrawText (hDC, Height/2-3, Width/2+3, "The Power of HMG", "Comic Sans MS", 42, GRAY, BLACK, nTypeText, nAlingText) // Shadow Effect
    BT_DrawText (hDC, Height/2, Width/2, "The Power of HMG", "Comic Sans MS", 42, YELLOW, BLACK, nTypeText, nAlingText)   
   
  BT_DeleteDC (BTstruct) 
do events
RETURN
Certainly you need to refresh all components, but seems to work in code in C help. Probably Dr. Soto could help to give right way in order to find solution without
gradient effects. I hope to be helpfull.

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 1:37 am
by srvet_claudio
serge_girard wrote:Hello All,

Is it possible to change the background color of a SPLITCHILD Window?

Grtz & Thx,

Serge
Hi Serge.

See this example.

Best regards,
Claudio.

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 1:40 am
by Pablo César
Wow Dr. Claudio !!!

Your are a genius ! Very good and nice ! I liked, I liked !

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 1:43 am
by Pablo César
Dear Claudio, this same example, could it be background not in gradient mode ?

I am sking this, because would it be difficult to change components with grandient background and being solid mode will be easier.

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 1:54 am
by srvet_claudio
Pablo César wrote:Dear Claudio, this same example, could it be background not in gradient mode ?

I am sking this, because would it be difficult to change components with grandient background and being solid mode will be easier.
Yes, only change:

Code: Select all

BT_DrawGradientFillHorizontal()  and  BT_DrawGradientFillVertical()
for:

Code: Select all

BT_DrawFillRectangle (hDC, 0, 0, Width, Height, ColorRGBFill) 

Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 2:02 am
by Pablo César
Thank you Claudio ! Works perfectly !
Screen91.PNG
Screen91.PNG (28.29 KiB) Viewed 4208 times
Look like so nice !

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 2:28 am
by srvet_claudio
Pablo César wrote:Thank you Claudio ! Works perfectly !
With common window and solid background color remove the On Paint event and put BackColor property, it's more easy.

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 3:14 am
by Pablo César
Yeah, I had already thought about it.

Thank you, genious !

Re: Change BACKCOLOR of SPLITCHILD Window

Posted: Sat Jun 01, 2013 7:35 am
by serge_girard
Great !

I will try this at once.

It's getting better all the time!!

Thx,

Serge