Neil Pate Posted July 11, 2017 Report Share Posted July 11, 2017 (edited) Hi All, I am trying to make an on-screen keyboard (OSK). I have previously created a nice one that works perfectly if you can feed in the reference of the control that has focus. However I cannot seem to reliably get a unique control reference for several circumstances (e.g. an element of cluster that is inside an array). So I decided to try and make my own, in the spirit of the code of this open source project: https://sourceforge.net/projects/numpad-emulator/files/latest/download?source=typ_redirect The crux of my current problem is that whenever I click on one of my buttons of the OSK the focus is brought to the new window, and therefore I cannot direct the text into the control that previously had focus. I believe the way to solve this is to use the WinAPI to set the Extended Window Style of my OSK to be WS_EX_NOACTIVATE. According to MSDN "this style allows a top-level window created with this style to not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window". This is the technique used by the Numpad application I have linked to earlier and works perfectly. Attached is my attempt. The hex style 0x8000108 is what Numpad uses for the window style. I can successfully control this application from my LabVIEW test to turn on or off the NOACTIVATE by setting or resetting the greater "8" bit in the config. This just does not work for my LabVIEW window though. Any ideas? Num Keypad.vi Edited July 11, 2017 by Neil Pate Quote Link to comment
hooovahh Posted July 11, 2017 Report Share Posted July 11, 2017 I looked at my code for setting extended style and it is the same as yours (other than mine runs in any thread which I think is a bug). And it sounds like the call is functioning properly for other windows. So this makes me think this is something specific to LabVIEW and how multiple window management is done. Here might be a useful test. Can you built a separate LabVIEW EXE that is your OSK and have it work properly on LabVIEW.exe or other build applications? I suspect this will work but don't know why it wouldn't work from within LabVIEW and the same application instance. I'm guessing this is just one of those instances where LabVIEW and NI are doing something non standard that is breaking normal functionality. Quote Link to comment
Neil Pate Posted July 11, 2017 Author Report Share Posted July 11, 2017 (edited) Yeah, I suspected the same thing so I tried building an exe. It behaved the same as in the IDE. I am going to try this. Edited July 11, 2017 by Neil Pate Quote Link to comment
Neil Pate Posted July 11, 2017 Author Report Share Posted July 11, 2017 Strangely it seems there are two "somethings" for my LabVIEW executable (a LVDChild and a LVFrame class). Unfortunately this WinExplorer software does not seem to have support for the WS_EX_NOACTIVATE style. I suspect LabVIEW is doing a lot of its own window management behind the scenes. Bah humbug. Quote Link to comment
hooovahh Posted July 11, 2017 Report Share Posted July 11, 2017 Man I love sysinternals. One suggestion I was going to say was you could try looking into parent child window relationships, and then set the whole parent window to be non active. But in typing this I realize this wouldn't work because in a normal window relationship the desktop is the parent, and so I'm guessing you would have the same problem. I'm not sure there is much you can do for this one. Maybe someone at NI will have a suggestion. Quote Link to comment
Neil Pate Posted July 11, 2017 Author Report Share Posted July 11, 2017 Actually this WinExplorer application is not part of the SysInternals Suite (which yes does rock without doubt). I was just poking around now in the SysInternals Suite to see if they have something similar but cannot find one. Quote Link to comment
Thoric Posted July 11, 2017 Report Share Posted July 11, 2017 According to this it's not possible due to the complex manner in which LabVIEW owns and manages it's own FP windows 1 Quote Link to comment
Neil Pate Posted July 12, 2017 Author Report Share Posted July 12, 2017 Thanks Thoric, I did quite a bit of googling but that forum link did not come up. Guess I will have to live with a non-LabVIEW solution (for now). Quote Link to comment
Thoric Posted July 12, 2017 Report Share Posted July 12, 2017 Neil - Random thought. If you build your LabVIEW numeric keypad into a DLL and call it with the CLFN, maybe then it will exist in Windows separate from the LabVIEW windows and can be self-manipulated to be NonActive? Wouldn't take long to trial, possibly worth a shot. 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.