Salad...Thanx

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    Salad...Thanx

    Salad,
    I never got round to using the code you supplied back in October but
    have done today. It works just as I wanted and am really grateful.
    Thanx again,

    Mark


    Mark wrote:[color=blue]
    > 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
    >
    >[/color]

    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.TimerInterva l = GetCaretBlinkTi me()
    End Sub
    Private Sub CommandExit_Cli ck()
    DoCmd.Close
    End Sub
    Private Sub Form_Timer()
    Success = FlashWindow(lng Hwnd, 1)
    End Sub
    Private Sub Text0_GotFocus( )
    Me.TimerInterva l = 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
    GetCaretBlinkTi me 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 GetCaretBlinkTi me Lib "user32" () As Long

    Private Declare Function apiGetDesktopWi ndow Lib "user32" Alias _
    "GetDesktopWind ow" () As Long
    Private Declare Function apiGetWindow Lib "user32" Alias _
    "GetWindow" (ByVal Hwnd As Long, _
    ByVal wCmd As Long) As Long
    Private Declare Function apiGetWindowLon g Lib "user32" Alias _
    "GetWindowLongA " (ByVal Hwnd As Long, ByVal _
    nIndex As Long) As Long
    Private Declare Function apiGetWindowTex t 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 = apiGetDesktopWi ndow()

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

    Do While Not lngx = 0
    strCaption = fGetCaption(lng x)
    If Len(strCaption) > 0 Then
    lngStyle = apiGetWindowLon g(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(fGetCapti on(lngx), "Microsoft Access") > 0 Then
    fEnumWindows = lngx
    Exit Do
    End If
    'Debug.Print lngx
    'Debug.Print "Caption = " & fGetCaption(lng x)
    'Debug.Print
    End If
    End If
    lngx = apiGetWindow(ln gx, mcGWHWNDNEXT)
    Loop
    End Function
    Private Function fGetCaption(Hwn d As Long) As String
    Dim strBuffer As String
    Dim intCount As Integer

    strBuffer = String$(mconMAX LEN - 1, 0)
    intCount = apiGetWindowTex t(Hwnd, strBuffer, mconMAXLEN)
    If intCount > 0 Then
    fGetCaption = Left$(strBuffer , intCount)
    End If
    End Function
    'end cut here



Working...