Backcolor of Radiogroup

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Backcolor of Radiogroup

Post by serge_girard »

Hello,

I noticed some strange behaviour when changing backcolor of a radiogroup.

Depending on the changed value of a radiogroup I change the backcolor of my radiogroup.

I attache a little demo, compile this and run and then open some of your own HMG compiled programs and see what occurs when changing radio value.
A good example is running the multi-instance demo + my demo.

Sometimes nothing happens, sometimes a form in the back is repainted.

Code: Select all

#include "hmg.ch"
 

function main()
/***************/
DEFINE WINDOW Form_1   ;
   AT 0,0	   ;
   WIDTH  1100	;  
   HEIGHT 600	;
   TITLE 'demo     '   ;
   MAIN	 		 

ON KEY ESCAPE ACTION   Form_1.Release  

 
@ 10,10 LABEL Label_NM ;
   VALUE "VNaam-Fnaam" ;
   WIDTH 175;
   HEIGHT 35 ;
   FONT 'Arial' SIZE 09  

@ 10,200 TEXTBOX TWKL_VNM ;
   TOOLTIP 'VoorNaam'	;
   WIDTH 90 ;
   MAXLENGTH 10	;
   VALUE ''   ;
   BACKCOLOR SILVER	;
   FONTCOLOR BLUE BOLD  

 @  40,10 RADIOGROUP RG_GENDER ;
   OPTIONS {'All', 'Male' , 'Female', 'Child', 'Unknown' } ;
   BACKCOLOR SILVER ;
   VALUE 1 ;
   TOOLTIP 'Gender' ;
   WIDTH  95;
   FONT 'Arial' SIZE 8 ;
   ON CHANGE Change_RADIO()

@ 10,310  BUTTON Btn_Nieuw Of Form_1	;
   CAPTION 'GO!'		;
   ACTION SHOW_F2() 	;       
   WIDTH 120 ;
   HEIGHT 27		;
   FONT "Arial" SIZE 09		;
   TOOLTIP "Go"	;
   FLAT


END WINDOW
 
CENTER WINDOW   Form_1
ACTIVATE WINDOW Form_1
RETURN





FUNCTION SHOW_F2()
/*****************/
DEFINE WINDOW Form_2   ;
   AT 0,0	   ;
   WIDTH  800	;  
   HEIGHT 800	;
   TITLE 'demo     '   
   
 @  10,10 RADIOGROUP RG_x ;
   OPTIONS {'All', 'Male' , 'Female', 'Child', 'Unknown' } ;
   BACKCOLOR SILVER ;
   VALUE 1 ;
   TOOLTIP 'Gender' ;
   WIDTH  95;
   HORIZONTAL ;
   FONT 'Arial' SIZE 8  

@ 40,10 CHECKBOX CB_CONTR_AD CAPTION '' ;
   BACKCOLOR {127,255,212};
   VALUE .F. ;
   WIDTH 30 ;
   FONT 'Arial' SIZE 09		;
   FONTCOLOR BLUE ;
   NOTABSTOP

END WINDOW
ACTIVATE WINDOW Form_2
RETURN





FUNCTION Change_RADIO()
/**********************/
 
DO CASE 
CASE Form_1.RG_GENDER.Value == 1
   Form_1.RG_GENDER.BACKCOLOR := {192,192,192 }   
CASE Form_1.RG_GENDER.Value == 2
   Form_1.RG_GENDER.BACKCOLOR := {127,255,212}   
CASE Form_1.RG_GENDER.Value == 3
   Form_1.RG_GENDER.BACKCOLOR := PINK   
CASE Form_1.RG_GENDER.Value == 4
   Form_1.RG_GENDER.BACKCOLOR := {230,230,250}   
OTHERWISE
   Form_1.RG_GENDER.BACKCOLOR := {175,175,175 }    
ENDCASE

RETURN
Strange isn't it?

Serge
There's nothing you can do that can't be done...
User avatar
gfilatov
Posts: 1057
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Backcolor of Radiogroup

Post by gfilatov »

serge_girard wrote: Tue Jan 02, 2018 9:34 am Hello,

I noticed some strange behaviour when changing backcolor of a radiogroup.
...

Strange isn't it?

Serge
Hello Serge,

You are right!

There is a small bug in the function _SetBackColor() of the source file h_controlmisc.prg.

Step by step fix is below:

1) open source file h_controlmisc.prg in your folder hmg3.4.4\SOURCE with your favorite editor
2) go to line #4691 and replace the following string

Code: Select all

    RedrawWindow ( _HMG_SYSDATA [3] [i] )
with the following code

Code: Select all

    ControlHandle := _HMG_SYSDATA [3] [i]
    IF ValType (ControlHandle) == "A"
       FOR k = 1 TO HMG_LEN (ControlHandle)
           RedrawWindow ( ControlHandle [k])
       NEXT
    ELSE
       RedrawWindow ( ControlHandle )
    ENDIF
3) add on top of the function _SetBackColor() the following definition

Code: Select all

Local ControlHandle , k
after the string
Local i , f
4) recompile libhmg library with the batch file BuildLib32.bat
5) check a result with your above sample

That's all :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Backcolor of Radiogroup

Post by serge_girard »

Thanks Grigory !

You're a Wizard, a True Star! This works fine. I allready noticed this a long time ago and could not live with it any more....

Question: there are several lines with 'RedrawWindow ( _HMG_SYSDATA [3] )'. Should it all be replaced with your suggestion?

Serge
There's nothing you can do that can't be done...
Post Reply