LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bug in "ui to code converter"when used with menus with bitmap images (CVI 8.1.0 o XPpro)

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.
0 Kudos
Message 1 of 5
(4,094 Views)

I'm replying to my own posting...

I removed al the bitmaps in my menus, recreated the *.c and *.h file via the UI to Code Converter, built my project with those files (tracing the code execution via breakpoints to ensure that this new "BuildMEN1" was going to operate properly).

Guess what?  The problem I mentioned earlier went away (dataptr = NULL).

But I no longer have bitmaps in my menu unless I stick the menu into the panel via the UIR, and load the UIR directly.

So my feeling is that someone at NI needs to revisit the source code to the UI to Code Converter to fix this.

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.
0 Kudos
Message 2 of 5
(4,083 Views)
Thanks for reporting this, JB.  I am looking into this and will let you know what I find.
Cheers,

David Goldberg
National Instruments
Software R&D
Message 3 of 5
(4,042 Views)
JB,

I confirmed that this is a bug in the UI to Code Converter. A fix will be included in an upcoming maintenance release.

I am attaching a fixed uiconv.exe. If you replace <NI>\CVI81\bin\uiconv.exe with this executable (please backup your original first), it should solve your problem in the meantime.

Sorry for the inconvenience.

-alex
Message 4 of 5
(4,030 Views)
Works great now, thanks for the quick fix.
 
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.
0 Kudos
Message 5 of 5
(4,012 Views)