473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Current focused textbox

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
Nov 21 '05 #1
4 2821
Hi,

Take a look at the forms activecontrol property.

http://msdn.microsoft.com/library/de...ntroltopic.asp

Ken

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

"Eugene" <Eu****@discussions.microsoft.com> wrote in message
news:DB**********************************@microsof t.com...
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
Nov 21 '05 #2
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

"Ken Tucker [MVP]" wrote:
Hi,

Take a look at the forms activecontrol property.

http://msdn.microsoft.com/library/de...ntroltopic.asp

Ken

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

"Eugene" <Eu****@discussions.microsoft.com> wrote in message
news:DB**********************************@microsof t.com...
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

Nov 21 '05 #3
"Eugene" <Eu****@discussions.microsoft.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
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

"Herfried K. Wagner [MVP]" wrote:
"Eugene" <Eu****@discussions.microsoft.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
41
by: Mountain Bikn' Guy | last post by:
What is the current preferred way to save user preferences in dotnet? Is the registry the right place to do this? Can anyone recommend a good article (or book) for this topic? Thanks.
3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
3
by: Lal - Luxor | last post by:
dear all, one of my form have 3 text boxes and 1 button i want to trap my cursor on which text box please help me regards with thanks lal
2
by: Anders | last post by:
Hi Im trying to develop a C# application which interacts with a Fingerprint scanner. The appliaction is going to run in the background (and as trayicon). When my applicatons catches an...
2
by: panwala_bhavesh | last post by:
Thanks in advance... I have a form displaying the results of a query in a continuous form style. I want to be able to double-click on the key field of the form (a textbox, in this case a AssetID)...
3
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
1
by: CHNLAKSHMI | last post by:
There are two textboxes and a button. If we click the button,the text must be entered into focused textbox
0
by: Gilgul | last post by:
Hi i am trying to find the handle of the current focused control in all the running application. I tried GETFOCUS() but it gave the the handle only of the current thread There are 2 options of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.