Hello, I have a GUI built using the menu bar from the "tooldemo.prj" project from the CVI "samples" folder as a starting point, because I wanted to use a formal menu bar with a toolbar, and have the icons match. When I started to use the "UI to Code Converter" tool with his menu bar, I immediately found what I think might be a bug.
I named my menu bar with the constant "MEN1" (because someday I will add a MEN2, etc.). The resulting code for the "BuildMEN1" function that this converter tool creates is excerpted and given below:
//----------------------------------------------------------------------------------------------------
// BuildMEN1 (): Build UI object MEN1; return handle or standard UI error code.
//----------------------------------------------------------------------------------------------------
int BuildMEN1 (int hParentPanel)
{
int hMenubar;
int error = 0;
int bitmapId = 0; // needed if there are bitmaps
char *dataPtr = NULL;
// Create the menubar
errChk(hMenubar = NewMenuBar (hParentPanel));
errChk(SetMenuBarAttribute (hMenubar, 0, ATTR_CONSTANT_NAME, "MEN1"));
errChk(SetMenuBarAttribute (hMenubar, 0, ATTR_MENU_BAR_FONT, VAL_MENU_META_FONT));
errChk(SetMenuBarAttribute (hMenubar, 0, ATTR_MENU_BAR_ITALIC, 0));
errChk(SetMenuBarAttribute (hMenubar, 0, ATTR_MENU_BAR_UNDERLINE, 0));
errChk(SetMenuBarAttribute (hMenubar, 0, ATTR_MENU_BAR_STRIKEOUT, 0));
errChk(SetMenuBarAttribute (hMenubar, 0, ATTR_MENU_BAR_POINT_SIZE, 11));
errChk(SetMenuBarAttribute (hMenubar, 0, ATTR_MENU_BAR_BOLD, 0));
// Build menu: MEN1_FILEMENU
errChk(MEN1_FILEMENU = NewMenu (hMenubar, "__File", -1));
errChk(SetMenuBarAttribute (hMenubar, MEN1_FILEMENU, ATTR_CONSTANT_NAME, "FILEMENU"));
// errChk(SetMenuBarAttribute (hMenubar, MEN1_FILEMENU, ATTR_DIMMED, 0));
// errChk(SetMenuBarAttribute (hMenubar, MEN1_FILEMENU, ATTR_CALLBACK_FUNCTION_POINTER, NULL));
// Create item: NEWITEM (MenuBar001_Menu001_Item001)
dataPtr =
"!!!!!%!!\"\"-#!%!!!!C!!!%Y!!!%!!!!!!!!!1!1!!A!!!!!0!``Q`!!1/D!!!!!3/(!I!!!1/*!!!"
"!!K!!!%!/'````%!/*!!!!+!!!B!!/0'``Q`!!!!!!````%!/(!!!!+!!!B!!/0'``R`!/!*!!#!!!I!"
"!!4/*`]``!1/'!!!!!K!!!%!/*````%!/'!!!!+!!!B!!/0*``R`!/!'!!#!!!I!!!4/*`]``!1/'!!!"
"!!K!!!%!/*````%!/'!!!!+!!!B!!/0*``R`!/!'!!#!!!I!!!4/*`]``!1/'!!!!!K!!!%!/*````%!"
"
/D!!!!!!!!!!!@TA@Q-@Y@T]@]-@]@T]@]-@]@T]@]-@]@Q]!!";
errChk(GetUserBitmapFromText (dataPtr, 102, &bitmapId));
if (bitmapId)
{
errChk(SetMenuBarAttribute (hMenubar, MEN1_FILEMENU_NEWITEM, ATTR_ITEM_BITMAP, bitmapId));
errChk(DiscardBitmap (bitmapId));
bitmapId = 0;
}
errChk(MEN1_FILEMENU_NEWITEM = NewMenuItem (hMenubar, MEN1_FILEMENU, "__New", -1, VAL_MENUKEY_MODIFIER | 'n', FileNewMCB, 0));
-----------------------------------------------------------------------------------------------
I snipped off the rest of this auto-created function at this point, since the problem I see at run-time when it breaks on the library error at SetMenuBarAttribute seems to be either:
A.) that "bitmapId" is negative after I execute the "GetUserBitmapFromText, or...
B.) the constant "MEN1_FILEMENU_NEWITEM" is not yet defined by the time that "SetMenuBarAttribute" is invoked, or...
C.) all of the above
The constant "MEN1_FILEMENU_NEWITEM" is zero value when it breaks. It seems like it would eventually get its a value at the line that comes later (when it does a "NewMenuItem"). But it never gets there because the errChk macro at this break forces it to jump to out with a return -46, which means "the attribute passed is not valid" (non-fatal). I do a "Go to Defiinition" on ATTR_ITEM_BITMAP and I can see it has a value of 1992, so it must be the other arguments to that function that make it kick out the error.
It isn't imperative that I use this ui to code converter, so I can work around this by simply using the UIR file as usual.
But I thought I'd pass this discovery on to the CVI power-users and developers, mainly beause I'd like to know if I'm goofing up Big-Time.
JB
--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.