[ Pobierz całość w formacie PDF ]
.Devel opi ng t he appl i c at i on user i nt er f ac e 9-15 Wo r k i n g wi t h f r a me sIf, on the other hand, you put your database components into a frame, later changeswould need to be made in only one place; changes to an original frame automaticallypropagate to its embedded descendants when your projects are recompiled.At thesame time, you are free to modify any embedded frame without affecting the originalframe or other embedded descendants of it.The only limitation on modifyingembedded frames is that you cannot add components to them.Figure 9.1 A frame with data-aware controls and a data source componentIn addition to simplifying maintenance, frames can help you to use resources moreefficiently.For example, to use a bitmap or other graphic in an application, you mightload the graphic into the Picture property of a TImage control.If, however, you usethe same graphic repeatedly in one application, each Image object you place on aform will result in another copy of the graphic being added to the form s resourcefile.(This is true even if you set TImage.Picture once and save the Image control as acomponent template.) A better solution is to drop the Image object onto a frame, loadyour graphic into it, then use the frame where you want the graphic to appear.Thisresults in smaller form files and has the added advantage of letting you change thegraphic everywhere it occurs simply by modifying the Image on the original frame.Sharing framesYou can share a frame with other developers in two ways:" Add the frame to the Object Repository." Distribute the frame s unit (.pas) and form (.dfm or.xfm) files.To add a frame to the Repository, open any project that includes the frame, right-click in the Form Designer, and choose Add to Repository.For more information, see Using the Object Repository on page 8-21.If you send a frame s unit and form files to other developers, they can open them andadd them to the Component palette.If the frame has other frames embedded in it,they will have to open it as part of a project.9-16 Devel oper  s Gui de De v e l o p i n g d i a l o g b o x e sDeveloping dialog boxesThe dialog box components on the Dialogs page of the Component palette makevarious dialog boxes available to your applications.These dialog boxes provideapplications with a familiar, consistent interface that enables the user to performcommon file operations such as opening, saving, and printing files.Dialog boxesdisplay and/or obtain data.Each dialog box opens when its Execute method is called.Execute returns a Booleanvalue: if the user chooses OK to accept any changes made in the dialog box, Executereturns True; if the user chooses Cancel to escape from the dialog box withoutmaking or saving changes, Execute returns False.Note For CLX applications, you can use the dialogs provided in the QDialogs unit.Foroperating systems that have native dialog box types for common tasks, such as foropening or saving a file or for changing font or color, you can use the UseNativeDialogproperty.Set UseNativeDialog to True if your application will run in such anenvironment, and if you want it to use the native dialogs instead of the Qt dialogs.Using open dialog boxesOne of the commonly used dialog box components is TOpenDialog.This componentis usually invoked by a New or Open menu item under the File option on the mainmenu bar of a form.The dialog box contains controls that let you select groups of filesusing a wildcard character and navigate through directories.The TOpenDialog component makes an Open dialog box available to yourapplication.The purpose of this dialog box is to let a user specify a file to open.Youuse the Execute method to display the dialog box.When the user chooses OK in the dialog box, the user s file is stored in theTOpenDialog FileName property, which you can then process as you want.The following code can be placed in an Action and linked to the Action property of aTMainMenu subitem or be placed in the subitem s OnClick event:if OpenDialog1.Execute thenfilename := OpenDialog1.FileName;This code will show the dialog box and if the user presses the OK button, it will copythe name of the file into a previously declared AnsiString variable named filename [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • swpc.opx.pl
  •