home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
- PRODUCT : Turbo Pascal NUMBER : 992
- VERSION : 1.0
- OS : Windows
- DATE : April 28, 1992 PAGE : 1/3
-
- TITLE : Use Collections and ListBoxes.
-
-
-
-
- {$X+}
-
- (*
- The Resource file will only have one item in it. A dialog
- with a listbox and an OK button. The listbox ID should be
- 101 and the OK Button ID should be 1. The name of the
- dialog is NewDialog.
- *)
-
- program Initialization_ListBox_with_Collection;
-
- {$R CollDlg.res}
-
- uses WinTypes, winprocs, wobjectb, strings, BWCC;
-
- var
- st1,st2,st3: PChar;
-
- const
- buttonid = 100;
- listid = 101;
-
- type
- Plbtrans =^Tlbtrans;
- Tlbtrans = record
- Strings: PStrCollection;
- Selection: integer;
- end;
-
- type
- typePMyApp = ^TMyApp;
- TMyApp = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PMyMainWindow = ^TMyMainWindow;
- TMyMainWindow = object(TWindow)
- But: PButton;
- Constructor Init(AName: PChar);
- Destructor Done; virtual;
- procedure SetUpWindow; virtual;
- procedure TestButton(var Msg:TMessage);
- virtual id_First + ButtonId;
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Turbo Pascal NUMBER : 992
- VERSION : 1.0
- OS : Windows
- DATE : April 28, 1992 PAGE : 2/3
-
- TITLE : Use Collections and ListBoxes.
-
-
-
-
- end;
-
- var
- Buf: TlbTrans;
-
- procedure TMyApp.InitMainWindow;
- begin
- MainWindow:= New(PMyMainWindow, init('Main Window'));
- end;
-
- constructor TMyMainWindow.Init(AName: PChar);
- begin
- TWIndow.Init(nil, AName);
- but:= New(PButton,init(@self,ButtonId,'&Test',10,10,
- 50,50,false));
- end;
-
- Destructor TMyMainWindow.Done;
- { dispose of collection }
- begin
- TWindow.Done;
- Dispose(But);
- FreeMem(St2,8);
- FreeMem(St3,8);
- end;
-
- procedure TMyMainWindow.SetUpWindow;
- begin
- TWindow.SetUpWindow;
- end;
-
- procedure TMyMainWindow.TestButton(var Msg: TMessage);
- { Setup DialogBox with a ListBox }
- var
- TheDialog: PDialog;
- LB: PListBox;
- S: PChar;
- begin
- TheDialog:= new(PDialog,init(@Self,'NewDialog'));
- New(LB,InitResource(TheDialog,101));
- { create collection }
- Buf.Strings:=New(PStrCollection, init(10,10));
- GetMem(St1,8);
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Turbo Pascal NUMBER : 992
- VERSION : 1.0
- OS : Windows
- DATE : April 28, 1992 PAGE : 3/3
-
- TITLE : Use Collections and ListBoxes.
-
-
-
-
- StrCopy(St1,'Hello');
- Buf.Strings^.Insert(St1);
- GetMem(st2,8);
- StrCopy(St2,'Goodbye');
- Buf.Strings^.Insert(St2);
- GetMem(st3,8);
- StrCopy(St3,'Hey');
- Buf.Strings^.Insert(St3);
- Buf.Selection:=1;
- TheDialog^.TransferBuffer:= @Buf;
- Application^.ExecDialog(TheDialog);
- GetMem(S, 8);
- S:= buf.Strings^.at(Buf.Selection);
- MessageBox(hWindow,S,'Data from ListBox',mb_Ok);
- FreeMem(S, 8);
- end;
-
- var
- MyApp: TMyApp;
- begin
- MyApp.Init('MyApp');
- MyApp.Run;
- MyApp.Done;
- end.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-