Current focused textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, how can I get the current control having the focus for the active window
and be able to SendMessage over so that I can display text on it, eg. display
a string in a textbox. What I want is essentially the same effect as
SendKey().

I am using the Rs232 class for .net from Microsoft where I need to get the
input from the COM port and display the value in the vb.net form. I tried
using SendKey() but it doesn't show the value on the form and the codes after
SendKey command in the function doesn't get runned.

Eugene
 
Hi,

Take a look at the forms activecontrol property.



http://msdn.microsoft.com/library/d...mscontainercontrolclassactivecontroltopic.asp



Ken

-----------------------------

Hi, how can I get the current control having the focus for the active window
and be able to SendMessage over so that I can display text on it, eg.
display
a string in a textbox. What I want is essentially the same effect as
SendKey().

I am using the Rs232 class for .net from Microsoft where I need to get the
input from the COM port and display the value in the vb.net form. I tried
using SendKey() but it doesn't show the value on the form and the codes
after
SendKey command in the function doesn't get runned.

Eugene
 
Hi Ken, glad for your help. With your example, consider I have multiple forms
shown in one application, how can I determine which form is currently active?
I see that the interface would set the IContainerControl.ActiveControl and
IContainerControl.ActivateControl, in this case, if the code just simply call
controlA.Focus = True, would I still be able to keep track of the control
having the focus?

Eugene
 
Eugene said:
With your example, consider I have multiple forms
shown in one application, how can I determine which form is currently
active?

You can use 'Form.ActiveForm' to get a reference to the active form.
 
Hi Herfried,

thanks. But it seems that the .ActiveForm can only get the form from the
application itself. When I set my Notepad as the active form, then an
exception happens. Anyhow that I can get the control in other application?
Since other application may not be developed in .net, would it be a problem?

Secondly, I want to put some text on the control having the focus, which I
can use .Text property if it were a textbox. But when it is not, eg Button,
then I would modified the button's caption (.Text). Anyhow I can do something
like SendKey on the control so it would simply change the text wrongly.
Remember that I have got problem with SendKey initially that causes me to
find alternative. I still can't figure out why SendKey is not working. Anyone
know in what condition SendKey would not work?

Eugene
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top