📄 gradform.txt
字号:
TdfsGradientForm v2.03
Description:
A form that paints it's caption bar in a gradient pattern, like the new
Microsoft Office applications. It starts with black and moves gradually
to the system defined color.
Contact Information:
The lateset version will always be available on the web at:
http://www.delphifreestuff.com
If you have any questions, comments or suggestions, please use the Delphi
Free Stuff Support Forum at:
http://www.delphifreestuff.com/discus/
If, for some reason, you can not use the web-based support forum, you can
email me at bstowers@delphifreestuff.com. However, the support forum will
always take precedence over direct email since it provides a resource that
others can use when they have a problem. Every message posted to the forum
is emailed directly to this account, so emailing me directly will not get
your message to me any faster. It will only make the message less important
for me to respond to since only one person (you) is benefiting from it
instead of everyone interested. Having said all that, please do email me
directly if it is regarding something that isn't really support related,
i.e. just to say thanks (as novel as that idea is).
Installation:
Delphi 1:
* This class is not compatible with Delphi 1.
Delphi 2, C++Builder 1:
* Simply place the files in the directory of your choosing. There is no
component involved.
Delphi 3, 4, 5, C++Builder 3 & 4:
* Do one of the following:
+ Create a new package by selecting File | New and choosing Package from
the New tab in the dialog.
+ Open an existing package file. I suggest you do this if you already
have a package that you like to use for small, third party components.
I specifically have a package named "3rdParty.dpk" that I use for
small components that come from other people. Or, if you are using
several of my components, you might create a "DFS.dpk" package and
use it for all of my DFS components.
* In the resulting package window, click the Add button.
* In the Add dialog, on the Add Unit tab, enter the full path name of the
component's registration unit (the unit that ends with 'Reg.pas', i.e.
'BrowseDrReg.pas') and click OK.
* You may want to add the other source files (*.pas) to the package as
well in the same manner as you did the registration unit. While this is
not required, not doing it will cause compiler warnings when the package
is compiled. The component will function fine either way, but I
personally find the warnings very irritating and am not happy until
every compiler warning and hint is gone.
* If this package is new, or it has never been installed, click the
Install button in the package window. If this package is already
installed in Delphi, click the Compile button.
Note that this will NOT add any items to your component palette.
TdfsGradientForm is not a component, but a TForm descendant class. So,
instead of a component palette icon, you will instead have a new "DFS"
tab added to the Object Repository (File | New). If you prefer a tab
name other than "DFS", you can edit the sGradFormObjRepositoryPage and
sGradFormProjObjRepositoryPage constants in DSAMsgReg.pas and recompile
the package. Note that you can use the name of an existing tab
("Forms" for example) to have the items added there.
C++Builder 5 and up:
* Perform the "Delphi 3 and up, C++Builder 3 and up" steps above, except
for the last step (Compile or Install).
* Select the package the component has been added to, and choose
Project | Edit Option Source to open the package options in the editor.
* In the entry for PFLAGS, add the "-LUvcl50" option. For example:
<PFLAGS value="-$YD -$W -$O -v -JPHNE -M -LUvcl50"/>
* Perform the final step from above, Compile or Install.
* For Borland's official word on this situation, open the C++Builder help
file and search the index for "dsgnintf.dcu" and see the "Compiling
packages with DsgnIntf" section.
Delphi 6 and up:
* Perform the "Delphi 3, 4, 5, C++Builder 3 & 4" steps above, except
for the last step (Compile or Install).
* Add the DesignIDE package to the Requires list of the package into which
the component is being installed.
* Perform the final step from above, Compile or Install.
* This is necessary because of changes to the design-time support units
introduced in Delphi 6. For complete information, see the Del6New.hlp
file in your Delphi 6 Help directory. In the index, search for
"upgrade issues" and in the resulting list of topics, select the
"DsgnIntf renamed and related changes" topic.
Help File:
* Copy GradForm.Hlp to your Delphi\Help (or Builder\Help) directory.
* Edit the Delphi3.cnt (or Delphi4.cnt or bcb3.cnt) file and add the following
line to the Index section:
:Index TdfsGradientForm Reference=GradForm.hlp
Design-Time Access to TdfsGradientForm Properties:
NOTE: This information applies only to Delphi 3 and above, and C++Builder 3
and above. Previous versions of Delphi and C++Builder do NOT support
design-time access of TForm descendants. Sorry. You can still use
this class with those prior versions, you just won't have access to
the new properties at design-time.
* Create a new application project.
* Select File | New and choose the "DFS" tab in the Object Repository window.
* Select the "Gradient Form" item and click the OK button.
* You should now have a new TdfsGradientForm type form added to the project, and
when you select it all new properties should be visible in the IDE.
Adding Help to Delphi 2:
* Copy GradForm.Hlp and GradForm.Kwf to your Delphi\Help directory.
* Use the HelpInst tool included with Delphi to install the GradForm.Kwf
into Delphi.
Delphi 2 and C++Builder 1 Notes:
* The best way to use this form is to add it to your Object Repository.
Simply open this unit in Delphi (or C++Builder 1, right click on the form
and select Add To Repository. Then, when you want a TdfsGradientForm, you
just select it from the repository (File | New) and use the "Inherit"
option so you don't have to see all this code in your form.
Delphi 2: If you have existing forms that you want converted to gradient
forms in Delphi, simply add "GradForm" to your "Uses" clause, and change
your form's ancestor to TdfsGradientForm. An example:
Change:
TMyForm = class(TForm)
To:
TMyForm = class(TdfsGradientForm)
C++Builder 1: To convert existing forms, add the GradForm.pas file to the
project (using Project Manager), then open the form's header file and add:
#include "gradform.hpp"
above the form class declaration. Next, change the form's class declaraion:
Change:
class TForm1 : public TForm
To:
class TForm1 : public TdfsGradientForm
And finally, change the form's constructor in the source (.cpp) file:
Change:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
To:
__fastcall TForm1::TForm1(TComponent* Owner)
: TdfsGradientForm(Owner)
{
Developer's Notes:
* Special thanks go to Michiel Ouwehand of Epic MegaGames for the
clipping region tips (See the WMNCPaint method) and for pointing out
the DrawFrameControl API function (see the PaintCaptionButtons method).
* Be aware that this form has had some problems in MDI applications. I
think I have worked them out, but I suggest you test everything very
thoroughly. I used a small hack to do it (see GradClientWndProc).
* I've used strictly GDI calls for the painting in this component. No
TCanvas, TBitmap, TBrush, etc. This is because that although they are
extremely nice to use, they are not nearly as efficient. That's not a
slam on them. They have to be able to know how to do a lot of things,
and that requires overhead. I have a very specific set of things to do
here, and I am *very* interested in getting it to do it as fast as
possible, so I'm willing to sacrifice the convenience of the classes
for the speed of the API. One day I'll sit down and do a speed
comparison to see if I really gained that much this way. If you don't
understand the GDI calls, leave them alone, or use them to experiment
with in learning how to use them.
* This form will only work in the 32-bit world. I have used very few calls
that would prevent it from working on Delphi 1, so it will be fairly simple
to convert to Delphi 1, but there is a lot of stuff that would have to
be changed to make it look right. For instance, I paint an icon in the
left corner for the system menu. This is a Win95 style only. Also, I
allow for BorderStyles like bsToolWindow that don't exist in Delphi 1.
Converting to Delphi 1 could be done, and shouldn't be all that
difficult since all the painting routines should work fine except for
the icon painting, and you don't need that for Win 3.1x anyway.
I just don't do any Delphi 1 development any more, so I leave it to one
of you to implement. If you do, I would appreciate it if you could do
it using $IFDEF DFS_WIN32, and send me the changes so others can use it as
well.
Known Issues:
* Help file has not been updated from the 1.56 version, so it does not include
the new stuff. I'm switching help authoring tools and just don't have the
time at the moment to convert over the existing stuff into the new tool.
I will get it in a future version.
Revision History:
2.03: + Updated for Delphi 6 compatibility. See updated install directions
above.
2.02: + Updated for C++Builder 5 compatibility.
2.01: + Setting the BorderStyle property to bsNone would cause division by
zero exceptions. I'm not sure why you would do this since it results
in a form without a caption, but it's fixed anyway.
2.00: + Mikl髎 Kov醕s was kind enough to fix the known issue of the help
button not wanting to stay depressed.
+ Fixed problem of restore caption button only being pained on
minimized MDI child, not on any style child.
+ Some people still got a range check in the FillRectGradient function.
Should definitely be fixed now.
+ Added some new properties: Logo, InactiveLogo, LogoAlign, and
LogoLayered. These are based on code provided by Joe White. Many
thanks to him for sharing. These related properties are for
displaying an image on the caption. LogoLayered is probably the only
one that needs an explanation: If true, the caption text is drawn
over the logo, if false it is moved over next to it.
1.95: + It's *really* D5 compatible now. Small change between the D5 eval
version and the real, shipping D5 version broke it.
1.94: + Classname changed.
D5 compatibility.
1.93: + It was possible to get range check errors under D4 in the NC
painting (a very bad place for it to happen) because the underlying
HRGN type was changed in the RTL to an unsigned type and I wasn't
typecasting a WPARAM value. Fixed.
1.92: + Updated for C++Builder 4 compatibility.
1.91: + Cleaned up most of the {$IFDEF DFS_CPPB} stuff to make the code
easier to read/maintain. I always do the typecast now, which isn't
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -