<<

Visual ++ Using Microsoft Visual Developer Studio IDE C++ Developer Studio See notes & example programs from CS-360

URLs: http://www.cs.binghamton.edu/~reckert/360/1_f01_fin.PDF http://www.cs.binghamton.edu/~reckert/360/360notes.html http://www.cs.binghamton.edu/~reckert/360/360pgms.html

Using Microsoft Visual C++ Visual Studio Components Developer Studio l The Editors l Self-contained environment for C or C++ source program text editor Windows program development: • cut/paste color cues, indentation, – creating • generates text files – compiling Resource Editor – linking • icons, bitmaps, cursors, menus, dialog boxes, – testing/ etc. • graphical, WYSIWYG, Integrated l IDE that accompanies Visual C++ • generates resource script (.rc) files • integrated with text editor

The The Linker l C/C++ – translates source programs to machine l reads compiler .obj/.res files language l accesses C/C++/Windows libraries – detects and reports errors l generates executable (.exe or .dll) – generates object (.obj) files for linker l Resource Compiler – Reads .rc file – Generates binary resource (.res) file for linker

1 The Debugger

l powerful source code debugger l integrated with all parts of Dev Studio l Features – breakpoints – tracing through/over functions – variable watch windows – much more

The Wizards Online Help

l AppWizard l Can be accessed by: – Windows code generator for MFC apps – InfoViewer book/chapter – automatically creates working program skeletons – Topic (keyword search-->relevant topics/articles)…Help/Index from Menu l ClassWizard – F1 help (help on item under mouse cursor) – facilitates easy extension of AppWizard- – The Web: MSDN (Microsoft Developer generated classes Network) – used to tailor AppWizard-generated MFC skeletons

InfoViewer Online Help InfoViewer Online Help (Win32 API Programming) (MFC Programming)

MSDN Visual Studio 6.0 MSDN Library Visual Studio 6.0 Platform SDK Visual C++ Documentation Reference Reference Microsoft Found. Class Lib. & Templates Win32 Functions by Category Microsoft Foundation Class Library Win32 Simple Data Types Class Library Reference Select Desired Class

2 MSDN Library (on Web) Other Advanced Tools l Go to: http://msdn.microsoft.com l SPY++ – Search on desired topic l PVIEW – Good URL for MFC: http://msdn.microsoft.com/library/default.asp l ActiveX utilities, a gallery of software ?url=/library/enus/vcmfc98/html/_mfc_class components _library_reference_introduction.asp l More

Using Developer Studio 97 and Visual C++ 5.0/6.0 l To prepare many kinds of applications – Win32 Console Applications (DOS programs) – Win32 API Apps – Win32 MFC apps – DLLs – Lots of others

Components Toolbars l Menu bar l Contain icons--instant routes to main l Several tool bars menu functions l Project Workspace Window (left) l Output, Workspace, Standard, Build, – InfoView, FileView, ClassView, ResourceView Edit, InfoViewer, Resource, etc. l Editor Window (right) l May not be visible – Use Text Editor to Enter C/C++ code l If not, right click on any visible toolbar – Use Resource Editors l Brings up following popup window l Output Window (bottom). l Can activate a toolbar by clicking on its – System messages (errors) check box

3 Projects and Workspaces l Project – collection of interrelated source files – compiled/linked to generate a Windows executable – project information stored in .dsp text file l Project Workspace – contains all information relating to a project – can have multi-project workspaces • combinations of projects in one application – workspace information stored in .dsw text files

Important Dev Studio Temporary Dev Studio Generated Files generated files l .dsp Project file l Many are huge and can (should) be removed! l .c or .cpp C/C++ source l .ilk Incremental link file l .h C/C++ header l .pch Precompiled header l .dsw Workspace file l .pdb Precompiled debugging info l .rc Resource script l .idb Incremental debug info l .res Compiled resource l .ncb Supports viewing classes l .ico Icon l .aps Supports viewing resources l .bmp Bitmap image l .bsc Browser information file l .exe Executable program l .clw Supports ClassWizard l .dll Dynamic Link Library (if used) l .opt Workspace configuration l .obj translations l .plg Build log file

Windows Program Setting the Configuration Configurations

l Debug l Click "Build" on Main Menu – appends debugging info l Choose "Select Active Configuration” – produces more and larger files l Choose configuration (“Debug” or l Release “Release”) – no debugging info l Default is “Debug” – optimized for size & efficiency

4 Create a Win32 App w/ Dev Studio l “Win32 Application, Step 1 of 1” l Startup Window – click ‘Start’ on Task Bar – Select “An Empty Project” – ‘Programs | | Microsoft • Click “Finish” Visual C++’ l “New Project Information” Window l Creating Project • Click “OK” – ‘File | New’ from menu – ‘Projects’ Tab (if not chosen) – ‘Win32 Application’ – Name the project (e.g. winapp1) – ‘OK’

l Inserting source files into project: l Building Project: – Open new C++ file, type or copy/paste the – ‘Build | Build winapp1” from menu code into the program • Shortcut key: F7 • “File | New | Files tab | C++ Source” – Project will be compiled/linked • Make sure “Add to Project is checked” – Messages will appear in Output Window • Enter a file name (e.g., winapp1) • Type or paste in the resulting Edit window l Running Program: – To see/modify a file added to project: – ‘Build | Execute winapp1” • click FileView tab in Workspace Window • Shortcut key: Ctrl-F5, or click exclamation point • click on file name in FileView window

l Cleanup: – Copy workspace, project, source, header, resource files to disk – Copy .exe from project's Debug directory – Best: Delete all temporary files & copy entire workspace (project directory) to floppy – Delete project directory from hard drive l Exiting Developer Studio: – ‘File | Exit’ from menu

5