                                  TTaskBarInfo

                                  Version 1.11
                                July 28th, 1999

                     Copyright 1998-1999 Computer Solutions
                              Released as FreeWare


Description

  TTaskBarInfo retrieves the current position and state of the Win32 Task Bar.
  TTaskBarInfo can also retrieve information about other Win32 Application
  Bars by modifying the WindowName property.


Upgrading

  If you are upgrading from version 1.0, you will receive errors when loading
  a form which contains TTaskBarInfo.  The error is "Invalid property path,"
  and can be ignored.  These errors are caused because of the changes since
  version 1.0.  Please read Revision History below for more information.

  I don't recommend upgrading from version 1.10.  The only thing that changed
  was the addition of the "jmr" prefix in front of several internal data
  types.  Upgrading from version 1.10 will just cause a bunch of errors when
  loading your forms and doesn't provide any additional benefit.


License

  This component may be used freely and distributed in commercial or
  private environments, provided this notice is not modified or removed
  and there is no charge for the component other than nominal handling fees.
  This component may be included in compilations of other software, as long
  as there is no charge for TTaskBarInfo specifically.

  DFS.INC is Copyright 1986, Brad Stowers, used by permission.  Please
  observe Brad's DFS license agreement when using or distributing DFS.INC.
  Brad's DFS web page is located at http://www.delphifreestuff.com/.


Properties

  A majority of the properties are read-only, although write methods have been
  provided.  I wanted to see the properties in the Object Inspector, and read-
  only properties are not displayed in the Object Inspector.  The only
  property which is truely writable is WindowName.  Setting values to the
  other properties will have no affect.

  At first glance, it appears the SHAppBarMessage API provides a way to resize
  a Win32 Application Bar.  However, the ABM_SETPOS message is used to notify
  Win32 when an Application Bar has been moved.  Win32 then resizes any
  maximized applications based on the new position of the Application Bar.

  AutoHide    - Indicates if the Application Bar is set to auto-hide.

  AlwaysOnTop - Indicates if the Application Bar is always the top window.

  BarRect     - Represents the coordinates of the Application Bar's window.
                BarRect is a TBarRect, which is the equivalent of a TRect.
                In contains the properties Left, Right, Top, and Bottom.
                Currently, a TBarRect is not assignment compatible with a
                TRect.

  BarHeight   - Indicates the Application Bar's height.

  BarWidth    - Indicates the Application Bar's width.

  BarPosition - Indicates the screen position of the Application Bar.
                Possible values are abeTop, abeBottom, abeLeft, and abeRight.

  BarHidden   - Indicates if the Application Bar is presently hidden.  This
                value is actually a guess based on the bar's height and
                width.  Please read "Author's Comments" below for more info.

  BarFound    - Indicates if the Application Bar's window was found based on
                the value of WindowName.                              

  WindowName  - Indicates the name of the Application Bar's window.  The name
                of the window is required to retrieve a handle (hWnd) to the
                bar.  The default value is Shell_TrayWnd, which is the name
                of the Win32 Task Bar.

                By allowing this value to be modified, TTaskBarInfo can
                be used to obtain information about other Application Bars,
                such as the Office 95 Shortcut Bar.  WindowName can be reset
                to its default value by setting WindowName to an empty string.


Events

  OnBarChange - This event is triggered whenever the position or state of the
                Application Bar is changed.  Be careful not to tie up the
                system within this event.  The Application Bar sends Win32 a
                message to indicate the change, but Win32 does not return
                control to the Application Bar until after this event is
                finished.


16-bit Support

  TTaskBarInfo will work in 16-bit applications with limited functionality.
  The properties AutoHide, AlwaysOnTop, BarHidden, and BarPosition, as well
  as the OnBarChange event are not available in a 16-bit application.  These
  rely on the Win32 API to function.

  I could implement full 16-bit support using Call32NT.pas.  However, I
  doubt this will be implemented unless there are requests from D1 users.


Future Revisions

  I would like to make TBarRect assignment compatible with a TRect.  Then
  the C statement TRect Rect = TaskBarInfo1.BarRect; would work.  Presently,
  I have no idea how to implement this.

  Currently, the user can change TTaskBarInfo.FBarRect.  I would like to
  change the write method for TTaskBarInfo.FBarRect to an empty procedure,
  like the other write methods.  However, when I do this, I get an Access
  Violation when loading the component from a form file.


Author's Comments

  TTaskBarInfo has been tested with D1, D2, D3, D4, BCB1, BCB3, and BCB4.

  TTaskBarInfo actually creates an invisible Application Bar and registers it
  with Win32 in order to receive messages from other Application Bars.  Thanks
  to Brad Stowers for providing the code that accomplishes this.

  BarHidden is determined by examining the bar's width and height.  When the
  Win32 Task Bar is hidden, it's height or width is 4 pixels, depending on
  the screen location of the bar.

  In a 16-bit application, BarRect is determined using GetWindowRect instead
  of the ABM_GETTASKBARPOS message.  GetWindowRect returns the same
  coordinates regardless of the bar's hidden state.  Therefore, BarHidden is
  not available in 16-bit applications.

  BarPosition is determined by examining the window position of the
  Application Bar.  According to the BCB3 documentation of the SHAppBarMessage
  API, the ABM_QUERYPOS message "Requests a size and position for an appbar."
  However, the uEdge member is not modified by ABM_QUERYPOS.

  I would like to thank Brad Stowers, Michael Tier, and Lanny Grim for their
  help with this project.  I would also like to thank everyone in the Internet
  community for taking a few minutes out of your busy day to answer a question
  or two.  With the demise of vender support, the Internet is the only reason
  many of us survive from day to day.


Revision History

1.11  + Simply added the prefix "jmr" to all internal data structures.
        I have registered the prefix at the Delphi Prefix Registry.

1.10  + Changed the implementation of TBarRect.  The class is no longer
        derived from TPersistent.  This was initially done to provide RTTI
        information so the class was published.  RTTI is now generated with
        the {$M+} compiler switch.  This has reduced the size of the compiled
        code.
      + Added methods to TBarRect to simplify assigning and retrieving a TRect.
      + Changed most properties to non-stored properties.  Most of the
        information about an Application Bar is determined at run-time,
        so there is no need to store this information.  WindowName and
        OnBarChange are still stored.
      + Removed the read methods for several properties.  The methods were
        originally needed before the OnBarChange event handler was working.
        Now the internal variables are automatically updated when the
        application bar changes and the read methods are no longer needed.
      + Corrected a mistake when setting the BarRect value for 16-bit support
        only.

1.00  + First non-beta release.

0.20  + Added code provided by Brad Stowers to create an invisible Application
        Bar and handle messages received from other Application Bars.  This
        provided a way to implement the OnBarChange event.
      + Implemented the OnBarChange event.
      + Removed the call to GetInfo from each read method.  GetInfo is now
        called automatically when the bar changes.
      + Added the BarRect property.  Removed the Top, Bottom, Left, and Right
        properties.
      + Added the BarHidden property.
      + Added the WindowName property.
      + Added the pseudo-Component Editor to display the version number.

0.10  + Initial release.
