Экспертная система Delphi.int.ru

Сообщество программистов
Общение, помощь, обмен опытом

Логин:
Пароль:
Регистрация | Забыли пароль?

Delphi.int.ru Expert

Другие разделы портала

Переход к вопросу:

#   

Статистика за сегодня:  


Лучшие эксперты

Подробнее »



Вопрос # 549

Раздел: Delphi » Прочее
/ вопрос открыт /

Здравствуйте, уважаемые эксперты! Спасибо за помощь, вы просто боги! Тогда вот вам еще вопрос. У меня есть фриварный компонент KWizard. Так вот в нем страницы листаются либо кнопкой с формы либо ENTERом с клавиатуры. Я залез в его исходники но никак не могу найти как у них реализовано через ENTER, ну все блин облазил, помогите!

Приложение:
  1. {+---------------------------------------------------------------------------+
  2.  
  3. | Unit Name: KWizard |
  4. +---------------------------------------------------------------------------+
  5. | Author: yu wei |
  6. | URL: http://members.rogers.com/wyu66/index.htm |
  7. | Email: william_yuwei@yahoo.com |
  8. | Date: December 30, 2001 |
  9. | Time: 15:59:46 |
  10. | Last Updated: Feburary 16, 2002 |
  11. | Purpose: Wizard VCL component |
  12. +---------------------------------------------------------------------------+
  13. | IMPORTANT: This is a freeware components, so you can use them any way. |
  14. | Please note that the component and software are provided |
  15. | "AS-IS" without warranty. |
  16. +---------------------------------------------------------------------------+
  17. | LICENCE AGREEMENT |
  18. +---------------------------------------------------------------------------+
  19. | THIS COMPONENT IS FREEWARE. IT IS FREE FOR COMMERICAL OR NON-COMMERICAL |
  20. | USE. BEFORE PROCEEDING WITH THE INSTALLATION AND/OR USE OF THIS |
  21. | COMPONENT, CAREFULLY READ THE FOLLOWING TERMS AND CONDITIONS OF THIS |
  22. | LICENSE AGREEMENT. |
  23. | |
  24. | BY INSTALLING OR USING THE COMPONENT YOU INDICATE YOUR ACCEPTANCE |
  25. | OF THIS AGREEMENT. IF YOU DO NOT ACCEPT OR AGREE WITH THESE TERMS, |
  26. | YOU MAY NOT INSTALL OR USE IT! |
  27. | |
  28. | DISTRIBUTION RIGHTS: |
  29. | |
  30. | YOU ARE GRANTED A NON-EXCISIVE, ROYALTY-FREE RIGHT TO PRODUCE AND |
  31. | DISTRIBUTE COMPILED BINARY FILES (EXE, DLLs, ETC.) THAT ARE BUILT |
  32. | WITH THIS COMPONENT. YOU ARE FURTHER GRANTED PERMISSION TO |
  33. | REDISTRIBUTE ANY OF MY SOURCE CODES, PROVIDED THAT THE ORIGINAL |
  34. | ARCHIVE AS FOUND ON MY WEB SITE IS DISTRIBUTED UNMODIFIED. FOR |
  35. | EXAMPLE, IF YOU CREATE A DESCENDANT OF THIS COMPONENET YOU MUST |
  36. | INCLUDE IN THE ORIGINAL COMPONENT IN YOUR DISTRIBUTION PACKAGE. |
  37. | |
  38. | RESTRICTIONS: |
  39. | |
  40. | WITHOUT THE EXPRESS WRITTEN CONSENT OF THE AUTHOR, YOU CANNOT: |
  41. | |
  42. | DISTRIBUTE MODIFIED VERSIONS OF MY SOURCES CODES. YOU MUST |
  43. | INCLUDE THE ORIGINAL ARCHIVE AS YOU FOUND IT AT MY WEB SITE. |
  44. | SELL OR LEASE ANY PORTION OF THIS SOURCE CODE. |
  45. | YOU ARE, OF COURSE FREE TO SELL ANY OF YOUR OWN ORIGINAL CODE |
  46. | THAT WORKS WITH, ENHANCES WITH IT. DISTRIBUTE THIS SOURCE CODE |
  47. | FOR PROFIT. |
  48. | |
  49. | WARRANTY: |
  50. | |
  51. | THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT WARRANTY. |
  52. | THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PRODUCT IS |
  53. | YOURS. SHOULD THE PRODUCT PROVE DEFECTIVE, YOU ASSUME THE COST OF |
  54. | ALL NECESSARY SERVICING OR ERROR CORRECTION. THE AUTHOR DON'T WARRANT |
  55. | THAT THE FUNCTIONS CONTAINED IN COMPONENT WILL MEET YOUR REQUIREMENTS |
  56. | OR THAT OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE. |
  57. | |
  58. | SUGGESTIONS, COMMENTS AND BUGS: |
  59. | |
  60. | Any suggestion, comment or bugs, please send to |
  61. | |
  62. | william_yuwei@yahoo.com |
  63. | |
  64. +---------------------------------------------------------------------------+
  65. | CONTRIBUTORS: |
  66. +---------------------------------------------------------------------------+
  67. | Steve Forbes <ozmosys@mira.net> |
  68. | Chris Macksey <c_macksey@hotmail.com> |
  69. | Wayne Niddery <waynen@logicfundamentals.com> |
  70. | Raymond J. Schappe <rschappe@isthmus-ts.com> |
  71. | Theodore <thpana@otenet.gr> |
  72. | Max Evans <max@codecraft.com.au> |
  73. +---------------------------------------------------------------------------+
  74. | HISTORY COMMENTS |
  75. +---------------------------------------------------------------------------+
  76. | 02/18/2002 OnStartButtonClick, OnLastButtonClick, OnNextButtonClick, |
  77. | OnBackButtonClick, OnFinishButtonClick, OnCancelButtonClick, |
  78. | is added for TKWizardCustomPage with a Stop parameter. |
  79. | |
  80. | Note: these page click events is called before the wizard |
  81. | button click events. |
  82. | |
  83. | 02/16/2002 Suggested by <Theodore>: |
  84. | 1) ModalResult property is added for TKWizardButton |
  85. | 2) Width property is added for TKWizardButton |
  86. | |
  87. | 02/12/2002 1) Suggested by <Max Evans>: |
  88. | Having the next/finish buttons to be the default |
  89. | button when a page shows. |
  90. | 2) Having the cancel button to be the default cancel button. |
  91. | |
  92. | 02/11/2002 1) CanDisplay function is added for TKWizardRouteMapControl. |
  93. | 2) OnDisplaying event is added for TKWizardRouteMapControl, |
  94. | so the route map can decide if it could display the page |
  95. | item or not. |
  96. | |
  97. | 02/10/2002 1) Introduce TKWizardImage class. |
  98. | 2) Clean up the code (TKWizardGraphicObject, |
  99. | TKWizardPageObject, ..., etc) |
  100. | 3) Now the TKWizardPageTitle is inherited from |
  101. | TKWizardGraphicObject(known as TKWizardPersistent |
  102. | in former). |
  103. | 4) Suggested by <Tim Schneider>: |
  104. | Controls in the wizard page with aligned set to |
  105. | something should be aligned properly without covering |
  106. | the page header as well as the watermark. Hint: |
  107. | overrided AdjustClientRect method is added for |
  108. | both TKWizardCustomPage and TKWizardWelcomePage. |
  109. | |
  110. | 02/09/2002 1) Finish button can be displayed separatly. |
  111. | 2) Bug fixed: Changing the value of EnabledButtons property |
  112. | of TKWizardCustomPage at run time doesn't refresh the |
  113. | buttons' status on the screen. |
  114. | |
  115. | 02/08/2002 Bug fixed: the OnEnterPage event is not triggled properly, |
  116. | they would be called at the time the wizard is loading |
  117. | them. 'not (csLoading in ComponentState)' added as the |
  118. | part of checking condition in SetActivePage method |
  119. | of TKWizard. |
  120. | |
  121. | 02/07/2002 VERSION 1.6 RELEASED |
  122. | |
  123. | 1) New property EnabledButtons and VisibleButtons added for |
  124. | TKWizardCustomPage, so the developers can customize |
  125. | buttons for each page at design time and run time. |
  126. | 2) Remove Enabled and Visible properties from |
  127. | TKWizardButton of TKWizard. |
  128. | |
  129. | 02/06/2002 1) Bug fixed: change TKWizardWelcomePage's color from |
  130. | clWindow to other colors or change |
  131. | TKWizardInteriorPage's color from other colors to |
  132. | clWindow, the pages won't display in correct color. |
  133. | Hint: |
  134. | By assigning default value of Color property in |
  135. | published section of TKWizardCustomPage and |
  136. | TKWizardWelcomePage class. |
  137. | 2) Suggested by <Steve Forbes>: |
  138. | ShowDivider added for TKWizardPageHeader to enable |
  139. | or disable drawing the page header divider. |
  140. | 3) Use Object.Free instead of FreeAndNil, |
  141. | Rectangle(ARect.Left, ...) instead of Rectangle(ARect), |
  142. | so we can support Delphi 4. |
  143. | |
  144. | 02/05/2002 1) Added by <Theodore>: |
  145. | ButtonHelp added for TKWizard. |
  146. | 2) RepositionButtons method of TKWizard is improved. |
  147. | |
  148. | 02/04/2002 function IsForward added, return true if FromPage is |
  149. | forward to ToPage, return false if FromPage is backward |
  150. | to ToPage. |
  151. | |
  152. | 02/03/2002 1) Bug fixed by <Theodore>: SelectPriorPage calls |
  153. | OnSelectFirstPage event rather the OnSelectPriorPage. |
  154. | 2) Suggested by <Theodore>: |
  155. | FromPage parameters added for OnEnterPage event, |
  156. | so the developers can detect from where it enters. |
  157. | 3) Suggested by <Theodore>: |
  158. | ToPage paramters added for OnExitPage event, so the |
  159. | developers can detect to where it exits. |
  160. | 4) Suggested by <Theodore>: |
  161. | OnExitPage event now is called just BEFORE (not after) |
  162. | the page is hidden and BEFORE the new page is actived. |
  163. | It provides the last chance to the developers to stop |
  164. | changing to the new page by raising a message. |
  165. | |
  166. | 02/02/2002 VERSION 1.5 RELEASED |
  167. | |
  168. | 1) DoAddPage, DoDeletePage, DoUpdatePage, DoMovePage added |
  169. | for TKWizardRouteMapControl |
  170. | 2) Overrided SetParent added for TKWizardRouteMapControl |
  171. | to detect if the parent is TKWizard or its descentants. |
  172. | 01/31/2002 1) Improved the RepositionButtons method of TKWizard, |
  173. | so all the buttons can be positioned properly regardless |
  174. | how their neighbors are. |
  175. | 2) CM_VisibleChanged message handler added for |
  176. | TKWizardButtonControl, so when the button is visible or |
  177. | invisible, it can make the rest buttons in proper |
  178. | position. |
  179. | |
  180. | 01/30/2002 1) Rename the methods of TKWizardRouteMapControl |
  181. | 2) WizardPageMoved method added for TKWizardRouteMapControl |
  182. | which fired after the order of the page changed. |
  183. | 3) OnPaintPage event added for TKWizardCustomPage, so |
  184. | the developers can custom draw the page. |
  185. | 4) A TKWizardCustomPage parameter added for IsFirstPage, |
  186. | IsLastPage of TKWizard to test if the specific page is |
  187. | the first page or the last page. |
  188. | 5) Buttons property added for TKWizardCustomPage, it can |
  189. | easily access all navigation buttons of TKWizard. |
  190. | 6) Improved the process to handle the button visible |
  191. | property in more efficent way. |
  192. | see UpdateButtonsStatus method of TKWizard |
  193. | |
  194. | 01/29/2002 1) Pages property added for TKWizard. |
  195. | 2) PageCount property added for TKWizard. |
  196. | 3) Page List Property Editor added for Pages property |
  197. | of TKWizard. From this property editor, we can |
  198. | |
  199. | a) Add new wizard pages. |
  200. | b) Remove selected pages. |
  201. | c) Drag drop selected page item to change pages' order. |
  202. | |
  203. | 01/28/2002 1) Bug fixed: if the current active page set to disabled, |
  204. | the wizard would not go to next page. |
  205. | 2) Page screen flicker problem solved by setting |
  206. | the DoubleBuffered property of TKWizardCustomPage |
  207. | to True. |
  208. | 3) ParentFont property added for TKWizardPageHeader. |
  209. | |
  210. | 01/27/2002 VERSION 1.5 BETA RELEASED |
  211. | |
  212. | 1) KWizard About form added by <Steve Forbes> |
  213. | Thanks for his great job !!!! |
  214. | 2) Improve the design time button function, press Back |
  215. | button at first page will forward to the last page. |
  216. | While press Next button at last page will forward to |
  217. | the first page. (See FindNextPage method in TKWizard) |
  218. | 3) Fixed AV when delete only one page in the wizard at |
  219. | design time. (see RemovePage method in TKWizard) |
  220. | 4) NumGlyphs property added for TKWizardNavigateButton by |
  221. | <Steve Forbes>, to solve the problem where the |
  222. | NumGlyphs property of the actual button always reset |
  223. | to 1 when it is created dynamically. |
  224. | 5) Layout property added for TKWizardNavigateButton. |
  225. | 6) Set ImageAlign property's default value of |
  226. | TKWizardPageHeader to waRight. |
  227. | |
  228. | 01/26/2002 1) Suggested by <Steve Forbes>: |
  229. | Anchors, AnchorPlacement, Indent property added for |
  230. | the text in TKWizardPageTitle. Remove Left, Top, |
  231. | Width, Height properties from TKWizardPageTitle. so |
  232. | it is much easiler to operate the title and subtitle. |
  233. | 2) Image property added for TKWizardCustomPage, |
  234. | both Welcome page and Interior page can display a |
  235. | background image. |
  236. | 3) Image property added for the TKWizardWaterMark. |
  237. | 4) ImageIndex, ImageAlign, ImageOffset property added for |
  238. | TKWizardPageHeader. the PageHeader use ImageIndex |
  239. | to retreive image from the header image list of |
  240. | TKWizard. |
  241. | |
  242. | 01/25/2002 VERSION 1.2 RELEASED |
  243. | |
  244. | Finally, KWizard has its offical icon!!! It is very cool! |
  245. | Thanks <Steve Forbes> for his great job !!!! |
  246. | |
  247. | 1) Move OnEnterPage, OnPage, OnExitPage event from TKWizard |
  248. | into TKWizardCustomPage. |
  249. | 2) TKWizardPagePanel added, suggested by <Steve Forbes>. |
  250. | 3) Glyph property added for TKWizardNavigateButton. |
  251. | 4) HeaderImages property added for TKWizard, it is an |
  252. | image list, which stores all the page header images. |
  253. | |
  254. | 01/24/2002 1) Rename TKWizardTitle to TKWizardPageTitle. |
  255. | 2) PaintTo method added for TKWizardWaterMark. |
  256. | PaintTo method added for TKWizardPageHeader. |
  257. | PainTo method added for TKWizardPageTitle. |
  258. | 3) Remove the DisplayPageHeader method from |
  259. | TKWizardCustomPage. |
  260. | 4) OnPage event added for TKWizard, fired after the page |
  261. | shows up. |
  262. | 5) Pages, PageCount, PageIndex property, and default code |
  263. | added for all virtual method for TKWizardRouteMapControl. |
  264. | 6) Compiler directive added, suggested |
  265. | by <Raymond J. Schappe>. |
  266. | 7) Handle Design time package and Run time package, |
  267. | package file name convenstion suggested by |
  268. | <Steve Forbes>: |
  269. | Design time package: KWizardD?.dpk (bpl, dcp, ...) |
  270. | Run time package: KWizardD?R.dbp (bpl, dcp, ...) |
  271. | here the ? = Delphi Version (5, 6, ..., etc) |
  272. | |
  273. | 01/23/2002 1) Start Page, Last Page buttons added for TKWizard, |
  274. | default they are invisible. |
  275. | 2) Visible property added for TKWizardNavigateButton. |
  276. | |
  277. | 01/22/2002 BorderWidth property added for TKWizardWaterMark, suggested |
  278. | by <Steve Forbes> |
  279. | |
  280. | 1) Remove the TKWizardButtonBar, now all the navigate |
  281. | buttons are located in the Wizard. Hint: |
  282. | Add overrided AdjustClientRect for TKWizard. |
  283. | 2) Bug fixed: Add csAcceptsControls control style into |
  284. | TKWizard, otherwise it won't accept other controls |
  285. | like KWizardRouteMap. |
  286. | 3) Bug fixed: TKWizard.GetChildren procedure, it won't |
  287. | display another controls (include KWizardRouteMap |
  288. | Control) even if the control is in the wizard. |
  289. | 4) Align property added for TKWizardRouteMap, so the |
  290. | KWizardRouteMap can display at either left or right |
  291. | side of the Wizard. |
  292. | 5) Align property added for TKWaterMark, so it can be |
  293. | displayed at either left or right side of Welcome Page. |
  294. | |
  295. | 01/21/2002 VERSION 1.1 RELEASED |
  296. | |
  297. | Suggested by <Chris Macksey>: |
  298. | |
  299. | 1) Add OnSelectNextPage, OnSelectPriorPage, |
  300. | OnSelectFirstPage, OnSelectLastPage events, so user can |
  301. | redirect the page try to go to. |
  302. | 2) Add OnEnterPage, triggled before the page shows up. |
  303. | Add OnExitPage, triggled after the page is hidded. |
  304. | |
  305. | 01/14/2002 1) Add ShowRouteMap property for the TKWizard. |
  306. | 2) Add destructor in the TKWizardRouteMap class to fix |
  307. | AV when browse pages after destroy the TKWizardRouteMap |
  308. | component. |
  309. | |
  310. | 01/13/2002 Make the TKWizardRouteMap as a separat new component |
  311. | so the user can design its own routemap and communicate |
  312. | with TKWizard smoothly. |
  313. | |
  314. | 01/12/2002 VERSION 1.0 RELEASED |
  315. | |
  316. | 1) Fixed by <Wayne Niddery> : |
  317. | Under certain circumstance, the Wizard did not always |
  318. | default to the first page. Add overrided |
  319. | Loaded method in the TKWizard class. |
  320. | 2) Restructure: add TKWizardHeader and TKWizardWaterMark, |
  321. | I hate to list all properites like: HeaderColor, |
  322. | HeaderWidth, HeaderVisible, ... etc. Instead, I group |
  323. | them together into particular class, and it can make |
  324. | the whole component has a very clean property |
  325. | structure. |
  326. | |
  327. | 01/11/2002 1) Add word break feature when display title and subtitle. |
  328. | 2) At Design time, display page name in the wizard page. |
  329. | 3) Let the TWizardCustomPage paint and fill its area first |
  330. | and let TWizardWelcomePage and TWizardInteriorPage |
  331. | do the rest. |
  332. | |
  333. | 01/10/2002 BETA VERSION RELEASED |
  334. | |
  335. | 1) Delete BackButton, NextButton, FinishButton, |
  336. | CancelButton property, instead of a Button array. |
  337. | 2) Introduce TKWizardBackButton, TKWizardNextButton, |
  338. | TKWizardFinishButton and TKWizardCancelButton Control |
  339. | 3) Add TKWizardTitle class, HeaderColor, HeaderHeight, |
  340. | HeaderVisible property for TKWizardCustomPage. |
  341. | 4) Add WaterMarkColor, WaterMarkWidth, WaterMarkVisible |
  342. | property for TKWizardWelcomePage. |
  343. | 5) Paint method of TKWizardWelcomPage improved, |
  344. | TKWizardInteriorPage, so they can display header |
  345. | as well as title and subtitle. |
  346. | |
  347. | 01/06/2002 1) Add TKWizardRouteMap, Improve all existing functions |
  348. | and class. |
  349. | 2) Add TKWizardCustomPage. |
  350. | |
  351. | 01/05/2002 1) Add TKWizardNavigateButton class. |
  352. | 2) Add BackButton, NextButton, FinishButton, |
  353. | CancelButton property for TKWizard. |
  354. | |
  355. | 01/04/2002 1) Add ShowDivider property for TKWizard. |
  356. | 2) Add GetButtonClick, SetButtonClick for TKWizardButtonBar. |
  357. | 3) Draw divider in fsGroove frame style. |
  358. | |
  359. | 12/30/2001 Initial create. |
  360. +---------------------------------------------------------------------------+
  361. | TODO LIST |
  362. +---------------------------------------------------------------------------+
  363. | Wizard page can be transparent |
  364. +---------------------------------------------------------------------------+}
  365.  
  366. unit KWizard;
  367.  
  368. interface
  369.  
  370. {$I KOMPONENTS.INC}
  371.  
  372. uses Windows, {$IFDEF DELPHI6}Types,{$ENDIF} Classes, Messages, SysUtils,
  373. Controls, Forms, Graphics, Buttons, ImgList, KCommon;
  374.  
  375. type
  376. TKWizardAboutInfo = (KWizardAbout); // Added by <Steve Forbes>
  377. TKWizardAlign = alTop..alRight;
  378. TKWizardLeftRight = alLeft..alRight;
  379. TKWizardButtonKind = (bkStart, bkLast, bkBack, bkNext, bkFinish, bkCancel,
  380. bkHelp);
  381. TKWizardButtonSet = set of TKWizardButtonKind;
  382.  
  383. const
  384. bkAllButtons = [bkStart, bkLast, bkBack, bkFinish, bkNext, bkCancel, bkHelp];
  385.  
  386. type
  387. TKWizardCustomPage = class;
  388. TKWizard = class;
  389.  
  390. TKWizardButtonControl = class(TBitBtn)
  391. private
  392. FWizard: TKWizard;
  393. FAlignment: TKWizardLeftRight;
  394. procedure CMVisibleChanged(var Msg: TMessage); message CM_VISIBLECHANGED;
  395. procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;
  396. protected
  397. property Wizard: TKWizard read FWizard write FWizard;
  398. property Alignment: TKWizardLeftRight read FAlignment write FAlignment;
  399. public
  400. constructor Create(AOwner: TComponent); override;
  401. end;
  402.  
  403. TKWizardButtonControlClass = class of TKWizardButtonControl;
  404.  
  405. { YW - The wrapper of the TKWizardButtonControl }
  406. TKWizardNavigateButton = class(TPersistent)
  407. private
  408. FControl: TKWizardButtonControl;
  409. procedure SetCaption(const Value: string);
  410. function GetCaption: string;
  411. function GetGlyph: TBitmap;
  412. procedure SetGlyph(const Value: TBitmap);
  413. function GetNumGlyphs: Integer;
  414. procedure SetNumGlyphs(const Value: Integer);
  415. function GetLayout: TButtonLayout;
  416. procedure SetLayout(const Value: TButtonLayout);
  417. function GetModalResult: TModalResult;
  418. procedure SetModalResult(const Value: TModalResult);
  419. function GetButtonWidth: Integer;
  420. procedure SetButtonWidth(const Value: Integer);
  421. protected
  422. property Control: TKWizardButtonControl
  423. read FControl write FControl;
  424. published
  425. property Glyph: TBitmap read GetGlyph write SetGlyph;
  426. property Caption: string read GetCaption write SetCaption;
  427. property NumGlyphs: Integer read GetNumGlyphs write SetNumGlyphs;
  428. property Layout: TButtonLayout read GetLayout write SetLayout;
  429. property ModalResult: TModalResult read GetModalResult write SetModalResult;
  430. property Width: Integer read GetButtonWidth write SetButtonWidth;
  431. end;
  432.  
  433. TKWizardRouteMapDisplayEvent = procedure(Sender: TObject;
  434. const Page: TKWizardCustomPage; var AllowDisplay: Boolean) of object;
  435.  
  436. { YW - TKWizardRouteMap base class }
  437. TKWizardRouteMapControl = class(TCustomControl)
  438. private
  439. FWizard: TKWizard;
  440. FAlign: TKWizardAlign;
  441. FPages: TList;
  442. FPageIndex: Integer;
  443. FOnDisplaying: TKWizardRouteMapDisplayEvent;
  444. function GetPage(Index: Integer): TKWizardCustomPage;
  445. function GetPageCount: Integer;
  446. procedure SetAlign(Value: TKWizardAlign);
  447. procedure SetPageIndex(Value: Integer);
  448. procedure CMDesignHitTest(var Msg: TCMDesignHitTest); message CM_DESIGNHITTEST;
  449. procedure DoAddPage(const APage: TKWizardCustomPage);
  450. procedure DoDeletePage(const APage: TKWizardCustomPage);
  451. procedure DoUpdatePage(const APage: TKWizardCustomPage);
  452. procedure DoActivatePage(const APage: TKWizardCustomPage);
  453. procedure DoMovePage(const APage: TKWizardCustomPage; const OldIndex: Integer);
  454. protected
  455. procedure SetParent(AParent: TWinControl); override;
  456. procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
  457. X, Y: Integer); override;
  458. function PageAtPos(Pt: TPoint): TKWizardCustomPage; virtual;
  459. procedure WizardPageAdded(const APage: TKWizardCustomPage); virtual;
  460. procedure WizardPageDeleted(const APage: TKWizardCustomPage); virtual;
  461. procedure WizardPageUpdated(const APage: TKWizardCustomPage); virtual;
  462. procedure WizardPageActivated(const APage: TKWizardCustomPage); virtual;
  463. procedure WizardPageMoved(const APage: TKWizardCustomPage;
  464. const OldIndex: Integer); virtual;
  465. function CanDisplay(const APage: TKWizardCustomPage): Boolean; virtual;
  466. property Wizard: TKWizard read FWizard write FWizard;
  467. property Align: TKWizardAlign read FAlign write SetAlign default alLeft;
  468. property OnDisplaying: TKWizardRouteMapDisplayEvent
  469. read FOnDisplaying write FOnDisplaying;
  470. public
  471. constructor Create(AOwner: TComponent); override;
  472. destructor Destroy; override;
  473. property Pages[Index: Integer]: TKWizardCustomPage read GetPage;
  474. property PageCount: Integer read GetPageCount;
  475. property PageIndex: Integer read FPageIndex write SetPageIndex;
  476. end;
  477.  
  478. TKWizardImage = class(TPersistent)
  479. private
  480. FPicture: TPicture;
  481. FAlignment: TKImageAlignment;
  482. FLayout: TKImageLayout;
  483. FOnChange: TNotifyEvent;
  484. procedure SetPicture(Value: TPicture);
  485. procedure SetAlignment(Value: TKImageAlignment);
  486. procedure SetLayout(Value: TKImageLayout);
  487. function GetTransparent: Boolean;
  488. procedure SetTransparent(Value: Boolean);
  489. procedure SetOnChange(Value: TNotifyEvent);
  490. procedure DoChange;
  491. protected
  492. procedure PaintTo(const ACanvas: TCanvas; ARect: TRect);
  493. public
  494. constructor Create;
  495. destructor Destroy; override;
  496. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  497. published
  498. property Picture: TPicture read FPicture write SetPicture;
  499. property Alignment: TKImageAlignment read FAlignment write SetAlignment;
  500. property Layout: TKImageLayout read FLayout write SetLayout;
  501. property Transparent: Boolean read GetTransparent write SetTransparent;
  502. end;
  503.  
  504. TKWizardGraphicObject = class(TPersistent)
  505. private
  506. FColor: TColor;
  507. FVisible: Boolean;
  508. procedure SetColor(Value: TColor);
  509. procedure SetVisible(Value: Boolean);
  510. protected
  511. procedure VisibleChanged; virtual;
  512. procedure ColorChanged; virtual;
  513. procedure DoChange; virtual; abstract;
  514. public
  515. constructor Create; virtual;
  516. procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); virtual; abstract;
  517. published
  518. property Color: TColor read FColor write SetColor;
  519. property Visible: Boolean read FVisible write SetVisible;
  520. end;
  521.  
  522. TKWizardPageHeader = class;
  523.  
  524. { YW - Wizard Page Title class }
  525. TKWizardPageTitle = class(TKWizardGraphicObject)
  526. private
  527. FWizardPageHeader: TKWizardPageHeader;
  528. FText: string;
  529. FAlignment: TAlignment;
  530. FAnchorPlacement: Integer;
  531. FAnchors: TAnchors;
  532. FIndent: Integer;
  533. FFont: TFont;
  534. procedure SetText(Value: string);
  535. procedure SetAlignment(Value: TAlignment);
  536. procedure SetAnchors(Value: TAnchors);
  537. procedure SetAnchorPlacement(Value: Integer);
  538. procedure SetIndent(Value: Integer);
  539. procedure SetFont(Value: TFont);
  540. procedure SetWizardPageHeader(Value: TKWizardPageHeader);
  541. procedure OnChange(Sender: TObject);
  542. procedure AdjustFont(const AFont: TFont);
  543. protected
  544. { YW - Get the area where the title text should be painted on. }
  545. function GetTextRect(const ACanvas: TCanvas;
  546. const ARect: TRect): TRect; virtual;
  547. procedure DoChange; override;
  548. property WizardPageHeader: TKWizardPageHeader
  549. read FWizardPageHeader write SetWizardPageHeader;
  550. public
  551. constructor Create; override;
  552. destructor Destroy; override;
  553. procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
  554. published
  555. property Text: string read FText write SetText;
  556. property Anchors: TAnchors read FAnchors write SetAnchors;
  557. property AnchorPlacement: Integer
  558. read FAnchorPlacement write SetAnchorPlacement;
  559. property Indent: Integer read FIndent write SetIndent;
  560. property Alignment: TAlignment read FAlignment write SetAlignment;
  561. property Font: TFont read FFont write SetFont;
  562. end;
  563.  
  564. TKWizardPageObject = class(TKWizardGraphicObject)
  565. private
  566. FWizardPage: TKWizardCustomPage;
  567. procedure SetWizardPage(Value: TKWizardCustomPage);
  568. protected
  569. procedure Initialize; virtual;
  570. procedure DoChange; override;
  571. property WizardPage: TKWizardCustomPage read FWizardPage write SetWizardPage;
  572. end;
  573.  
  574. { YW - Wizard Page Header class }
  575. TKWizardPageHeader = class(TKWizardPageObject)
  576. private
  577. FHeight: Integer;
  578. FParentFont: Boolean;
  579. FTitle: TKWizardPageTitle;
  580. FSubtitle: TKWizardPageTitle;
  581. FImageIndex: Integer;
  582. FImageOffset: Integer;
  583. FImageAlignment: TKImageLeftRight;
  584. FShowDivider: Boolean;
  585. procedure SetHeight(Value: Integer);
  586. procedure SetImageIndex(Value: Integer);
  587. procedure SetImageOffset(Value: Integer);
  588. procedure SetImageAlignment(Value: TKImageLeftRight);
  589. procedure SetParentFont(Value: Boolean);
  590. procedure SetShowDivider(Value: Boolean);
  591. procedure AdjustTitleFont;
  592. protected
  593. procedure VisibleChanged; override;
  594. procedure Initialize; override;
  595. { YW - the return value of ARect is the area where the title should be
  596. painted on. The result of GetImageRect is the image area. }
  597. function GetImageRect(const AImages: TCustomImageList;
  598. var ARect: TRect): TRect; virtual;
  599. public
  600. constructor Create; override;
  601. destructor Destroy; override;
  602. procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
  603. published
  604. property ImageIndex: Integer read FImageIndex write SetImageIndex;
  605. property ImageOffset: Integer read FImageOffset write SetImageOffset;
  606. property ImageAlignment: TKImageLeftRight
  607. read FImageAlignment write SetImageAlignment;
  608. property Height: Integer read FHeight write SetHeight;
  609. property ParentFont: Boolean read FParentFont write SetParentFont;
  610. property Title: TKWizardPageTitle read FTitle write FTitle;
  611. property Subtitle: TKWizardPageTitle read FSubtitle write FSubtitle;
  612. property ShowDivider: Boolean read FShowDivider write SetShowDivider;
  613. property Color;
  614. property Visible;
  615. end;
  616.  
  617. { YW - Welcome Page's watermark class }
  618. TKWizardWaterMark = class(TKWizardPageObject)
  619. private
  620. FAlign: TKWizardLeftRight;
  621. FWidth: Integer;
  622. FBorderWidth: Integer;
  623. FImage: TKWizardImage;
  624. procedure SetWidth(Value: Integer);
  625. procedure SetBorderWidth(Value: Integer);
  626. procedure SetAlign(Value: TKWizardLeftRight);
  627. procedure ImageChanged(Sender: TObject);
  628. protected
  629. procedure VisibleChanged; override;
  630. public
  631. constructor Create; override;
  632. destructor Destroy; override;
  633. procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
  634. published
  635. property Align: TKWizardLeftRight read FAlign write SetAlign;
  636. property BorderWidth: Integer read FBorderWidth write SetBorderWidth;
  637. property Image: TKWizardImage read FImage write FImage;
  638. property Width: Integer read FWidth write SetWidth;
  639. property Color;
  640. property Visible;
  641. end;
  642.  
  643. { YW - Wizard Page Panel class used by Wizard Custom Page }
  644. TKWizardPagePanel = class(TKWizardPageObject)
  645. private
  646. FBorderWidth: Word;
  647. procedure SetBorderWidth(Value: Word);
  648. public
  649. constructor Create; override;
  650. procedure PaintTo(ACanvas: TCanvas; var ARect: TRect); override;
  651. published
  652. property BorderWidth: Word read FBorderWidth write SetBorderWidth;
  653. property Color;
  654. property Visible;
  655. end;
  656.  
  657. TKWizardPageClickEvent = procedure(Sender: TObject; var Stop: Boolean) of object;
  658. TKWizardPaintPageEvent = procedure(Sender: TObject; ACanvas: TCanvas;
  659. var ARect: TRect) of object;
  660. TKWizardChangePageEvent = procedure(Sender: TObject;
  661. const Page: TKWizardCustomPage) of object;
  662.  
  663. { YW - Wizard Custom Page }
  664. TKWizardCustomPage = class(TCustomControl)
  665. private
  666. FWizard: TKWizard;
  667. FHeader: TKWizardPageHeader;
  668. FPanel: TKWizardPagePanel;
  669. FImage: TKWizardImage;
  670. FEnabledButtons: TKWizardButtonSet;
  671. FVisibleButtons: TKWizardButtonSet;
  672. FDrawing: Boolean;
  673. FOnPaintPage: TKWizardPaintPageEvent;
  674. FOnEnterPage: TKWizardChangePageEvent;
  675. FOnPage: TNotifyEvent;
  676. FOnExitPage: TKWizardChangePageEvent;
  677. FOnStartButtonClick: TKWizardPageClickEvent;
  678. FOnLastButtonClick: TKWizardPageClickEvent;
  679. FOnNextButtonClick: TKWizardPageClickEvent;
  680. FOnBackButtonClick: TKWizardPageClickEvent;
  681. FOnCancelButtonClick: TKWizardPageClickEvent;
  682. FOnFinishButtonClick: TKWizardPageClickEvent;
  683. function GetPageIndex: Integer;
  684. procedure SetPageIndex(const Value: Integer);
  685. procedure SetWizard(AWizard: TKWizard);
  686. procedure SetEnabledButtons(Value: TKWizardButtonSet);
  687. procedure SetVisibleButtons(Value: TKWizardButtonSet);
  688. procedure ImageChanged(Sender: TObject);
  689. procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND;
  690. procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
  691. procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
  692. procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
  693. protected
  694. procedure CreateParams(var Params: TCreateParams); override;
  695. procedure ReadState(Reader: TReader); override;
  696. procedure AdjustClientRect(var Rect: TRect); override;
  697. procedure Paint; override;
  698. { YW - DrawPage is called by paint method. all the derived page controls
  699. should call this method to paint itsself rather than the overrided
  700. paint method. }
  701. procedure DrawPage(ACanvas: TCanvas; var ARect: TRect); virtual;
  702. { YW - called before the page shows up. Page: From page }
  703. procedure Enter(const FromPage: TKWizardCustomPage); virtual;
  704. { YW - called after the page shows up. }
  705. procedure Done; virtual;
  706. { YW - called just before the page is hidden. Page: To page }
  707. procedure Exit(const ToPage: TKWizardCustomPage); virtual;
  708. public
  709. constructor Create(AOwner: TComponent); override;
  710. destructor Destroy; override;
  711. property Wizard: TKWizard read FWizard write SetWizard;
  712. property PageIndex: Integer
  713. read GetPageIndex write SetPageIndex stored False;
  714. published
  715. property Header: TKWizardPageHeader read FHeader write FHeader;
  716. property Image: TKWizardImage read FImage write FImage;
  717. property Panel: TKWizardPagePanel read FPanel write FPanel;
  718. property EnabledButtons: TKWizardButtonSet
  719. read FEnabledButtons write SetEnabledButtons default bkAllButtons;
  720. property VisibleButtons: TKWizardButtonSet
  721. read FVisibleButtons write SetVisibleButtons
  722. default [bkBack, bkNext, bkCancel];
  723. property Color default clBtnFace;
  724. property Caption;
  725. property Enabled;
  726. property Font;
  727. property Left stored False;
  728. property Height stored False;
  729. property PopupMenu;
  730. property ShowHint;
  731. property Top stored False;
  732. property Width stored False;
  733. property OnEnterPage: TKWizardChangePageEvent
  734. read FOnEnterPage write FOnEnterPage;
  735. property OnPage: TNotifyEvent read FOnPage write FOnPage;
  736. property OnExitPage: TKWizardChangePageEvent
  737. read FOnExitPage write FOnExitPage;
  738. property OnPaintPage: TKWizardPaintPageEvent
  739. read FOnPaintPage write FOnPaintPage;
  740. property OnStartButtonClick: TKWizardPageClickEvent
  741. read FOnStartButtonClick write FOnStartButtonClick;
  742. property OnLastButtonClick: TKWizardPageClickEvent
  743. read FOnLastButtonClick write FOnLastButtonClick;
  744. property OnNextButtonClick: TKWizardPageClickEvent
  745. read FOnNextButtonClick write FOnNextButtonClick;
  746. property OnBackButtonClick: TKWizardPageClickEvent
  747. read FOnBackButtonClick write FOnBackButtonClick;
  748. property OnCancelButtonClick: TKWizardPageClickEvent
  749. read FOnCancelButtonClick write FOnCancelButtonClick;
  750. property OnFinishButtonClick: TKWizardPageClickEvent
  751. read FOnFinishButtonClick write FOnFinishButtonClick;
  752. end;
  753.  
  754. { YW - Wizard Welcome Page }
  755. TKWizardWelcomePage = class(TKWizardCustomPage)
  756. private
  757. FWaterMark: TKWizardWaterMark;
  758. protected
  759. procedure AdjustClientRect(var Rect: TRect); override;
  760. procedure DrawPage(ACanvas: TCanvas; var ARect: TRect); override;
  761. public
  762. constructor Create(AOwner: TComponent); override;
  763. destructor Destroy; override;
  764. published
  765. property Color default clWindow;
  766. property WaterMark: TKWizardWaterMark read FWaterMark write FWaterMark;
  767. end;
  768.  
  769. { YW - Wizard Interior Page }
  770. TKWizardInteriorPage = class(TKWizardCustomPage)
  771. protected
  772. procedure DrawPage(ACanvas: TCanvas; var ARect: TRect); override;
  773. end;
  774.  
  775. TKWizardSelectPageEvent = procedure(Sender: TObject;
  776. FromPage: TKWizardCustomPage; var ToPage: TKWizardCustomPage) of object;
  777.  
  778. { YW - KWizard Page List }
  779. TKWizardPageList = class(TList)
  780. private
  781. FWizard: TKWizard;
  782. protected
  783. procedure Notify(Ptr: Pointer; Action: TListNotification); override;
  784. property Wizard: TKWizard read FWizard write FWizard;
  785. public
  786. destructor Destroy; override;
  787. end;
  788.  
  789. { YW - KWizard Control }
  790. TKWizard = class(TCustomControl)
  791. private
  792. FPages: TKWizardPageList;
  793. FActivePage: TKWizardCustomPage;
  794. FRouteMap: TKWizardRouteMapControl;
  795. FNavigateButtons: array[TKWizardButtonKind] of TKWizardNavigateButton;
  796. FButtonBarHeight: Integer;
  797. FShowDivider: Boolean;
  798. FOnSelectNextPage: TKWizardSelectPageEvent;
  799. FOnSelectPriorPage: TKWizardSelectPageEvent;
  800. FOnSelectFirstPage: TKWizardSelectPageEvent;
  801. FOnSelectLastPage: TKWizardSelectPageEvent;
  802. FHeaderImages: TCustomImageList;
  803. FImageChangeLink: TChangeLink;
  804. FAboutInfo: TKWizardAboutInfo; // Add by Steve Forbes
  805. procedure SetShowDivider(Value: Boolean);
  806. function GetShowRouteMap: Boolean;
  807. procedure SetShowRouteMap(Value: Boolean);
  808. procedure SetButtonBarHeight(Value: Integer);
  809. procedure SetActivePage(Page: TKWizardCustomPage);
  810. procedure SetHeaderImages(Value: TCustomImageList);
  811. function GetButtonClick(const Index: TKWizardButtonKind): TNotifyEvent;
  812. procedure SetButtonClick(const Index: TKWizardButtonKind;
  813. const Value: TNotifyEvent);
  814. procedure ImageListChange(Sender: TObject);
  815. procedure CreateNavigateButtons;
  816. procedure ChangeActivePage(Page: TKWizardCustomPage);
  817. function GetActivePageIndex: Integer;
  818. procedure SetActivePageIndex(Value: Integer);
  819. function GetPageCount: Integer;
  820. procedure RepositionButtons;
  821. procedure UpdateButtonsStatus;
  822. procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
  823. procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
  824. procedure CMDesignHitTest(var Message: TCMDesignHitTest); message CM_DESIGNHITTEST;
  825. protected
  826. procedure Loaded; override;
  827. procedure AdjustClientRect(var Rect: TRect); override;
  828. procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  829. procedure ShowControl(AControl: TControl); override;
  830. procedure Paint; override;
  831. procedure Resize; override;
  832. procedure InsertPage(Page: TKWizardCustomPage);
  833. procedure RemovePage(Page: TKWizardCustomPage);
  834. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  835. function GetButtonControlClass(
  836. AKind: TKWizardButtonKind): TKWizardButtonControlClass; virtual;
  837. property ButtonBarHeight: Integer
  838. read FButtonBarHeight write SetButtonBarHeight;
  839. public
  840. constructor Create(AComponent: TComponent); override;
  841. destructor Destroy; override;
  842. procedure SelectPriorPage;
  843. procedure SelectNextPage;
  844. procedure SelectFirstPage;
  845. procedure SelectLastPage;
  846. function IsFirstPage(const APage: TKWizardCustomPage;
  847. CheckDisable: Boolean = True): Boolean;
  848. function IsLastPage(const APage: TKWizardCustomPage;
  849. CheckDisable: Boolean = True): Boolean;
  850. function FindNextPage(PageIndex: Integer; const Step: Integer = 1;
  851. CheckDisable: Boolean = True): TKWizardCustomPage;
  852. function IsForward(const FromPage, ToPage: TKWizardCustomPage): Boolean;
  853. property ActivePageIndex: Integer
  854. read GetActivePageIndex write SetActivePageIndex;
  855. property PageCount: Integer read GetPageCount;
  856. published
  857. property Pages: TKWizardPageList read FPages;
  858. property About: TKWizardAboutInfo // Add by Steve Forbes
  859. read FAboutInfo write FAboutInfo stored False;
  860. property ActivePage: TKWizardCustomPage
  861. read FActivePage write SetActivePage;
  862. property ButtonStart: TKWizardNavigateButton
  863. read FNavigateButtons[bkStart] write FNavigateButtons[bkStart];
  864. property ButtonLast: TKWizardNavigateButton
  865. read FNavigateButtons[bkLast] write FNavigateButtons[bkLast];
  866. property ButtonBack: TKWizardNavigateButton
  867. read FNavigateButtons[bkBack] write FNavigateButtons[bkBack];
  868. property ButtonNext: TKWizardNavigateButton
  869. read FNavigateButtons[bkNext] write FNavigateButtons[bkNext];
  870. property ButtonFinish: TKWizardNavigateButton
  871. read FNavigateButtons[bkFinish] write FNavigateButtons[bkFinish];
  872. property ButtonCancel: TKWizardNavigateButton
  873. read FNavigateButtons[bkCancel] write FNavigateButtons[bkCancel];
  874. property ButtonHelp: TKWizardNavigateButton
  875. read FNavigateButtons[bkHelp] write FNavigateButtons[bkHelp];
  876. property ShowDivider: Boolean
  877. read FShowDivider write SetShowDivider default True;
  878. property ShowRouteMap: Boolean
  879. read GetShowRouteMap write SetShowRouteMap;
  880. property HeaderImages: TCustomImageList
  881. read FHeaderImages write SetHeaderImages;
  882. property OnSelectFirstPage: TKWizardSelectPageEvent
  883. read FOnSelectFirstPage write FOnSelectFirstPage;
  884. property OnSelectLastPage: TKWizardSelectPageEvent
  885. read FOnSelectLastPage write FOnSelectLastPage;
  886. property OnSelectNextPage: TKWizardSelectPageEvent
  887. read FOnSelectNextPage write FOnSelectNextPage;
  888. property OnSelectPriorPage: TKWizardSelectPageEvent
  889. read FOnSelectPriorPage write FOnSelectPriorPage;
  890. property OnStartButtonClick: TNotifyEvent index bkStart
  891. read GetButtonClick write SetButtonClick;
  892. property OnLastButtonClick: TNotifyEvent index bkLast
  893. read GetButtonClick write SetButtonClick;
  894. property OnBackButtonClick: TNotifyEvent index bkBack
  895. read GetButtonClick write SetButtonClick;
  896. property OnNextButtonClick: TNotifyEvent index bkNext
  897. read GetButtonClick write SetButtonClick;
  898. property OnFinishButtonClick: TNotifyEvent index bkFinish
  899. read GetButtonClick write SetButtonClick;
  900. property OnCancelButtonClick: TNotifyEvent index bkCancel
  901. read GetButtonClick write SetButtonClick;
  902. property Color;
  903. property Font;
  904. property Enabled;
  905. property Visible;
  906. end;
  907.  
  908. implementation
  909.  
  910. const
  911.  
  912. ciButtonWidth = 75;
  913. ciButtonHeight = 25;
  914. ciButtonBarHeight = 42;
  915. ciButtonPlacement = (ciButtonBarHeight - ciButtonHeight) div 2;
  916.  
  917. resourcestring
  918.  
  919. rsFirstButtonCaption = 'To &Start Page';
  920. rsLastButtonCaption = 'To &Last Page';
  921. rsBackButtonCaption = '< &Back';
  922. rsNextButtonCaption = '&Next >';
  923. rsCancelButtonCaption = 'Cancel';
  924. rsFinishButtonCaption = '&Finish';
  925. rsHelpButtonCaption = '&Help';
  926. rsWelcome = 'Welcome';
  927. rsTitle = 'Title';
  928. rsSubtitle = 'Subtitle';
  929. rsInvalidParentControl = 'The Parent should be TKWizard or its descendants.';
  930. rsInvalidWizardPage = 'Pages are belong to different wizard.';
  931.  
  932. type
  933. EKWizard = class(Exception);
  934.  
  935. { YW - First Button }
  936. TKWizardStartButton = class(TKWizardButtonControl)
  937. public
  938. constructor Create(AOwner: TComponent); override;
  939. procedure Click; override;
  940. end;
  941.  
  942. { YW - Last Button }
  943. TKWizardLastButton = class(TKWizardButtonControl)
  944. public
  945. constructor Create(AOwner: TComponent); override;
  946. procedure Click; override;
  947. end;
  948.  
  949. { YW - Back Button }
  950. TKWizardBackButton = class(TKWizardButtonControl)
  951. public
  952. constructor Create(AOwner: TComponent); override;
  953. procedure Click; override;
  954. end;
  955.  
  956. { YW - Next Button }
  957. TKWizardNextButton = class(TKWizardButtonControl)
  958. public
  959. constructor Create(AOwner: TComponent); override;
  960. procedure Click; override;
  961. end;
  962.  
  963. { YW - Finish Button }
  964. TKWizardFinishButton = class(TKWizardButtonControl)
  965. public
  966. constructor Create(AOwner: TComponent); override;
  967. procedure Click; override;
  968. end;
  969.  
  970. { YW - Cancel Button }
  971. TKWizardCancelButton = class(TKWizardButtonControl)
  972. public
  973. constructor Create(AOwner: TComponent); override;
  974. procedure Click; override;
  975. end;
  976.  
  977. { YW - Help Button }
  978. TKWizardHelpButton = class(TKWizardButtonControl)
  979. public
  980. constructor Create(AOwner: TComponent); override;
  981. procedure Click; override;
  982. end;
  983.  
  984. { TKWizardButtonControl }
  985.  
  986. constructor TKWizardButtonControl.Create(AOwner: TComponent);
  987. begin
  988. inherited;
  989. if csDesigning in ComponentState then
  990. begin
  991. {$IFDEF DELPHI6}
  992. { !!! YW - Add csClickEvents in order to fired the Click method
  993. at design time. It does NOT need at run time, otherwise it cause
  994. the OnClick event to be called twice. }
  995. ControlStyle := ControlStyle + [csClickEvents];
  996. {$ENDIF}
  997. ControlStyle := ControlStyle + [csNoDesignVisible];
  998. end;
  999. Kind := bkCustom;
  1000. Anchors := [akRight, akBottom];
  1001. end;
  1002.  
  1003. procedure TKWizardButtonControl.CMDesignHitTest(var Msg: TCMDesignHitTest);
  1004. begin
  1005. inherited;
  1006. if Enabled then
  1007. begin
  1008. Msg.Result := 1;
  1009. end;
  1010. end;
  1011.  
  1012. procedure TKWizardButtonControl.CMVisibleChanged(var Msg: TMessage);
  1013. begin
  1014. inherited;
  1015. if Assigned(FWizard) then
  1016. begin
  1017. FWizard.RepositionButtons;
  1018. end;
  1019. end;
  1020.  
  1021. { TKWizardStartButton }
  1022.  
  1023. constructor TKWizardStartButton.Create(AOwner: TComponent);
  1024. begin
  1025. inherited;
  1026. Caption := rsFirstButtonCaption;
  1027. Visible := False;
  1028. Anchors := [akLeft, akBottom];
  1029. Width := ciButtonWidth + 10;
  1030. Alignment := alLeft;
  1031. end;
  1032.  
  1033. procedure TKWizardStartButton.Click;
  1034. var
  1035. Stop: Boolean;
  1036. Page: TKWizardCustomPage;
  1037. begin
  1038. if Assigned(FWizard) then
  1039. begin
  1040. if not (csDesigning in ComponentState) then
  1041. begin
  1042. Stop := False;
  1043. Page := FWizard.FActivePage;
  1044. if Assigned(Page) and Assigned(Page.FOnStartButtonClick) then
  1045. begin
  1046. Page.FOnStartButtonClick(Page, Stop);
  1047. end;
  1048. if Stop then Exit;
  1049. inherited;
  1050. end;
  1051. FWizard.SelectFirstPage;
  1052. end;
  1053. end;
  1054.  
  1055. { TKWizardLastButton }
  1056.  
  1057. constructor TKWizardLastButton.Create(AOwner: TComponent);
  1058. begin
  1059. inherited;
  1060. Caption := rsLastButtonCaption;
  1061. Visible := False;
  1062. Anchors := [akLeft, akBottom];
  1063. Width := ciButtonWidth + 10;
  1064. Alignment := alLeft;
  1065. end;
  1066.  
  1067. procedure TKWizardLastButton.Click;
  1068. var
  1069. Stop: Boolean;
  1070. Page: TKWizardCustomPage;
  1071. begin
  1072. if Assigned(FWizard) then
  1073. begin
  1074. if not (csDesigning in ComponentState) then
  1075. begin
  1076. Stop := False;
  1077. Page := FWizard.FActivePage;
  1078. if Assigned(Page) and Assigned(Page.FOnLastButtonClick) then
  1079. begin
  1080. Page.FOnLastButtonClick(Page, Stop);
  1081. end;
  1082. if Stop then Exit;
  1083. inherited;
  1084. end;
  1085. FWizard.SelectLastPage;
  1086. end;
  1087. end;
  1088.  
  1089. { TKWizardBackButton }
  1090.  
  1091. constructor TKWizardBackButton.Create(AOwner: TComponent);
  1092. begin
  1093. inherited;
  1094. Caption := rsBackButtonCaption;
  1095. Enabled := False;
  1096. Visible := True;
  1097. Width := ciButtonWidth;
  1098. Alignment := alRight;
  1099. end;
  1100.  
  1101. procedure TKWizardBackButton.Click;
  1102. var
  1103. Stop: Boolean;
  1104. Page: TKWizardCustomPage;
  1105. begin
  1106. if Assigned(FWizard) then
  1107. begin
  1108. if not (csDesigning in ComponentState) then
  1109. begin
  1110. Stop := False;
  1111. Page := FWizard.FActivePage;
  1112. if Assigned(Page) and Assigned(Page.FOnBackButtonClick) then
  1113. begin
  1114. Page.FOnBackButtonClick(Page, Stop);
  1115. end;
  1116. if Stop then Exit;
  1117. inherited;
  1118. end;
  1119. FWizard.SelectPriorPage;
  1120. end;
  1121. end;
  1122.  
  1123. { TKWizardNextButton }
  1124.  
  1125. constructor TKWizardNextButton.Create(AOwner: TComponent);
  1126. begin
  1127. inherited;
  1128. Caption := rsNextButtonCaption;
  1129. Enabled := False;
  1130. Visible := True;
  1131. Width := ciButtonWidth;
  1132. Alignment := alRight;
  1133. end;
  1134.  
  1135. procedure TKWizardNextButton.Click;
  1136. var
  1137. Stop: Boolean;
  1138. Page: TKWizardCustomPage;
  1139. begin
  1140. if Assigned(FWizard) then
  1141. begin
  1142. if not (csDesigning in ComponentState) then
  1143. begin
  1144. Stop := False;
  1145. Page := FWizard.FActivePage;
  1146. if Assigned(Page) and Assigned(Page.FOnNextButtonClick) then
  1147. begin
  1148. Page.FOnNextButtonClick(Page, Stop);
  1149. end;
  1150. if Stop then Exit;
  1151. inherited;
  1152. end;
  1153. FWizard.SelectNextPage;
  1154. end;
  1155. end;
  1156.  
  1157. { TKWizardFinishButton }
  1158.  
  1159. constructor TKWizardFinishButton.Create(AOwner: TComponent);
  1160. begin
  1161. inherited;
  1162. Caption := rsFinishButtonCaption;
  1163. Visible := False;
  1164. Width := ciButtonWidth;
  1165. Alignment := alRight;
  1166. end;
  1167.  
  1168. procedure TKWizardFinishButton.Click;
  1169. var
  1170. Stop: Boolean;
  1171. Page: TKWizardCustomPage;
  1172. begin
  1173. if not (csDesigning in ComponentState) and Assigned(FWizard) then
  1174. begin
  1175. Stop := False;
  1176. Page := FWizard.FActivePage;
  1177. if Assigned(Page) and Assigned(Page.FOnFinishButtonClick) then
  1178. begin
  1179. Page.FOnFinishButtonClick(Page, Stop);
  1180. end;
  1181. if Stop then Exit;
  1182. inherited;
  1183. end;
  1184. end;
  1185.  
  1186. { TKWizardCancelButton }
  1187.  
  1188. constructor TKWizardCancelButton.Create(AOwner: TComponent);
  1189. begin
  1190. inherited;
  1191. Caption := rsCancelButtonCaption;
  1192. Visible := True;
  1193. Cancel := True;
  1194. Width := ciButtonWidth;
  1195. Alignment := alRight;
  1196. ModalResult := mrCancel;
  1197. end;
  1198.  
  1199. procedure TKWizardCancelButton.Click;
  1200. var
  1201. Stop: Boolean;
  1202. Page: TKWizardCustomPage;
  1203. begin
  1204. if not (csDesigning in ComponentState) and Assigned(FWizard) then
  1205. begin
  1206. Stop := False;
  1207. Page := FWizard.FActivePage;
  1208. if Assigned(Page) and Assigned(Page.FOnCancelButtonClick) then
  1209. begin
  1210. Page.FOnCancelButtonClick(Page, Stop);
  1211. end;
  1212. if Stop then Exit;
  1213. inherited;
  1214. end;
  1215. end;
  1216.  
  1217. { TKWizardHelpButton }
  1218.  
  1219. constructor TKWizardHelpButton.Create(AOwner: TComponent); // Added by Theodore
  1220. begin
  1221. inherited;
  1222. Caption := rsHelpButtonCaption;
  1223. Visible := False;
  1224. Anchors := [akLeft, akBottom];
  1225. Width := ciButtonWidth;
  1226. Alignment := alLeft;
  1227. end;
  1228.  
  1229. procedure TKWizardHelpButton.Click; // Added by Theodore, Modified by Yu Wei
  1230. var
  1231. ID: THelpContext;
  1232. begin
  1233. ID := 0;
  1234. if not (csDesigning in ComponentState) then
  1235. begin
  1236. if Assigned(FWizard) and Assigned(FWizard.ActivePage) then
  1237. ID := FWizard.ActivePage.HelpContext
  1238. else
  1239. ID := GetParentForm(Self).HelpContext;
  1240. end;
  1241. if ID <> 0 then
  1242. begin
  1243. Application.HelpContext(ID);
  1244. end;
  1245. end;
  1246.  
  1247. { TKWizardNavigateButton }
  1248.  
  1249. function TKWizardNavigateButton.GetCaption: string;
  1250. begin
  1251. if Assigned(FControl) then
  1252. Result := FControl.Caption
  1253. else
  1254. Result := '';
  1255. end;
  1256.  
  1257. function TKWizardNavigateButton.GetGlyph: TBitmap;
  1258. begin
  1259. if Assigned(FControl) then
  1260. Result := FControl.Glyph
  1261. else
  1262. Result := nil;
  1263. end;
  1264.  
  1265. function TKWizardNavigateButton.GetLayout: TButtonLayout;
  1266. begin
  1267. if Assigned(FControl) then
  1268. Result := FControl.Layout
  1269. else
  1270. Result := blGlyphLeft;
  1271. end;
  1272.  
  1273. function TKWizardNavigateButton.GetNumGlyphs: Integer;
  1274. begin
  1275. if Assigned(FControl) then
  1276. Result := FControl.NumGlyphs
  1277. else
  1278. Result := 0;
  1279. end;
  1280.  
  1281. procedure TKWizardNavigateButton.SetCaption(const Value: string);
  1282. begin
  1283. if Assigned(FControl) then
  1284. begin
  1285. FControl.Caption := Value;
  1286. end;
  1287. end;
  1288.  
  1289. procedure TKWizardNavigateButton.SetGlyph(const Value: TBitmap);
  1290. begin
  1291. if Assigned(FControl) then
  1292. begin
  1293. FControl.Glyph := Value;
  1294. end;
  1295. end;
  1296.  
  1297. procedure TKWizardNavigateButton.SetNumGlyphs(const Value: Integer);
  1298. begin
  1299. if Assigned(FControl) then
  1300. begin
  1301. FControl.NumGlyphs := Value;
  1302. end;
  1303. end;
  1304.  
  1305. procedure TKWizardNavigateButton.SetLayout(const Value: TButtonLayout);
  1306. begin
  1307. if Assigned(FControl) then
  1308. begin
  1309. FControl.Layout := Value;
  1310. end;
  1311. end;
  1312.  
  1313. function TKWizardNavigateButton.GetModalResult: TModalResult;
  1314. begin
  1315. if Assigned(FControl) then
  1316. Result := FControl.ModalResult
  1317. else
  1318. Result := mrNone;
  1319. end;
  1320.  
  1321. procedure TKWizardNavigateButton.SetModalResult(const Value: TModalResult);
  1322. begin
  1323. if Assigned(FControl) then
  1324. begin
  1325. FControl.ModalResult := Value;
  1326. end;
  1327. end;
  1328.  
  1329. function TKWizardNavigateButton.GetButtonWidth: Integer;
  1330. begin
  1331. if Assigned(FControl) then
  1332. Result := FControl.Width
  1333. else
  1334. Result := 0;
  1335. end;
  1336.  
  1337. procedure TKWizardNavigateButton.SetButtonWidth(const Value: Integer);
  1338. begin
  1339. if Assigned(FControl) and (FControl.Width <> Value) then
  1340. begin
  1341. FControl.Width := Value;
  1342. if Assigned(FControl.FWizard) then
  1343. begin
  1344. FControl.FWizard.RepositionButtons;
  1345. end;
  1346. end;
  1347. end;
  1348.  
  1349. { TKWizardRouteMapControl }
  1350.  
  1351. constructor TKWizardRouteMapControl.Create(AOwner: TComponent);
  1352. begin
  1353. inherited;
  1354. { !!! YW - Add csNoDesignVisible in order to make it visible and invisible
  1355. at design Time. }
  1356. if csDesigning in ComponentState then
  1357. begin
  1358. ControlStyle := ControlStyle + [csNoDesignVisible];
  1359. end;
  1360. FAlign := alLeft;
  1361. inherited Align := alLeft;
  1362. TabStop := False;
  1363. Width := 145;
  1364. Visible := True;
  1365. FPages := TList.Create;
  1366. DoubleBuffered := True;
  1367. end;
  1368.  
  1369. destructor TKWizardRouteMapControl.Destroy;
  1370. begin
  1371. if Assigned(Wizard) then
  1372. begin
  1373. Wizard.FRouteMap := nil;
  1374. end;
  1375. FPages.Free;
  1376. inherited;
  1377. end;
  1378.  
  1379. procedure TKWizardRouteMapControl.DoAddPage(const APage: TKWizardCustomPage);
  1380. begin
  1381. if Assigned(FWizard) then
  1382. begin
  1383. if Assigned(APage) and (FPages.IndexOf(APage) < 0) then
  1384. begin
  1385. FPages.Add(APage);
  1386. end;
  1387. WizardPageAdded(APage);
  1388. end;
  1389. end;
  1390.  
  1391. procedure TKWizardRouteMapControl.DoDeletePage(const APage: TKWizardCustomPage);
  1392. var
  1393. i: Integer;
  1394. begin
  1395. if Assigned(FWizard) then
  1396. begin
  1397. if Assigned(APage) then
  1398. begin
  1399. i := FPages.Remove(APage);
  1400. if FPageIndex = i then
  1401. begin
  1402. FPageIndex := -1;
  1403. end;
  1404. end;
  1405. WizardPageDeleted(APage);
  1406. end;
  1407. end;
  1408.  
  1409. procedure TKWizardRouteMapControl.DoActivatePage(const APage: TKWizardCustomPage);
  1410. begin
  1411. if Assigned(FWizard) then
  1412. begin
  1413. if Assigned(APage) then
  1414. begin
  1415. FPageIndex := FPages.IndexOf(APage);
  1416. end;
  1417. WizardPageActivated(APage);
  1418. end;
  1419. end;
  1420.  
  1421. procedure TKWizardRouteMapControl.DoUpdatePage(const APage: TKWizardCustomPage);
  1422. begin
  1423. if Assigned(FWizard) then
  1424. begin
  1425. WizardPageUpdated(APage);
  1426. end;
  1427. end;
  1428.  
  1429. procedure TKWizardRouteMapControl.DoMovePage(
  1430. const APage: TKWizardCustomPage; const OldIndex: Integer);
  1431. begin
  1432. if Assigned(FWizard) then
  1433. begin
  1434. if Assigned(APage) then
  1435. begin
  1436. FPages.Move(OldIndex, APage.PageIndex);
  1437. if OldIndex = FPageIndex then
  1438. begin
  1439. FPageIndex := APage.PageIndex;
  1440. end;
  1441. end;
  1442. WizardPageMoved(APage, OldIndex);
  1443. end;
  1444. end;
  1445.  
  1446. procedure TKWizardRouteMapControl.SetAlign(Value: TKWizardAlign);
  1447. begin
  1448. if FAlign <> Value then
  1449. begin
  1450. FAlign := Value;
  1451. inherited Align := FAlign;
  1452. end;
  1453. end;
  1454.  
  1455. function TKWizardRouteMapControl.GetPage(Index: Integer): TKWizardCustomPage;
  1456. begin
  1457. if (Index >= 0) and (Index < FPages.Count) then
  1458. Result := TKWizardCustomPage(FPages[Index])
  1459. else
  1460. Result := nil;
  1461. end;
  1462.  
  1463. function TKWizardRouteMapControl.GetPageCount: Integer;
  1464. begin
  1465. Result := FPages.Count;
  1466. end;
  1467.  
  1468. procedure TKWizardRouteMapControl.SetPageIndex(Value: Integer);
  1469. begin
  1470. if (FPageIndex <> Value) and (Value >= 0) and (Value < PageCount) then
  1471. begin
  1472. FPageIndex := Value;
  1473. if Assigned(FWizard) and (Pages[FPageIndex].Wizard = FWizard) then
  1474. begin
  1475. FWizard.SetActivePage(Pages[FPageI


егоров Вопрос ожидает решения (принимаются ответы, доступен мини-форум)

Вопрос задал: егоров (статус: Посетитель)
Вопрос отправлен: 4 мая 2007, 10:06
Состояние вопроса: открыт, ответов: 1.

Ответ #1. Отвечает эксперт: Помфюк Владимир Степанович

Здравствуйте, егоров!
У кнопки свойство "Default" выставлено в True - вот и весь фокус (кнопка по умолчанию). Ещё есть похожее свойство Cancel - тогда кнопка будет на Escape реагировать.

Ответ отправил: Помфюк Владимир Степанович (статус: Абитуриент)
Время отправки: 4 мая 2007, 10:16
Оценка за ответ: 5


Мини-форум вопроса

Мини-форум пуст.

Чтобы оставлять сообщения в мини-форумах, Вы должны авторизироваться на сайте.

Версия движка: 2.6+ (26.01.2011)
Текущее время: 16 ноября 2024, 21:26
Выполнено за 0.03 сек.