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

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.EventHandler(this.Form1_LostFocuse);

private void Form1_LostFocuse(object sender, System.EventArgs e)
{
MessageBox.Show("Write ");
}
Nov 17 '05 #1
5 1740
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.EventHandler(this.Form1_LostFocuse);

private void Form1_LostFocuse(object sender, System.EventArgs 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**@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.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
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...
5
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...
4
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...
25
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...
19
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...
11
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...
2
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...
7
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...
3
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...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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,...

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.