Page 1 of 3
GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 12:08 am
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)

:
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 (14.36 KiB) Viewed 6504 times
I've checked at C:\hmg.3.4.3\SOURCE\h_checkbox.prg and _DefineCheckButton function is declared IMO wrongly as "CHECKBOX"
Ths same occurs at HMG Extended. Please note Mr. Filatov
Re: GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 12:16 am
by srvet_claudio
I will check
GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 12:23 am
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...

GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 11:13 am
by Pablo César
Images and codes proves that is wrong control type for CheckButtons (for long time...

)

- Screen19.png (18.49 KiB) Viewed 6465 times
MsgInfo("Control type: "+GetControlType("CheckButton_1","Form_1"),(This.Name)) => "CHECKBOX"

- Screen20.png (23.74 KiB) Viewed 6462 times
Re: GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 11:50 am
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 
GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 1:23 pm
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.

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.
Re: GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 1:48 pm
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...
Re: GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 2:00 pm
by srvet_claudio
Roberto Lopez wrote:
Please, don't fix something that is not broken 
OK, no problem.
GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 2:01 pm
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...

Re: GetControlType in CHECKBUTTON
Posted: Wed Oct 19, 2016 3:07 pm
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.