473,387 Members | 1,705 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.

Flashing task bar button

Hi All,
Does anyone know of a way that I can get a task bar button to flash if a
form is open? I have created something like a messenger application within
my database but there are a few people who have it open but do not use it
exclusivley. If someone was to send them a message, it could be hours before
they see it so if I could get the taskbar button to flash if the form opens,
they can be alerted instantly.

Many thanks,

Mark
Nov 13 '05 #1
6 6570
"Mark" <ma*********@ntlworld.com> wrote:
I have created something like a messenger application within
my database but there are a few people who have it open but do not use
it exclusivley. If someone was to send them a message, it could be
hours before they see it so if I could get the taskbar button to flash
if the form opens, they can be alerted instantly.


Hi Mark,

Not knowing much about your app this is a bit of a shot in the dark, but if
the code in your app detects a new record, how about having it fire off a
'net send' message to the user in question?

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #2
Mark wrote:
Hi All,
Does anyone know of a way that I can get a task bar button to flash if a
form is open? I have created something like a messenger application within
my database but there are a few people who have it open but do not use it
exclusivley. If someone was to send them a message, it could be hours before
they see it so if I could get the taskbar button to flash if the form opens,
they can be alerted instantly.

Many thanks,

Mark


I went to Google and was referred to the following kb article at
http://support.microsoft.com...Q147815.

OK, this KB is referring to VB. Plus, it needed to be modified for the
taskbar, not the window. So if you want a quick demo of how I modified
it, do the following.

Create a form...Form1. Add a text field (Text0) and a command button
CommandExit.

Set the tab order to command button first, text0 last, since when you
put your mouse onto Text0 it will stop the blinking.

Now, drop the following code into the form1's module by cut/paste

'start cut
Option Compare Database
Option Explicit
Dim Success As Long
Dim lngHwnd As Long
Private Sub Form_Load()
'get the hwnd of Access
lngHwnd = fEnumWindows()
Me.TimerInterval = GetCaretBlinkTime()
End Sub
Private Sub CommandExit_Click()
DoCmd.Close
End Sub
Private Sub Form_Timer()
Success = FlashWindow(lngHwnd, 1)
End Sub
Private Sub Text0_GotFocus()
Me.TimerInterval = 0
End Sub
'end cut

What happens is that when the form loads, it will start blinking.
Minimize Access if you like...the taskbar for Access should be blinking.

Now when you maxmize Access and go to Text0, the blinking will stop.

In order to make this work, you need to get the hwnd of Access. So I
swiped the code at http://www.mvps.org/access/api/api0013.htm and
modified it slightly. First, I added the function calls for
GetCaretBlinkTime and FlashWindow and removed the calls to get the class
name. I do a search for the phrase "Microsoft Access". You may want to
change the search for something else. Anyway.........

Create a new code module and cut/paste the following code. Save the
module. Now save/close Form1. Now open it. Minimize it. It should be
blinking.
'start cut here
Option Compare Database
Option Explicit

Declare Function FlashWindow Lib "user32" ( _
ByVal Hwnd As Long, _
ByVal bInvert As Long) As Long

Declare Function GetCaretBlinkTime Lib "user32" () As Long

Private Declare Function apiGetDesktopWindow Lib "user32" Alias _
"GetDesktopWindow" () As Long
Private Declare Function apiGetWindow Lib "user32" Alias _
"GetWindow" (ByVal Hwnd As Long, _
ByVal wCmd As Long) As Long
Private Declare Function apiGetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal Hwnd As Long, ByVal _
nIndex As Long) As Long
Private Declare Function apiGetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal Hwnd As Long, ByVal _
lpString As String, ByVal aint As Long) As Long
Private Const mcGWCHILD = 5
Private Const mcGWHWNDNEXT = 2
Private Const mcGWLSTYLE = (-16)
Private Const mcWSVISIBLE = &H10000000
Private Const mconMAXLEN = 255
Function fEnumWindows()
Dim lngx As Long, lngLen As Long
Dim lngStyle As Long, strCaption As String

lngx = apiGetDesktopWindow()

'Return the first child to Desktop
lngx = apiGetWindow(lngx, mcGWCHILD)

Do While Not lngx = 0
strCaption = fGetCaption(lngx)
If Len(strCaption) > 0 Then
lngStyle = apiGetWindowLong(lngx, mcGWLSTYLE)
'enum visible windows only
If lngStyle And mcWSVISIBLE Then

'CHANGE YOUR SEARCH STRING HERE. I USE MS ACCESS
'YOU CAN SEARCH FOR YOUR APP NAME TOO. THE DEBUG
'PRINT SHOULD HELP YOU OUT TO DETERMINE WHAT
'WINDOW TO SEARCH FOR,

If InStr(fGetCaption(lngx), "Microsoft Access") > 0 Then
fEnumWindows = lngx
Exit Do
End If
'Debug.Print lngx
'Debug.Print "Caption = " & fGetCaption(lngx)
'Debug.Print
End If
End If
lngx = apiGetWindow(lngx, mcGWHWNDNEXT)
Loop
End Function
Private Function fGetCaption(Hwnd As Long) As String
Dim strBuffer As String
Dim intCount As Integer

strBuffer = String$(mconMAXLEN - 1, 0)
intCount = apiGetWindowText(Hwnd, strBuffer, mconMAXLEN)
If intCount > 0 Then
fGetCaption = Left$(strBuffer, intCount)
End If
End Function
'end cut here
Nov 13 '05 #3
Chuck Grimsby wrote:
On Mon, 25 Oct 2004 09:46:55 GMT, Salad <oi*@vinegar.com> wrote:

That's pretty cool, Salad! I'm not really sure how useful it is, I,
myself, don't like stuff that flashes all over the place, but still
it's pretty darn cool!

Thanks!


Thanks for the compliment. It put a smile on my face, it coming from
one of the gurus here on the board.

Sometimes I've had my non-Access apps minimized on the start bar as they
work away and when it completes it starts blinking to let me know it
completed. It's kinda cool to let the program know when it expects my
attention.

And I agree with you. I doubt I'd put this in my code. The gent who
started this thread tho did need a way to inform the user who had the
app minimized so this is an elegant way of doing so. I suppose he could
also check to see if the window is maximized. If so, no blink, else blink.
Nov 13 '05 #4
Chuck Grimsby wrote:
On Tue, 26 Oct 2004 17:45:42 GMT, Salad <oi*@vinegar.com> wrote:

Chuck Grimsby wrote:
On Mon, 25 Oct 2004 09:46:55 GMT, Salad <oi*@vinegar.com> wrote:
That's pretty cool, Salad! I'm not really sure how useful it is, I,
myself, don't like stuff that flashes all over the place, but still
it's pretty darn cool!
Thanks!


Sometimes I've had my non-Access apps minimized on the start bar as they
work away and when it completes it starts blinking to let me know it
completed. It's kinda cool to let the program know when it expects my
attention.

Well, of course the "cheap" way to do that in Access is to just pop up
a msgbox. Most of my code contains a really stupid msgbox that just
says "Done" for that reason. Windows will automatically "flash" the
button on start bar for you when that happens. It'll flash for a
while, then stop and stay highlighted.

A msgbox like that also really *clearly* tells the user that your
routine is finished, whether or not they have the app minimized or
not. And it's really easy to document... "Wait for the box that says
'Done'..." I *like* easily documented stuff as well, since 9 times
out of 10 I'm the one doing the documentation. <Grin!>

This is a really quick'n'easy way to do it.
I'll be using this in my code from now on.
Excellent and simple. Many thanks for this pointer!
Nov 13 '05 #5
"Mark" <ma*********@ntlworld.com> wrote in message news:<5S***************@newsfe6-gui.ntli.net>...
Hi All,
Does anyone know of a way that I can get a task bar button to flash if a
form is open? I have created something like a messenger application within
my database but there are a few people who have it open but do not use it
exclusivley. If someone was to send them a message, it could be hours before
they see it so if I could get the taskbar button to flash if the form opens,
they can be alerted instantly.

Many thanks,

Mark


If your target OS is 2000 or XP, then you can just shove in a call to
BringWindowForward() (It's an API call, but not too complicated).

In 2000 and XP, they disabled the actual functionality of this call
unless special permissions have been granted to your program by the
window that is currently topmost - what happens instead is that the
taskbar button flashes.

It is this behaviour that you have probably observed in other programs
and are attempting to replicate.

HTH,

Damien
Nov 13 '05 #6
Chuck Grimsby wrote:
On Tue, 26 Oct 2004 22:50:43 GMT, Chuck Grimsby
<c.*******@worldnet.att.net.invalid> wrote:
On Tue, 26 Oct 2004 17:45:42 GMT, Salad <oi*@vinegar.com> wrote:
Chuck Grimsby wrote:

That's pretty cool, Salad! I'm not really sure how useful it is, I,
myself, don't like stuff that flashes all over the place, but still
it's pretty darn cool!
Thanks!
Sometimes I've had my non-Access apps minimized on the start bar as they
work away and when it completes it starts blinking to let me know it
completed. It's kinda cool to let the program know when it expects my
attention.


Well, of course the "cheap" way to do that in Access is to just pop up
a msgbox. Most of my code contains a really stupid msgbox that just
says "Done" for that reason. Windows will automatically "flash" the
button on start bar for you when that happens. It'll flash for a
while, then stop and stay highlighted.
A msgbox like that also really *clearly* tells the user that your
routine is finished, whether or not they have the app minimized or
not. And it's really easy to document... "Wait for the box that says
'Done'..." I *like* easily documented stuff as well, since 9 times
out of 10 I'm the one doing the documentation. <Grin!>

Aw, crud. There was supposed to be another paragraph in this post:

One of the problems with using a msgbox however, is that the code
stops while the msgbox is open, so in this case that may not be the
best option, which is why your code is so cool! Since the original
poster wanted something like a messenger system with an alert, popping
up a msgbox would make their code stop and not receive any more
messages. Probably not a good thing.


But you had a great tip on using the msgbox. It makes sense to use that
method for the vast majority of instances.

This is what I like about this group, I learn new things all the time.
Nov 13 '05 #7

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

Similar topics

4
by: Christina | last post by:
Dear All, How can I pop up the windows task scheduler inside of my .net application? Such as I have a button called Schedule Now, after clicking it, the Add Scheduled Task window will pop up,...
9
by: Phillip Parr | last post by:
Hello, I know there is no way in Javascript to make the task bar flash when your window is minimised. However, I found out recently that if a javascript alert is sent to netscape when the window...
3
by: JC | last post by:
Hi all! I have written a little Instant messenger application and I want the task bar button to flash when a message is recieved - and herein is my problem - I'm not sure how to make the task...
1
by: Terry | last post by:
I've seen several posts from people who have seen this flashing in TreeView's when resizing a form. I've noticed it in my app, but only in the child windows. For example, my main form has a...
5
by: EMW | last post by:
Hi, On my ASPx.NET page I have quite a lot of controls, so it takes a little time to build it. Because of this when you click on a button, the page is redrawn and whatever the action was, the...
10
by: shiry | last post by:
Hi, I need to do some important cleanup before my console application exists. I used the console ctrl event. This is working well and it fires for all cases, including the CTRL_CLOSE_EVENT (if I...
1
by: Jeroen Gouma | last post by:
How can I make the Access-button in the taskbar start flashing from my VBA-code? I would like to have the user's attention if needed when they have the application mnimized. Thanks, Jeroen
3
by: Simon Verona | last post by:
I have a parent form which contains a toolbar. The toolbar controls the loading and switching to of MDI child forms. The code for the toolbar click event and one of the subroutines that loads...
0
oll3i
by: oll3i | last post by:
import javax.swing.*; import java.awt.event.*; import java.util.ArrayList; import java.util.List; import java.util.concurrent.*; import java.lang.reflect.*; public class Exec1 extends JFrame...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.