473,585 Members | 2,771 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 1758
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
5641
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
6079
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
2110
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
10193
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
3599
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
18823
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
1031
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
5453
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
1412
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
7900
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
7832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8332
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5705
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
3828
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
3853
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1167
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.