150 likes | 295 Views
Microsof t Visua l Studio: A n Integrate d Windows Progra m Development Environment. Microsof t Visua l Studio • Self - containe d environmen t fo r Windows progra m development: – Creating/editing – Compiling/linkin g (building) – Testing/debugging
E N D
MicrosoftVisualStudio:AnIntegratedWindowsProgramDevelopmentEnvironmentMicrosoftVisualStudio:AnIntegratedWindowsProgramDevelopmentEnvironment MicrosoftVisualStudio •Self-containedenvironmentforWindowsprogramdevelopment: –Creating/editing –Compiling/linking(building) –Testing/debugging •IDEthataccompaniesVisualC++,Visual Basic,VisualC#,andotherMicrosoftWindowsprogramminglanguages •SeeChapter2&AppendixCoftheDeiteltext •AlsoAppendixCoftheGregorytext
SomeVisualStudioComponents •TheEditors: C,C++,C#,VBsourceprogramtexteditors •cut/paste,colorcues,indentation •generatesourcetextfiles ResourceEditors •Resources:Windowsstaticdata •Determinelookandfeelofanapplication -icons,bitmaps,cursors,menus,dialogboxes,etc. •graphical •generateresourcescript(.rc)files •integratedwithtexteditor •createdvisually .NETLanguageCompilers •UnmanagedCodeC/C++Compiler -translatessourceprogramstomachinelanguage -generatesobject(.obj)filesforlinker •ManagedCode.NETLanguageCompilers -Manyofthem�multi-languageinteroperability -TranslatesourceprogramstoMSIL -Generatea“PortableExecutable”thatmustbetranslatedtotargetmachinelanguagebytheCLR •ResourceCompiler -Reads.rcfile -Generatesbinaryresource(.res)fileforlinker
TheLinker •Readscompiler.objand.resfiles •AccessesC/C++/Windowslibraries •Generatesexecutable(.exeor.dll)
ProgramBuildandRuninthe .NETFramework CommonLanguageRuntime TheDebugger •Powerfulsourcecodedebugger •IntegratedwithallpartsofVisualStudio •Features -breakpoints -tracingthrough/overfunctions -variablewatchwindows •SeeAppendixCofDeiteltextbook
TheWizards •AppWizard -WindowscodegeneratorforWindowsapps -automaticallycreatesworkingprogramtemplates&skeletoncode •ClassWizard -facilitateseasyextensionofAppWizard-generatedclasses -creationofnewclasses -usedtotailorAppWizard-generatedMFC& .NETskeletons -AccessibleinthePropertiesWindowin.NET Help •EssentialwhendevelopingWindowsapps •Hoveroverkeywordsineditwindowandaone-linehelpmessageappears •‘Help’MenuItem -‘DynamicHelp’-contextsensitive •Clickontextineditwindowandcorrespondingtopicappearsinhelpwindow •Clickontopicinhelpwindowtogethelp -‘Contents’:Selectatopic -‘Search’:Enteratopic -‘Index’:Enter/chooseatopic
MSDNLibrary(onWeb) •Goto:http://msdn.microsoft.com -SearchMSDNfordesiredtopic -Someexamples: •WindowsAPIreference •MFCreference •Windowsformsclasslibrary UsingVisualStudio •Topreparemanykindsofapplications -Win32ConsoleApplications(DOSprograms) -Win32APIAppsinCorVC++ -MFCAppsinVC++ -DLLs -.NETWindowsFormsAppsinManagedC#,VB,VC++,andotherlanguages -ASP.NETWebAppsandServices -ADO.NETDataBaseApps -Others
VisualStudioLayout •MenuBar •SeveralToolBars •ViewWindows(totheside) -SolutionExplorer -ClassView -ResourceView -PropertiesWindow •WorkingArea(mainwindow) -TextEditortoenter/modifysourcecode -ResourceEditors -Tabbetweendifferentworkareas •OutputWindow&StatusBar(bottom). -SystemMessages(errors) •Windowscanbemovedaround,dockedandundocked
Toolbars •ContainIcons--instantroutestomainmenufunctions •Maynotbevisible •Ifnot,rightclickonanyvisibletoolbar •Bringsupfollowingpopupwindow •Canactivateatoolbarbyclickingonitscheckbox KeyboardShortcuts •AllMenu/Toolbarselectionsareavailable fromthekeyboardusingkeycombinations •Canbefaster •MoreinformationinOnlineHelp -‘Index’|‘KeyboardShortcuts’|‘Predefined’
SolutionsandProjects •Solution -Asingleapplication -Cancontainoneormoreprojects •InManagedapplications,projectscanbeindifferentlanguages -Overallsolutioninformationstoredina.SLNfile -Openthiswhenyouwanttoworkonasolution •Project -Basiccomponentofanapplication -Collectionoffiles: •Source,headers,resources,settings,configurationinformation,manymore ImportantVisualStudioGeneratedFiles •.slnSolution •.vcprojProject •.c,.cpp,.csC/C++/C#WindowsAppsourcecode •.hC/C++header •.rcResourcescript •.resCompiledresource •.icoIcon •.bmpBitmapimage •.exeExecutableprogram •.dllDynamicLinkLibrary •.aspxASP.NETWebFormsourcecode •.asmxASP.NETWebServicesourcecode
TemporaryVisualStudioGenerated Files •Manyareverybigandcan(should)beremoved! •.objCompilermachinecodetranslation •.ilkIncrementallinkfile •.pchPrecompiledheader(huge!) •.pdbPrecompileddebugginginfo •.idbIncrementaldebuginfo •.ncbintellisensedatabase(huge!) •.apsSupportsviewingresources •Others •Canbedeleted ProgramConfigurations •Debug -appendsdebugginginformation -producesmoreandlargerfiles •Release -nodebugginginformation -optimizedforsize,performance,&efficiency
SettingtheConfiguration •Click‘Build’onMainMenu •Choose‘ConfigurationManager’ •Choosedesiredconfiguration(‘Debug’or ‘Release’)inConfigurationManager’s ‘ActiveSolutionConfigurationBox’ •Defaultis‘Debug’ CreatingaWin32APIWindows ApplicationwithVisualStudio •Startup -Click‘Start’onTaskBar-‘AllPrograms’ -‘MicrosoftVisualStudio2008’|‘Microsoft VisualStudio2008’ •CreatinganewWin32APIsolution -‘File’|‘New’|‘Project’fromMenuBar -In‘NewProject’box,select‘VisualC++’‘Win32’from‘ProjectTypes:’&clickon‘Win32Project’in‘Templates’ -Setthe‘Location’toaconvenientdirectory& nametheproject(e.g.win32app1) -‘OK’
•Click‘ApplicationSettings’inresulting ‘Win32ApplicationWizard’Box -Select‘WindowsApplication’from ‘ApplicationType’radiobuttons -Select‘EmptyProject’from‘Additional Options’checkboxes -Click‘Finish’ •Insertingsourcefilesintoproject: -OpenanewC++file&typeorcopy/pastethecodeintotheprogram: •‘File’|‘New’|‘File’frommenu •Choose‘VisualC++’from‘Categories’,C++file(.cpp) from‘InstalledTemplates’,&click‘Open’ •TypeorpastesourcecodeintotheresultingEditwindow •Savethefileintheproject’ssubdirectoryasaC++sourcefile,givingitanappropriatename(e.g.,win32app1) -Addthesourcefiletotheproject: •Choose‘Project’|‘AddExistingItem’frommenu •Clickonthefileyousaved(e.g.win32app1.cpp) •Confirmthatitwasaddedtotheprojectbyexpanding ‘SourceFiles’intheSolutionExplorerWindow -IfSolutionExplorerisnotvisible,select‘View-SolutionExplorer’ fromthemenu
•AlternativeWayofAddingaSourceFiletoaProject: -Youcanalsocopyanexistingsourcecodefileintotheproject’ssubdirectory -Thenasbefore: •Choose‘Project’|‘AddExistingItem’fromthemenu •Selectthe.cppfile&click‘Open’ -ShouldappearinSolutionExplorerwindow -Openitbydoubleclickingonit •BuildingtheSolution: -‘Build’|‘BuildSolution’frommenu -Projectwillbecompiled/linked -Messages/errorswillappearinOutput Window •RunningtheProgram: -‘Debug’|‘Start’frommenu •Shortcutkey:F5 -Or‘Debug’|‘StartWithoutDebugging’frommenu •Shortcutkey:Ctrl-F5
CompilingfromCommandLine •CommandLineCompilers: -C++:CL.EXE -C#:CSC.EXE -VisualBasic:VBC.EXE •AllarerunfromaDOSsession,butdirectorypathsmustbesetcorrectly •EasiesttostartaVisualStudio2008 CommandPrompt(pathsalreadyset) -FromTaskBar: •Start|AllPrograms|MicrosoftVisualStudio2008|VisualStudioTools|VisualStudio2008CommandPrompt CommandLineCompiling,continued •TocompileourfirstVisualC++,Win32API application(win32a1.cpp)fromthecommandline: -clkernel32.libuser32.libgdi32.libwin32a1.cc -Notethatanyrequiredlibraries(DLLs)mustbespecified •Therearemanycompileroptions: -SeeOnlineHelp: -‘Index’|‘cl.execompiler’|‘buildingprograms’ -ForC#:‘Index’|‘csc.exe’ •Wewon’tbeusingcommandlinecompilersmuchinthiscourse,butthey’rethereifyouneedthem
•Cleanup: -Copysolution,project,source,header,resourcefilestodisk -Copy.exefilefromproject'sDebugdirectory -Best:Deletealltemporaryfiles©entire solution(projectdirectory)tofloppyorCD -Deleteprojectdirectoryfromharddrive •ExitingDeveloperStudio: -‘File’|‘Exit’frommenu