Documente Academic
Documente Profesional
Documente Cultură
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
Application Framework MFC library Visual C++ Components Event Handling Mapping modes colors fonts modal and modeless dialog windows common controls bitmaps
2
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
Windows Programming
History of Windows:
IBM PC 1981
OS MSDOS ( Microsoft Disk Operating System) MS DOS was minimal operating system. For the user, it provided a command-line interface to commands such as DIR and TYPE and loaded application programs into memory for execution.
Windows Programming
History of Windows:
For the application programmer, MS-DOS offered little more
than a set of function calls for doing file input/output (I/O).
For other tasksin particular, writing text and sometimes graphics to the video displayapplications accessed the hardware of the PC directly.
Windows Programming
History of Windows:
Apple Computer Jan 1983
OS - Lisa set a standard for graphical environments with Macintosh in Jan 1984.
pre-Macintosh)
10
Windows Programming
History of Windows:
Windows1.0
Nov 1985. with several updates to support the international market. with additional drivers for additional video displays and printers.
11
Windows Programming
History of Windows:
Windows2.0
Nov 1987. with several changes to the user interface. also enhancements to the keyboard and mouse interface, particularly for menus and dialog boxes.
12
Windows Programming
History of Windows:
Windows2.0
requires only Intel 8086 or 8088 microprocessor running in "real mode" to access 1 megabyte (MB) of memory. Windows/386 released shortly after Windows 2.0
Windows Programming
History of Windows:
Windows/286
Windows 2.1 was renamed Windows/286.
Windows3.0
May 22, 1990.
14
Windows Programming
History of Windows:
Windows3.1 April 1992
several significant features included the TrueType font technology, multimedia (sound and music), Object Linking and
15
Windows Programming
History of Windows:
WindowsNT July 1993 was the first version of Windows to support the 32-bit mode of the Intel 386, 486, and Pentium microprocessors. Programs that run under Windows NT have access to a 32-bit flat address space and use a 32-bit instruction set. required a 286 or 386 processor with at least 1 MB of was also designed to be portable to non-Intel processors. it runs on several RISC-based workstations.
16
Windows Programming
History of Windows:
Windows95 Aug 1995
also supported the 32-bit programming mode of the Intel 386 and later microprocessors. Adv - requiring fewer hardware resources. Dis adv - lacked some of the features of Windows NT, such as high security and portability to RISC machines.
17
Windows Programming
History of Windows:
Windows95 June 1998
has a number of enhancements such as, performance improvements. better hardware support. a closer integration with the Internet and the World Wide Web.
18
Windows Programming
Dynamic Linking:
Windows provides function calls that an application needs to
implement its user interface and display text and graphics on the video display.
Windows Programming
Dynamic Linking:
In the early days, Windows was implemented in just three
dynamic-link libraries. These represented the three main subsystems of Windows, which were referred to as Kernel, User, and GDI.
Kernel - handles memory management, file I/O and tasking. User - refers to the user interface, and implements all the
windowing logic.
GDI - is the Graphics Device Interface, which allows a program to display text and graphics on the screen and printer.
20
Windows Programming
Dynamic Linking:
Windows98 supports several thousand function calls that
applications can use.
21
Windows Programming
Dynamic Linking:
In Windows program, we use the Windows function calls same as
C library functions like strlen.
Difference The machine code for C library functions is linked into program code. whereas the code for Windows functions is located outside of
22
Windows Programming
Dynamic Linking:
When you run a Windows program,
23
Windows Programming
Dynamic Linking:
When a Windows program is loaded into memory,
the calls in the program are resolved to point to the entries of the DLL functions.
DLL functions are also loaded into memory if not already there.
24
Windows Programming
Dynamic Linking:
When link a Windows program to produce an executable file,
must link with special "import libraries" provided with programming environment.
These import libraries contain the dynamic-link library names and reference information for all the Windows function calls.
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
28
);
LPSTR & PSTR are two data types defined in WINNT.H as pointers to character strings. The LP prefix stands for "long pointer.
32
Hungarian Notation
33
34
35
Fourth parameter indicates how the program should be initially displayedeither normally or maximized to fill the window, or minimized to be displayed in the task list bar.
36
For example,
37
Third Parameter
- is the text string that appears in the caption bar of the message box.
38
Fourth Parameter - can be a combination of constants beginning with the prefix MB_ that are defined in WINUSER.H. can pick one constant from the first set to indicate what buttons you wish to appear in the dialog box:
39
0x00000000L 0x00000001L
#define MB_ABORTRETRYIGNORE
#define MB_YESNOCANCEL #define MB_YESNO #define MB_RETRYCANCEL
0x00000002L
0x00000003L 0x00000004L 0x00000005L
Note: When set the fourth argument to 0, only the OK button appears in the message box.
40
can use the OR (|) operator to combine one of the constants shown above with a constant that indicates which of the buttons is
the default:
#define MB_DEFBUTTON1 #define MB_DEFBUTTON2 #define MB_DEFBUTTON3 #define MB_DEFBUTTON4 0x00000000L 0x00000100L 0x00000200L 0x00000300L
41
can also use a constant that indicates the appearance of an icon in the message box:
42
43
Will get a message box asking you if you want to build the program.
44
46
dynamic-link libraries.
Configuration Files:
In the Visual C++ Developer Studio, compile and link the program
in different configurations. By default, these are called Debug and Release.
47
48