資源描述:
《modal dialogs:模態(tài)對(duì)話框》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫(kù)。
1、ModalDialogsModaldialogs:mustbedismissedbyuserbeforeanyworkcanbedoneoutsidethedialoginthesameapplication.(Butyoucanworkinanotherapplication).Systemmodal:can'tevenclicktoanotherapplication(example,theControl-Alt-Deletedialog).Modeless:dialogcanstayupwhileyouworkelsewhere(example,toolbarsor
2、toolpalettes).Purposesofmodaldialogs:·collectdatafromuser·presentdatatotheuser·permitusertocontrolapplicationdataModaldialogsareusedwithanordinarySDIorMDIapplication.Whenyouchoosea“dialog-based”application,yourmainwindowsisadialogboxthatisneverdismissed.Thisisnotamodaldialog.Ofcourse,such
3、anapplicationcanalsomakeuseofmodaldialogs,butthemainwindowisnotamodaldialog.ExampleLet’smakethesimplestpossibledialogbox,withjusttwocontrols,tolettheuserspecifytheheightandwidthofarectangle.TheninOnDrawwewilldrawarectangleinthespecifiedsize.MakeanewSDIapplicationcalledRectangleDialog.Choo
4、seProject
5、AddResourceandscrolldowntoDialog:SelectDialogandclicktheNewbutton,ordouble-clickDialog.YouwillbethrownintotheDialogEditor,whichweusedinthepreviouslecture.Designyourdialog.Inthiscase,putintwoeditboxes,oneabovetheother,andtwostatictextboxes,toholdthelabelsHeightandWidth.TheIDnumbe
6、rsofthestatictextboxesdonotmatter,asnocodewillinvolvethem.ChangetheIDnumbersoftheeditboxestoIDC_HEIGHTandIDC_WIDTH.Note:thetoolbarreferstoaneditboxasan“EditControl”—buteverybodycallsthem“editboxes”.Similarly,thetoolbarsays“StaticText”,buteveryonecallsita“statictextbox”.Here’sapictureofthe
7、dialogboxinthedialogeditor,afterdraggingthecontrolstothedesiredposition,andchangingthecaptionsofthestatictextboxesontheirpropertysheets:Right-clickyourdialogintheDialogEditor(inablankareathatisnotpartofacontrol).ChooseAddClass.ThatbringsupClassWizard:Giveyourclassaname(RectangleDialog)and
8、notethatthenamesofthe.hand.cppfilearefilledinforyou.ChangethebaseclasstoCDialog—thepictureshowsthedefault,whichisNOTCDialog.Ifyouforgettochangethis,you’llfindoutmuchlaterthatyoudialogdoesn’tworkproperly;thentheeasiestwaytocorrecttheerrorwillbetodeletethewrongdialoga