473,786 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event raised when Application/Form regains focus...

Hello!

So im working on an applicaiton that all pretty much sits on a single
form.

When the application completes a task, I'd like it to use
FlashWindow() to notify the user that it has completed. I have this
part working; however, I cant seem to find the right event to use to
Stop the flashing.

Ive tried the GotFocus and the Enter events on the form, but those
dont seem to do the trick.

Anybody have any ideas?

Thanks!!!

Aug 3 '07 #1
17 5393
Do they not work because your form already has focus? If that is the
case, then maybe have a condition where you don't flash the window if the
window already has focus.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Bodyboarde r20" <Sh**********@g mail.comwrote in message
news:11******** *************@1 9g2000hsx.googl egroups.com...
Hello!

So im working on an applicaiton that all pretty much sits on a single
form.

When the application completes a task, I'd like it to use
FlashWindow() to notify the user that it has completed. I have this
part working; however, I cant seem to find the right event to use to
Stop the flashing.

Ive tried the GotFocus and the Enter events on the form, but those
dont seem to do the trick.

Anybody have any ideas?

Thanks!!!
Aug 3 '07 #2


Well for instance if the form is "minimized" . Or if there is another
application on top of it. What event is raised when I bring the
entire application back into focus?

Aug 3 '07 #3
You might want to look into the Activated event as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Bodyboarde r20" <Sh**********@g mail.comwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
>

Well for instance if the form is "minimized" . Or if there is another
application on top of it. What event is raised when I bring the
entire application back into focus?
Aug 3 '07 #4
Activated event seemed to be no goal as well... Is there a way to
monitor an application to see when each event is thrown? That way I
can see what events are thrown and when?

Aug 3 '07 #5
On Aug 3, 9:46 am, Bodyboarder20 <ShieldsJa...@g mail.comwrote:
Activated event seemed to be no goal as well... Is there a way to
monitor an application to see when each event is thrown? That way I
can see what events are thrown and when?
Okay, activated seems to be the one.. however...

Now I seem to be having trouble determining if my application is the
topmost active application that is running.

I dont want the application to flash if it is, cause then i seem to
have to minimize it and restore it before the flashing stops...

ugh...

Aug 3 '07 #6
Bodyboarder20 wrote:
[...]
Now I seem to be having trouble determining if my application is the
topmost active application that is running.

I dont want the application to flash if it is, cause then i seem to
have to minimize it and restore it before the flashing stops...

ugh...
From what I've gathered based on your posts in this thread, it seems to
me that you are making things way too hard on yourself. There's no
FlashWindow() in .NET, so you appear to be using p/invoke, which isn't
the right way to do what you want.

Just call Form.Activate() on your form instance. It will only flash in
the taskbar if it cannot be activated due to not being the foreground
application.

And for what it's worth, even in non-managed code, FlashWindow() wasn't
the right way to do it either. SetForegroundWi ndow() would have done
what you want, without all the extra fuss.

Pete
Aug 3 '07 #7
On Aug 3, 12:38 pm, Peter Duniho <NpOeStPe...@Nn OwSlPiAnMk.comw rote:
Bodyboarder20 wrote:
[...]
Now I seem to be having trouble determining if my application is the
topmost active application that is running.
I dont want the application to flash if it is, cause then i seem to
have to minimize it and restore it before the flashing stops...
ugh...

From what I've gathered based on your posts in this thread, it seems to
me that you are making things way too hard on yourself. There's no
FlashWindow() in .NET, so you appear to be using p/invoke, which isn't
the right way to do what you want.

Just call Form.Activate() on your form instance. It will only flash in
the taskbar if it cannot be activated due to not being the foreground
application.

And for what it's worth, even in non-managed code, FlashWindow() wasn't
the right way to do it either. SetForegroundWi ndow() would have done
what you want, without all the extra fuss.

Pete
Well, i managed to get it working using FlashWindow and overriding the
WndProc of the form...

I tried your method and all it did was set the application active and
brought it forward. I dont necessarily want to bring the application
forward. I just wont it to bring in the taskbar. That way a user
will know it's done completing it task. Similar to AIM when you
recieve and instant message...

Thanks to all who have responded!

Problem Solved!

Aug 3 '07 #8
Bodyboarder20 wrote:
Well, i managed to get it working using FlashWindow and overriding the
WndProc of the form...
What FlashWindow()? There's no FlashWindow() in .NET.
I tried your method and all it did was set the application active and
brought it forward.
Then your application was already a valid candidate for being the
foreground window. Don't you want it brought forward if it can be?

See the docs for non-managed SetForegroundWi ndow() for a more detailed
explanation of when your application can actually be made the foreground
application and when it can't be (thus causing the taskbar item to flash):
http://msdn2.microsoft.com/en-us/library/ms633539.aspx
I dont necessarily want to bring the application
forward. I just wont it to bring in the taskbar.
If you have some other application that is active and your application
is not a valid candidate for being the foreground window when you call
Activate(), it will flash in the task bar.
That way a user
will know it's done completing it task. Similar to AIM when you
recieve and instant message...

Thanks to all who have responded!

Problem Solved!
Not in a very good way, from the sounds of it. It sounds to me as
though you are abusing the UI guidelines (flashing your taskbar item
when you could simply show the user your window), and at the same time
making your code messier (since you are using non-managed code,
overriding the WndProc, and checking state that has no need of checking).

Pete
Aug 3 '07 #9
Peter Duniho wrote:
Bodyboarder20 wrote:
>I tried your method and all it did was set the application active and
brought it forward.

Then your application was already a valid candidate for being the
foreground window. Don't you want it brought forward if it can be?
It sounds like he doesn't; it sounds to me like he just wants the
taskbar to flash regardless of whether the window is a candidate for
being brought forward or not.
>I dont necessarily want to bring the application
forward. I just wont it to bring in the taskbar.
Sounds like he found a pretty good workaround to a current Windows Forms
limitation. Nice to know how to do this (I can use it in a couple of apps).
>Problem Solved!

Not in a very good way, from the sounds of it. It sounds to me as
though you are abusing the UI guidelines (flashing your taskbar item
when you could simply show the user your window), and at the same time
making your code messier (since you are using non-managed code,
overriding the WndProc, and checking state that has no need of checking).
FlashWindow[Ex] is a perfectly good Windows function. Just because
Windows Forms hasn't gotten around to implementing this functionality
(assuming that is that case) doesn't mean it breaks any UI guidelines
(apps have been doing this prior to Windows Forms), just that you can't
do it easily with a .NET library call.

--
-glenn-
Aug 3 '07 #10

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

Similar topics

18
2889
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
4
1367
by: Ron Gliane | last post by:
Hi, this seems like something so basic that there must be some way to do it...Is there a way for Visual Studio or some other tool to let me see Events as they are raised in an application? For example, I've created a form with two fields. I would like to be able to see ALL the events for the application as I run/debug it. I want to know that clicking on field1 and then field2 produces: fld1.enter, fld1.leave, fld2.enter, etc. I guess...
5
11074
by: Stan Sainte-Rose | last post by:
Hi, Which event is called when the user click on the close window icon (X) ? I want, when he clicks on this icon, to display a message before closing the form. If he replys by No, I don't want to close the form. Thks for your help Stan
5
3342
by: Steve | last post by:
I have a datagrid in a WinForm. When the user edits an entry in the datagrid, after he leaves that field, I would like to do some cheking. What event fires when the user does that? I need to make sure that the value he modified does not create a dup value in my DB. Thank you for your help, Steve
2
5382
by: Simon Verona | last post by:
I have a usercontrol with code in the "leave" event which updates the final data back into a database. This works fine except if I have a default "accept" button on a form and invoke it by pressing the ENTER key on the keyboard. In this case, it would appear that whilst the code on the button is executing and therefore presumably the button actually has focus, the leave event in the user control is not fired. Should I be interfacing...
1
6319
by: Bob | last post by:
In Vs 2005 you have new applicationsEvents.vb I was testing it in a simple app and found that it was easier to implement unhandled exception management tah it was in Vs2003 (vb.net) You can, if you want to, prevent your app from terminating on an unhandled exception, and for me this is important. In an Ivr app it will let me hang up the phone only on the line that triggered the unhandled exception, leaving other callers to complete their...
5
2165
by: rn5a | last post by:
Consider the following user control which resides in Address.ascx: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String) txtAddress.Text = value End Set
5
7460
by: =?Utf-8?B?QmVuIFIu?= | last post by:
Hi, In a .NET 2.0 winforms application, I've got a textbox that, when updated, uses the validated event to cascade the change to another textbox (along with another value). This works well if the user does indeed move the cursor to another textbox, but if the user clicks my "done" toolstripbutton after making a change in the textbox but without moving the cursor out, the validated event never fires. I have a pretty bad workaround where...
0
11355
MMcCarthy
by: MMcCarthy | last post by:
VBA is described as an Event driven programming language. What is meant by this? Access, like most Windows programs, is an event driven application. This means that nothing happens unless it is in response to some event that has been detected by the application. The steps are fairly straightforward: An event happens The event is detected by the application The application responds to the eventThe Windows OS will automatically detect...
0
9647
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9496
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8989
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.