[ Pobierz całość w formacie PDF ]
.If you do not create the form,the pointer to the form is uninitialized, which means that the pointer has not yetbeen assigned a meaningful value.(Remember that the pointer is automatically createdby Delphi.) Attempting to use the pointer will result in an access violation or erraticprogram behavior.After you remove a form from the auto-create list, it is your responsibilityto make sure the form has been created before using it.Your application has one other problem I need to address.When you click the closebutton on one of the MDI windows, you will find that the window minimizes insteadof closing.Believe it or not this is the standard behavior as prescribed by Microsoft.Standard behavior or not, it's weird, so you can fix it so that clicking the closebox actually closes the window (as any rational person would expect).To do so, followthese steps:1.Bring up the child window form in the Form Designer.Be sure the formitself is selected and not the Image component on the form (choose the Child fromthe Component Selector at the top of the Object Inspector, if necessary).2.Double-click the Value column next to the OnClose event in the ObjectInspector.Add a line of code to the event handler so that it looks like this:procedure TChild.FormClose(Sender: TObject; var Action: TCloseAction);beginAction := caFree;end;Setting the close action to caFree tells VCL to close the child window and tofree the memory associated with the window.Now the child window will behave as itshould when the close box is clicked.3.Again run the program to prove that the program behaves as advertised.SummaryThe Delphi IDE can be intimidating until you become familiar with it.If you learnit a little at a time, it's not nearly so daunting.Today you learned more aboutthe various pieces that make up the Delphi IDE.Then you learned about how projectsare used to create an executable file.You also learned more about forms.You foundout how Delphi deals with dialog boxes and other child windows.You found out moreabout the Object Inspector and how it can be used to change a component's properties.You also learned about the docking features of the Delphi IDE.Finally, you got tocreate a program that actually does something interesting.Tomorrow you'll find outabout the visual component model.WorkshopThe Workshop contains quiz questions to help you solidify your understanding ofthe material covered and exercises to provide you with experience in using what youhave learned.You can find the answers to the quiz questions in Appendix A, "Answersto the Quiz Questions."Q&AQ The Delphi toolbar doesn't have buttons for the features I use most often.Can I change the toolbar?A Absolutely.The toolbar is fully customizable.You can add or removebuttons as you see fit.Q I placed multiple Label components on a form and then attempted to selectthem all by dragging.Instead I just got another big Label component.What have Idone wrong?A You forgot to turn off the multiple placement option.After placingmultiple components on the form, you need to click the arrow button on the Componentpalette to turn off the multiple placement option.Q I'm trying to position one of the IDE windows off to the side of the CodeEditor.Every time I try, however, the window wants to dock to the Code Editor.Howdo I prevent the window from docking?A Right-click on the window and turn the Dockable option off.Q When I accidentally type a character for my form's Top property, I get anerror message.I realize I should type a number rather than a character, but wheredoes the error message come from?A The Object Inspector knows what kind of value is correct for a givenproperty.A character is not valid for an integer property, so an error message isshown.In some cases it is the property editor that performs checks on the valueinput.Q What do I need to do in order for my application to be an MDI application?A Just be sure that the main form has a FormStyle of fsMDIForm and thatany MDI child forms have a FormStyle of fsMDIChild.Q What's the difference between a dialog box and a child window in Delphi?A There is no real difference.A dialog box form might have certain traitssuch as a dialog box border rather than a sizing border; OK, Cancel, and Help buttons;and no minimize or maximize buttons.But a dialog box is just a form like any other.A form might have the appearance of a dialog box or of a child window, but a formis just a form.Q Can I check the unit I'm working on for errors without running the program?A Yes.Just choose Project | Syntax Check from the main menu
[ Pobierz całość w formacie PDF ]