Unit CapBar

----------------------------------------------------------------- this is a component to provide applications with a gradient and buttons in the titlebar. i really wrote the code for this component on my own, but i took a lot of ideas from other free- warecomponents. first i had to learn how to handle the nonclient- area of a window and then i had to learn a lot of creating a propertyeditor for delphi. i'm not through with learning about it, but i think, this component is worth being released. if you have trouble with this component or ideas for enhancing it then you can contact me via e-mail at andreas.perlitz@btg-agb.isar.de or aperlitz@mail.augustanet.de ---------------------------------------------------------------- before we start i have to thank Brad Stowers for his help in making this component work. i wouldn't have been able to create it if he hadn't such an impressive deep knowledge of the Windows API and the readiness to share this knowledge with me. SANX A LOT! ---------------------------------------------------------------- i created this component with Delphi 1.0 under Windows NT. i know, i know, many people will think now that i am completely crazy, but i want my programs to run also under Windows 3.x (at least until Microsoft releases a better followup than Windows 95). but this is the reason why i cannot guarantee that it will work in every environment. so mnuch for pathos. let's go on: to install this component simply copy the files CAPBAR.PAS and CAPBARED.PAS in the path where Delphi looks for it's components (normally this will be C:\DELPHI\LIB). then go to OPTIONS in your Delphi-environment and choose INSTALL COMPONENT (or something that sounds like this, i only have the german version of Delphi). then select the file APCOMPS.PAS to add the component. that's all! okay, what can this component do? if it is activated (Enabled=True) then it paints the titlebar of the form on which it is placed with a gradient that is defined by ColorActiveLeft and ColorActiveRight (or ColorInActiveLeft and ColorInActiveRight if the form is inactive). the fading from color1 to color2 is done in as many steps as are given in the property GradientSteps. GradientWaves defines the number of fadings that should be done from left to right. if GradientSwap is true then the fading is done in real waves. i think this is a little confusing. so here is a little example: Left Color ist Black Right Color is Yellow GradientWaves is 0 with these settings you get a fading from black on the left to yellow on the right. if you set GradientWaves to 1 and GradientSwap to true then you get a fading from black on the left to yellow in the middle of the titlebar and back to black on the right. if you set GradientSwap to false then you get a fading from black on the left to yellow in the middle. then it again starts with black in the middle and fades to yellow on the right. did you get the picture? if not then just try it. another thing what this component does is to give you the ability to limit the size of the form to given values. these are MinWidth, MaxWidth, MinHeight and MaxHeight. this is enabled by setting LockSize to true (by default it is set to false). now you also have the ability to define buttons in the titlebar. you do this by clicking on the editbutton in the Buttonsproperty. a window will open with two lists. the left list contains the buttons that are displayed on the left side of the titlebar and the right list shows the buttons for the right side of the titlebar. you have add- and delete-buttons on top the lists (i think the function needs no explanation) and three buttons to change the order of the buttons (change from left to right, one row up and one row down). at the bottom of the lists is the closebutton for this editor. you can define how the buttons are displayed (colors, shape, font, caption), if they are enabled or disabled (disabled buttons are shown but they do not respond to mouseclicks) and if they are active or not. if the Active-property of a button is set to false then the button will not be shown. okay, i think this is enough. the other properties are explained in the sourcecode. don't try to understand all... bert the ;-

Classes

TTitleBar - the titlebar-component itself
TTitleButton - the definition for the buttons in the titlebar

Functions

Types

TButAlign
TCapAlign
TCapStr
TLimit

Constants

htTitleButton

Variables


Functions


Types


TButAlign=(baLeft,baRight);

TCapAlign=(caLeft,caCenter,caRight);

TCapStr=string[20]

TLimit = record
Left : integer;
Right : integer;
end;
the record for defining the limits in which the gradient is painted

Constants

htTitleButton = htSizeLast+50

this constant is used to identify if a button was hit with the mouse in the nca (nonclientarea) of the form. i added 50 to htSizeLast (which is the biggest value for the messagehandling on my system) to be sure that there is no greater value used by windows.

Variables