Change BACKCOLOR of SPLITCHILD Window

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
serge_girard
Posts: 2630
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 904 times
Been thanked: 164 times
Contact:

Change BACKCOLOR of SPLITCHILD Window

Post by serge_girard »

Hello All,


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


Grtz & Thx,


Serge

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
srvet_claudio
Posts: 2117
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 53 times
Been thanked: 238 times
Contact:

Post 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.
Attachments
demo14.PNG
demo14.PNG (62.9 KiB) Viewed 3486 times
BT_Demo14.rar
(1.93 KiB) Downloaded 186 times
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César »

Wow Dr. Claudio !!!

Your are a genius ! Very good and nice ! I liked, I liked !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
srvet_claudio
Posts: 2117
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 53 times
Been thanked: 238 times
Contact:

Post 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) 
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César »

Thank you Claudio ! Works perfectly !
Screen91.PNG
Screen91.PNG (28.29 KiB) Viewed 3462 times
Look like so nice !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
srvet_claudio
Posts: 2117
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 53 times
Been thanked: 238 times
Contact:

Post 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.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César »

Yeah, I had already thought about it.

Thank you, genious !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
serge_girard
Posts: 2630
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 904 times
Been thanked: 164 times
Contact:

Post by serge_girard »

Great !

I will try this at once.

It's getting better all the time!!

Thx,

Serge

Post Reply