Changeset 6 for ProtocolBuffers/UMainForm.pas
- Timestamp:
- Oct 9, 2009, 1:44:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ProtocolBuffers/UMainForm.pas
r5 r6 1 1 unit UMainForm; 2 2 3 {$mode objfpc}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs; 8 Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, 9 StdCtrls, UProtocolBuffers, UMemoryStreamEx; 9 10 10 11 type 12 { TMainForm } 11 13 TMainForm = class(TForm) 14 Memo1: TMemo; 15 procedure FormCreate(Sender: TObject); 16 procedure FormDestroy(Sender: TObject); 12 17 private 13 18 { private declarations } 14 19 public 15 { public declarations }20 PB: TProtocolBuffer; 16 21 end; 17 22 … … 21 26 implementation 22 27 28 { TMainForm } 29 30 procedure TMainForm.FormCreate(Sender: TObject); 31 var 32 Stream: TMemoryStreamEx; 33 Text: string; 34 I: Integer; 35 begin 36 Stream := TMemoryStreamEx.Create; 37 PB := TProtocolBuffer.Create; 38 with PB do begin 39 BaseMessage := TPBMessage.Create; 40 BaseMessage.Name := 'SampleMessage'; 41 BaseMessage.Tag := $aaaa; 42 SaveToStream(Stream); 43 end; 44 45 Stream.Position := 0; 46 Text := ''; 47 for I := 1 to Stream.Size do begin 48 Text := Text + IntToHex(Stream.ReadByte, 2) + ' '; 49 end; 50 Memo1.Lines.Text := Text; 51 Stream.Free; 52 end; 53 54 procedure TMainForm.FormDestroy(Sender: TObject); 55 begin 56 PB.Free; 57 end; 58 23 59 initialization 24 60 {$I UMainForm.lrs}
Note:
See TracChangeset
for help on using the changeset viewer.