LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to correctly call modal vi function in dll from C

Solved!
Go to solution

I have a labview function which takes a string input and passes it to the output when the user clicks OK on a 2 button dialog. I have built this to a dll and am then calling the function from a C++ enviroment using the LoadLibrary function. If i define the front panel display settings to default and NOT modal the vi displays correctly but the dialog box does not. If i set the vi front panel to Modal then the vi front panel does not display correctly, therefor from this i conclude that the dialog must be modal in its display mode.

 

My question is from C++ how can i correctly call a dll which displays a Modal form? or how can i change the dialog to a modeless/default behaviour as can be done for the vi front panel?

 

Thanks in advance for any help.

0 Kudos
Message 1 of 11
(1,758 Views)

When you say it "does not display correctly", what does this mean? Is it warped? Is it only partially there? Is it there at all? If you are using the One Button Dialog or the Two Button Dialog functions those are modal dialog boxes. Have you tried using the Prompt User Express VIs?

0 Kudos
Message 2 of 11
(1,746 Views)
Solution
Accepted by DazW

Hi, Thanks for yor response.

The dialog box only partially displays. No i have not tried the express vi's, but i did create a vi to behave the same as a 2 button dialog

which allowed me to define it as modeless. This also only partially displayed.  I have since first posting also tried running the dll from teststand and also using labview to call the dll, in both cases the dll loads and behaves correctly, that the dialog box displays correctly.

This suggests that the problem is with the C++ code but not being a very experienced C++ programmer i am not sure how to debug the problem further.

Any help is greatfully appreciated.

0 Kudos
Message 3 of 11
(1,731 Views)

Can't say that I've ever seen the behaviour you're describing. Is it possible for you to upload the LabVIEW project and the C++ code? If the C++ code is part of a bigger project could you just extract the part that loads the LabVIEW DLL and calls the VI?

0 Kudos
Message 4 of 11
(1,726 Views)

I have added the source files for c++ in VS2010 and the labview vi.

 

 

Download All
0 Kudos
Message 5 of 11
(1,717 Views)

I can say that I'm seeing the same thing, but I don't think it has to do with C. I created a simple C# project to replicate the operation and it did the same thing. The Express VI has in its bowels calls to the One Button Dialog and Two Button Dialogs. Not sure what the exact issue is, though, but it appears that you can't have a LabVIEW VI inside a DLL to be modal.

0 Kudos
Message 6 of 11
(1,706 Views)

The other thing i tried was to hide the c++ application window just before calling the labview dll and then reshow it once the labview function is closed. This allows the dialog box to display correctly, but this is not an option for me in the full TestEngine. I have now created a vi to perform the function of the 2 button dialog and since that allows me to set the window type to modeless this also works.

It would be really good to know why it does not work with a Modal application though, perhaps one of NI's developers could have look?

 

Thanks for your help with this.

0 Kudos
Message 7 of 11
(1,703 Views)

Actually, I think I found the problem. In your build spec in the Advanced page there is an option called "Delay operating system messages in shared library". Uncheck this option. When you build the LabVIEW DLL the modals should appear. At least they did for me. Even if the top-level VI was set to modal, the Express VI was called properly. The underlying issue was that it appears as if the Paint message was never getting to the VI. 

Message 8 of 11
(1,693 Views)

That is great! Top marks to you Smiley Happy

 

Thanks very much for your help.

 

 

 

0 Kudos
Message 9 of 11
(1,689 Views)

Hi:

Could you please tell me which lib?

Boone

 

0 Kudos
Message 10 of 11
(1,685 Views)