472,331 Members | 1,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 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 1637
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...
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...
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...
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...
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,...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.