Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Easily Create a .NET Menu (Horizontal or Vertical)

Overview
To demonstrate how to make toolbars and menu bars with a dedicated palette

Description:
LabVIEW lets you create toolbars and menu bars with a dedicated palette. Nevertheless, you can not do anything with the LabVIEW menu palette and can hardly customize it. Here's a tiny API that will enable you to create a .NET Menu bar.

Instructions:
To implement this example:

  1. Run VI

To execute this example:

  1. Install the required software.
  2. Open the VI and refer the Implement Steps


Requirements
Software
LabVIEW 2012 or compatible

Hardware
-

2017-11-03_10-45-16.jpg2017-11-03_10-41-55.jpg

**This document has been updated to meet the current required format for the NI Code Exchange.**

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

Comments
Member GriffinRU
Member

Very Nice,

Menu with Icons, excellent.

-Artur

Member maheshyt
Member

It would be more effective, if its possible to set the key board short cut keys to drop down items.

--mahesh y t

Member nshenoyk
Member

Hi, I see an issue with using this .NET control. If there is a Labview control below the "menu item" you are clicking in the .NET menustrip, Labview ignores the click on the .NET control and executes the MOUSE DOWN event on the Labview Control. Do you have any idea how to make this work. Procedure to replicate the issue:

1. Place a Labview Control just below the MENUSTRIP. (May be a Boolean Control)

2. Run the Example Program VI and click the Menu Item Just above the Boolean control that you placed.

3. You can see that it clicks the boolean control and not the menu strip. Sometimes, it does click on the menu item too.. Any workarounds for this?

Thank you!

Member GriffinRU
Member

Quick work arounds:

Move control or disable temporary, while operating .net menu

I haven't used this .net control, but overall my experience with .net controls in LabVIEW environment was that they always stay on top - i.e. ignore LabVIEW order (and even been re-drawn sometimes, while hidden), so that you always clicking on .net controls not LabVIEW controls.

-Artur

Active Participant J-M
Active Participant

Eric_M,

Are there a way to force the text to be interpreted as Unicode (in ToolStripMenuItem)?

ToolStripMenuItem.png

Regards,

Jean-Marc

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member GriffinRU
Member

Not sure, but check what you can do with "Font" property under ToolStripMenuItem. Setting GdiCharSet or FontName might be the ticket...

-Artur

Active Participant J-M
Active Participant

Unfortunately, this is not working (I already tried a Unicode font and GdiCharSet is a only read property).

  

The problem in my understanding (I could be wrong) is that LabVIEW is an ANSI software:

  

“ A window class is supported by a window procedure. Your application can register a window class by using either RegisterClassA or RegisterClassW. New applications should typically use RegisterClassW.

  

  If the application registers the window class using RegisterClassA, the function informs the operating system that the windows of the created class expect messages with text or character parameters to use a Windows (ANSI) code page character set.”

    

http://msdn.microsoft.com/en-us/library/windows/desktop/dd319108%28v=vs.85%29.aspx

  

I think that ToolSripMenuItem expects, in LabVIEW,  an ANSI string.

  

I just wonder if someone have an idea how to force ToolSripMenuItem to expect (in LabVIEW) an Unicode string.

  

JM

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member GriffinRU
Member

Font constructor allows you to set what you need.

I do not think that labview is the problem here, text value is unicode in .net.

Try it,

-Artur

Active Participant Eric.M
Active Participant

LabVIEW handles a char as a 8-bit data type (UTF-8 or Latin1). If you want to use "true" unicode that allows you to display any language like chinese or russian, the chars must be 16-bits capable. C# does handle chars as 16-bits so you can create a menu displaying russian, BUT all the strings must be hard-coded into an assembly built from Visual Studio. If you use the regular strings from LabVIEW to call .NET, the Component Language Runtime will just take your LV string so it will not work.

Sorry for the bad news :-/

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

Member GriffinRU
Member

I missed that "ToolStripMenuItem" accepts "text" as string only not a reference - thats a bummer...

-Artur