473,569 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form focuse

Why I can't catch the Form lost focuse event ?
I mad a FORM , I want to print message each time I moved to another
application my my desktop .
I thryed the following but not work .

this.LostFocus += new System.EventHan dler(this.Form1 _LostFocuse);

private void Form1_LostFocus e(object sender, System.EventArg s e)
{
MessageBox.Show ("Write ");
}
Nov 17 '05 #1
5 1757
I also Tryed the Leave event also not work
"[Yosi]" wrote:
Why I can't catch the Form lost focuse event ?
I mad a FORM , I want to print message each time I moved to another
application my my desktop .
I thryed the following but not work .

this.LostFocus += new System.EventHan dler(this.Form1 _LostFocuse);

private void Form1_LostFocus e(object sender, System.EventArg s e)
{
MessageBox.Show ("Write ");
}

Nov 17 '05 #2
Hi Yosi,

I see nothing wrong with your code.
If you copy those lines into a new blank Windows Form, do you get the same
(no event fired)?
If not, something else in your code is interfering, if you do you might
want to reinstall .net.

PS! The Enter/Leave events are for regular controls and should not be
used for Windows Forms, instead use the Activated/Deactivate events.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #3
When I add TextBox or Button this not work , when remove them this is work
Why ?

"Morten Wennevik" wrote:
Hi Yosi,

I see nothing wrong with your code.
If you copy those lines into a new blank Windows Form, do you get the same
(no event fired)?
If not, something else in your code is interfering, if you do you might
want to reinstall .net.

PS! The Enter/Leave events are for regular controls and should not be
used for Windows Forms, instead use the Activated/Deactivate events.

--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #4
Hi,
I think I remember that somewhere in the documentation it says that
Form.Focus will not be fired when a control is added, In the MSDN from
form.focus says the same that morten said, use Activate
FROM MSDN:
Note The GotFocus and LostFocus events are low-level focus events that are
tied to the WM_KILLFOCUS and WM_SETFOCUS Windows messages. Typically, the
GotFocus and LostFocus events are only used when updating UICues. The Enter
and Leave events should be used for all controls except the Form class,
which uses the Activated and Deactivate events. For more information about
the GotFocus and LostFocus events, see the WM_SETFOCUS and WM_KILLFOCUS
topics in the Keyboard Input Reference section of the Platform SDK
Documentation in the MSDN Library.
Anyway I'm sure that I read somewhere explicitely they will not get fired,
use Activate/Deactivate instead

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"[Yosi]" <Yo**@discussio ns.microsoft.co m> wrote in message
news:98******** *************** ***********@mic rosoft.com...
When I add TextBox or Button this not work , when remove them this is work
Why ?

"Morten Wennevik" wrote:
Hi Yosi,

I see nothing wrong with your code.
If you copy those lines into a new blank Windows Form, do you get the
same
(no event fired)?
If not, something else in your code is interfering, if you do you might
want to reinstall .net.

PS! The Enter/Leave events are for regular controls and should not be
used for Windows Forms, instead use the Activated/Deactivate events.

--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #5
Is there a way to catch these events at a higher level? I want to know
whenever any application is launched, focused, or exited, without having to
attach a form focus handler to each possible form. I really just want the
Windows Task Manager information as it happens. Is this possible? If so,
can you direct me to the API or sample code in C#?

Nov 17 '05 #6

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

Similar topics

3
5639
by: John | last post by:
Dear all, It been more than 3 days I am trying to debug this program, I interpret it using activePerl and it is giving (perl -wc code_process.pl) no error syntax but when I put it online, change to the appropriate mode and test the html form it gave me an 500 internel server error. I really need it to be done soon, I would not post here...
5
6078
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the Internet. Specifically, marking up a document that will contain multiple related form controls (intended exclusively for client-side scripting) that...
4
2105
by: Targa | last post by:
Trying to total some price fields in a form but doesnt work when all the referenced form fields dont exisit. This is for an invoice - pulled prom a database and the form doesnt always contain the same amount of Line Items. If I have all 20 Line Items, it works great. var sub1 = form.Line_Item_Subtotal1.value var sub2 =...
25
10183
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab...
19
3589
by: Raposa Velha | last post by:
Hello to all! Does any of you want to comment the approach I implement for instantiating a form? A description and an example follow. Cheers, RV jmclopesAThotmail.com replace the AT with the thing you know ;-) After discovering that access 2000 support form properties (I'm a
11
18815
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that they are too big and wind up covering up some of the fields on the main form. Is there any good code out there that works in a similar fashion...
2
1025
by: Mohammed | last post by:
when I add new nods to the tree and it has Hscroll bar the scroll bar goes down and the focuse goes to the first node shown in the down part of the tree how can I get the scroll bar goes up and get the focuse at the very first node of the tree
7
5450
by: vinthan | last post by:
hi, I am new to python. I have to write test cases in python. An application is open in the desk top ( application writen in .Net) I have to write code to get focuse the application and click on the link which in the one side and it will load the map on the other and I have to check map is loaded. Any one tell me how do I use Dispatch or any...
3
1411
Ajm113
by: Ajm113 | last post by:
Ok for some reason after the update of Firefox it seems that my form keeps getting submitted when the user made a error on the form. I just want the page to reload so the user may try again. Because I have it so the submit button is a hit once only. Here is the code: <SCRIPT LANGUAGE="JavaScript"> function validateForm(form) { if...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5513
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.