|
Вопрос # 549/ вопрос открыт / |
|
Здравствуйте, уважаемые эксперты! Спасибо за помощь, вы просто боги! Тогда вот вам еще вопрос. У меня есть фриварный компонент KWizard. Так вот в нем страницы листаются либо кнопкой с формы либо ENTERом с клавиатуры. Я залез в его исходники но никак не могу найти как у них реализовано через ENTER, ну все блин облазил, помогите!
Приложение: Переключить в обычный режим- {+---------------------------------------------------------------------------+
-
- | Unit Name: KWizard |
- +---------------------------------------------------------------------------+
- | Author: yu wei |
- | URL: http://members.rogers.com/wyu66/index.htm |
- | Email: william_yuwei@yahoo.com |
- | Date: December 30, 2001 |
- | Time: 15:59:46 |
- | Last Updated: Feburary 16, 2002 |
- | Purpose: Wizard VCL component |
- +---------------------------------------------------------------------------+
- | IMPORTANT: This is a freeware components, so you can use them any way. |
- | Please note that the component and software are provided |
- | "AS-IS" without warranty. |
- +---------------------------------------------------------------------------+
- | LICENCE AGREEMENT |
- +---------------------------------------------------------------------------+
- | THIS COMPONENT IS FREEWARE. IT IS FREE FOR COMMERICAL OR NON-COMMERICAL |
- | USE. BEFORE PROCEEDING WITH THE INSTALLATION AND/OR USE OF THIS |
- | COMPONENT, CAREFULLY READ THE FOLLOWING TERMS AND CONDITIONS OF THIS |
- | LICENSE AGREEMENT. |
- | |
- | BY INSTALLING OR USING THE COMPONENT YOU INDICATE YOUR ACCEPTANCE |
- | OF THIS AGREEMENT. IF YOU DO NOT ACCEPT OR AGREE WITH THESE TERMS, |
- | YOU MAY NOT INSTALL OR USE IT! |
- | |
- | DISTRIBUTION RIGHTS: |
- | |
- | YOU ARE GRANTED A NON-EXCISIVE, ROYALTY-FREE RIGHT TO PRODUCE AND |
- | DISTRIBUTE COMPILED BINARY FILES (EXE, DLLs, ETC.) THAT ARE BUILT |
- | WITH THIS COMPONENT. YOU ARE FURTHER GRANTED PERMISSION TO |
- | REDISTRIBUTE ANY OF MY SOURCE CODES, PROVIDED THAT THE ORIGINAL |
- | ARCHIVE AS FOUND ON MY WEB SITE IS DISTRIBUTED UNMODIFIED. FOR |
- | EXAMPLE, IF YOU CREATE A DESCENDANT OF THIS COMPONENET YOU MUST |
- | INCLUDE IN THE ORIGINAL COMPONENT IN YOUR DISTRIBUTION PACKAGE. |
- | |
- | RESTRICTIONS: |
- | |
- | WITHOUT THE EXPRESS WRITTEN CONSENT OF THE AUTHOR, YOU CANNOT: |
- | |
- | DISTRIBUTE MODIFIED VERSIONS OF MY SOURCES CODES. YOU MUST |
- | INCLUDE THE ORIGINAL ARCHIVE AS YOU FOUND IT AT MY WEB SITE. |
- | SELL OR LEASE ANY PORTION OF THIS SOURCE CODE. |
- | YOU ARE, OF COURSE FREE TO SELL ANY OF YOUR OWN ORIGINAL CODE |
- | THAT WORKS WITH, ENHANCES WITH IT. DISTRIBUTE THIS SOURCE CODE |
- | FOR PROFIT. |
- | |
- | WARRANTY: |
- | |
- | THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT WARRANTY. |
- | THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PRODUCT IS |
- | YOURS. SHOULD THE PRODUCT PROVE DEFECTIVE, YOU ASSUME THE COST OF |
- | ALL NECESSARY SERVICING OR ERROR CORRECTION. THE AUTHOR DON'T WARRANT |
- | THAT THE FUNCTIONS CONTAINED IN COMPONENT WILL MEET YOUR REQUIREMENTS |
- | OR THAT OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE. |
- | |
- | SUGGESTIONS, COMMENTS AND BUGS: |
- | |
- | Any suggestion, comment or bugs, please send to |
- | |
- | william_yuwei@yahoo.com |
- | |
- +---------------------------------------------------------------------------+
- | CONTRIBUTORS: |
- +---------------------------------------------------------------------------+
- | Steve Forbes <ozmosys@mira.net> |
- | Chris Macksey <c_macksey@hotmail.com> |
- | Wayne Niddery <waynen@logicfundamentals.com> |
- | Raymond J. Schappe <rschappe@isthmus-ts.com> |
- | Theodore <thpana@otenet.gr> |
- | Max Evans <max@codecraft.com.au> |
- +---------------------------------------------------------------------------+
- | HISTORY COMMENTS |
- +---------------------------------------------------------------------------+
- | 02/18/2002 OnStartButtonClick, OnLastButtonClick, OnNextButtonClick, |
- | OnBackButtonClick, OnFinishButtonClick, OnCancelButtonClick, |
- | is added for TKWizardCustomPage with a Stop parameter. |
- | |
- | Note: these page click events is called before the wizard |
- | button click events. |
- | |
- | 02/16/2002 Suggested by <Theodore>: |
- | 1) ModalResult property is added for TKWizardButton |
- | 2) Width property is added for TKWizardButton |
- | |
- | 02/12/2002 1) Suggested by <Max Evans>: |
- | Having the next/finish buttons to be the default |
- | button when a page shows. |
- | 2) Having the cancel button to be the default cancel button. |
- | |
- | 02/11/2002 1) CanDisplay function is added for TKWizardRouteMapControl. |
- | 2) OnDisplaying event is added for TKWizardRouteMapControl, |
- | so the route map can decide if it could display the page |
- | item or not. |
- | |
- | 02/10/2002 1) Introduce TKWizardImage class. |
- | 2) Clean up the code (TKWizardGraphicObject, |
- | TKWizardPageObject, ..., etc) |
- | 3) Now the TKWizardPageTitle is inherited from |
- | TKWizardGraphicObject(known as TKWizardPersistent |
- | in former). |
- | 4) Suggested by <Tim Schneider>: |
- | Controls in the wizard page with aligned set to |
- | something should be aligned properly without covering |
- | the page header as well as the watermark. Hint: |
- | overrided AdjustClientRect method is added for |
- | both TKWizardCustomPage and TKWizardWelcomePage. |
- | |
- | 02/09/2002 1) Finish button can be displayed separatly. |
- | 2) Bug fixed: Changing the value of EnabledButtons property |
- | of TKWizardCustomPage at run time doesn't refresh the |
- | buttons' status on the screen. |
- | |
- | 02/08/2002 Bug fixed: the OnEnterPage event is not triggled properly, |
- | they would be called at the time the wizard is loading |
- | them. 'not (csLoading in ComponentState)' added as the |
- | part of checking condition in SetActivePage method |
- | of TKWizard. |
- | |
- | 02/07/2002 VERSION 1.6 RELEASED |
- | |
- | 1) New property EnabledButtons and VisibleButtons added for |
- | TKWizardCustomPage, so the developers can customize |
- | buttons for each page at design time and run time. |
- | 2) Remove Enabled and Visible properties from |
- | TKWizardButton of TKWizard. |
- | |
- | 02/06/2002 1) Bug fixed: change TKWizardWelcomePage's color from |
- | clWindow to other colors or change |
- | TKWizardInteriorPage's color from other colors to |
- | clWindow, the pages won't display in correct color. |
- | Hint: |
- | By assigning default value of Color property in |
- | published section of TKWizardCustomPage and |
- | TKWizardWelcomePage class. |
- | 2) Suggested by <Steve Forbes>: |
- | ShowDivider added for TKWizardPageHeader to enable |
- | or disable drawing the page header divider. |
- | 3) Use Object.Free instead of FreeAndNil, |
- | Rectangle(ARect.Left, ...) instead of Rectangle(ARect), |
- | so we can support Delphi 4. |
- | |
- | 02/05/2002 1) Added by <Theodore>: |
- | ButtonHelp added for TKWizard. |
- | 2) RepositionButtons method of TKWizard is improved. |
- | |
- | 02/04/2002 function IsForward added, return true if FromPage is |
- | forward to ToPage, return false if FromPage is backward |
- | to ToPage. |
- | |
- | 02/03/2002 1) Bug fixed by <Theodore>: SelectPriorPage calls |
- | OnSelectFirstPage event rather the OnSelectPriorPage. |
- | 2) Suggested by <Theodore>: |
- | FromPage parameters added for OnEnterPage event, |
- | so the developers can detect from where it enters. |
- | 3) Suggested by <Theodore>: |
- | ToPage paramters added for OnExitPage event, so the |
- | developers can detect to where it exits. |
- | 4) Suggested by <Theodore>: |
- | OnExitPage event now is called just BEFORE (not after) |
- | the page is hidden and BEFORE the new page is actived. |
- | It provides the last chance to the developers to stop |
- | changing to the new page by raising a message. |
- | |
- | 02/02/2002 VERSION 1.5 RELEASED |
- | |
- | 1) DoAddPage, DoDeletePage, DoUpdatePage, DoMovePage added |
- | for TKWizardRouteMapControl |
- | 2) Overrided SetParent added for TKWizardRouteMapControl |
- | to detect if the parent is TKWizard or its descentants. |
- | 01/31/2002 1) Improved the RepositionButtons method of TKWizard, |
- | so all the buttons can be positioned properly regardless |
- | how their neighbors are. |
- | 2) CM_VisibleChanged message handler added for |
- | TKWizardButtonControl, so when the button is visible or |
- | invisible, it can make the rest buttons in proper |
- | position. |
- | |
- | 01/30/2002 1) Rename the methods of TKWizardRouteMapControl |
- | 2) WizardPageMoved method added for TKWizardRouteMapControl |
- | which fired after the order of the page changed. |
- | 3) OnPaintPage event added for TKWizardCustomPage, so |
- | the developers can custom draw the page. |
- | 4) A TKWizardCustomPage parameter added for IsFirstPage, |
- | IsLastPage of TKWizard to test if the specific page is |
- | the first page or the last page. |
- | 5) Buttons property added for TKWizardCustomPage, it can |
- | easily access all navigation buttons of TKWizard. |
- | 6) Improved the process to handle the button visible |
- | property in more efficent way. |
- | see UpdateButtonsStatus method of TKWizard |
- | |
- | 01/29/2002 1) Pages property added for TKWizard. |
- | 2) PageCount property added for TKWizard. |
- | 3) Page List Property Editor added for Pages property |
- | of TKWizard. From this property editor, we can |
- | |
- | a) Add new wizard pages. |
- | b) Remove selected pages. |
- | c) Drag drop selected page item to change pages' order. |
- | |
- | 01/28/2002 1) Bug fixed: if the current active page set to disabled, |
- | the wizard would not go to next page. |
- | 2) Page screen flicker problem solved by setting |
- | the DoubleBuffered property of TKWizardCustomPage |
- | to True. |
- | 3) ParentFont property added for TKWizardPageHeader. |
- | |
- | 01/27/2002 VERSION 1.5 BETA RELEASED |
- | |
- | 1) KWizard About form added by <Steve Forbes> |
- | Thanks for his great job !!!! |
- | 2) Improve the design time button function, press Back |
- | button at first page will forward to the last page. |
- | While press Next button at last page will forward to |
- | the first page. (See FindNextPage method in TKWizard) |
- | 3) Fixed AV when delete only one page in the wizard at |
- | design time. (see RemovePage method in TKWizard) |
- | 4) NumGlyphs property added for TKWizardNavigateButton by |
- | <Steve Forbes>, to solve the problem where the |
- | NumGlyphs property of the actual button always reset |
- | to 1 when it is created dynamically. |
- | 5) Layout property added for TKWizardNavigateButton. |
- | 6) Set ImageAlign property's default value of |
- | TKWizardPageHeader to waRight. |
- | |
- | 01/26/2002 1) Suggested by <Steve Forbes>: |
- | Anchors, AnchorPlacement, Indent property added for |
- | the text in TKWizardPageTitle. Remove Left, Top, |
- | Width, Height properties from TKWizardPageTitle. so |
- | it is much easiler to operate the title and subtitle. |
- | 2) Image property added for TKWizardCustomPage, |
- | both Welcome page and Interior page can display a |
- | background image. |
- | 3) Image property added for the TKWizardWaterMark. |
- | 4) ImageIndex, ImageAlign, ImageOffset property added for |
- | TKWizardPageHeader. the PageHeader use ImageIndex |
- | to retreive image from the header image list of |
- | TKWizard. |
- | |
- | 01/25/2002 VERSION 1.2 RELEASED |
- | |
- | Finally, KWizard has its offical icon!!! It is very cool! |
- | Thanks <Steve Forbes> for his great job !!!! |
- | |
- | 1) Move OnEnterPage, OnPage, OnExitPage event from TKWizard |
- | into TKWizardCustomPage. |
- | 2) TKWizardPagePanel added, suggested by <Steve Forbes>. |
- | 3) Glyph property added for TKWizardNavigateButton. |
- | 4) HeaderImages property added for TKWizard, it is an |
- | image list, which stores all the page header images. |
- | |
- | 01/24/2002 1) Rename TKWizardTitle to TKWizardPageTitle. |
- | 2) PaintTo method added for TKWizardWaterMark. |
- | PaintTo method added for TKWizardPageHeader. |
- | PainTo method added for TKWizardPageTitle. |
- | 3) Remove the DisplayPageHeader method from |
- | TKWizardCustomPage. |
- | 4) OnPage event added for TKWizard, fired after the page |
- | shows up. |
- | 5) Pages, PageCount, PageIndex property, and default code |
- | added for all virtual method for TKWizardRouteMapControl. |
- | 6) Compiler directive added, suggested |
- | by <Raymond J. Schappe>. |
- | 7) Handle Design time package and Run time package, |
- | package file name convenstion suggested by |
- | <Steve Forbes>: |
- | Design time package: KWizardD?.dpk (bpl, dcp, ...) |
- | Run time package: KWizardD?R.dbp (bpl, dcp, ...) |
- | here the ? = Delphi Version (5, 6, ..., etc) |
- | |
- | 01/23/2002 1) Start Page, Last Page buttons added for TKWizard, |
- | default they are invisible. |
- | 2) Visible property added for TKWizardNavigateButton. |
- | |
- | 01/22/2002 BorderWidth property added for TKWizardWaterMark, suggested |
- | by <Steve Forbes> |
- | |
- | 1) Remove the TKWizardButtonBar, now all the navigate |
- | buttons are located in the Wizard. Hint: |
- | Add overrided AdjustClientRect for TKWizard. |
- | 2) Bug fixed: Add csAcceptsControls control style into |
- | TKWizard, otherwise it won't accept other controls |
- | like KWizardRouteMap. |
- | 3) Bug fixed: TKWizard.GetChildren procedure, it won't |
- | display another controls (include KWizardRouteMap |
- | Control) even if the control is in the wizard. |
- | 4) Align property added for TKWizardRouteMap, so the |
- | KWizardRouteMap can display at either left or right |
- | side of the Wizard. |
- | 5) Align property added for TKWaterMark, so it can be |
- | displayed at either left or right side of Welcome Page. |
- | |
- | 01/21/2002 VERSION 1.1 RELEASED |
- | |
- | Suggested by <Chris Macksey>: |
- | |
- | 1) Add OnSelectNextPage, OnSelectPriorPage, |
- | OnSelectFirstPage, OnSelectLastPage events, so user can |
- | redirect the page try to go to. |
- | 2) Add OnEnterPage, triggled before the page shows up. |
- | Add OnExitPage, triggled after the page is hidded. |
- | |
- | 01/14/2002 1) Add ShowRouteMap property for the TKWizard. |
- | 2) Add destructor in the TKWizardRouteMap class to fix |
- | AV when browse pages after destroy the TKWizardRouteMap |
- | component. |
- | |
- | 01/13/2002 Make the TKWizardRouteMap as a separat new component |
- | so the user can design its own routemap and communicate |
- | with TKWizard smoothly. |
- | |
- | 01/12/2002 VERSION 1.0 RELEASED |
- | |
- | 1) Fixed by <Wayne Niddery> : |
- | Under certain circumstance, the Wizard did not always |
- | default to the first page. Add overrided |
- | Loaded method in the TKWizard class. |
- | 2) Restructure: add TKWizardHeader and TKWizardWaterMark, |
- | I hate to list all properites like: HeaderColor, |
- | HeaderWidth, HeaderVisible, ... etc. Instead, I group |
- | them together into particular class, and it can make |
- | the whole component has a very clean property |
- | structure. |
- | |
- | 01/11/2002 1) Add word break feature when display title and subtitle. |
- | 2) At Design time, display page name in the wizard page. |
- | 3) Let the TWizardCustomPage paint and fill its area first |
- | and let TWizardWelcomePage and TWizardInteriorPage |
- | do the rest. |
- | |
- | 01/10/2002 BETA VERSION RELEASED |
- | |
- | 1) Delete BackButton, NextButton, FinishButton, |
- | CancelButton property, instead of a Button array. |
- | 2) Introduce TKWizardBackButton, TKWizardNextButton, |
- | TKWizardFinishButton and TKWizardCancelButton Control |
- | 3) Add TKWizardTitle class, HeaderColor, HeaderHeight, |
- | HeaderVisible property for TKWizardCustomPage. |
- | 4) Add WaterMarkColor, WaterMarkWidth, WaterMarkVisible |
- | property for TKWizardWelcomePage. |
- | 5) Paint method of TKWizardWelcomPage improved, |
- | TKWizardInteriorPage, so they can display header |
- | as well as title and subtitle. |
- | |
- | 01/06/2002 1) Add TKWizardRouteMap, Improve all existing functions |
- | and class. |
- | 2) Add TKWizardCustomPage. |
- | |
- | 01/05/2002 1) Add TKWizardNavigateButton class. |
- | 2) Add BackButton, NextButton, FinishButton, |
- | CancelButton property for TKWizard. |
- | |
- | 01/04/2002 1) Add ShowDivider property for TKWizard. |
- | 2) Add GetButtonClick, SetButtonClick for TKWizardButtonBar. |
- | 3) Draw divider in fsGroove frame style. |
- | |
- | 12/30/2001 Initial create. |
- +---------------------------------------------------------------------------+
- | TODO LIST |
- +---------------------------------------------------------------------------+
- | Wizard page can be transparent |
- +---------------------------------------------------------------------------+}
-
- unit KWizard;
-
- interface
-
- {$I KOMPONENTS.INC}
-
- uses Windows, {$IFDEF DELPHI6}Types,{$ENDIF} Classes, Messages, SysUtils,
- Controls, Forms, Graphics, Buttons, ImgList, KCommon;
-
- type
- TKWizardAboutInfo = (KWizardAbout); // Added by <Steve Forbes>
- TKWizardAlign = alTop..alRight;
- TKWizardLeftRight = alLeft..alRight;
- TKWizardButtonKind = (bkStart, bkLast, bkBack, bkNext, bkFinish, bkCancel,
- bkHelp);
- TKWizardButtonSet = set of TKWizardButtonKind;
-
- const
- bkAllButtons = [bkStart, bkLast, bkBack, bkFinish, bkNext, bkCancel, bkHelp];
-
- type
- TKWizardCustomPage = class;
- TKWizard = class;
-
- TKWizardButtonControl = class(TBitBtn)
- private
- FWizard: TKWizard;
- FAlignment: TKWizardLeftRight;
- procedure CMVisibleChanged(var Msg: TMessage); message CM_VISIBLECHANGED;
- procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;
- protected
- property Wizard: TKWizard read FWizard write FWizard;
- property Alignment: TKWizardLeftRight read FAlignment write FAlignment;
- public
- constructor Create(AOwner: TComponent); override;
- end;
-
- TKWizardButtonControlClass = class of TKWizardButtonControl;
-
- { YW - The wrapper of the TKWizardButtonControl }
- TKWizardNavigateButton = class(TPersistent)
- private
- FControl: TKWizardButtonControl;
- procedure SetCaption(const Value: string);
- function GetCaption: string;
- function GetGlyph: TBitmap;
- procedure SetGlyph(const Value: TBitmap);
- function GetNumGlyphs: Integer;
- procedure SetNumGlyphs(const Value: Integer);
- function GetLayout: TButtonLayout;
- procedure SetLayout(const Value: TButtonLayout);
- function GetModalResult: TModalResult;
- procedure SetModalResult(const Value: TModalResult);
- function GetButtonWidth: Integer;
- procedure SetButtonWidth(const Value: Integer);
- protected
- property Control: TKWizardButtonControl
- read FControl write FControl;
- published
- property Glyph: TBitmap read GetGlyph write SetGlyph;
- property Caption: string read GetCaption write SetCaption;
- property NumGlyphs: Integer read GetNumGlyphs write SetNumGlyphs;
- property Layout: TButtonLayout read GetLayout write SetLayout;
- property ModalResult: TModalResult read GetModalResult write SetModalResult;
- property Width: Integer read GetButtonWidth write SetButtonWidth;
- end;
-
- TKWizardRouteMapDisplayEvent = procedure(Sender: TObject;
- const Page: TKWizardCustomPage; var AllowDisplay: Boolean) of object;
-
- { YW - TKWizardRouteMap base class }
- TKWizardRouteMapControl = class(TCustomControl)
- private
- FWizard: TKWizard;
- FAlign: TKWizardAlign;
- FPages: TList;
- FPageIndex: Integer;
- FOnDisplaying: TKWizardRouteMapDisplayEvent;
- function GetPage(Index: Integer): TKWizardCustomPage;
- function GetPageCount: Integer;
- procedure SetAlign(Value: TKWizardAlign);
- procedure SetPageIndex(Value: Integer);
- procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;
- procedure DoAddPage(const APage: TKWizardCustomPage);
- procedure DoDeletePage(const APage: TKWizardCustomPage);
- procedure DoUpdatePage(const APage: TKWizardCustomPage);
- procedure DoActivatePage(const APage: TKWizardCustomPage);
- procedure DoMovePage(const APage: TKWizardCustomPage; const OldIndex: Integer);
- protected
- procedure SetParent(AParent: TWinControl); override;
- procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
- X, Y: Integer); override;
- function PageAtPos(Pt: TPoint): TKWizardCustomPage; virtual;
- procedure WizardPageAdded(const APage: TKWizardCustomPage); virtual;
- procedure WizardPageDeleted(const APage: TKWizardCustomPage); virtual;
- procedure WizardPageUpdated(const APage: TKWizardCustomPage); virtual;
- procedure WizardPageActivated(const APage: TKWizardCustomPage); virtual;
- procedure WizardPageMoved(const APage: TKWizardCustomPage;
- const OldIndex: Integer); virtual;
- function CanDisplay(const APage: TKWizardCustomPage): Boolean; virtual;
- property Wizard: TKWizard read FWizard write FWizard;
- property Align: TKWizardAlign read FAlign write SetAlign default alLeft;
- property OnDisplaying: TKWizardRouteMapDisplayEvent
- read FOnDisplaying write FOnDisplaying;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- property Pages[Index: Integer]: TKWizardCustomPage read GetPage;
- property PageCount: Integer read GetPageCount;
- property PageIndex: Integer read FPageIndex write SetPageIndex;
- end;
-
- TKWizardImage = class(TPersistent)
- private
- FPicture: TPicture;
- FAlignment: TKImageAlignment;
- FLayout: TKImageLayout;
- FOnChange: TNotifyEvent;
- procedure SetPicture(Value: TPicture);
- procedure SetAlignment(Value: TKImageAlignment);
- procedure SetLayout(Value: TKImageLayout);
- function GetTransparent: Boolean;
- procedure SetTransparent(Value: Boolean);
- procedure SetOnChange(Value: TNotifyEvent);
- procedure DoChange;
- protected
- procedure PaintTo(const ACanvas: TCanvas; ARect: TRect);
- public
- constructor Create;
- destructor Destroy; override;
- property OnChange: TNotifyEvent read FOnChange write SetOnChange;
- published
- property Picture: TPicture read FPicture write SetPicture;
- property Alignment: TKImageAlignment read FAlignment write SetAlignment;
- property Layout: TKImageLayout read FLayout write SetLayout;
- property Transparent: Boolean read GetTransparent write SetTransparent;
- end;
-
- TKWizardGraphicObject = class(TPersistent)
- private
- FColor: TColor;
- FVisible: Boolean;
- procedure SetColor(Value: TColor);
- procedure SetVisible(Value: Boolean);
- protected
- procedure VisibleChanged; virtual;
- procedure ColorChanged; virtual;
- procedure DoChange; virtual; abstract;
- public
- constructor Create; virtual;
- procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); virtual; abstract;
- published
- property Color: TColor read FColor write SetColor;
- property Visible: Boolean read FVisible write SetVisible;
- end;
-
- TKWizardPageHeader = class;
-
- { YW - Wizard Page Title class }
- TKWizardPageTitle = class(TKWizardGraphicObject)
- private
- FWizardPageHeader: TKWizardPageHeader;
- FText: string;
- FAlignment: TAlignment;
- FAnchorPlacement: Integer;
- FAnchors: TAnchors;
- FIndent: Integer;
- FFont: TFont;
- procedure SetText(Value: string);
- procedure SetAlignment(Value: TAlignment);
- procedure SetAnchors(Value: TAnchors);
- procedure SetAnchorPlacement(Value: Integer);
- procedure SetIndent(Value: Integer);
- procedure SetFont(Value: TFont);
- procedure SetWizardPageHeader(Value: TKWizardPageHeader);
- procedure OnChange(Sender: TObject);
- procedure AdjustFont(const AFont: TFont);
- protected
- { YW - Get the area where the title text should be painted on. }
- function GetTextRect(const ACanvas: TCanvas;
- const ARect: TRect): TRect; virtual;
- procedure DoChange; override;
- property WizardPageHeader: TKWizardPageHeader
- read FWizardPageHeader write SetWizardPageHeader;
- public
- constructor Create; override;
- destructor Destroy; override;
- procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
- published
- property Text: string read FText write SetText;
- property Anchors: TAnchors read FAnchors write SetAnchors;
- property AnchorPlacement: Integer
- read FAnchorPlacement write SetAnchorPlacement;
- property Indent: Integer read FIndent write SetIndent;
- property Alignment: TAlignment read FAlignment write SetAlignment;
- property Font: TFont read FFont write SetFont;
- end;
-
- TKWizardPageObject = class(TKWizardGraphicObject)
- private
- FWizardPage: TKWizardCustomPage;
- procedure SetWizardPage(Value: TKWizardCustomPage);
- protected
- procedure Initialize; virtual;
- procedure DoChange; override;
- property WizardPage: TKWizardCustomPage read FWizardPage write SetWizardPage;
- end;
-
- { YW - Wizard Page Header class }
- TKWizardPageHeader = class(TKWizardPageObject)
- private
- FHeight: Integer;
- FParentFont: Boolean;
- FTitle: TKWizardPageTitle;
- FSubtitle: TKWizardPageTitle;
- FImageIndex: Integer;
- FImageOffset: Integer;
- FImageAlignment: TKImageLeftRight;
- FShowDivider: Boolean;
- procedure SetHeight(Value: Integer);
- procedure SetImageIndex(Value: Integer);
- procedure SetImageOffset(Value: Integer);
- procedure SetImageAlignment(Value: TKImageLeftRight);
- procedure SetParentFont(Value: Boolean);
- procedure SetShowDivider(Value: Boolean);
- procedure AdjustTitleFont;
- protected
- procedure VisibleChanged; override;
- procedure Initialize; override;
- { YW - the return value of ARect is the area where the title should be
- painted on. The result of GetImageRect is the image area. }
- function GetImageRect(const AImages: TCustomImageList;
- var ARect: TRect): TRect; virtual;
- public
- constructor Create; override;
- destructor Destroy; override;
- procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
- published
- property ImageIndex: Integer read FImageIndex write SetImageIndex;
- property ImageOffset: Integer read FImageOffset write SetImageOffset;
- property ImageAlignment: TKImageLeftRight
- read FImageAlignment write SetImageAlignment;
- property Height: Integer read FHeight write SetHeight;
- property ParentFont: Boolean read FParentFont write SetParentFont;
- property Title: TKWizardPageTitle read FTitle write FTitle;
- property Subtitle: TKWizardPageTitle read FSubtitle write FSubtitle;
- property ShowDivider: Boolean read FShowDivider write SetShowDivider;
- property Color;
- property Visible;
- end;
-
- { YW - Welcome Page's watermark class }
- TKWizardWaterMark = class(TKWizardPageObject)
- private
- FAlign: TKWizardLeftRight;
- FWidth: Integer;
- FBorderWidth: Integer;
- FImage: TKWizardImage;
- procedure SetWidth(Value: Integer);
- procedure SetBorderWidth(Value: Integer);
- procedure SetAlign(Value: TKWizardLeftRight);
- procedure ImageChanged(Sender: TObject);
- protected
- procedure VisibleChanged; override;
- public
- constructor Create; override;
- destructor Destroy; override;
- procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
- published
- property Align: TKWizardLeftRight read FAlign write SetAlign;
- property BorderWidth: Integer read FBorderWidth write SetBorderWidth;
- property Image: TKWizardImage read FImage write FImage;
- property Width: Integer read FWidth write SetWidth;
- property Color;
- property Visible;
- end;
-
- { YW - Wizard Page Panel class used by Wizard Custom Page }
- TKWizardPagePanel = class(TKWizardPageObject)
- private
- FBorderWidth: Word;
- procedure SetBorderWidth(Value: Word);
- public
- constructor Create; override;
- procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
- published
- property BorderWidth: Word read FBorderWidth write SetBorderWidth;
- property Color;
- property Visible;
- end;
-
- TKWizardPageClickEvent = procedure(Sender: TObject; var Stop: Boolean) of object;
- TKWizardPaintPageEvent = procedure(Sender: TObject; ACanvas: TCanvas;
- var ARect: TRect) of object;
- TKWizardChangePageEvent = procedure(Sender: TObject;
- const Page: TKWizardCustomPage) of object;
-
- { YW - Wizard Custom Page }
- TKWizardCustomPage = class(TCustomControl)
- private
- FWizard: TKWizard;
- FHeader: TKWizardPageHeader;
- FPanel: TKWizardPagePanel;
- FImage: TKWizardImage;
- FEnabledButtons: TKWizardButtonSet;
- FVisibleButtons: TKWizardButtonSet;
- FDrawing: Boolean;
- FOnPaintPage: TKWizardPaintPageEvent;
- FOnEnterPage: TKWizardChangePageEvent;
- FOnPage: TNotifyEvent;
- FOnExitPage: TKWizardChangePageEvent;
- FOnStartButtonClick: TKWizardPageClickEvent;
- FOnLastButtonClick: TKWizardPageClickEvent;
- FOnNextButtonClick: TKWizardPageClickEvent;
- FOnBackButtonClick: TKWizardPageClickEvent;
- FOnCancelButtonClick: TKWizardPageClickEvent;
- FOnFinishButtonClick: TKWizardPageClickEvent;
- function GetPageIndex: Integer;
- procedure SetPageIndex(const Value: Integer);
- procedure SetWizard(AWizard: TKWizard);
- procedure SetEnabledButtons(Value: TKWizardButtonSet);
- procedure SetVisibleButtons(Value: TKWizardButtonSet);
- procedure ImageChanged(Sender: TObject);
- procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND;
- procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
- procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
- procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
- protected
- procedure CreateParams(var Params: TCreateParams); override;
- procedure ReadState(Reader: TReader); override;
- procedure AdjustClientRect(var Rect: TRect); override;
- procedure Paint; override;
- { YW - DrawPage is called by paint method. all the derived page controls
- should call this method to paint itsself rather than the overrided
- paint method. }
- procedure DrawPage(ACanvas: TCanvas; var ARect: TRect); virtual;
- { YW - called before the page shows up. Page: From page }
- procedure Enter(const FromPage: TKWizardCustomPage); virtual;
- { YW - called after the page shows up. }
- procedure Done; virtual;
- { YW - called just before the page is hidden. Page: To page }
- procedure Exit(const ToPage: TKWizardCustomPage); virtual;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- property Wizard: TKWizard read FWizard write SetWizard;
- property PageIndex: Integer
- read GetPageIndex write SetPageIndex stored False;
- published
- property Header: TKWizardPageHeader read FHeader write FHeader;
- property Image: TKWizardImage read FImage write FImage;
- property Panel: TKWizardPagePanel read FPanel write FPanel;
- property EnabledButtons: TKWizardButtonSet
- read FEnabledButtons write SetEnabledButtons default bkAllButtons;
- property VisibleButtons: TKWizardButtonSet
- read FVisibleButtons write SetVisibleButtons
- default [bkBack, bkNext, bkCancel];
- property Color default clBtnFace;
- property Caption;
- property Enabled;
- property Font;
- property Left stored False;
- property Height stored False;
- property PopupMenu;
- property ShowHint;
- property Top stored False;
- property Width stored False;
- property OnEnterPage: TKWizardChangePageEvent
- read FOnEnterPage write FOnEnterPage;
- property OnPage: TNotifyEvent read FOnPage write FOnPage;
- property OnExitPage: TKWizardChangePageEvent
- read FOnExitPage write FOnExitPage;
- property OnPaintPage: TKWizardPaintPageEvent
- read FOnPaintPage write FOnPaintPage;
- property OnStartButtonClick: TKWizardPageClickEvent
- read FOnStartButtonClick write FOnStartButtonClick;
- property OnLastButtonClick: TKWizardPageClickEvent
- read FOnLastButtonClick write FOnLastButtonClick;
- property OnNextButtonClick: TKWizardPageClickEvent
- read FOnNextButtonClick write FOnNextButtonClick;
- property OnBackButtonClick: TKWizardPageClickEvent
- read FOnBackButtonClick write FOnBackButtonClick;
- property OnCancelButtonClick: TKWizardPageClickEvent
- read FOnCancelButtonClick write FOnCancelButtonClick;
- property OnFinishButtonClick: TKWizardPageClickEvent
- read FOnFinishButtonClick write FOnFinishButtonClick;
- end;
-
- { YW - Wizard Welcome Page }
- TKWizardWelcomePage = class(TKWizardCustomPage)
- private
- FWaterMark: TKWizardWaterMark;
- protected
- procedure AdjustClientRect(var Rect: TRect); override;
- procedure DrawPage(ACanvas: TCanvas; var ARect: TRect); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- published
- property Color default clWindow;
- property WaterMark: TKWizardWaterMark read FWaterMark write FWaterMark;
- end;
-
- { YW - Wizard Interior Page }
- TKWizardInteriorPage = class(TKWizardCustomPage)
- protected
- procedure DrawPage(ACanvas: TCanvas; var ARect: TRect); override;
- end;
-
- TKWizardSelectPageEvent = procedure(Sender: TObject;
- FromPage: TKWizardCustomPage; var ToPage: TKWizardCustomPage) of object;
-
- { YW - KWizard Page List }
- TKWizardPageList = class(TList)
- private
- FWizard: TKWizard;
- protected
- procedure Notify(Ptr: Pointer; Action: TListNotification); override;
- property Wizard: TKWizard read FWizard write FWizard;
- public
- destructor Destroy; override;
- end;
-
- { YW - KWizard Control }
- TKWizard = class(TCustomControl)
- private
- FPages: TKWizardPageList;
- FActivePage: TKWizardCustomPage;
- FRouteMap: TKWizardRouteMapControl;
- FNavigateButtons: array[TKWizardButtonKind] of TKWizardNavigateButton;
- FButtonBarHeight: Integer;
- FShowDivider: Boolean;
- FOnSelectNextPage: TKWizardSelectPageEvent;
- FOnSelectPriorPage: TKWizardSelectPageEvent;
- FOnSelectFirstPage: TKWizardSelectPageEvent;
- FOnSelectLastPage: TKWizardSelectPageEvent;
- FHeaderImages: TCustomImageList;
- FImageChangeLink: TChangeLink;
- FAboutInfo: TKWizardAboutInfo; // Add by Steve Forbes
- procedure SetShowDivider(Value: Boolean);
- function GetShowRouteMap: Boolean;
- procedure SetShowRouteMap(Value: Boolean);
- procedure SetButtonBarHeight(Value: Integer);
- procedure SetActivePage(Page: TKWizardCustomPage);
- procedure SetHeaderImages(Value: TCustomImageList);
- function GetButtonClick(const Index: TKWizardButtonKind): TNotifyEvent;
- procedure SetButtonClick(const Index: TKWizardButtonKind;
- const Value: TNotifyEvent);
- procedure ImageListChange(Sender: TObject);
- procedure CreateNavigateButtons;
- procedure ChangeActivePage(Page: TKWizardCustomPage);
- function GetActivePageIndex: Integer;
- procedure SetActivePageIndex(Value: Integer);
- function GetPageCount: Integer;
- procedure RepositionButtons;
- procedure UpdateButtonsStatus;
- procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
- procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
- procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
- protected
- procedure Loaded; override;
- procedure AdjustClientRect(var Rect: TRect); override;
- procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
- procedure ShowControl(AControl: TControl); override;
- procedure Paint; override;
- procedure Resize; override;
- procedure InsertPage(Page: TKWizardCustomPage);
- procedure RemovePage(Page: TKWizardCustomPage);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- function GetButtonControlClass(
- AKind: TKWizardButtonKind): TKWizardButtonControlClass; virtual;
- property ButtonBarHeight: Integer
- read FButtonBarHeight write SetButtonBarHeight;
- public
- constructor Create(AComponent: TComponent); override;
- destructor Destroy; override;
- procedure SelectPriorPage;
- procedure SelectNextPage;
- procedure SelectFirstPage;
- procedure SelectLastPage;
- function IsFirstPage(const APage: TKWizardCustomPage;
- CheckDisable: Boolean = True): Boolean;
- function IsLastPage(const APage: TKWizardCustomPage;
- CheckDisable: Boolean = True): Boolean;
- function FindNextPage(PageIndex: Integer; const Step: Integer = 1;
- CheckDisable: Boolean = True): TKWizardCustomPage;
- function IsForward(const FromPage, ToPage: TKWizardCustomPage): Boolean;
- property ActivePageIndex: Integer
- read GetActivePageIndex write SetActivePageIndex;
- property PageCount: Integer read GetPageCount;
- published
- property Pages: TKWizardPageList read FPages;
- property About: TKWizardAboutInfo // Add by Steve Forbes
- read FAboutInfo write FAboutInfo stored False;
- property ActivePage: TKWizardCustomPage
- read FActivePage write SetActivePage;
- property ButtonStart: TKWizardNavigateButton
- read FNavigateButtons[bkStart] write FNavigateButtons[bkStart];
- property ButtonLast: TKWizardNavigateButton
- read FNavigateButtons[bkLast] write FNavigateButtons[bkLast];
- property ButtonBack: TKWizardNavigateButton
- read FNavigateButtons[bkBack] write FNavigateButtons[bkBack];
- property ButtonNext: TKWizardNavigateButton
- read FNavigateButtons[bkNext] write FNavigateButtons[bkNext];
- property ButtonFinish: TKWizardNavigateButton
- read FNavigateButtons[bkFinish] write FNavigateButtons[bkFinish];
- property ButtonCancel: TKWizardNavigateButton
- read FNavigateButtons[bkCancel] write FNavigateButtons[bkCancel];
- property ButtonHelp: TKWizardNavigateButton
- read FNavigateButtons[bkHelp] write FNavigateButtons[bkHelp];
- property ShowDivider: Boolean
- read FShowDivider write SetShowDivider default True;
- property ShowRouteMap: Boolean
- read GetShowRouteMap write SetShowRouteMap;
- property HeaderImages: TCustomImageList
- read FHeaderImages write SetHeaderImages;
- property OnSelectFirstPage: TKWizardSelectPageEvent
- read FOnSelectFirstPage write FOnSelectFirstPage;
- property OnSelectLastPage: TKWizardSelectPageEvent
- read FOnSelectLastPage write FOnSelectLastPage;
- property OnSelectNextPage: TKWizardSelectPageEvent
- read FOnSelectNextPage write FOnSelectNextPage;
- property OnSelectPriorPage: TKWizardSelectPageEvent
- read FOnSelectPriorPage write FOnSelectPriorPage;
- property OnStartButtonClick: TNotifyEvent index bkStart
- read GetButtonClick write SetButtonClick;
- property OnLastButtonClick: TNotifyEvent index bkLast
- read GetButtonClick write SetButtonClick;
- property OnBackButtonClick: TNotifyEvent index bkBack
- read GetButtonClick write SetButtonClick;
- property OnNextButtonClick: TNotifyEvent index bkNext
- read GetButtonClick write SetButtonClick;
- property OnFinishButtonClick: TNotifyEvent index bkFinish
- read GetButtonClick write SetButtonClick;
- property OnCancelButtonClick: TNotifyEvent index bkCancel
- read GetButtonClick write SetButtonClick;
- property Color;
- property Font;
- property Enabled;
- property Visible;
- end;
-
- implementation
-
- const
-
- ciButtonWidth = 75;
- ciButtonHeight = 25;
- ciButtonBarHeight = 42;
- ciButtonPlacement = (ciButtonBarHeight - ciButtonHeight) div 2;
-
- resourcestring
-
- rsFirstButtonCaption = 'To &Start Page';
- rsLastButtonCaption = 'To &Last Page';
- rsBackButtonCaption = '< &Back';
- rsNextButtonCaption = '&Next >';
- rsCancelButtonCaption = 'Cancel';
- rsFinishButtonCaption = '&Finish';
- rsHelpButtonCaption = '&Help';
- rsWelcome = 'Welcome';
- rsTitle = 'Title';
- rsSubtitle = 'Subtitle';
- rsInvalidParentControl = 'The Parent should be TKWizard or its descendants.';
- rsInvalidWizardPage = 'Pages are belong to different wizard.';
-
- type
- EKWizard = class(Exception);
-
- { YW - First Button }
- TKWizardStartButton = class(TKWizardButtonControl)
- public
- constructor Create(AOwner: TComponent); override;
- procedure Click; override;
- end;
-
- { YW - Last Button }
- TKWizardLastButton = class(TKWizardButtonControl)
- public
- constructor Create(AOwner: TComponent); override;
- procedure Click; override;
- end;
-
- { YW - Back Button }
- TKWizardBackButton = class(TKWizardButtonControl)
- public
- constructor Create(AOwner: TComponent); override;
- procedure Click; override;
- end;
-
- { YW - Next Button }
- TKWizardNextButton = class(TKWizardButtonControl)
- public
- constructor Create(AOwner: TComponent); override;
- procedure Click; override;
- end;
-
- { YW - Finish Button }
- TKWizardFinishButton = class(TKWizardButtonControl)
- public
- constructor Create(AOwner: TComponent); override;
- procedure Click; override;
- end;
-
- { YW - Cancel Button }
- TKWizardCancelButton = class(TKWizardButtonControl)
- public
- constructor Create(AOwner: TComponent); override;
- procedure Click; override;
- end;
-
- { YW - Help Button }
- TKWizardHelpButton = class(TKWizardButtonControl)
- public
- constructor Create(AOwner: TComponent); override;
- procedure Click; override;
- end;
-
- { TKWizardButtonControl }
-
- constructor TKWizardButtonControl.Create(AOwner: TComponent);
- begin
- inherited;
- if csDesigning in ComponentState then
- begin
- {$IFDEF DELPHI6}
- { !!! YW - Add csClickEvents in order to fired the Click method
- at design time. It does NOT need at run time, otherwise it cause
- the OnClick event to be called twice. }
- ControlStyle := ControlStyle + [csClickEvents];
- {$ENDIF}
- ControlStyle := ControlStyle + [csNoDesignVisible];
- end;
- Kind := bkCustom;
- Anchors := [akRight, akBottom];
- end;
-
- procedure TKWizardButtonControl.CMDesignHitTest(var Msg: TCMDesignHitTest);
- begin
- inherited;
- if Enabled then
- begin
- Msg.Result := 1;
- end;
- end;
-
- procedure TKWizardButtonControl.CMVisibleChanged(var Msg: TMessage);
- begin
- inherited;
- if Assigned(FWizard) then
- begin
- FWizard.RepositionButtons;
- end;
- end;
-
- { TKWizardStartButton }
-
- constructor TKWizardStartButton.Create(AOwner: TComponent);
- begin
- inherited;
- Caption := rsFirstButtonCaption;
- Visible := False;
- Anchors := [akLeft, akBottom];
- Width := ciButtonWidth + 10;
- Alignment := alLeft;
- end;
-
- procedure TKWizardStartButton.Click;
- var
- Stop: Boolean;
- Page: TKWizardCustomPage;
- begin
- if Assigned(FWizard) then
- begin
- if not (csDesigning in ComponentState) then
- begin
- Stop := False;
- Page := FWizard.FActivePage;
- if Assigned(Page) and Assigned(Page.FOnStartButtonClick) then
- begin
- Page.FOnStartButtonClick(Page, Stop);
- end;
- if Stop then Exit;
- inherited;
- end;
- FWizard.SelectFirstPage;
- end;
- end;
-
- { TKWizardLastButton }
-
- constructor TKWizardLastButton.Create(AOwner: TComponent);
- begin
- inherited;
- Caption := rsLastButtonCaption;
- Visible := False;
- Anchors := [akLeft, akBottom];
- Width := ciButtonWidth + 10;
- Alignment := alLeft;
- end;
-
- procedure TKWizardLastButton.Click;
- var
- Stop: Boolean;
- Page: TKWizardCustomPage;
- begin
- if Assigned(FWizard) then
- begin
- if not (csDesigning in ComponentState) then
- begin
- Stop := False;
- Page := FWizard.FActivePage;
- if Assigned(Page) and Assigned(Page.FOnLastButtonClick) then
- begin
- Page.FOnLastButtonClick(Page, Stop);
- end;
- if Stop then Exit;
- inherited;
- end;
- FWizard.SelectLastPage;
- end;
- end;
-
- { TKWizardBackButton }
-
- constructor TKWizardBackButton.Create(AOwner: TComponent);
- begin
- inherited;
- Caption := rsBackButtonCaption;
- Enabled := False;
- Visible := True;
- Width := ciButtonWidth;
- Alignment := alRight;
- end;
-
- procedure TKWizardBackButton.Click;
- var
- Stop: Boolean;
- Page: TKWizardCustomPage;
- begin
- if Assigned(FWizard) then
- begin
- if not (csDesigning in ComponentState) then
- begin
- Stop := False;
- Page := FWizard.FActivePage;
- if Assigned(Page) and Assigned(Page.FOnBackButtonClick) then
- begin
- Page.FOnBackButtonClick(Page, Stop);
- end;
- if Stop then Exit;
- inherited;
- end;
- FWizard.SelectPriorPage;
- end;
- end;
-
- { TKWizardNextButton }
-
- constructor TKWizardNextButton.Create(AOwner: TComponent);
- begin
- inherited;
- Caption := rsNextButtonCaption;
- Enabled := False;
- Visible := True;
- Width := ciButtonWidth;
- Alignment := alRight;
- end;
-
- procedure TKWizardNextButton.Click;
- var
- Stop: Boolean;
- Page: TKWizardCustomPage;
- begin
- if Assigned(FWizard) then
- begin
- if not (csDesigning in ComponentState) then
- begin
- Stop := False;
- Page := FWizard.FActivePage;
- if Assigned(Page) and Assigned(Page.FOnNextButtonClick) then
- begin
- Page.FOnNextButtonClick(Page, Stop);
- end;
- if Stop then Exit;
- inherited;
- end;
- FWizard.SelectNextPage;
- end;
- end;
-
- { TKWizardFinishButton }
-
- constructor TKWizardFinishButton.Create(AOwner: TComponent);
- begin
- inherited;
- Caption := rsFinishButtonCaption;
- Visible := False;
- Width := ciButtonWidth;
- Alignment := alRight;
- end;
-
- procedure TKWizardFinishButton.Click;
- var
- Stop: Boolean;
- Page: TKWizardCustomPage;
- begin
- if not (csDesigning in ComponentState) and Assigned(FWizard) then
- begin
- Stop := False;
- Page := FWizard.FActivePage;
- if Assigned(Page) and Assigned(Page.FOnFinishButtonClick) then
- begin
- Page.FOnFinishButtonClick(Page, Stop);
- end;
- if Stop then Exit;
- inherited;
- end;
- end;
-
- { TKWizardCancelButton }
-
- constructor TKWizardCancelButton.Create(AOwner: TComponent);
- begin
- inherited;
- Caption := rsCancelButtonCaption;
- Visible := True;
- Cancel := True;
- Width := ciButtonWidth;
- Alignment := alRight;
- ModalResult := mrCancel;
- end;
-
- procedure TKWizardCancelButton.Click;
- var
- Stop: Boolean;
- Page: TKWizardCustomPage;
- begin
- if not (csDesigning in ComponentState) and Assigned(FWizard) then
- begin
- Stop := False;
- Page := FWizard.FActivePage;
- if Assigned(Page) and Assigned(Page.FOnCancelButtonClick) then
- begin
- Page.FOnCancelButtonClick(Page, Stop);
- end;
- if Stop then Exit;
- inherited;
- end;
- end;
-
- { TKWizardHelpButton }
-
- constructor TKWizardHelpButton.Create(AOwner: TComponent); // Added by Theodore
- begin
- inherited;
- Caption := rsHelpButtonCaption;
- Visible := False;
- Anchors := [akLeft, akBottom];
- Width := ciButtonWidth;
- Alignment := alLeft;
- end;
-
- procedure TKWizardHelpButton.Click; // Added by Theodore, Modified by Yu Wei
- var
- ID: THelpContext;
- begin
- ID := 0;
- if not (csDesigning in ComponentState) then
- begin
- if Assigned(FWizard) and Assigned(FWizard.ActivePage) then
- ID := FWizard.ActivePage.HelpContext
- else
- ID := GetParentForm(Self).HelpContext;
- end;
- if ID <> 0 then
- begin
- Application.HelpContext(ID);
- end;
- end;
-
- { TKWizardNavigateButton }
-
- function TKWizardNavigateButton.GetCaption: string;
- begin
- if Assigned(FControl) then
- Result := FControl.Caption
- else
- Result := '';
- end;
-
- function TKWizardNavigateButton.GetGlyph: TBitmap;
- begin
- if Assigned(FControl) then
- Result := FControl.Glyph
- else
- Result := nil;
- end;
-
- function TKWizardNavigateButton.GetLayout: TButtonLayout;
- begin
- if Assigned(FControl) then
- Result := FControl.Layout
- else
- Result := blGlyphLeft;
- end;
-
- function TKWizardNavigateButton.GetNumGlyphs: Integer;
- begin
- if Assigned(FControl) then
- Result := FControl.NumGlyphs
- else
- Result := 0;
- end;
-
- procedure TKWizardNavigateButton.SetCaption(const Value: string);
- begin
- if Assigned(FControl) then
- begin
- FControl.Caption := Value;
- end;
- end;
-
- procedure TKWizardNavigateButton.SetGlyph(const Value: TBitmap);
- begin
- if Assigned(FControl) then
- begin
- FControl.Glyph := Value;
- end;
- end;
-
- procedure TKWizardNavigateButton.SetNumGlyphs(const Value: Integer);
- begin
- if Assigned(FControl) then
- begin
- FControl.NumGlyphs := Value;
- end;
- end;
-
- procedure TKWizardNavigateButton.SetLayout(const Value: TButtonLayout);
- begin
- if Assigned(FControl) then
- begin
- FControl.Layout := Value;
- end;
- end;
-
- function TKWizardNavigateButton.GetModalResult: TModalResult;
- begin
- if Assigned(FControl) then
- Result := FControl.ModalResult
- else
- Result := mrNone;
- end;
-
- procedure TKWizardNavigateButton.SetModalResult(const Value: TModalResult);
- begin
- if Assigned(FControl) then
- begin
- FControl.ModalResult := Value;
- end;
- end;
-
- function TKWizardNavigateButton.GetButtonWidth: Integer;
- begin
- if Assigned(FControl) then
- Result := FControl.Width
- else
- Result := 0;
- end;
-
- procedure TKWizardNavigateButton.SetButtonWidth(const Value: Integer);
- begin
- if Assigned(FControl) and (FControl.Width <> Value) then
- begin
- FControl.Width := Value;
- if Assigned(FControl.FWizard) then
- begin
- FControl.FWizard.RepositionButtons;
- end;
- end;
- end;
-
- { TKWizardRouteMapControl }
-
- constructor TKWizardRouteMapControl.Create(AOwner: TComponent);
- begin
- inherited;
- { !!! YW - Add csNoDesignVisible in order to make it visible and invisible
- at design Time. }
- if csDesigning in ComponentState then
- begin
- ControlStyle := ControlStyle + [csNoDesignVisible];
- end;
- FAlign := alLeft;
- inherited Align := alLeft;
- TabStop := False;
- Width := 145;
- Visible := True;
- FPages := TList.Create;
- DoubleBuffered := True;
- end;
-
- destructor TKWizardRouteMapControl.Destroy;
- begin
- if Assigned(Wizard) then
- begin
- Wizard.FRouteMap := nil;
- end;
- FPages.Free;
- inherited;
- end;
-
- procedure TKWizardRouteMapControl.DoAddPage(const APage: TKWizardCustomPage);
- begin
- if Assigned(FWizard) then
- begin
- if Assigned(APage) and (FPages.IndexOf(APage) < 0) then
- begin
- FPages.Add(APage);
- end;
- WizardPageAdded(APage);
- end;
- end;
-
- procedure TKWizardRouteMapControl.DoDeletePage(const APage: TKWizardCustomPage);
- var
- i: Integer;
- begin
- if Assigned(FWizard) then
- begin
- if Assigned(APage) then
- begin
- i := FPages.Remove(APage);
- if FPageIndex = i then
- begin
- FPageIndex := -1;
- end;
- end;
- WizardPageDeleted(APage);
- end;
- end;
-
- procedure TKWizardRouteMapControl.DoActivatePage(const APage: TKWizardCustomPage);
- begin
- if Assigned(FWizard) then
- begin
- if Assigned(APage) then
- begin
- FPageIndex := FPages.IndexOf(APage);
- end;
- WizardPageActivated(APage);
- end;
- end;
-
- procedure TKWizardRouteMapControl.DoUpdatePage(const APage: TKWizardCustomPage);
- begin
- if Assigned(FWizard) then
- begin
- WizardPageUpdated(APage);
- end;
- end;
-
- procedure TKWizardRouteMapControl.DoMovePage(
- const APage: TKWizardCustomPage; const OldIndex: Integer);
- begin
- if Assigned(FWizard) then
- begin
- if Assigned(APage) then
- begin
- FPages.Move(OldIndex, APage.PageIndex);
- if OldIndex = FPageIndex then
- begin
- FPageIndex := APage.PageIndex;
- end;
- end;
- WizardPageMoved(APage, OldIndex);
- end;
- end;
-
- procedure TKWizardRouteMapControl.SetAlign(Value: TKWizardAlign);
- begin
- if FAlign <> Value then
- begin
- FAlign := Value;
- inherited Align := FAlign;
- end;
- end;
-
- function TKWizardRouteMapControl.GetPage(Index: Integer): TKWizardCustomPage;
- begin
- if (Index >= 0) and (Index < FPages.Count) then
- Result := TKWizardCustomPage(FPages[Index])
- else
- Result := nil;
- end;
-
- function TKWizardRouteMapControl.GetPageCount: Integer;
- begin
- Result := FPages.Count;
- end;
-
- procedure TKWizardRouteMapControl.SetPageIndex(Value: Integer);
- begin
- if (FPageIndex <> Value) and (Value >= 0) and (Value < PageCount) then
- begin
- FPageIndex := Value;
- if Assigned(FWizard) and (Pages[FPageIndex].Wizard = FWizard) then
- begin
- FWizard.SetActivePage(Pages[FPageI
|
Вопрос задал: егоров (статус: Посетитель)
Вопрос отправлен: 4 мая 2007, 10:06
Состояние вопроса: открыт, ответов: 1.
|
Ответ #1. Отвечает эксперт: Помфюк Владимир Степанович
Здравствуйте, егоров!
У кнопки свойство "Default" выставлено в True - вот и весь фокус (кнопка по умолчанию). Ещё есть похожее свойство Cancel - тогда кнопка будет на Escape реагировать.
Мини-форум вопроса
Мини-форум пуст.
Чтобы оставлять сообщения в мини-форумах, Вы должны авторизироваться на сайте.
|