473,322 Members | 1,538 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,322 software developers and data experts.

Getting the window/control that lost the focus

When processing the OnGotFocus event, I need to know the window/control that
lost the focus. Is there a way to determint this?

With MFC, you could use OnSetFocus which passed you the window that lost the
focus. It there something similar with a c# control.
May 15 '07 #1
1 2658
On Tue, 15 May 2007 14:37:01 -0700, ja***@nospam.com
<ja************@discussions.microsoft.comwrote:
When processing the OnGotFocus event, I need to know the window/control
that lost the focus. Is there a way to determint this?
Not sure...nothing explicit is in the GotFocus event args passed in, so it
doesn't look like it.

However, you could override the WndProc for your control, handling the
WM_SETFOCUS message. You get the window handle that lost the focus in
that message (in the wParam), and then can use the Control.FromHandle()
method to get the actual control.

Seems like an odd oversight for the GotFocus event, considering the
underlying window message provides the information you want, *and*
previous Windows API wrappers (eg MFC) provided that information too.

Pete
May 15 '07 #2

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

Similar topics

1
by: Barry Svee | last post by:
I'm struggling with the JavaScript blur event. I have an activex control that I need to interact with when a window loses focus, namely to instruct it to give up control of a barcode scanner so...
31
by: Benno Bös | last post by:
If I use the following construct in the frame "main" for a link to an extern site: <A HREF="http://www.any.xy" TARGET="extern"> the Browser is creating the window "extern", loading the page...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
4
by: Sameh Ahmed | last post by:
Hello there Is there a way to get the last control that was in focus before the current control? please note that I don't want the next or previous control in the tab order, I need the last one...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
0
by: Nick | last post by:
I have a situation wherein i have a text box, that has abc() being executed whenever the lost focus event is triggered. However, there is an exceptional case where, if a button click causes the...
6
by: Jack | last post by:
I have a main webpage that has a list of records, each with a link to a window.open function call. As an example, a page that opens is editrecord.aspx?RecordID=34, and another is...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi all! I have one combobox, two grids and nine textbox. All textbox are tab index one following another. When I press tab I go to the next textbox. How can I known if I click on another...
2
by: afromanam | last post by:
Hi I've been setting up a custom toolbar on start up for the application via VBA code. I've generated, for the custom menu bar, the drop-down menus File, Edit, Window and Help and successfully...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.