Professional Documents
Culture Documents
CS1253 Visual Programming: Unit I Windows Programming
CS1253 Visual Programming: Unit I Windows Programming
VISUAL PROGRAMMING
UNIT I WINDOWS PROGRAMMING
Windows environment – a simple windows
program – windows and messages –
creating the window – displaying the window
– message loop – the window procedure –
message processing – text output – painting
and repainting – introduction to GDI – device
context – basic drawing – child window
controls
1
CS1253
VISUAL PROGRAMMING
UNIT II VISUAL C++ PROGRAMMING –
INTRODUCTION
Application Framework – MFC library –
Visual C++ Components – Event Handling –
Mapping modes – colors – fonts – modal and
modeless dialog – windows common
controls – bitmaps
2
CS1253
VISUAL PROGRAMMING
UNIT III THE DOCUMENT AND VIEW
ARCHITECTURE
Menus – Keyboard accelerators – rich edit
control – toolbars – status bars – reusable
frame window base class – separating
document from its view – reading and writing
SDI and MDI documents – splitter window
and multiple views – creating DLLs – dialog
based applications 3
CS1253
VISUAL PROGRAMMING
UNIT IV ACTIVEX AND OBJECT LINKING
AND EMBEDDING (OLE)
ActiveX controls Vs. Ordinary Windows Controls –
Installing ActiveX controls – Calendar Control –
ActiveX control container programming – create
ActiveX control at runtime – Component Object
Model (COM) – containment and aggregation Vs.
inheritance – OLE drag and drop – OLE embedded
component and containers – sample applications
4
CS1253
VISUAL PROGRAMMING
UNIT-V ADVANCED CONCEPTS
Database Management with Microsoft ODBC –
Structured Query Language – MFC ODBC classes
– sample database applications – filter and sort
strings – DAO concepts – displaying database
records in scrolling view – Threading – VC++
Networking issues – Winsock – WinInet – building
a web client – Internet Information Server – ISAPI
server extension – chat application – playing and
multimedia (sound and video) files 5
CS1253
VISUAL PROGRAMMING
TEXT BOOKS
1. Charles Petzold, “Windows Programming”,
Microsoft press, 1996 (Unit I – Chapter 1-9)
2. David J.Kruglinski, George Shepherd and Scot
Wingo, “Programming Visual C++”, Microsoft
press, 1999 (Unit II – V)
REFERENCES
1. Steve Holtzner, “Visual C++ 6 Programming”,
Wiley Dreamtech India Pvt. Ltd., 2003.
6
UNIT – I
Windows Programming
Text Book :
7
Windows Programming
History of Windows:
IBM PC – 1981
8
Windows Programming
History of Windows:
9
Windows Programming
History of Windows:
• OS - Lisa
Windows
10
Windows Programming
History of Windows:
Windows1.0
• Nov 1985.
11
Windows Programming
History of Windows:
Windows2.0
• Nov 1987.
12
Windows Programming
History of Windows:
Windows2.0
Windows/386
Windows/286
Windows3.0
14
Windows Programming
History of Windows:
15
Windows Programming
History of Windows:
17
Windows Programming
History of Windows:
• performance improvements.
Web.
18
Windows Programming
Dynamic Linking:
19
Windows Programming
Dynamic Linking:
• All the Windows functions that an application may use are declared in
header files.
21
Windows Programming
Dynamic Linking:
Difference –
• The machine code for C library functions is linked into program
code.
• whereas the code for Windows functions is located outside of
the program in the DLLs.
22
Windows Programming
Dynamic Linking:
23
Windows Programming
Dynamic Linking:
• DLL functions are also loaded into memory if not already there.
24
Windows Programming
Dynamic Linking:
• The linker uses this information to construct the table in the .EXE
file that Windows uses to resolve calls to Windows functions
when loading the program. 25
Simple Windows Program
First Windows Program:
It has
• an include statement,
• a return statement.
26
Simple Windows Program
First Windows Program:
For Example,
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE
hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
MessageBox (NULL, TEXT ("Hello Welcome!!!"), TEXT
("HelloMsg"), 0) ;
return 0 ;
} 27
Simple Windows Program
First Windows Program:
The C run-time library function printf has been replaced with the
Windows API function MessageBox.
28
Simple Windows Program
The Header Files:
#include <windows.h>
The most important and most basic of these header files are:
These header files define all the Windows data types, function
calls, data structures, and constant identifiers.
It is convenient to use the Find In Files option from the Edit menu
in the Visual C++ Developer Studio to search through these
header files.
It can also open the header files in the Developer Studio and
examine them directly.
30
Simple Windows Program
Program Entry Point:
int
WINAPI
WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
);
LPSTR & PSTR are two data types defined in WINNT.H as pointers
to character strings.
The LP prefix stands for "long pointer“.
32
Simple Windows Program
Prefix Data Type Hungarian
b BOOL Notation
c or ch char
clr COLORREF Note:
cx, cy Horizontal or vertical distance Prefixes can be
dw DWORD combined:
h Handle pszName
l LONG m_nAge
n int
p Pointer
sz Zero-terminated string
w WORD
wnd CWnd
str CString
m_ class member variable
33
Simple Windows Program
Program Entry Point:
WinMain Parameters:
First parameter -
34
Simple Windows Program
Program Entry Point:
WinMain Parameters:
Second parameter -
• It could then skip certain chores and move some data from the
previous instance into its own data area.
WinMain Parameters:
Third parameter -
• is the command line used to run the program.
• Some Windows applications use this to load a file into memory
when the program is started.
Fourth parameter –
• indicates how the program should be initially displayed—either
normally or maximized to fill the window, or minimized to be
displayed in the task list bar.
36
Simple Windows Program
MessageBox Function:
37
Simple Windows Program
MessageBox Function:
Parameters:
38
Simple Windows Program
MessageBox Function:
Parameters:
• can pick one constant from the first set to indicate what buttons you
wish to appear in the dialog box:
39
Simple Windows Program
MessageBox Function:
Buttons:
40
Simple Windows Program
MessageBox Function:
Buttons:
41
Simple Windows Program
MessageBox Function:
Buttons:
42
Simple Windows Program
MessageBox Function:
Buttons:
43
Simple Windows Program
Compile, Link and Run:
Will get a message box asking you if you want to build the
program.
44
Simple Windows Program
Compile, Link and Run:
45
Simple Windows Program
Compile, Link and Run:
Import Libraries:
46
Simple Windows Program
Compile, Link and Run:
Import Libraries:
Configuration Files:
In the Visual C++ Developer Studio, compile and link the program
in different configurations.
Configuration Files:
48