Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

KeyBoard Operations and Threads?

I am currently using LabWindows CVI 5.0.1 and I
want to create an application that utilizes one hand on the keyboard and one hand on the mouse. The mouse
will be used to move a cursor in a canvas graph, while the keyboard sends character commands to a text control.
I see some problems ahead. The CVI
documents say that the GetKey or KbHit functions only apply to stdio windows,... AND if I am using the mouse in one window, the focus will not be appropriate for
the text box. SO I am wondering if it is even possible to accomplish the task.

But maybe, if I purchase CVI 6.0-?!?!? I could in
principle use one thread to handle the mouse and canvas, while a second thread dealt with the textwindow. Am I thinking correctly?
0 Kudos
Message 1 of 3
(3,374 Views)
I'm not really sure what you are wanting to do as there are a few conflicting descriptions about where you are wanting text to be entered and what the purpose is for making an application like this, but I can give you some suggestions for the different topics you are asking about.

Since you can only give focus to one window at a time, a user of your app will only be able to send mouse and keyboard input to one window at a time in normal situations (Windows ties mouse and keyboard input to a single window that has focus at any one time). If you are talking about communicating between two different applications' windows you would have to actually program the application window that has focus at any given time to disperse the type of input you want to send to other application's windows when it is received via tcp/ip, DataSocket (which isn't supported in CVI 5.0, but is in 6.0, so that would be a good reason to upgrde), DDE, or ActiveX Automation. If you are talking about multiple windows in the same application, you can at any time update the contents of other panels in your app with functions like SetCtrlVal or SetCtrlAttribute making sure that you specify the correct panel to update, you would merely have to create a callback function for the panel that has the focus to intercept the keystrokes.

I don't believe there are any examples that cover your specific needs, but if you want to find out more about the inter-application communication methods I mentioned above, you can find very good references for this in the set of manuals that were shipped with CVI 5.01. Just look in the Master Index for the subject matter and it will point you to the proper reference and page number that covers it. If you want to view the most up-to-date manuals available for LW/CVI 6.0, you can view them online at the following page:

Link -> http://digital.ni.com/manuals.nsf/display?ReadForm&lookup=Measurement%20and%20Automation%20Software%3E%3EMeasurement%20Studio%3E%3ELabWindows/CVI&view=web_product_currentandold&node=132100_US

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 2 of 3
(3,374 Views)
Jason, Thanks for the reply - let me clairify my question. The application I wish to create, (a simple version), would have two items on one panel. One would be a canvas inside of which the user would move a cursor to insert/delete/modify graphic elements. Mouse
events would cause the events in the canvas - both cursor movement and clicks. The second item on the panel would be a text box indicator. I desire the keyboard to cause events which direct characters to the text box indicator, (and also be able to send the
characters elsewhere). My concern is that the canvas
will have focus - ,... Oh heck, I think I just realized
my misunderstnading.

Even though the canvas has focus - the canvas STILL responds to keyboard events. I have just never
tried that - until a moment ago. I can just send the keyboard text to the text box indicator.

Ah well thanks for being the "ear", required for me to figure this out!

Cheers

DraftsmanEE Dude
0 Kudos
Message 3 of 3
(3,374 Views)