05-23-2012 08:28 PM
Hello all-
I'm trying to work around the "Labview freezes when there is large data on the clipboard known issue" (http://forums.ni.com/t5/LabVIEW/Labview-freeze-when-accessing-a-custom-menu-with-data-on-the/m-p/200...) and one thought is to try to determine if Labview has focus, and if it does then clear the clipboard. If Labview doesn't have focus, then let the user use the clipboard. This would be a good work-around because it would let the users paste screen shots and such into notes files and wouldn't risk a nasty clipboard/ menu/ freeze-crash.
My initial search for determining windows application focus, came up empty though. This old thread (from 2005) pretty much covers it:
The "Is Frontmost' property does not do it. I need to determine if Labview has focus, as opposed to Windows, notepad, firefox, etc. I also reviewed the commad prompt commands and didn't find anything immediately helpful there either.
Any ideas?
Thanks,
Casey
Solved! Go to Solution.
05-24-2012 09:55 AM
Hi,
You could use the GetForegroundWindow Function from the user32.dll. More Information at msdn.
Christian
05-24-2012 06:14 PM
Christian-
That's perfect! By using GetForegroundWindow, GetWindowTextA and GetWindowFileNameA in user32.dll I can detect which window has focus. If Labview has focus then I programatically clear the clipboard so the user can still use it when not clicking on Labview windowns, but also we do not risk a freeze and crash because of the clipboard/ freeze bug.
I briefly thought about using the .NET versions of these functions, but because that would have forced an upgrade to at least .NET framework 3.0 for all of my user computers, I decided on the unmanaged user32.dll.
Thanks for the suggestion. I think I'm pretty close to a work around here that should last me until they fix the clipboard/ freeze bug.
Thanks,
Casey