GetControlType in CHECKBUTTON

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

GetControlType in CHECKBUTTON

Post by Pablo César »

Recently I found there was not any demo for CHECKBUTTON at SAMPLES. This is not terrible but following bug occurrs for a very long time... (probably before 3.0.35) :shock: :

Code: Select all

#include "hmg.ch"

Function Main()
DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 200 ;
   HEIGHT 200 ;
   MAIN;
   TITLE 'CheckButton Test'

   @ 20,20 CHECKBOX CheckBox_1 CAPTION "Control Type" WIDTH 150 HEIGHT 50 ;
           ON CHANGE MsgInfo("Control type: "+GetControlType("CheckBox_1","Form_1"),(This.Name))
   
   @ 70,20 CHECKBUTTON CheckButton_1 CAPTION "Control Type" WIDTH 150 HEIGHT 50 ;
           ON CHANGE MsgInfo("Control type: "+GetControlType("CheckButton_1","Form_1"),(This.Name))

END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
In this demo the result should be CHECKBUTTON not CHECKBOX, right ?

At least in HMG/IDE we have these names for control types. Or am I wrong about it ?
Screen17.png
Screen17.png (14.36 KiB) Viewed 6348 times
I've checked at C:\hmg.3.4.3\SOURCE\h_checkbox.prg and _DefineCheckButton function is declared IMO wrongly as "CHECKBOX" :o

Ths same occurs at HMG Extended. Please note Mr. Filatov
Last edited by Pablo César on Wed Oct 19, 2016 11:34 am, edited 4 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: GetControlType in CHECKBUTTON

Post by srvet_claudio »

I will check
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

GetControlType in CHECKBUTTON

Post by Pablo César »

srvet_claudio wrote:I will check
Siempre guardo mi más alta consideracion por todo lo que haces por nosotros.

Lo siento Claudio por darte más trabajo... :|
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

GetControlType in CHECKBUTTON

Post by Pablo César »

Images and codes proves that is wrong control type for CheckButtons (for long time... :o )
Screen19.png
Screen19.png (18.49 KiB) Viewed 6309 times
MsgInfo("Control type: "+GetControlType("CheckButton_1","Form_1"),(This.Name)) => "CHECKBOX" :?:
Screen20.png
Screen20.png (23.74 KiB) Viewed 6306 times
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: GetControlType in CHECKBUTTON

Post by Roberto Lopez »

srvet_claudio wrote:I will check
This is not a bug :)

CheckBox and CheckButton are both defined on "h_checkbox.prg", because they are (basically) the same control (exactly the same behavior) with different styles.

The following was a deliberate design decision:

Code: Select all

_HMG_SYSDATA [1] [k] := "CHECKBOX" 
The most important thing:

GetControlType() IS AN INTERNAL FUNCTION, NOT AIMED TO BE EXPOSED TO THE FINAL USERS, THIS IS THE REASON BECAUSE I'VE NOT INCLUDED IN THE DOCUMENTATION.

Advanced users, digging in HMG internals, will find their way to (if required) differentiate both controls.

Please, don't fix something that is not broken :)
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

GetControlType in CHECKBUTTON

Post by Pablo César »

Roberto Lopez wrote:
srvet_claudio wrote:I will check
This is not a bug :)

CheckBox and CheckButton are both defined on "h_checkbox.prg", because they are (basically) the same control (exactly the same behavior) with different styles.

The following was a deliberate design decision:

Code: Select all

_HMG_SYSDATA [1] [k] := "CHECKBOX" 
The most important thing:

GetControlType() IS AN INTERNAL FUNCTION, NOT AIMED TO BE EXPOSED TO THE FINAL USERS, THIS IS THE REASON BECAUSE I'VE NOT INCLUDED IN THE DOCUMENTATION.

Advanced users, digging in HMG internals, will find their way to (if required) differentiate both controls.

Please, don't fix something that is not broken :)
Sorry to disagree. :oops: Is not broken but wrongly working... :?
You said not exposed before because there was a fail?
Its means that we should not use GetControlType() ?
Because we can not trust in GetControlType().

So, what about GetProperty() ? We should not use neither ?

Please note this another demo:

Code: Select all

#include "hmg.ch"

Function Main()
DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 200 ;
   HEIGHT 200 ;
   MAIN;
   TITLE 'CheckButton Test'

   @ 20,20 CHECKBOX CheckBox_1 CAPTION "Control Type" WIDTH 150 HEIGHT 50 ;
           ON CHANGE MsgInfo("Control type: "+GetProperty("Form_1","CheckBox_1","TYPE"),(This.Name))
//            ON CHANGE MsgInfo("Control type: "+GetControlType("CheckBox_1","Form_1"),(This.Name))
   
   @ 70,20 CHECKBUTTON CheckButton_1 CAPTION "Control Type" WIDTH 150 HEIGHT 50 ;
           ON CHANGE MsgInfo("Control type: "+GetProperty("Form_1","CheckButton_1","TYPE"),(This.Name))
//           ON CHANGE MsgInfo("Control type: "+GetControlType("CheckButton_1","Form_1"),(This.Name))

END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
Please Roberto, give us a good reason to understand it better and turn up the failed info for a good one. Because for me to know what type is the control is IMPORTANT. Is not a private case. In the future others will find same problem, of course there is a way to turn around but IMHO this is not good.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: GetControlType in CHECKBUTTON

Post by Roberto Lopez »

Dear Rathinagiri,

I love this forum... I want to be here... I'm happy here... but I'm relly sick to be constantly 'bullied' over the years via various kinds of aggressions...

Please... I want to stay here... but, if this is the price... maybe not...
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: GetControlType in CHECKBUTTON

Post by srvet_claudio »

Roberto Lopez wrote: Please, don't fix something that is not broken :)
OK, no problem.
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

GetControlType in CHECKBUTTON

Post by Pablo César »

Roberto Lopez wrote:but I'm relly sick to be constantly 'bullied' over the years via various kinds of aggressions...
Why you felt bullied Roberto? From my side It's nothing personal. I make my arguments and I asked for your opinion... :oops:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: GetControlType in CHECKBUTTON

Post by Rathinagiri »

Pablo,

I think Roberto had explained to you rightly.

But you still hang on the same thing that is why he feels he is bullied. Any body will be.
Advanced users, digging in HMG internals, will find their way to (if required) differentiate both controls.
See his words. GetControlType, like Handle, ControlEvents are for advanced users who has some knowledge about C.

HMG is simple simply because it is a wrapper around the Win32API. An ordinary user needs not to go beyond HMG main functions.

Only when we need to write some tools (like yours) we need to go beyond HMG internals. If you make a small dig, you can differentiate things.

Even after going through the internals if you can't find the difference you might have come with the question where to find such difference.

GetProperty() is also a wrapper for HMG controls as you know. There also TYPE property is touching internal.

So, when the developer who had actually developed that code tries to explain something, please give your thought and effort on that.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply