home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d123456 / DFS.ZIP / DFSStatusBar.txt < prev    next >
Text File  |  2001-06-28  |  18KB  |  324 lines

  1. TDFSStatusBar v1.24
  2.  
  3. A status bar that provides many common specialized panels.  The main features
  4. are key lock indicators (caps, num, scroll), gauges, images, ellipsis text, and
  5. date/time.  Also, the status bar can own other components (i.e. you can drop
  6. something on it in the IDE).
  7.  
  8.  
  9. Contact Information:
  10. --------------------
  11.   The lateset version will always be available on the web at:
  12.     http://www.delphifreestuff.com
  13.   If you have any questions, comments or suggestions, please use the Delphi
  14.   Free Stuff Support Forum at:
  15.     http://www.delphifreestuff.com/discus/
  16.   If, for some reason, you can not use the web-based support forum, you can
  17.   email me at bstowers@delphifreestuff.com.  However, the support forum will
  18.   always take precedence over direct email since it provides a resource that
  19.   others can use when they have a problem.  Every message posted to the forum
  20.   is emailed directly to this account, so emailing me directly will not get
  21.   your message to me any faster.  It will only make the message less important
  22.   for me to respond to since only one person (you) is benefiting from it
  23.   instead of everyone interested.  Having said all that, please do email me
  24.   directly if it is regarding something that isn't really support related,
  25.   i.e. just to say thanks (as novel as that idea is).
  26.  
  27.  
  28. Installation:
  29. -------------
  30.   Delphi 1, Delphi 2, C++Builder 1:
  31.     * This component is not compatible with Delphi 1, 2, or C++Builder 1.
  32.  
  33.   Delphi 3, 4, 5, C++Builder 3 & 4:
  34.     * Do one of the following:
  35.       + Create a new package by selecting File | New and choosing Package from
  36.         the New tab in the dialog.
  37.       + Open an existing package file.  I suggest you do this if you already
  38.         have a package that you like to use for small, third party components.
  39.         I specifically have a package named "3rdParty.dpk" that I use for
  40.         small components that come from other people.  Or, if you are using
  41.         several of my components, you might create a "DFS.dpk" package and
  42.         use it for all of my DFS components.
  43.     * In the resulting package window, click the Add button.
  44.     * In the Add dialog, on the Add Unit tab, enter the full path name of the
  45.       component's registration unit (the unit that ends with 'Reg.pas', i.e.
  46.       'BrowseDrReg.pas') and click OK.
  47.     * You may want to add the other source files (*.pas) to the package as
  48.       well in the same manner as you did the registration unit.  While this is
  49.       not required, not doing it will cause compiler warnings when the package
  50.       is compiled.  The component will function fine either way, but I
  51.       personally find the warnings very irritating and am not happy until
  52.       every compiler warning and hint is gone.
  53.     * If this package is new, or it has never been installed, click the
  54.       Install button in the package window.  If this package is already
  55.       installed in Delphi, click the Compile button.
  56.  
  57.   C++Builder 5 and up:
  58.     * Perform the "Delphi 3 and up, C++Builder 3 and up" steps above, except
  59.       for the last step (Compile or Install).
  60.     * Select the package the component has been added to, and choose
  61.       Project | Edit Option Source to open the package options in the editor.
  62.     * In the entry for PFLAGS, add the "-LUvcl50" option.  For example:
  63.         <PFLAGS value="-$YD -$W -$O -v -JPHNE -M -LUvcl50"/>
  64.     * Perform the final step from above, Compile or Install.
  65.     * For Borland's official word on this situation, open the C++Builder help
  66.       file and search the index for "dsgnintf.dcu" and see the "Compiling
  67.       packages with DsgnIntf" section.
  68.  
  69.   Delphi 6 and up:
  70.     * Perform the "Delphi 3, 4, 5, C++Builder 3 & 4" steps above, except
  71.       for the last step (Compile or Install).
  72.     * Add the DesignIDE package to the Requires list of the package into which
  73.       the component is being installed.
  74.     * Perform the final step from above, Compile or Install.
  75.     * This is necessary because of changes to the design-time support units
  76.       introduced in Delphi 6.  For complete information, see the Del6New.hlp
  77.       file in your Delphi 6 Help directory.  In the index, search for
  78.       "upgrade issues" and in the resulting list of topics, select the
  79.       "DsgnIntf renamed and related changes" topic.
  80.  
  81.  
  82. Documentation:
  83. --------------
  84.  
  85. TDFSStatusBar:
  86.  
  87.   procedure InvalidatePanel(Index: integer);
  88.     This method causes only the specific panel identified by Index to be
  89.     redrawn.
  90.   property UseMonitorDLL: boolean;
  91.     This property indicates whether the indicator keys (Caps, Num & Scroll lock)
  92.     should be monitored system wide or in the app only.  If set to true, your
  93.     app will require the DFSKbMon.DLL to be present.  See the Implementation
  94.     Notes section for more information, including how to rename the DLL.
  95.  
  96.  
  97. TDFSStatusPanel:
  98.  
  99.   procedure Invalidate(RefreshNow: boolean);
  100.     This method causes the panel to be invalidated. RefreshNow indicates whether
  101.     the repaint should take place immediately or later when the next WM_PAINT
  102.     message is processed.
  103.  
  104.   property StatusBar: TDFSStatusBar;
  105.     The TDFSStatusBar that owns this panel.
  106.  
  107.   property PanelType: TDFSStatusPanelType;
  108.     sptNormal - Nothing special, same as a regular TStatusPanel.
  109.     sptCapsLock - Caps lock indicator.  Normal color if on, gray if off.
  110.     sptNumLock - Num lock indicator.  Normal color if on, gray if off.
  111.     sptScrollLock - Scroll lock indicator.  Normal color if on, gray if off.
  112.     sptDate - Current date.  Uses DateFormat property for format of text.
  113.     sptTime - Current time.  Uses TimeFormat property for format of text.
  114.     sptDateTime - Current date and time.  Uses DateFormat and TimeFormat
  115.         properties for format of text.
  116.     sptTimeDate - Current time and date.  Uses DateFormat and TimeFormat
  117.         properties for format of text.
  118.     sptEllipsisText - Shorten text at the end with '...' when it won't fit.
  119.     sptEllipsisPath - Shorten by removing path info with '...' when it won't fit.
  120.     sptGlyph - Displays a TPicture object in the panel along with a string from
  121.       the Text property (if any).
  122.     sptGauge - A progress meter.  Use GaugeAttrs to customize it.
  123.     sptOwnerDraw - Same as the old TStatusPanel.Style = psOwnerDraw.
  124.  
  125.   property GaugeAttrs: TDFSGaugeAttrs;
  126.     property Style: TDFSGaugeStyle;
  127.       gsPercent - Your basic progress meter.
  128.       gsIndeterminate - A progress indicator where the min/max are not known.
  129.         That is, you want to show something going on, but don't know how long
  130.         it will take.  Same concept as the Netscape status panel gauge when you
  131.         are connecting to a site.  Use the Enabled property to start and stop
  132.         the gauge.  This one looks like a little ball bouncing back and forth.
  133.       gsIndeterminate2 - Same as last, but looks like Netscapes (a gradient
  134.         bar bouncing).
  135.     property Position: TPercent;
  136.       A value from 0 to 100 indicating the current percentage to display for
  137.       sptGauge panel types when the Style is gsPercent.  It the Text property
  138.       is blank, this value will be displayed within the gauge (i.e. "51%").
  139.       If Text is not blank, it's value will be drawn inside the gauge.  If you
  140.       don't want any text within the gauge, just set Text to a space character.
  141.       This property has no meaning for any other panel types.
  142.     property Color: TColor;
  143.       The color to paint the "filled" area of the gauge with.
  144.     property TextColor: TColor;
  145.       Only for gsPercent.  Color of text painted in the "filled" area.
  146.     property Speed: integer;
  147.       How fast the movement occurs for indeterminate styles.
  148.  
  149.   property AutoFit: boolean;
  150.     Automatically adjust the width of the panel to be wide enough to display
  151.     the information.  Note that this property has no meaning to some panel
  152.     types, and setting it will likely result in the panel's width becoming very
  153.     small.  For example, sptGauge has no idea how big you would want it to
  154.     automatically become.
  155.  
  156.   property Glyph: TPicture;
  157.     The image to show on the panel for sptGlyph panel types.  This property has
  158.     no meaning for any other panel type.
  159.  
  160.   property DateFormat: string;
  161.     For use with sptDate, sptTimeDate and sptDateTime PanelTypes.  This property
  162.     has no meaning for any other panel types.  Use the same format as described
  163.     in the Delphi Help, FormatDateTime function.  You can leave this property
  164.     blank, and the user's short date format setting will be used.
  165.  
  166.   property TimeFormat: string;
  167.     For use with sptTime, sptTimeDate and sptDateTime PanelTypes.  This property
  168.     has no meaning for any other panel types.  Use the same format as described
  169.     in the Delphi Help, FormatDateTime function.  You can leave this property
  170.     blank, and the user's long time format setting will be used.
  171.  
  172.   property Enabled: boolean;
  173.     Whether the panel should be enabled or not.  Disabled panels are blank.  The
  174.     one exception to this is sptOwnerDraw.  The OnDrawPanel event fires
  175.     regardless of the Enabled state, that way you can draw it however you like
  176.     based on the Enabled property.
  177.  
  178.   property Hint: string;
  179.     Hint text to be displayed for the panel.  If blank, the hint text displayed
  180.     will be the bar's hint (if any).  For sptEllipsisText and sptEllipsisPath
  181.     panels, the hint will be the full value of Text if this value is set to
  182.     '...'.  You can override the value of this property by using the OnHintText
  183.     event (see below).
  184.  
  185.   property BorderWidth: TBorderWidth;
  186.     Use BorderWidth to specify how wide the border around the panel should be.
  187.     A value of 0 means no border should appear. The border of a panel is the
  188.     area between the outer shading rectangle and the data that apears within.
  189.  
  190.   property Text: string;
  191.     The text to display in the panel.  For some panel types, this is controlled
  192.     automatically (sptCapsLock, sptDateTime, etc.).  For sptGlyph, text is
  193.     displayed to the right of the glyph (if there is any text), except for
  194.     right justified panels which display text to the left of the glyph.
  195.  
  196.   property OnDrawPanel: TDFSDrawPanelEvent;
  197.     This event fires when the panel needs to be redrawn, and PanelType is
  198.     sptOwnerDraw.  Note that TDFSStatusBar also has this event and it fires for
  199.     any panel that needs to be drawn.  This event is intended for seperating out
  200.     owner drawing code into events tied to a single panel, rather than having
  201.     one big event that has to know how to draw every panel.
  202.  
  203.   property OnHintText: TDFSPanelHintTextEvent;
  204.     This event fires when hint text is being retrieved for the panel.  When the
  205.     event handler is entered, the current hint text, if any, will be in the
  206.     HintText parameter.
  207.  
  208.  
  209. Implementation Notes:
  210. ---------------------
  211.   * For owner draw panels (sptOwnerDraw PanelType), the status bar's OnDrawPanel
  212.     event fires first, and then the individual panels' OnDrawPanel events are
  213.     fired.  You can paint the panels in whichever handler you prefer.
  214.  
  215.   * The lock indicators (caps, scroll, num) operate by using a windows hook
  216.     (SetWindowsHookEx).  Every effort has been made to reduce the impact this
  217.     will have on the user's system.  The hook is only active if it is needed
  218.     (there are indicator panels), and only if the panels are enabled.  If
  219.     multiple indicators exist (even across multiple status bars), there is still
  220.     only one hook installed, not one hook for each.  The hook is active for the
  221.     thread that contains the status bar, not system wide, if UseMonitorDLL is
  222.     false; otherwise, the hook is system wide.  Setting UseMonitorDLL to false
  223.     will lessen the impact on the user's system, but it has the side effect of
  224.     causing the indicators to function only within the thread.  That is, if you
  225.     switch to another app and change the Num Lock, it will not be reflected
  226.     until you switch back. Also, if UseMonitorDLL is set to true, the
  227.     DFSKbMon.DLL is required to be present on the system.
  228.  
  229.   * If you will be using the UseMonitorDLL property, you must include the
  230.     monitoring DLL with your application.  It is strongly suggested that you
  231.     rename the DLL to something specific to your app so as not to conflict with
  232.     any others that may be on the users' system.  If you do rename the DLL, you
  233.     need to add a line of code to your main form's or project source (DPR) file
  234.     like this:
  235.  
  236.       DFSKbDLLName := 'MyMonitorDLL.DLL';
  237.  
  238.     You will also need the DFSKb unit in the uses clause for this to compile.
  239.     You can include path information, but it is not necessary if the DLL will
  240.     be in the system path or in the app's directory (suggested).  If
  241.     UseMonitorDLL will never be set to true, you can ignore this DLL and it will
  242.     NOT be needed by applications using TDFSStatusBar.
  243.  
  244.   * The sptDate, sptTime, sptTimeDate, sptDateTime, and sptGauge
  245.     (GaugeAttrs.Style = gsIndeterminate only) panels require the use of a timer.
  246.     Every effort has been made to be conservative with the resources, however.
  247.     The timer is only created when there is a panel that needs it, and then only
  248.     if the panel is enabled.  The timer is shared across all panels on a status
  249.     bar that need it, so if you have a sptDate, sptTime and
  250.     sptIndeterminateGauge on a status bar, there is still only one timer active.
  251.     Also, the interval of the timer event firing is adjusted according to what
  252.     kind of panels need it.  That is, if you have a sptTime and a sptDate panel,
  253.     the timer will fire once per second.  But, if you have only a sptDate (or
  254.     you disable sptTime), the timer interval is adjusted to fire less often.
  255.  
  256.   * Collection properties (i.e. TDFSStatusPanels) don't have a built-in Object
  257.     Inspector interface in Delphi 2 or C++Builder 1.   I'm really screwed here
  258.     because I DON'T want to write a big monster property editor for all of the
  259.     TDFSStatusPanel class just for D2/C1.  During beta testing, no one
  260.     complained about this, so I have decided not to do it.  If enough people
  261.     ask for a D2/C1 version, I will reconsider.
  262.  
  263.  
  264. Known Issues:
  265. -------------
  266.   * Key lock indicators don't get updated correctly when they are changed from
  267.     outside the app.  That is, if you change the state of the caps lock from
  268.     Notepad and then switch to the app with the statusbar, it does not update to
  269.     show the new state.  As best I can tell, this is a problem at the Windows
  270.     API level; more a design flaw than a bug.  GetKeyState (which is used to
  271.     find the toggled state of the indicator keys) is only updated as a thread
  272.     reads key messages from its queue, it does not actually go out and find out
  273.     what the real state is.  GetAsyncKeyState will go find the real state of
  274.     the key at the time of the call, but it will not return any information
  275.     about they toggled state; only up/down state and whether it has changed
  276.     since the last time it was called.  I experimented with using
  277.     GetAsyncKeyState when the app was deactivated and activated and checking to
  278.     see if the key state had changed, but there are problems with that as well.
  279.     GetAsyncKeyState seems to be system-wide, so it's only going to tell you if
  280.     the key state has changed since the last time ANYTHING called it, not just
  281.     your app.  The best I can do is force the indicator panels to update when
  282.     a key is pressed after the app is deactivaed and then activated again.  The
  283.     really strange part of all this is that it only happens if you use Alt-Tab
  284.     to task switch.  If you switch apps using the mouse, it works fine.  In my
  285.     defense, I offer this:  MS WordPad has this same bug.  :)  This only applies
  286.     if UseMonitorDLL is false.  If using the system wide hook (the DLL), the
  287.     indicators are monitored in every process, so the problem does not occur.
  288.  
  289.  
  290. Revision History:
  291. -----------------
  292.  
  293. 1.24: + Updated for Delphi 6 compatibility.  See updated install directions
  294.         above.
  295. 1.23: + Updated for C++Builder 5 compatibility.
  296. 1.22: + Fixed problem with taLeftJustify panel Alignment when used with the
  297.         last panel on a status bar.
  298.       + The resize grip will now draw in the same color as the status bar.
  299.         Before, it would only draw in clBtnFace (system) color regardless of
  300.         what color the rest of the status bar was.  Thanks to Eric Bole-Feysot
  301.         for sending me this code from a Usenet post. 
  302. 1.21: + sptDate, sptTime, sptDateTime, and sptTimeDate PanelTypes no longer
  303.         store the value of the Text property in the form file.  There was no
  304.         reason to store them, and one user reported it actually causing a
  305.         problem although I couldn't duplicate it.
  306. 1.20: + Added new panel type, sptTimeDate, and changed behavior of sptDateTime.
  307.         Now, sptDateTime shows the date and time in that order.  sptTimeDate
  308.         shows it in time/date order.  If you had panels of sptDateTime type,
  309.         you might want to change them to sptTimeDate.  sptDateTime was added by
  310.         Lars Black because it is often displayed that way where he's from.
  311.       + Added BorderWidth property to panels.  See docs above.
  312.       + sptGlyph panels now support text.  See docs above.
  313. 1.12: + It's *really* D5 compatible now.  Small change between the D5 eval
  314.         version and the real, shipping D5 version broke it.
  315. 1.11: + D5 compatibility.
  316. 1.10: + Added a new panel style gsIndeterminate2, and added three new GaugeAttrs
  317.         properties: Color, TextColor, and Speed.  See documentation above.
  318.         This is based on code sent to me by David Wright.  Many thanks to him
  319.         for sharing.
  320.       + Font.Color property was not honored.
  321. 1.01: + Right aligned text would draw right up to a panel's shadow.  It now
  322.         keeps a 1 pixel border between the text and the shadow.
  323. 1.00: + Initial public release
  324.