home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l040 / 11.ddi / WDOCDEMO.ZIP / TRANTEST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-27  |  4.0 KB  |  124 lines

  1. {************************************************}
  2. {                                                }
  3. {   ObjectWindows Demo                           }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program TranApp;
  9.  
  10. {$R TRANTEST.RES }
  11.  
  12. uses WinTypes, WinProcs, Strings, OWindows, ODialogs;
  13.  
  14. const
  15.   cm_MenuTest      = 399;
  16.   id_AddressStatic = 101;
  17.   id_MrButton      = 102;
  18.   id_MsButton      = 103;
  19.   id_DrButton      = 104;
  20.   id_NameEdit      = 106;
  21.   id_Address1Edit  = 107;
  22.   id_Address2Edit  = 108;
  23.   id_CityStateEdit = 109;
  24.   id_CountryEdit   = 110;
  25.  
  26. type
  27.   TransferAddressRecord = record
  28.     AddressStatic: array[0..40] of Char;
  29.     MrTitle: Bool;
  30.     MsTitle: Bool;
  31.     DrTitle: Bool;
  32.     NameEdit: array[0..40] of Char;
  33.     Address1Edit: array[0..40] of Char;
  34.     Address2Edit: array[0..40] of Char;
  35.     CityStateEdit: array[0..40] of Char;
  36.     CountryEdit: array[0..40] of Char;
  37.   end;
  38.  
  39.   { TransferApplication type declaration. }
  40.   TransferApplication = object(TApplication)
  41.     procedure InitMainWindow; virtual;
  42.   end;
  43.  
  44.   { TransferWindow type declaration. }
  45.   PTransferWindow = ^TransferWindow;
  46.   TransferWindow = object(TWindow)
  47.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  48.     procedure Test(var Msg: TMessage); virtual cm_First + cm_MenuTest;
  49.   end;
  50.  
  51. var
  52.   MyApp: TransferApplication;
  53.  
  54. { Constructor; init each child control. }
  55. constructor TransferWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  56. begin
  57.   inherited Init(AParent, ATitle);
  58.   Attr.Menu := LoadMenu(HInstance, MakeIntResource(cm_MenuTest));
  59. end;
  60.  
  61. { Init the main window of a TransferApplication - an TransferWindow. }
  62. procedure TransferApplication.InitMainWindow;
  63. begin
  64.   MainWindow := New(PTransferWindow, Init(nil, 'Test Dialog Transfer'));
  65. end;
  66.  
  67. procedure TransferWindow.Test(var Msg: TMessage);
  68. const
  69.   AddressRecord: TransferAddressRecord = (
  70.     AddressStatic: 'First Mailing Label';
  71.     MrTitle: True;
  72.     MsTitle: False;
  73.     DrTitle: False);
  74.   NewLine = #13#10;
  75. var
  76.   D: PDialog;
  77.   S1: PStatic;
  78.   R1: PRadioButton;
  79.   E1: PEdit;
  80.   ReturnValue: Integer;
  81.   ALabel: array[0..255] of Char;
  82. begin
  83.   D := New(PDialog, Init(@Self, MakeIntResource(100)));
  84.   New(S1, InitResource(D, id_AddressStatic, SizeOf(AddressRecord.AddressStatic)));
  85.   New(R1, InitResource(D, id_MrButton));
  86.   New(R1, InitResource(D, id_MsButton));
  87.   New(R1, InitResource(D, id_DrButton));
  88.   New(E1, InitResource(D, id_NameEdit, SizeOf(AddressRecord.NameEdit)));
  89.   New(E1, InitResource(D, id_Address1Edit, SizeOf(AddressRecord.Address1Edit)));
  90.   New(E1, InitResource(D, id_Address2Edit, SizeOf(AddressRecord.Address2Edit)));
  91.   New(E1, InitResource(D, id_CityStateEdit, SizeOf(AddressRecord.CityStateEdit)));
  92.   New(E1, InitResource(D, id_CountryEdit, SizeOf(AddressRecord.CountryEdit)));
  93.   D^.TransferBuffer := @AddressRecord;
  94.   ReturnValue := Application^.ExecDialog(D);
  95.   if ReturnValue = idCancel then
  96.     MessageBox(HWindow, 'Cancelled', 'AddressDialog', 0)
  97.   else
  98.   begin
  99.     StrCopy(ALabel, 'Mailing Label Entered:');
  100.     StrLCat(ALabel, NewLine, SizeOf(ALabel));
  101.     StrLCat(ALabel, NewLine, SizeOf(ALabel));
  102.     StrLCat(ALabel, AddressRecord.NameEdit, SizeOf(ALabel));
  103.     StrLCat(ALabel, NewLine, SizeOf(ALabel));
  104.     StrLCat(ALabel, AddressRecord.Address1Edit, SizeOf(ALabel));
  105.     StrLCat(ALabel, NewLine, SizeOf(ALabel));
  106.     if StrComp(AddressRecord.Address2Edit, '') <> 0 then
  107.     begin
  108.       StrLCat(ALabel, AddressRecord.Address2Edit, SizeOf(ALabel));
  109.       StrLCat(ALabel, NewLine, SizeOf(ALabel));
  110.     end;
  111.     StrLCat(ALabel, AddressRecord.CityStateEdit, SizeOf(ALabel));
  112.     StrLCat(ALabel, NewLine, SizeOf(ALabel));
  113.     StrLCat(ALabel, AddressRecord.CountryEdit, SizeOf(ALabel));
  114.     MessageBox(HWindow, ALabel, 'Test Dialog Transfer', mb_Ok);
  115.     StrCopy(AddressRecord.AddressStatic, 'Subsequent Mailing Labels');
  116.   end;
  117. end;
  118.  
  119. begin
  120.   MyApp.Init('TranApp');
  121.   MyApp.Run;
  122.   MyApp.Done;
  123. end.
  124.