multiple_dm.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:4k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit multiple_dm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, HTTPApp, WebModu, HTTPProd,
  5.   WebAdapt, WebComp, CompProd, PagItems, SiteProd, MidItems, WebForm;
  6. type
  7.   Tmultiple = class(TWebPageModule)
  8.     AdapterPageProducer: TAdapterPageProducer;
  9.     PagedAdapter1: TPagedAdapter;
  10.     NumbersList: TStringsValuesList;
  11.     AdapterForm1: TAdapterForm;
  12.     AdapterGrid1: TAdapterGrid;
  13.     AdapterCommandGroup1: TAdapterCommandGroup;
  14.     CmdPrevPage: TAdapterActionButton;
  15.     CmdGotoPage: TAdapterActionButton;
  16.     CmdNextPage: TAdapterActionButton;
  17.     Number: TAdapterMultiValueField;
  18.     Square: TAdapterMultiValueField;
  19.     ColNumber: TAdapterDisplayColumn;
  20.     ColSquare: TAdapterDisplayColumn;
  21.     AdapterField: TAdapterField;
  22.     procedure WebPageModuleActivate(Sender: TObject);
  23.     procedure NumberGetValues(Sender: TObject;
  24.       Index: Integer; var Value: Variant);
  25.     procedure NumberGetValueCount(Sender: TObject;
  26.       var Count: Integer);
  27.     procedure SquareGetValues(Sender: TObject; Index: Integer;
  28.       var Value: Variant);
  29.     procedure PagedAdapter1GetRecordCount(Sender: TObject;
  30.       var Count: Integer);
  31.     procedure PagedAdapter1GetNextRecord(Sender: TObject;
  32.       var EOF: Boolean);
  33.     procedure PagedAdapter1GetFirstRecord(Sender: TObject;
  34.       var EOF: Boolean);
  35.     procedure PagedAdapter1GetEOF(Sender: TObject; var EOF: Boolean);
  36.     procedure PagedAdapter1GetRecordIndex(Sender: TObject;
  37.       var Index: Integer);
  38.     procedure AdapterFieldGetValue(Sender: TObject; var Value: Variant);
  39.   private
  40.     CurrentPos: Integer;
  41.   public
  42.     { Public declarations }
  43.   end;
  44.   function multiple: Tmultiple;
  45. implementation
  46. {$R *.dfm}  {*.html}
  47. uses WebReq, WebCntxt, WebFact, Variants;
  48. function multiple: Tmultiple;
  49. begin
  50.   Result := Tmultiple(WebContext.FindModuleClass(Tmultiple));
  51. end;
  52. procedure Tmultiple.WebPageModuleActivate(Sender: TObject);
  53. var
  54.   i: Integer;
  55. begin
  56.   for i := 1 to 100 do
  57.     NumbersList.Strings.Add(
  58.       IntToStr(i) + '=' + IntToStr (Sqr(i)));
  59. end;
  60. procedure Tmultiple.NumberGetValues(Sender: TObject;
  61.   Index: Integer; var Value: Variant);
  62. begin
  63.   Value := NumbersList.Strings.Names [Index];
  64. end;
  65. procedure Tmultiple.NumberGetValueCount(Sender: TObject;
  66.   var Count: Integer);
  67. begin
  68.   Count := NumbersList.Strings.Count;
  69. end;
  70. procedure Tmultiple.SquareGetValues(Sender: TObject; Index: Integer;
  71.   var Value: Variant);
  72. begin
  73.   with NumbersList.Strings do
  74.     Value := Values [Names [Index]];
  75. end;
  76. procedure Tmultiple.PagedAdapter1GetRecordCount(Sender: TObject;
  77.   var Count: Integer);
  78. begin
  79.   Count := NumbersList.Strings.Count;
  80. end;
  81. procedure Tmultiple.PagedAdapter1GetNextRecord(Sender: TObject;
  82.   var EOF: Boolean);
  83. begin
  84.   Inc (CurrentPos);
  85.   EOF := (CurrentPos = NumbersList.Strings.Count - 1);
  86. end;
  87. procedure Tmultiple.PagedAdapter1GetFirstRecord(Sender: TObject;
  88.   var EOF: Boolean);
  89. begin
  90.   CurrentPos := 0;
  91. end;
  92. procedure Tmultiple.PagedAdapter1GetEOF(Sender: TObject; var EOF: Boolean);
  93. begin
  94.   EOF := (CurrentPos = NumbersList.Strings.Count);
  95. end;
  96. procedure Tmultiple.PagedAdapter1GetRecordIndex(Sender: TObject;
  97.   var Index: Integer);
  98. begin
  99.   CurrentPos := Index;
  100. end;
  101. procedure Tmultiple.AdapterFieldGetValue(Sender: TObject;
  102.   var Value: Variant);
  103. begin
  104.   Value := NumbersList.Strings.Names [CurrentPos];
  105. end;
  106. initialization
  107.   if WebRequestHandler <> nil then
  108.     WebRequestHandler.AddWebModuleFactory(TWebPageModuleFactory.Create(Tmultiple, TWebPageInfo.Create([wpPublished {, wpLoginRequired}], '.html'), crOnDemand, caCache));
  109. end.