CnNetPropEditor.pas 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. {******************************************************************************}
  2. { CnPack For Delphi/C++Builder }
  3. { 中国人自己的开放源码第三方开发包 }
  4. { (C)Copyright 2001-2018 CnPack 开发组 }
  5. { ------------------------------------ }
  6. { }
  7. { 本开发包是开源的自由软件,您可以遵照 CnPack 的发布协议来修 }
  8. { 改和重新发布这一程序。 }
  9. { }
  10. { 发布这一开发包的目的是希望它有用,但没有任何担保。甚至没有 }
  11. { 适合特定目的而隐含的担保。更详细的情况请参阅 CnPack 发布协议。 }
  12. { }
  13. { 您应该已经和开发包一起收到一份 CnPack 发布协议的副本。如果 }
  14. { 还没有,可访问我们的网站: }
  15. { }
  16. { 网站地址:http://www.cnpack.org }
  17. { 电子邮件:master@cnpack.org }
  18. { }
  19. {******************************************************************************}
  20. unit CnNetPropEditor;
  21. {* |<PRE>
  22. ================================================================================
  23. * 软件名称:网络通讯组件包
  24. * 单元名称:网络通讯类属性编辑器单元
  25. * 单元作者:周劲羽 (zjy@cnpack.org)
  26. * 备 注:
  27. * 开发平台:PWin98SE + Delphi 5.0
  28. * 兼容测试:PWin9X/2000/XP + Delphi 5/6
  29. * 本 地 化:该单元中的字符串均符合本地化处理方式
  30. * 单元标识:$Id$
  31. * 修改记录:2002.04.18 V1.1
  32. * 为TCnRS232ConfigProperty和TCnRS232TimeoutsProperty增加
  33. * 对TRS232Dialog组件的支持
  34. * 2002.04.08 V1.0
  35. * 创建单元
  36. * 增加注释
  37. ================================================================================
  38. |</PRE>}
  39. interface
  40. {$I CnPack.inc}
  41. uses
  42. Windows, Messages, SysUtils, Classes,
  43. {$IFDEF COMPILER6_UP}
  44. DesignIntf, DesignEditors;
  45. {$ELSE}
  46. DsgnIntf;
  47. {$ENDIF}
  48. type
  49. //------------------------------------------------------------------------------
  50. // TCnRS232Config属性编辑器
  51. //------------------------------------------------------------------------------
  52. { TCnRS232ConfigProperty }
  53. TCnRS232ConfigProperty = class(TClassProperty)
  54. public
  55. procedure Edit; override;
  56. function GetAttributes: TPropertyAttributes; override;
  57. function GetValue: string; override;
  58. end;
  59. //------------------------------------------------------------------------------
  60. // TCnRS232Timeouts属性编辑器
  61. //------------------------------------------------------------------------------
  62. { TCnRS232TimeoutsProperty }
  63. TCnRS232TimeoutsProperty = class(TClassProperty)
  64. public
  65. procedure Edit; override;
  66. function GetAttributes: TPropertyAttributes; override;
  67. function GetValue: string; override;
  68. end;
  69. implementation
  70. uses
  71. CnRS232, CnRS232Dialog, CnNetConsts;
  72. //------------------------------------------------------------------------------
  73. // TCnRS232Config属性编辑器
  74. //------------------------------------------------------------------------------
  75. { TCnRS232ConfigProperty }
  76. // 编辑属性
  77. procedure TCnRS232ConfigProperty.Edit;
  78. var
  79. CommDlg: TCnRS232Dialog;
  80. CommConfig: TCnRS232Config;
  81. begin
  82. if GetComponent(0) is TCnRS232 then
  83. CommConfig := TCnRS232(GetComponent(0)).CommConfig
  84. else if GetComponent(0) is TCnRS232Dialog then
  85. CommConfig := TCnRS232Dialog(GetComponent(0)).CommConfig
  86. else
  87. Exit;
  88. CommDlg := TCnRS232Dialog.Create(nil);
  89. try
  90. CommDlg.Kind := ckExtended;
  91. CommDlg.Pages := [cpNormal, cpXonXoff, cpHardware];
  92. CommDlg.BaudRateList := False;
  93. CommDlg.ShowHint := csCheckHint;
  94. CommDlg.CommConfig.Assign(CommConfig);
  95. if CommDlg.Execute then
  96. begin
  97. CommConfig.Assign(CommDlg.CommConfig);
  98. end;
  99. Designer.Modified;
  100. finally
  101. CommDlg.Free;
  102. end;
  103. end;
  104. // 取属性编辑器设置
  105. function TCnRS232ConfigProperty.GetAttributes: TPropertyAttributes;
  106. begin
  107. Result := [paSubProperties, paDialog, paReadOnly];
  108. end;
  109. // 返回属性显示文本
  110. function TCnRS232ConfigProperty.GetValue: string;
  111. begin
  112. Result := SRS232Option;
  113. end;
  114. //------------------------------------------------------------------------------
  115. // TCnRS232Timeouts属性编辑器
  116. //------------------------------------------------------------------------------
  117. { TCnRS232TimeoutsProperty }
  118. // 编辑属性
  119. procedure TCnRS232TimeoutsProperty.Edit;
  120. var
  121. CommDlg: TCnRS232Dialog;
  122. CommTimeouts: TCnRS232Timeouts;
  123. begin
  124. if GetComponent(0) is TCnRS232 then
  125. CommTimeouts := TCnRS232(GetComponent(0)).Timeouts
  126. else if GetComponent(0) is TCnRS232Dialog then
  127. CommTimeouts := TCnRS232Dialog(GetComponent(0)).Timeouts
  128. else
  129. Exit;
  130. CommDlg := TCnRS232Dialog.Create(nil);
  131. try
  132. CommDlg.Kind := ckExtended;
  133. CommDlg.Pages := [cpTimeouts];
  134. CommDlg.BaudRateList := False;
  135. CommDlg.ShowHint := csCheckHint;
  136. CommDlg.Timeouts.Assign(CommTimeouts);
  137. if CommDlg.Execute then
  138. begin
  139. CommTimeouts.Assign(CommDlg.Timeouts);
  140. end;
  141. Designer.Modified;
  142. finally
  143. CommDlg.Free;
  144. end;
  145. end;
  146. // 取属性编辑器设置
  147. function TCnRS232TimeoutsProperty.GetAttributes: TPropertyAttributes;
  148. begin
  149. Result := [paSubProperties, paDialog, paReadOnly];
  150. end;
  151. // 返回属性显示文本
  152. function TCnRS232TimeoutsProperty.GetValue: string;
  153. begin
  154. Result := SRS232TimeoutsOption;
  155. end;
  156. end.