Jump to content

Set Windows To Not Activate


Recommended Posts

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 by Neil Pate
Link to comment

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.

Link to comment

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.

 

Capture.PNG

Link to comment

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.

Link to comment

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.

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.