Jump to content

Activating a Window Without Focus


Recommended Posts

Hello,

I'm using LabVIEW 8.6, I would like to give an unusual behavior to a subVI window when opened: I'd like the window to be activated without giving focus to it. What I mean, is that I would like the window to be able to catch even on the front panel like keystroke or mouse click without giving focus to this window. I'd like the focus to stay on another window.

A good example of what I want to do is the microsoft visual keyboard installed with Windows: when the visual keyboard in open you can press any button without giving focus to the window. I'd like to reproduce the same behaviour with a labview window.

I don't think it's possible with properties or invoke node, I think there might be something to do with the use of user32.dll. If anyone as already done that, or knows how to do it, it would be great.

Thanks for helping.

Clément

DAM

Link to comment

QUOTE (asbo @ May 11 2009, 04:35 PM)

You should mention that you're cross-posting: http://forums.ni.com/ni/board/message?boar...ssage.id=407852

You can accomplish this without having to mess with any APIs or registering for events like Ton mentioned in the opposing thread; check out the Input Device Control palette. All you need is Initialize Keyboard, Acquire Input Data, and Close Input Device.

Hi asbo,

Thanks for your answer, but i'm not sure you understood what I want to achieve.

I know about the input Device Control VI's, those allow me to catch key pressed on the keyboard or mouse, but it's not what I want to do.

What I want to do is to be able to click on a LabVIEW window without giving focus to this window.

I'll give you more details:

I developped a virtual keyboard to be used on touch screens, so the user won't have a real keyboard. When you press the screen, it's like the pc receiving a mouse click. Now what I want to be able to do is for example on a main application with a graph, the user could change the scaling by a click on the minimum or maximum scale and then using the virtual keyboard entering the new values, or if you want to click on a numeric control to enter a new value.

The problem is that you can give focus to a control or the graph scales, but when you press any of the button of the virtual keyboard which is another window from my main vi I loose the focus to my control and it's given to keyboard window.

What I want to reproduce is exactly the behavior of the microsoft visual keyboard, it doesn't take focus when you press any key on it.

If you can help, I would really appreciate.

Thanks

Clément

Link to comment

QUOTE (Bruno Costa @ May 12 2009, 10:48 PM)

Hi,

If you are using MS Windows you can do this. You must make 2 Windows API Calls

First, you will get the handle of the window with the function FindWindow

And after, you call the function SetWindowPos with thew option TopMost

See on MSDN for the parameters of functions

Hi Bruno,

Thanks for your answer, unfortunatly the method you proposed is not working for me: bringing my window to the top position doesn't mean is not taking focus when you click on this one. I tried to play with the parameters of the SetWindowsPos, but none of them is giving me the behavior I want to have.

Thanks anyway for your help.

Clément

Link to comment

QUOTE (Bruno Costa @ May 12 2009, 05:48 PM)

If you are using MS Windows you can do this. You must make 2 Windows API Calls... First, you will get the handle of the window with the function FindWindow... And after, you call the function SetWindowPos with thew option TopMost

Right - try this.

Link to comment

QUOTE (crelf @ May 13 2009, 05:47 PM)

Right - try this.

Hi crelf,

Thanks for the example, but I've already tried with the method, but bringing the window to the topmost position is not all I want to do.

My main problem is to be able to click on the window and press control on this one without giving focus to this window.

The topmost position is not working for that, you can still give focus to the window with a mouse click on it.

Thanks anyway for trying to help, I you have other idea you are welcome.

Have a great day.

Clément

Link to comment

QUOTE (clementgirod @ May 11 2009, 12:23 PM)

Hello,

I'm using LabVIEW 8.6, I would like to give an unusual behavior to a subVI window when opened: I'd like the window to be activated without giving focus to it. What I mean, is that I would like the window to be able to catch even on the front panel like keystroke or mouse click without giving focus to this window. I'd like the focus to stay on another window.

A good example of what I want to do is the microsoft visual keyboard installed with Windows: when the visual keyboard in open you can press any button without giving focus to the window. I'd like to reproduce the same behaviour with a labview window.

I don't think it's possible with properties or invoke node, I think there might be something to do with the use of user32.dll. If anyone as already done that, or knows how to do it, it would be great.

Thanks for helping.

Clément

DAM

Hi,

You must be able to handle windows messages,

Whe a window is inactive and you click inside it, the OS sends to the window the message WM_MOUSEACTIVATE and the window

must reply this message with MA_ACTIVATE, MA_NOACTIVATE or MA_ACTIVATEANDDEAT.

In your case you must use MA_NOACTIVATE.

I dont know how to disable alt+tab too.

Bruno.

Link to comment

QUOTE (Bruno Costa @ May 18 2009, 01:21 PM)

Hi,

You must be able to handle windows messages,

Whe a window is inactive and you click inside it, the OS sends to the window the message WM_MOUSEACTIVATE and the window

must reply this message with MA_ACTIVATE, MA_NOACTIVATE or MA_ACTIVATEANDDEAT.

In your case you must use MA_NOACTIVATE.

I dont know how to disable alt+tab too.

Bruno.

Hi Bruno,

That's true, you can receive the OS messages from LabVIEW? I found a librairy (Windows Message Queue.llb) on NI web site which allows to catch them. The llb uses a dll, since I don't think it's possible to do the operation directly from LabVIEW. Unfortunatly, the messages are caught at the same time the window catch them so you cannot disable them. Also you cannot write back messages with this librairy.

It seems that LV is too high level to handle such low level functions...

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
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.