Jump to content

.net file dialog


Recommended Posts

Hi guys,

I'm playing around with the .net file dialog, which I found in this thread. It works great, offers all the options I need for my project, BUT:

the dialog window does not appear on top of all other windows. I have to minimize my ther LV windows to dig my way thru to it.

I tried the show dialog method with the owner option and passed on the front panel and panes refnum (all typecasted), but no effect.

Any ideas how to solve this problem?

Thanks

Guenther

Link to post
Hi guys,

I'm playing around with the .net file dialog, which I found in this thread. It works great, offers all the options I need for my project, BUT:

the dialog window does not appear on top of all other windows. I have to minimize my ther LV windows to dig my way thru to it.

I tried the show dialog method with the owner option and passed on the front panel and panes refnum (all typecasted), but no effect.

Any ideas how to solve this problem?

Thanks

Guenther

LabVIEWs refnum is not a Windows window handle. To retrieve the actual host window pointer/handle/etc (works on all platforms) you can use the private Application property Application.ParentWindowForDialogs. Refer to the scripting forum about how to get those private properties visible. But it is a good idea to disable them afterwards again, since the property and method pull down menus get really huge with them.

Rolf Kalbermatter

Link to post

Hi Rolf,

only half a success. For some reason the property Application.ParentWindowForDialogs always returns zero.

The effect on my program is that when running the VI the first time, the file dialog window ist on top, like it should. But running the VI the second time, the file dialog window is again buried underneath all LV windows.

Any ideas what is wrong here?

Thanks,

Guenther

Link to post
Hi Rolf,

only half a success. For some reason the property Application.ParentWindowForDialogs always returns zero.

The effect on my program is that when running the VI the first time, the file dialog window ist on top, like it should. But running the VI the second time, the file dialog window is again buried underneath all LV windows.

Any ideas what is wrong here?

Thanks,

Guenther

I don't know what you are doing wrong, but I have attached a VI that finds the callers window handle the ugly way :)

Download File:post-5175-1170935219.vi

-Mikkel

Link to post
Hi Rolf,

only half a success. For some reason the property Application.ParentWindowForDialogs always returns zero.

The effect on my program is that when running the VI the first time, the file dialog window ist on top, like it should. But running the VI the second time, the file dialog window is again buried underneath all LV windows.

Any ideas what is wrong here?

Hmm, you are right that property always returns 0. However defining 0 for the parent window for a dialog should make the dialog system modal. Hmm, hmmm???

Rolf Kalbermatter

Link to post
I don't know what you are doing wrong, but I have attached a VI that finds the callers window handle the ugly way :)

Download File:post-5175-1170935219.vi

-Mikkel

Hmm, your VI does pass a non-zero refnum, but also no effect on the position of the file dialog window.

I'm attaching my VI, replacing the App.ParWinforDlgs property node with Mikkel's VI doesn't change anything. Maybe the mistake is at some other place?

Thanks

Guenther

Download File:post-3733-1170936325.vi

Link to post
Hmm, your VI does pass a non-zero refnum, but also no effect on the position of the file dialog window.

I'm attaching my VI, replacing the App.ParWinforDlgs property node with Mikkel's VI doesn't change anything. Maybe the mistake is at some other place?

Thanks

Guenther

Download File:post-3733-1170936325.vi

I remember this same dilemma - my fix was to write a simple .NET DLL that encapsulates the call into user32.dll to get the window handle and then implement the IWin32Window interface to wrap the handle and then hand the ShowDialog the wrapped handle internal to the DLL instead of as part of the ShowDialog call from LabVIEW - might seem kind of clunky and it requires a DLL, but it works. It seems you could do the work of wrapping the handle in LV w/.NET calls after you use Mikkel's vi if there's a way to implement a .NET interface from LV - anybody know? Then you could avoid carrying around the extra DLL. But, more than once, I've found the best way to use the .NET namespace from LV is to write wrappers that expose exactly the functionality you need since the .NET syntax is optimized for C# or C++/CLI and not for LV. Example attached (LV7.1)

Download File:post-1322-1170966265.zip

Link to post
  • 11 months later...

I also thought about using the .NET file dialog since I want to include a file preview thumbnail within the dialog (something which is not possible with LV's built-in dialog, AFAIK).

I found this thread as a starting point for using .NET and of course was stuck then by the 'dialog not on top' problem.

There is a workaround though. (I couldn't get the other workaround offered in this thread to work)

By using a WinAPI call ('Move Window to top.vi' from lvwutil32.llb) the dialog can be brought to top:

post-833-1200994212.png?width=400

the subVI code is this:

post-833-1200994039.png?width=400

Interestingly this does not work when the 'Move window to top' call is in the subVI...

-Franz

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.