By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Flashing task bar button

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.