200 likes | 545 Views
CS-360/580H GU I & Window s Programming Dr . Richar d R . Eckert Compute r Scienc e Department SUN Y Binghamton Fall , 2009 C S -360: MWF, 1:10- 2:1 0 P.M. , S L -210 C S -580H: TR, 8:30- 9:5 5 A.M. , S W -325. Cours e Information • Office : EB - N6 • Phone : 777 -4365
E N D
CS-360/580H GUI&WindowsProgramming Dr.RichardR.Eckert ComputerScienceDepartment SUNYBinghamton Fall,2009 CS-360:MWF,1:10-2:10P.M.,SL-210 CS-580H:TR,8:30-9:55A.M.,SW-325 CourseInformation •Office:EB-N6 •Phone:777-4365 •OfficeHours:W,R1:30-2:30P.M. •Email:reckert@binghamton.edu •http://www.cs.binghamton.edu/~reckert/ –CS-360linkforsyllabus,notes,programs,assignments,etc. •ClassListserv: –CS360-L@listserv.binghamton.edu •CS-360TA:ElifDede •CS-580HTA:YiboSun
CoursePrerequisites •CS-240,DataStructures •SomeknowledgeofCorC++ TextBookInformation •Required: –Deitel,et.al.,“VisualC#2005:HowtoProgram”, 2ndEdition,PH/Pearson,2005,ISBN0-13-152523-9 •Recommended: –KateGregory,“SpecialEditionVisualC++.NET”,Que,2002,ISBN0-7887-2466-9 •ManyBooksonReserve –SeeReserveListinCourseSyllabus
Software •MicrosoftVisualStudio2005or2008Professional Edition –2008availableatmostUniversitypubliccomputerfacilities –Getyourowncopyofeither •FromMicrosoftAcademicAlliance –AvailablenowtoallregisteredBUstudents –https://msdn04.e-academy.com/elms/Security/PasswordReminder.aspx?campus=binghamton_watson •Smaller.NET2005or2008“ExpressEditions”freefromMicrosoft: –VisualC++2005/08,VisualC#2005/08,SQLServer 2005/08VisualWebDeveloper2005/08ExpressEditions –http://msdn.microsoft.com/vstudio/express/ Evaluation •ProgrammingAssignments40% •TermExaminations(2)40% •Quizzes(360)/Paper(580H)10% •FinalProject10%
Policies •Assignments –Individual –Dueonduedate,butcanbeturnedintoCS- 360/CS-580Hdropdrawerinfilingcabinets outsideCSDepartmentanytimethatdayornight –5%offforeverydaylate •Weekendsandholidaysnotincluded –Noassignmentsacceptedmorethanoneweeklate •Originality –Anynon-originalwork(workfoundtobecopied)willbegroundsforanFinthecourse –Individualassignments •StudentsdoNOTworkinteams CourseSchedule(weekly) 1.IntrotoGUIs&WindowsProgramming,UsingVisualStudio 2.Win32APIProgramming 3.MFCProgramming:App/Window&Doc/ViewApproaches 4.VisualStudio.NET&C#,Classes,Windows Forms,Events,EssentialStructures 5.Graphics,Animation,Timers,DateTime 6.Mouse,Images,Bitmaps 7.Text,Fonts,Keyboard,Printing 8.Pages&Transformations,Menus
CourseSchedule(continued) 9.Controls:Buttons,Labels,TextBoxes,Scrollbars,Listboxes,etc. 10.DialogBoxes,CommonDialogBoxes,File/StreamI/O 11.Clipboard,Multimedia 12.NetworkProgramming,TCP/IPSockets 13.DataBasesandADO.NET,LINQ 14.XML,WebForms,WebControls,ASP.NET;WPF&WCF 15.ASP.NETWebServices 16.OtherWindowingSystems:XWindows,JavaAWT/Swing IntroductionToGUIsand WindowsProgramming
UserInterface •Connectionbetweenthecomputerandtheuser •Twotypes: –CommandLine –GUI:Graphical(Visual) CommandLineInterfaces •Usertypescommands,mustremembervalidcommands •ResultsScrollby •Text-based •“Interactive”buthardtouse •Onlykindofinterfaceavailableuntil1970s
Visual(Graphical)Interfaces •ShowGraphicalObjectsonscreen –e.g.,images,icons,buttons,scrollbars •Userinteractsusingpointingdevice •Intuitive –Objectscanbedragged,buttonspushed,etc.... •Betterwayofusingscreenspace –Panescanoverlap –Underlyingpanescanbebroughttoforefront –Desktopmetaphor(likepapersonadesk) GraphicalInterfaces,Continued •Usegraphicstoorganizeuserworkspace –Visuallyrichwayofconveyinginformation •Environmentallowsmanytaskstobeperformedsimultaneously •Differenttaskssharescreenspace
MainFeatureofGUIs •TheWindow –Rectangularareaofscreenontowhicha programdrawstextandgraphics –Userinteractswithprogramthatcreated thewindowusingapointerdeviceto selectobjectsinside –Somewindowcomponents: •border,titlebar,clientarea,menubar,toolbars,scrollbars,max/min/closebuttons,etc. HistoryofGUIs •DARPASRI(late60s) •XeroxPARCAlto(early70s) •Microcomputers(late70stopresent) –PC(DOScommandline) –AppleLisa,Macintosh •FirstrealmicrocomputerGUI –MicrosoftWindows •Manyversions •We’llemphasizeGUIProgrammingforMicrosoft Windowsinthiscourse
OtherGUI-WindowingSystems •SunMicrosystems:Java –AWT –Swing –Platformindependent –JDKisfree •TheXWindowSystem –DevelopedatMIT,late1980s –Networkedgraphicsprogramminginterface –Independentofmachinearchitecture/OS(butmostlyusedunderUNIX/LINUX) WindowingSystemsFeatures •Consistentuserinterface –Informationdisplayedwithinawindow –Menustoinitiateprogramfunctions –Makeuseofchildwindow“controls” –Pointandclickuserinteractionwithwindow •Allprogramshavesamelookandfeel •Samebuilt-inlogicto: –drawtext/graphics –displaymenus –receiveuserinput �controls,dialogboxes,useofmouse
Multitasking •Manyprogramsrun“simultaneously” •Eachprogramcreates/controlsitsown window •Userinteractswithprogramviaitswindow •Usercanswitchbetweenprogramsby switchingbetweenwindows WindowsMultitasking Features •Cooperative(Windows3.xx) –Programsmustgiveupcontrolsootherscanrun –Programscoexistwithotherprograms •Preemptive(WindowsNT,95,98,XP,2000, 2003,Vista) –Thread-based:Systemtimerallocatestimeslicestorunningprogramthreads •Underbothsystems,codeismovedorswappedintoandoutofmemoryasneeded
WindowsMemoryManagement •Olderversions:16-bit,segmentedmemory –Dictatedbyprocessorarchitecture –Hardtoprogram •64kilobytememorysegmentlimitation •Newerversions:32/64-bit,flatmemorymodel –Easiertoprogram –Eachprocesssees4Gigabytesofvirtualmemory •Asoldprogramsterminate,newonesstart –Codeswappedintoandoutofmemory –WindowsOSdoesthisautomatically •Programscansharecodelocatedinotherfiles (DynamicLinking) Staticvs.DynamicLinking •StaticLinking –Codeincorporatedintoexecutableatlink time •DynamicLinking –Codeisputintoseparatemodules(DLLs) –Theseareloadedatruntimeasneeded
Pros/ConsofDynamicLinking •Smallerprograms(codeisnotinprogram) •DLLcanbeusedbymanyprogramswithnomemorypenalty –Onlyloadedonce! •Disadvantages: –DLLmustbepresentatruntime==>nostandaloneprograms –“DLLHell”whennewDLLversionscomeout •MostoftheWindowsOSisimplementedas DLLs DeviceIndependentGraphics •Windowsprogramsdon’taccesshardware devicesdirectly •Makecallstogenericfunctionswithinthe Windows‘GraphicsDeviceInterface’ (GDI,GDI+,orWPF) •TheGDI/GDI+/WPFtranslatestheseinto HWcommands ProgramGDIHardware
WindowsAPI �ApplicationProgramInterface �Theprogrammer’sinterfacebetweenanapplicationandtheWindowsOS �AlibraryoffunctionsWindows programscancall �Severalversions �Win32APImostfundamental �(32bitappsforWindows NT/95/98/XP/2000/2003/Vista) ClassicalWin32APIWindows Programming •UseCtoaccessrawAPIfunctionsdirectly •NoC++classlibrarywrapperstohideAPI –ButC++compilercanbeused •Hardwaytogo,butmostbasic •Fasterexecutables •ProvidesunderstandingofhowWindowsOS andapplicationprograminteract •EstablishesafirmfoundationforMFCand .NETprogramming
Class-basedWindowsProgramming •“MicrosoftFoundationClass”Library (MFC) •Microsoft.NET“FrameworkClassLibrary”(FCL) •Borland’s“ObjectWindowLibrary”(OWL) •Characteristics: –EncapsulatetheAPIfunctionsintoclasses –Providealogicalframeworkforbuilding Windowsapplications –ObjectOrientationmeansreusablecode MFCLibrary •Microsoft’sfirstC++InterfacetoWin32API •Mostbasicobjectorientedapproachto Windowsprogramming •Some200classes •APIfunctionsencapsulatedintheMFC •ClassesderivedfromMFCdogruntwork •Justadddata/functionstocustomize –OrderiveyourownclassesfromMFCclasses •Providesauniformapplicationframework •Fastexecutables
Microsoft.NETFramework –AsoftwaresystemthataddressesnewSWrequirements •1.WindowsForms:standaloneWindowsapplications •2.WindowsdistributedapplicationsovertheInternet –ASP.NET –ADO.NET –Multi-tierapplications •LanguageIndependent(programscanbewritteninmultiple languages) •PlatformIndependentArchitecture •Newprogramdevelopmentprocess –Objectoriented –Providesincreasedproductivity –NewvisionforusingtheInternetinsoftwaredevelopment •Newsecurityandreliabilityfeatures
Componentsof.NETFramework •Languagecompilers •The.NETFrameworkClassLibrary(FCL) –Organizedinto“namespaces” •likepackagesinJava –Handlethingslike:I/O(simple&file),WindowsForms,WebForms,WindowsControls,UserInterfaces,Drawing,Threading,Exceptions,Networking,WebServices,DataBases(ADO),XML,ASP,Security,Collections,…lotsofothers •CommonTypeSystem(CTS) •CommonLanguageSpecification(CLS) •CommonLanguageRuntime(CLR) .NETArchitecture
Compilationinthe.NET Framework CommonLanguageRuntime SequentialProgramming versus Event-drivenProgramming
SequentialProgramming(Console Applications) �Standardprogramming--programsolicitsinput (pollingloop) �Approachfollowsastructuredsequenceofevents �Example--averaginggrades: �Inputname �Inputfirstgrade �Inputsecondgrade �Inputthirdgrade,etc. �Calculateaverage �Outputaverage Event-DrivenProgramming •Designedtoavoidlimitationsofsequential,procedure-drivenmethodologies •OSprocessesuseractions(events)astheyhappen:non-sequential •Programdoesn’tsolicitinput •OSdetectsaneventhashappened(e.g..,there’sinput)andsendsamessagetotheprogram •Programthenactsonthemessage •Messagescanoccurinanyorder
Sequentialvs.Event-DrivenProgramming •StandardSequentialprogramming: –Programdoessomething&userresponds –Programcontrolsuser •thetailwagsthedog •Event-DrivenProgramming: –Userdoessomethingandprogramresponds –Usercanactatanytime –Usercontrolsprogram •thedogwagsthetail –OSreallyisincontrol(coordinatesmessageflowtodifferentapplications) –Goodforappswithlotsofuserintervention