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

  1. {************************************************}
  2. {                                                }
  3. {   ObjectWindows Demo                           }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program InitResTest;
  9.  
  10. uses WinTypes, WinProcs, OWindows, ODialogs;
  11.  
  12. const
  13.   id_LB1 = 101;
  14.  
  15. type
  16.   TestApplication = object(TApplication)
  17.     procedure InitMainWindow; virtual;
  18.   end;
  19.  
  20.   PTestWindow = ^TestWindow;
  21.  
  22.   TestWindow = object(TWindow)
  23.     LB1: PListBox;
  24.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  25.     procedure SetupWindow; virtual;
  26.     procedure HandleListBoxMsg(var Msg: TMessage);
  27.       virtual id_First + id_LB1;
  28.   end;
  29.  
  30. { --------TestWindow methods------------------ }
  31. constructor TestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  32. begin
  33.   inherited Init(AParent, ATitle);
  34.   LB1 := new(PListBox, Init(@Self, id_LB1, 20, 20, 340, 100));
  35. end;
  36.  
  37. procedure TestWindow.SetupWindow;
  38. begin
  39.   inherited SetupWindow;
  40.   LB1^.AddString('Item 1');
  41.   LB1^.AddString('Item 2');
  42.   LB1^.AddString('Item 3');
  43.   LB1^.InsertString('Item 1.5', 1);
  44.   LB1^.AddString('Item 4');
  45.   LB1^.AddString('Item 5');
  46.   LB1^.AddString('Item 6');
  47. end;
  48.  
  49. procedure TestWindow.HandleListBoxMsg(var Msg: TMessage);
  50. var
  51.   Idx: Integer;
  52.   ItemText: array[0..10] of Char;
  53. begin
  54.   if Msg.LParamHi = lbn_SelChange then
  55.   begin
  56.     Idx := LB1^.GetSelIndex;
  57.     if LB1^.GetStringLen(Idx) < 11 then
  58.     begin
  59.       LB1^.GetSelString(ItemText, 10);
  60.       MessageBox(HWindow, ItemText, 'You selected:', mb_OK);
  61.     end;
  62.   end
  63.   else DefWndProc(Msg);
  64. end;
  65.  
  66. { -----------TestApplication Methods------------ }
  67. procedure TestApplication.InitMainWindow;
  68. begin
  69.   MainWindow := New(PTestWindow, Init(nil, 'List Box Tester'));
  70. end;
  71.  
  72. var
  73.   TestApp : TestApplication;
  74.  
  75. begin
  76.   TestApp.Init('LBoxTest');
  77.   TestApp.Run;
  78.   TestApp.Done;
  79. end.
  80.  
  81.