home *** CD-ROM | disk | FTP | other *** search
- (***************************************
- * WG-VISION 1.0 BEISPIELPROGRAMM *
- ****************************************
- * *
- * Listbox in ein Dialogfenster ein- *
- * binden. Dateinamen auflisten *
- * *
- ****************************************
- * (c) 1993 Dipl.Phys. Mathias Scholz *
- ***************************************)
-
- {$I COMPILER.INC}
-
- program LBoxTest;
-
- uses WDecl,
- WEvent,
- WApp,
- WViews,
- WDlg,
- Dos;
-
-
- const cmNewWindow=101;
-
- type TApplication=object(TApp)
- procedure InitMenuBar; virtual;
- procedure SetDialogData; virtual;
- procedure HandleEvent; virtual;
- procedure NewWindow;
- end;
-
- PNewWindow=^TNewWindow;
- TNewWindow=object(TDlgWindow)
- constructor Init;
- procedure SetListBox(X,Y,xl,yl:integer;Bez:str25;LScroller:word); virtual;
- end;
-
- PDateiListBox=^TDateiListBox;
- TDateiListBox=object(TListBox)
- procedure CreateDataList;
- end;
-
- tLBoxData=record
- Schalter:string[2];
- DName:string[12];
- end;
-
-
- var MyApp:TApplication;
- LBoxData:tLBoxData;
-
-
- {Implementation TApplication}
-
- procedure TApplication.InitMenuBar;
- begin
- MainMenu('~F~enster',0);
- SubMenu('~D~ialogfenster',cmNewWindow,0,0,false,false);
- SubMenu('E~x~it Alt-X',cmCloseApplication,0,altX,false,false);
- end;
-
- procedure TApplication.SetDialogData;
- begin
- with LBoxData do
- begin
- Schalter:='TB';
- FillChar(DName,SizeOf(DName),' ');
- end;
- end;
-
- procedure TApplication.HandleEvent;
- var I:byte;
- begin
- TProgram.HandleEvent;
- case Event.Command of
- cmNewWindow:NewWindow;
- end; {case}
- end;
-
- procedure TApplication.NewWindow;
- var Window:PNewWindow;
- begin
- Window:=New(PNewWindow, Init);
- InsertDesktop(Window);
- end;
-
- {Implementation TNewWindow}
-
- constructor TNewWindow.Init;
- var RR:TRect;
- begin
- RR.Assign(60,80,230,340);
- TDlgWindow.Init(RR,'Datei-Auswahl',winDouble+winPanel+winMenu+winKey);
- SetPushButton(36,210,100,22,'OK',cmCloseWindow);
- SetListBox(23,65,127,118,'~D~atei',VScrBar);
- SetData(LBoxData);
- end;
-
- procedure TNewWindow.SetListBox(X,Y,xl,yl:integer;Bez:str25;LScroller:word);
- var LBox:PDateiListBox;
- begin
- TDlgWindow.SetListBox(X,Y,xl,yl,Bez,LScroller);
- LBox:=New(PDateiListBox, Init(R,Bez,SBH,SBV));
- with LBox^ do
- begin
- CreateDataList;
- P.X:=X; P.Y:=Y;
- end;
- DlgList^.InsertItem(LBox);
- end;
-
- {Implementation TDateiListBox}
-
- procedure TDateiListBox.CreateDataList;
- var SRec:SearchRec;
- LfdPtr:PLine;
- begin
- FindFirst('\*.*',Archive,SRec);
- if SRec.Name<>'' then
- repeat
- LfdPtr:=New(PLine, Init);
- LfdPtr^.Eintrag:=SRec.Name;
- Liste^.InsertItem(LfdPtr);
- FindNext(SRec);
- until DosError=18;
- DataLen:=12; {sehr wichtig ! Wird in der Methode TDlgWindow.SetData benötigt !}
- SetLimit(12,Liste^.AnzElem,8,11);
- end;
-
- {Hauptprogramm}
-
- begin
- MyApp.Init('Dialogfenster mit Listbox');
- MyApp.Run;
- MyApp.Done;
- end.
-