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

  1. {************************************************}
  2. {                                                }
  3. {   ObjectWindows Demo                           }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program DialTest;
  9.  
  10. {$R DIALTEST.RES}
  11.          
  12. uses WinTypes, WinProcs, OWindows, ODialogs;
  13.  
  14. const
  15.   TheMenu     = 100;
  16.   id_LB1      = 151;
  17.   id_BN1      = 152;
  18.   cm_DialTest = 101;
  19.  
  20. type
  21.   PTestDialog = ^TTestDialog;
  22.   TTestDialog = object(TDialog)
  23.     procedure IDBN1(var Msg: TMessage); virtual id_First + id_BN1;
  24.     procedure IDLB1(var Msg: TMessage); virtual id_First + id_LB1;
  25.   end;
  26.  
  27.   PTestWindow = ^TTestWindow;
  28.   TTestWindow = object(TWindow)
  29.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  30.     procedure CMDialTest(var Msg: TMessage); virtual cm_First + cm_DialTest;
  31.   end;
  32.  
  33.   TDlgApplication = object(TApplication)
  34.     procedure InitMainWindow; virtual;
  35.   end;
  36.  
  37. { TTestDialog }
  38. procedure TTestDialog.IDBN1(var Msg: TMessage);
  39. var
  40.   TextItem : PChar;
  41. begin
  42.   TextItem := 'Item 1';
  43.   SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
  44.   TextItem := 'Item 2';
  45.   SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
  46.   TextItem := 'Item 3';
  47.   SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
  48.   TextItem := 'Item 4';
  49.   SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
  50.   TextItem := 'Item 5';
  51.   SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
  52.   TextItem := 'Item 6';
  53.   SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
  54.   TextItem := 'Item 7';
  55.   SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
  56. end;
  57.  
  58. procedure TTestDialog.IDLB1(var Msg: TMessage);
  59. var
  60.   Idx: Integer;
  61.   SelectedText: array[0..10] of Char;
  62. begin
  63.   if Msg.LParamHi = lbn_SelChange then
  64.   begin
  65.     Idx := SendDlgItemMsg(id_LB1, lb_GetCurSel, 0, Longint(0));
  66.     SendDlgItemMsg(id_LB1, lb_GetText, Idx, Longint(@SelectedText));
  67.     MessageBox(HWindow, SelectedText, 'List Box Notification', MB_OK);
  68.   end;
  69. end;
  70.  
  71. { TTestWindow }
  72. constructor TTestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  73. begin
  74.   inherited Init(AParent, ATitle);
  75.   Attr.Menu := LoadMenu(Hinstance, MakeIntResource(TheMenu));
  76. end;
  77.  
  78. procedure TTestWindow.CMDialTest(var Msg: TMessage);
  79. begin
  80.   Application^.ExecDialog(New(PTestDialog, Init(@Self, 'DIAL1')));
  81. end;
  82.  
  83. { TDlgApplication }
  84. procedure TDlgApplication.InitMainWindow;
  85. begin
  86.   MainWindow := New(PTestWindow, Init(nil, 'Dialog Tester'));
  87. end;
  88.  
  89. var
  90.   MyApp: TDlgApplication;
  91. begin
  92.   MyApp.Init('DialTest');
  93.   MyApp.Run;
  94.   MyApp.Done;
  95. end.
  96.