Guenther Posted February 7, 2007 Report Share Posted February 7, 2007 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 Quote Link to comment
Rolf Kalbermatter Posted February 7, 2007 Report Share Posted February 7, 2007 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 Quote Link to comment
Guenther Posted February 8, 2007 Author Report Share Posted February 8, 2007 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 Quote Link to comment
Mikkel Posted February 8, 2007 Report Share Posted February 8, 2007 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 Quote Link to comment
Rolf Kalbermatter Posted February 8, 2007 Report Share Posted February 8, 2007 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 Quote Link to comment
Guenther Posted February 8, 2007 Author Report Share Posted February 8, 2007 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 Quote Link to comment
Mark Smith Posted February 8, 2007 Report Share Posted February 8, 2007 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 Quote Link to comment
thomas2609 Posted January 22, 2008 Report Share Posted January 22, 2008 i did a file dialog, some time ago, with active-X, see http://forums.lavag.org/reading-multiple-f...7519#entry27519 also tried it with .net but hade the same problems with dialog not on top. but since i upgradet to LV version 8.0.1 i don't see any need to programm a file dialog on my own. instead i perefere the built in file dialog. Quote Link to comment
ahlers01 Posted January 23, 2008 Report Share Posted January 23, 2008 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: the subVI code is this: Interestingly this does not work when the 'Move window to top' call is in the subVI... -Franz Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.