LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Menu bar with item propertie checked

Solved!
Go to solution

I have an item in the menu with the properties checked activated. I do not manage to have the properties of checked. Do I have to use GetCtrlVal and SetCtrlVal to get and set the propertie checked ? At each time the user click on this menu entry, I would like to change the status of checked/not checked.

 

See the attached file.

 

Thanks for the support.

0 Kudos
Message 1 of 10
(4,263 Views)

Hi,

 

1) in the UI editor you set the initial attributes, i.e. when the program starts up your menu item will be checked.

 

2) If you want to change an attribute (dimmed, checked,...) at run time, you can use the function

SetMenuBarAttribute ( menu_bar_handle, menu_item_id, ATTR_CHECKED, 0 (or 1) );


Note that you are a setting an attribute (hence the name Set...Attribute), not a value; also you want to address a menu (hence the name SetMenuBarAttribute) and not a UI control Smiley Wink

0 Kudos
Message 2 of 10
(4,261 Views)

... and if you want to change the attribute every time a user clicks on this menu entry, you will need to use a menu callback such as

 

void CVICALLBACK EnableFMCLogFileMenuBar ( int menuBar, int menuItem, void *callbackData, int panel )

{
    fmc_log = !fmc_log;

    SetMenuBarAttribute ( menuBar, menuItem, ATTR_CHECKED, fmc_log );

    return;
}

Message 3 of 10
(4,258 Views)

Ok, I want to use GetMenuBarAttribute to get the status : here is my code

 

void CVICALLBACK EnableFMCLogFileMenuBar (int menuBar, int menuItem, void *callbackData,int panel)
{

int Value;

Value = GetMenuBarAttribute(menuBar, menuItem, MAIN_M_BAR_FMCLOG_LOG_FMC, &Value);

 

At execution, I have the following error message : "The attribute passed is not valid"

 

I dot not know what use for attribute instead of MAIN_M_BAR_FMCLOG_LOG_FMC

0 Kudos
Message 4 of 10
(4,255 Views)

Obviously, your function call is wrong as it does not contain a valid attribute....


@sfla wrote:

 

Value = GetMenuBarAttribute(menuBar, menuItem, MAIN_M_BAR_FMCLOG_LOG_FMC, &Value);

 

At execution, I have the following error message : "The attribute passed is not valid" 


Your MAIN_M_BAR_FMCLOG_LOG_FMC is not an attribute but probably your menuItem...A valid attribute, for example, is ATTR_CHECKED, so the function call should look like:

GetMenuBarAttribute ( menuBar, menuItem, ATTR_CHECKED, &Value );

0 Kudos
Message 5 of 10
(4,246 Views)

I have tried, but I have always Value = 0 (whatever the initial configuration checked or not)...

0 Kudos
Message 6 of 10
(4,244 Views)

That's because of a second mistake: you assign Value twice...as attribute, and as status:

 

Value = GetMenuBarAttribute ( menuBar, menuItem, ATTR_CHECKED, &Value );

 

so in this case Value = 0 means that the function returned without error (at the price that you overwrote your attribute value) Smiley Wink

 

So change it so something like:

 

status = GetMenuBarAttribute ( menuBar, menuItem, ATTR_CHECKED, &Value );

 

 

0 Kudos
Message 7 of 10
(4,239 Views)

Hi,

 

I am wondering if your question got resolved. If so, you could mark one of my answer as the solution, thanks.

0 Kudos
Message 8 of 10
(4,228 Views)
Solution
Accepted by topic author sfla

Ok, I was on vacation. It works now ! Thanks a lot for your help !

0 Kudos
Message 9 of 10
(4,226 Views)

You're welcome - but as a side note, you should have marked the post that solved your problem, not your own thank you Smiley Wink

Message 10 of 10
(4,223 Views)