LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with ATTR_CTRL_MODE - don't work

Hello, I try to use the attribute ATTR_CTRL_MODE but each time, its has no effect.
In my GUI, I have 1 numeric and 1 String.
On a checkbox click I want to change the mode: Indicator -> Hot.

 

code sample :

void xxxxxxx

{

  GetCtrlVal(PanelHandle2, PANEL_2_CHECKBOX,&status);      
   if(status==0)
    {

    SetCtrlAttribute(PanelHandle2, PANEL_2_STRING,ATTR_CTRL_MODE ,VAL_HOT);
    SetCtrlAttribute(PanelHandle2, PANEL_2_NUMERIC_4,ATTR_CTRL_MODE ,VAL_HOT);

 

    }

 

else {

       SetCtrlAttribute(PanelHandle2, PANEL_2_STRING,ATTR_CTRL_MODE ,VAL_INDICATOR);

      SetCtrlAttribute(PanelHandle2, PANEL_2_NUMERIC,ATTR_CTRL_MODE ,VAL_INDICATOR);

    }

 

 

}

Is this correct? - In my case, it has no effect.

-----------------------

Thank you for your answers.

0 Kudos
Message 1 of 10
(3,190 Views)

The code looks correct so I would check the panel handle value to ensure you are pointing to the correct panel instance.

Beside this, what is puzzling me is why you haven't handled this event in the checkbox control callback: this same code could be ported inside the EVENT_COMMIT case of the control callback where it should work correctly. Where exactly is your function called?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 10
(3,182 Views)

I try in the checkbox control callback, i same problem.

Actually, my code is in a extern fonction.

 

//Fonction on event of number ctrl

int extern CONF_diplay()
{
int pnl=0, ctrl=0, itemIndex=0, ret_valid=0;   
quit=0;
    if ((PanelHandle2 = LoadPanel (0, "test.uir", PANEL_2)) < 0)
    {
        return -1;
    }
 
    //recup data
    Conf_RECUP_Data();
    DisplayPanel (PanelHandle2);
    
    //while close
    while (!quit)
    {             
    GetUserEvent (1, &pnl, &ctrl);
        
       /*
        //event list
        if (ctrl == PANEL_2_CHECKBOX)
        {                                  
          Conf_checkbox();
         }
          */
        //event Save
        if (ctrl == PANEL_2_COMMANDBUTTON_3)
        {                                  
           Conf_Enreg(SAVE_MODIF);    
        }
        
        //event valid
        if (ctrl == PANEL_2_COMMANDBUTTON_2)
        {                                  
              GetCtrlIndex (PanelHandle2, PANEL_2_LISTBOX, &itemIndex);  
              ret_valid=Conf_valid(itemIndex);
              if(ret_valid)
              {
              quit=1;       
              }
        } 
        //event Quit
        if (ctrl == PANEL_2_bt_fermer)
        {                                  
        quit=1;                           
        }                                  
    }
        DiscardPanel (PanelHandle2);    
        return 1;
}

 

extern void Conf_checkbox()

{

int status;
    int itemIndex;
    GetCtrlVal(PanelHandle2, PANEL_2_CHECKBOX,&status);     


    if(status==0)
    {
    SetCtrlAttribute(PanelHandle2, PANEL_2_STRING,ATTR_CTRL_MODE ,VAL_HOT);
    }
    else

    {
     SetCtrlAttribute(PanelHandle2, PANEL_2_STRING,ATTR_CTRL_MODE ,VAL_INDICATOR);
     SetCtrlVal(PanelHandle2, PANEL_2_CHECKBOX,1);
     }
}

 

 

in debugg - it fits well in the function - no problem but no effect.

if you have an example - give it to me and i will test it.

0 Kudos
Message 3 of 10
(3,156 Views)

I made a short example trying to replicate your situation but all works well, you can give it a try.

I see no reason for this strange behaviour, except for that 'extern' keyword: is this function executing into a separate library or dll? If so, is it calling RunUserInterface?

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 10
(3,141 Views)

Extern it's a error. there are not extern.

 

For make simple :

 

int CVICALLBACK checkbox (......)

{

int status;

GetCtrlVal(PanelHandle2, PANEL_2_CHECKBOX,&status);  

 

 if(status==0) SetCtrlAttribute(PanelHandle2, PANEL_2_STRING,ATTR_CTRL_MODE ,VAL_HOT);

else SetCtrlAttribute(PanelHandle2, PANEL_2_STRING,ATTR_CTRL_MODE ,VAL_INDICATOR); 

 

}

 

I tested your example and i not the same behavior.
See my screenshot .
img.png

0 Kudos
Message 5 of 10
(3,134 Views)

It seems to me that my example is well behaving: in each condition, the mode of the lower numeric and string depends on the status of the upper checkbox, isn't it right?

 

BTW in your callback do not forget to trap for EVENT_COMMIT event, otherwise the callback will be fired for all events, including mouse moves and so on consuming system resources



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 10
(3,132 Views)

I want , when i click in checkbox, i change the mode : indicator to hot / normal.
But this example dont run for me.
When i click, it change inc/dec.
Functionality ATTR_MODE_CTRL isn't correct.

0 Kudos
Message 7 of 10
(3,130 Views)

Switching between hot and indicator is what I'm doing! Inc/Dec arrows are not shown when in indicator mode, but this is not the only effect: if you test it you'll see you are no more able to change the number or write into the string control. Isn't it what you are looking for? 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 10
(3,123 Views)

indeed, I had not noticed that the principle works.

But I want the graphic aspest (grayed).

 

Otherwise, I do with Dimmed, but visually, Indicator, would be better.
I tried to have a better visual data program.

 

 

0 Kudos
Message 9 of 10
(3,117 Views)

Well, you have a few options to play with to obtain what you want:

- Operable / Indicator

- Active / Disabled

Now, a disabled object is grayed and is not operable, but users are accustomed to intend it as "feature not installed / not usable / not present" and tend to ignore them at all, while an indicator object is normally not grayed and not modifiable as well but is not dimmed. Inc/dec arrows are a visual reminder that the value can be modified but make sense only on numerics: you may want to hide them on a operable object but it would make no sense showing them on an indicator.

There are other ways to differentiate elements on the UI; just as an example I normally have indicators right aligned and operable objects left aligned: I do not know whether it is a "standard" but the important thing is that you maintain a consistent set of rules throughout the whole application.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 10 of 10
(3,109 Views)