home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d123456 / DFS.ZIP / DlgTest.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-27  |  7KB  |  145 lines

  1. {$I DFS.INC}  { Standard defines for all Delphi Free Stuff components }
  2.  
  3. {------------------------------------------------------------------------------}
  4. { DlgTest v1.04                                                                }
  5. {------------------------------------------------------------------------------}
  6. { Design-time testing of TCommonDialog component descendants.                  }
  7. {                                                                              }
  8. { Copyright 2000-2001, Brad Stowers.  All Rights Reserved.                     }
  9. {                                                                              }
  10. { Copyright:                                                                   }
  11. { All Delphi Free Stuff (hereafter "DFS") source code is copyrighted by        }
  12. { Bradley D. Stowers (hereafter "author"), and shall remain the exclusive      }
  13. { property of the author.                                                      }
  14. {                                                                              }
  15. { Distribution Rights:                                                         }
  16. { You are granted a non-exlusive, royalty-free right to produce and distribute }
  17. { compiled binary files (executables, DLLs, etc.) that are built with any of   }
  18. { the DFS source code unless specifically stated otherwise.                    }
  19. { You are further granted permission to redistribute any of the DFS source     }
  20. { code in source code form, provided that the original archive as found on the }
  21. { DFS web site (http://www.delphifreestuff.com) is distributed unmodified. For }
  22. { example, if you create a descendant of TDFSColorButton, you must include in  }
  23. { the distribution package the colorbtn.zip file in the exact form that you    }
  24. { downloaded it from http://www.delphifreestuff.com/mine/files/colorbtn.zip.   }
  25. {                                                                              }
  26. { Restrictions:                                                                }
  27. { Without the express written consent of the author, you may not:              }
  28. {   * Distribute modified versions of any DFS source code by itself. You must  }
  29. {     include the original archive as you found it at the DFS site.            }
  30. {   * Sell or lease any portion of DFS source code. You are, of course, free   }
  31. {     to sell any of your own original code that works with, enhances, etc.    }
  32. {     DFS source code.                                                         }
  33. {   * Distribute DFS source code for profit.                                   }
  34. {                                                                              }
  35. { Warranty:                                                                    }
  36. { There is absolutely no warranty of any kind whatsoever with any of the DFS   }
  37. { source code (hereafter "software"). The software is provided to you "AS-IS", }
  38. { and all risks and losses associated with it's use are assumed by you. In no  }
  39. { event shall the author of the softare, Bradley D. Stowers, be held           }
  40. { accountable for any damages or losses that may occur from use or misuse of   }
  41. { the software.                                                                }
  42. {                                                                              }
  43. { Support:                                                                     }
  44. { Support is provided via the DFS Support Forum, which is a web-based message  }
  45. { system.  You can find it at http://www.delphifreestuff.com/discus/           }
  46. { All DFS source code is provided free of charge. As such, I can not guarantee }
  47. { any support whatsoever. While I do try to answer all questions that I        }
  48. { receive, and address all problems that are reported to me, you must          }
  49. { understand that I simply can not guarantee that this will always be so.      }
  50. {                                                                              }
  51. { Clarifications:                                                              }
  52. { If you need any further information, please feel free to contact me directly.}
  53. { This agreement can be found online at my site in the "Miscellaneous" section.}
  54. {------------------------------------------------------------------------------}
  55. { The lateset version of my components are always available on the web at:     }
  56. {   http://www.delphifreestuff.com/                                            }
  57. { See DlgTest.txt for notes, known issues, and revision history.               }
  58. {------------------------------------------------------------------------------}
  59. { Date last modified:  June 27, 2001                                           }
  60. {------------------------------------------------------------------------------}
  61.  
  62. unit DlgTest;
  63.  
  64. interface
  65.  
  66. uses
  67.   {$IFDEF DFS_NO_DSGNINTF}
  68.   DesignIntf,
  69.   DesignEditors;
  70.   {$ELSE}
  71.   DsgnIntf;
  72.   {$ENDIF}
  73.  
  74. type
  75.   TCommonDialogEditor = class(TDefaultEditor)
  76.   public
  77.     procedure ExecuteVerb(Index : Integer); override;
  78.     function GetVerb(Index : Integer): string; override;
  79.     function GetVerbCount : Integer; override;
  80.     procedure Edit; override;
  81.   end;
  82.  
  83. procedure Register;
  84.  
  85. implementation
  86.  
  87. uses Dialogs;
  88.  
  89. procedure TCommonDialogEditor.ExecuteVerb(Index: Integer);
  90. begin
  91.   if Index <> 0 then Exit; { We only have one verb, so exit if this ain't it }
  92.   Edit;  { Invoke the Edit function the same as if double click had happened }
  93. end;
  94.  
  95. function TCommonDialogEditor.GetVerb(Index: Integer): String;
  96. begin
  97.   Result := 'Test Dialog';  { Menu item caption for context menu }
  98. end;
  99.  
  100. function TCommonDialogEditor.GetVerbCount: Integer;
  101. begin
  102.   Result := 1;
  103. end;
  104.  
  105. type
  106.   THackCommonDialog = class(TCommonDialog)
  107.   end;
  108.  
  109. procedure TCommonDialogEditor.Edit;
  110. begin
  111. {$IFDEF DFS_COMPILER_3_UP}
  112.   if Component is TCommonDialog then
  113.     THackCommonDialog(Component).Execute;
  114. {$ELSE}
  115.   if Component is TColorDialog then
  116.     TColorDialog(Component).Execute
  117.   else if Component is TFindDialog then
  118.     TFindDialog(Component).Execute
  119.   else if Component is TReplaceDialog then
  120.     TReplaceDialog(Component).Execute
  121.   else if Component is TFontDialog then
  122.     TFontDialog(Component).Execute
  123.   else if Component is TOpenDialog then
  124.     TOpenDialog(Component).Execute
  125.   else if Component is TSaveDialog then
  126.     TSaveDialog(Component).Execute
  127.   else if Component is TPrintDialog then
  128.     TPrintDialog(Component).Execute
  129.   else if Component is TPrinterSetupDialog then
  130.     TPrinterSetupDialog(Component).Execute;
  131.   { If TCommonDialog had a virtual Execute method, we could replace all of   }
  132.   { the above code with two lines:                                           }
  133.   {   if Component is TCommonDialog then                                     }
  134.   {     TCommonDialog(Component).Execute;                                    }
  135. {$ENDIF}
  136. end;
  137.  
  138. procedure Register;
  139. begin
  140.   RegisterComponentEditor(TCommonDialog, TCommonDialogEditor);
  141. end;
  142.  
  143.  
  144. end.
  145.