05-31-2020 11:15 PM - edited 05-31-2020 11:19 PM
Hi guys,
I've been planning to modify Label text size using "for" loops. To check for the type of control, I'm using GetCtrlAttribute.I tried to run but it shows an error. "The Attribute passed is not valid"
Code:
GetPanelAttribute(panelHandle, ATTR_NUM_CTRLS, &i_num_of_controls);
for ( i = 2; i <= i_num_of_controls ; i++ )
{
// Transform the label attributes of the control.
if (GetCtrlAttribute (panelHandle, i, ATTR_LABEL_POINT_SIZE,&i_org_text_size) >= 0 )
{
f_new_text_size =ceil( (float) i_org_text_size * 0.8);
SetCtrlAttribute(panelHandle, i, ATTR_LABEL_POINT_SIZE, (int)f_new_text_size);
}
}
Error :
This error is prompted because, the control id passed into the GetCtrlAttribute, is not a "Label" control id.
I can bypass the error by manually check which control id is a Label control and put the id number as one of the if condition. This is not what I want to apply right now.
Question:
1. So, does anyone know, how can I check for Label control without having to check manually by getting the label's id from header file?
Thank you!
Solved! Go to Solution.
06-01-2020 05:41 AM
Try using GetCtrlAttribute() to read ATTR_CTRL_STYLE.
06-02-2020 11:41 PM
Thanks Sporty . It works wonders!
My solution is , I listed out the ALL styles for control type and then apply code for only selected control type's style.
Here is my sample code :
Feel free to point out anything that I can do to enhance my code 😄
Thank you!