LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

FileSelectPopup window on wrong monitor

Hello all,
 
My application is used for display testing and calibration purposes. On the PC where my application is running, the second DVI output is attached to the display to be tested. The second display is driven by enabeling the "Extend my Windows desktop onto this monitor" option in the Display Properties window.
Problem: at some systems, popup windows, like a FileSelectPopup window appear on the second monitor. Since this display is not always visible to the operator, it looks like the application hangs and has to be terminated the hard way (Ctrl-Alt-Del).
 
How can I make sure that popup windows ALWAYS appear on the monitor where my application is running?
 
Thanks,
Wim
0 Kudos
Message 1 of 12
(4,279 Views)
First, make sure the program is running on the correct monitor: call
GetMonitorFromPanel on your main panel, and move it around if it's not on
the right one. Then when you open a popup it should display on the same one,
or at least that's what I'd expect.
--
Guillaume Dargaud
http://www.gdargaud.net/


Message 2 of 12
(4,276 Views)

Check out the help for ATTR_DEFAULT_MONITOR in SetSystemAttribute.

- jared

Message 3 of 12
(4,252 Views)

Thanks for the tip, guys. I implemented this piece of code both in the main function and in the panel's callback function, when event is equal to EVENT_PANEL_MOVE:

   GetMonitorFromPanel (pnlMain, &monitor);
   SetSystemAttribute (ATTR_DEFAULT_MONITOR, monitor);

Now let's see if this solves the problem...

0 Kudos
Message 4 of 12
(4,209 Views)

I am having a similar issue.  I am using a system with 4 monitors and I need to make popups display on the monitor containing the program's main panel.

 

I tried adding Wim's code to the EVENT_PANEL_MOVE event in my main panel callback function.  The result is that most popups (such as ConfirmPopup, PromptPopup, GenericMessagePopup, XGraphPopup) display in the correct monitor, but FileSelectPopup, DirSelectPopup, and MultiFileSelectPopup always display in the monitor where the main panel first appeared.  The LabWindows help documentation for these popup types does not indicate that this behavior is intended.

 

I am using LabWindows 2010 on Windows 7 Ultimate.

 

Rich

0 Kudos
Message 5 of 12
(3,663 Views)

Rich, 

 

I'm not entirely sure what your current problem is, so I'll explain the current behavior in 2010 and earlier, and then hopefully give you some tips. In 2010 and earlier when you launch a FileSelectPopup the location and current monitor of the dialog is stored in the registry by Windows. Windows handles this positioning for a certain number of recently launched applications. As long as that information is stored in the registry the file/directory popups will appear in the last location and monitor that you dragged them to, regardless of what monitor is actually launching them. This seems to be the problem you're running into. Unfortunately CVI has no control over where this dialog will appear as it's a dialog that Windows owns.

 

If you've tried the CVI 2012 beta you'd have seen that the behavior has changed. Now what happens is that when File/Directory Popups are launched they will always appear on the monitor of the panel that launched them. If you drag the popup to a new location, Windows will remember that location and continue to display the popup in that location, so long as the dialog is always launched from the same panel and that panel has not moved. If you move the panel which is calling the popup, then the next time the popup is displayed it will appear on the monitor of the panel that launched it. This should fix the issue you are having.

 

Unfortunately there's no good workaround for this in CVI 2010 or earlier because CVI doesn't technically "own" those dialogs. I looked into whether you could just delete the settings from the registry, but Windows doesn't make that easy.  Those values are stored on my machine under:

[HKEY_USERS\S-1-5-21-4170831575-233351449-3708798867-15220\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{CEBFF5CD-ACE2-4F4F-9178-9926F41749EA}\Count]

Every individual process name has it's own entry so theoretically, you could search for the name of your executable and delete that key, but it seems that Windows scrambles the names using a ROT13. My guess is that they're doing this so that users don't edit these entries themselves, and bad things might occur if you try.

 

I'm sorry we don't have a better solution for you currently, but at least the problem has already been fixed going forward.

Kevin B.
Message 6 of 12
(3,643 Views)

Kevin,

 

What I'm trying to do is get popup windows for different programs to display on different monitors in our system. I'll try to clarify.

 

Our system has four monitors.  We have a control program called the PLATE that runs on the default monitor (monitor #1).  This control program launches several test tool programs, each of which runs in its own monitor.  I'll call them test tool A in monitor #2, B in monitor #3, and C in monitor #4.  We would like to have each program show all of its popup windows in its own monitor.  So when the control program calls MessagePopup or FileSelectPopup, we want the popup window to display in monitor #1; when Tool A calls a popup routine, we want it to display in monitor #2, and similarly for the other tools.

 

Here's what I'm seeing instead with Wim's code: the control program shows all its popups in monitor #1, which is what we want.  Tool A shows message popups, graph popups, and the like in monitor #2, which is what we want, but it shows file and directory selection popups in monitor #1.  The other test tools behave the same way.

 

I understand your response to mean that the file and directory selection popups work differently because they are controlled by the Windows OS while the message popups are controlled by LabWindows.  Is there any way to change the way Windows handles these popups?

 

Rich

0 Kudos
Message 7 of 12
(3,631 Views)

Rich,

 

Outside of the really ugly hack of tracking down and deleting the registry key before each call to FileSelectPopup I mentioned earlier, there's really no way to change how Windows handles these popups. When CVI 2012 releases this shouldn't be an issue for you anymore, but until then there's nothing we can do about it.

Kevin B.
0 Kudos
Message 8 of 12
(3,624 Views)

Is there someplace I can download the CVI 2012 beta?

0 Kudos
Message 9 of 12
(3,619 Views)

If you go to ni.com/beta you can register and download CVI 2012.

 

There is one thing to be aware of though. I updated the code which displays the File Dialogs after the beta went live, so the behavior you see in the beta might not be exactly what you'd see when 2012 releases. If you don't see the behavior you're expecting when running your program in the beta, try converting your Dir/FileSelectPopup function calls to the Ex versions (i.e. FileSelectPopupEx). I think those will definitely work the way you want, but I can't remember exactly what the behavior of the non Ex FileSelect functions was at the time the beta released.

Kevin B.
0 Kudos
Message 10 of 12
(3,616 Views)