Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.

Slides:



Advertisements
Similar presentations
What Was I Thinking??. Key Terms 1. Control 1. Control 2. Design Mode 2. Design Mode 3. Event 3. Event 4. Form 4. Form 5. Interface 5. Interface 6. Properties.
Advertisements

Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
Based on slides created by Edward Angel
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Win32 API Programming Event-driven, graphics oriented Example: User clicks mouse over a program’s window area (an event) -- – Windows decodes HW signals.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Welcome to CIS 083 ! Events CIS 068.
Software GCSE COMPUTING.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
Chapter 1: Hello, MFC Windows Programming Model Department of Digital Contents Sang Il Park.
Computer Graphics I, Fall 2010 Input and Interaction.
Introduction to the Windows API n API - Application Programming Interface n an API is the software interface for things such as the OS n an API is the.
CS 480/680 Computer Graphics Programming with Open GL Part 7: Input and Interaction Dr. Frederick C Harris, Jr. Fall 2011.
BZUPAGES.COM Visual Programming Lecture – 2 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
Visual Basic.NET BASICS Lesson 3 Events and Code.
CS350 – Windows Programming Formerly and more properly named: Event Driven Programming Dr. Randy Ribler.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
Applications Development
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
Introduction to visual programming C#. Learning Outcomes In this chapter, you will learn about :  Event-Based Programming  The Event Based Model  Application.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
University of New Mexico
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Types of Software Chapter 2.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Microsoft Foundation Classes
Learning Programming Windows API Morpheus Feb-28, 2008.
Overview of Previous Lesson(s) Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Sockets A popular API for client-server interaction.
Chapter 1: Introduction to Computers and Programming
Event loops 16-Jun-18.
Windows Programming Lecture 09.
CSC461 Lecture 8: Input Devices
Chapter 1: Introduction to Computers and Programming
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Event loops.
Windows Programming Lecture 13
Arrays
Isaac Gang University of Mary Hardin-Baylor
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Input and Interaction Ed Angel
University of New Mexico
Input and Interaction Ed Angel
Event loops 8-Apr-19.
Tonga Institute of Higher Education
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Event loops.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/19.
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Prepared by Fareeha Lecturer DCS IIUI 1 Windows API

Lecture 22 What is Window API API Stands for Application Programming Interface Set of Functions that are part of Windows OS Program created by calling Functions present in APIs Internal of functions don’t have to be known All API functions contained in DLL

Lecture 23 Types of Window API Two basic varieties –API for 16-bit windows (Win16 API) –API for 32-bit windows (Win32 API) Both are almost same Win16 API is subset of Win32 API

Lecture 24 Core Components of APIs Win16 APIWin32 API USER.EXEUSER.DLL Responsible for window management, including messages, menus, cursor GDI.EXEGDI.DLL Graphical device interface KRNL386.EXEKRNL386.DLL Handles low level functions In Win16 extension is.EXE but actually all are DLLs.

Lecture 25 Win32 API Programming Event-driven, graphics oriented Example: User clicks mouse over a program’s window area— – Windows decodes HW signals from mouse – figures out which window user has selected – sends a message to that window’s program:

Lecture 26 "User has clicked over (X,Y)” "Do something and return control to me” – Program reads message data, does what's needed, returns control to Windows

Lecture 27 Events occur in response to –Message being passed between windows –User interaction with OS and application EDM is similar to heart, Message loop. Message loop is While loop() Windows provide Message Queue for each process

Lecture 28 Win32 API Program Structure--2 main tasks: Initial activities –Creating program own window –Startup activities Process messages from Windows (the message loop)

Lecture 29 PSEUDOCODE Initialize variables, memory space Create & show program's Window Loop – Fetch any msg sent from Windows to this pgm – If message is QUIT terminate program, return control to Windows – If message is something else take actions based on message & parameters return control to Windows End Loop

Lecture 210 Essential Parts of a Windows Programming The source program (.c/.cpp file): – A. WinMain() function Entering point of window application Like main() Windows searches it at run time

Lecture 211 Functions performed by WinMain() 1.Declarations, initialization, etc. Program window declare through Window Class Structure (WNDCLASS) which define class icon, cursor shape, background color, either want Menu Resource, Window class name 2.register window class Pass window settings to operating system OS assign ID to this program window so that OS can send message to correct window

Lecture 212 Functions performed by WinMain() 3.create a window based on a registered class 4.show window 5.Create a message loop  get messages from Windows (send to application queue)  dispatch back to Windows for forwarding to correct callback message-processing function Message Queue Windows provided area for holding yours application's messages All messages sent by Windows are stored in queue until called for

Lecture 213 Types of Messages Queued Messages –Caused by user Input from either mouse or Keyboard –Windows places them in queue –WinMain() extract them from queue for processing Non-Queued Messages –Concerned with windows management –Handle by Windows itself

Lecture 214 The Message Loop Every thing in Windows happen in response to message Standard Mechanism for retrieving messages from message Queue while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } Program must keep checking for messages Retrieve a message from message queue OS Fills MSG struct msg ID value. data passed in msg more data in msg time msg was sent mouse cursor position (x,y) when message was posted

Lecture 215 B. WndProc(): the msg-processing function. The Window Procedure "callback" function (called by Windows) Handle message for particular window Should contain a switch/case statement : – Looks at message ID of current message – Acts appropriately on "interesting" messages – Handle all queued messages – Forwards other messages (non queued) to default Window procedure--DefWindowProc()

Lecture 216 Some Important Messages WM_COMMAND--User clicked on menu item (Param) = menu item ID WM_*BUTTONDOWN--left/right mouse button pressed (* = L or R, lParam=x,y coordinates) WM_MOUSEMOVE--mouse moved (lParam=x,y coords) WM_PAINT--Part of window was exposed & should be redrawn WM_KEYDOWN--keyboard key pressed (wParam= virtual key code)