Introduction. Windows Programming 2  Windows –32-bit preemptive multitasking and multithreading graphical operating systems –GUI(graphical user interface)

Slides:



Advertisements
Similar presentations
Prof. Muhammad Saeed. Procedure-Driven Programming Event-Driven Programming Events Messages Event Handlers GUI Windows and Multitasking Queues ( System.
Advertisements

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Computer Graphics1 Windows NT Graphics Interface.
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber.
IN-LAB # 1 - GETTING STARTED - BUT FIRST: 1.Project ideas - watch the scope!!! 2.Check accounts 3. Either myself or the TA need to check you off BEFORE.
1 CE6130 現代作業系統核心 Modern Operating System Kernels 許 富 皓.
Chapter 1- Visual Basic Schneider1 Chapter 1 An Introduction to Computers and Visual Basic.
First Windows Program Hello Windows. 2 HELLOWIN.C #include LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance,
Intro to Windows Programming Basic Ideas. Program Entry Point Int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
Chapter 1- Visual Basic Schneider 1 Chapter 1 An Introduction to Computers and Visual Basic.
Building a Win32API Application Raw access to the API.
1 CS1253 VISUAL PROGRAMMING UNIT I WINDOWS PROGRAMMING Windows environment – a simple windows program – windows and messages – creating the window – displaying.
Chapter 10Other Topics Contents Using Multiple Accounts Sending Form Letters by Using Stationery Formatting.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
GVE, Hallym University, Song, Chang Geun, Ph.D. 컴퓨터 그래픽스 응용 한림대학교 컴퓨터공학부 송 창근.
Win32 API Programming Event-driven, graphics oriented Example: User clicks mouse over a program’s window area (an event) -- – Windows decodes HW signals.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Chapter 1: Hello, MFC Windows Programming Model Department of Digital Contents Sang Il Park.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
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.
CSE3AGT Paul Taylor Stupid Conventions! l = Long p = Pointer h = handle g = global wnd = Windows WM = Windows Message d3d = Direct3D hr = HRESULT.
Further games and graphics concepts COSE50581 Introduction to Module and Recap Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
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.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
Lection №5 Modern integrated development environment.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
Presentation Outline Introduction Painting and Repainting GDI.
CITA 342 Section 2 Visual Programming. Allows the use of visual expressions (such as graphics, drawings, or animation) in the process of programming.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
Windows Environment History of Windows: Windows was announced by microsoft in november 1983 and was released in november Advantage: Windows 1.0.
GUI-Based Programming ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
Programming Input Devices. Getting the device state Schemes for processing input – Polling – Callbacks Ways to intercept messages from input devices –
Introduction to Game Programming Pertemuan 11 Matakuliah: T0944-Game Design and Programming Tahun: 2010.
INFORMATION SYSTEM – SOFTWARE TOPIC: GRAPHICAL USER INTERFACE.
The WM_NCHITTEST Message  This is an internal message used by Windows for generating all the other mouse messages.  Though it almost never needs to be.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
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.
Our good old first Win32 programme of lecture 8 #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
W indows Programming Lecture 08. Brief History of Win Windows is announced 1984 Work begins on Word for Windows 1.0 November 1985: Windows 1.0.
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
Windows Programming Lecture 14. WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT.
Presentation Outline Introduction Painting and Repainting GDI.
Windows Programming Lecture 10.
Visual Programming Lecture 1 & 2
Interfacing.
Windows Programming Lecture 09.
Window.
18 & 19.
Windows Programming Model
Threads and Locks.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Queued and Nonqueued Messages
The program in traditional OS
Hands-on Introduction to Visual Basic .NET
COMMON CONTROLS A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often.
Windows Programming Lecture 13
Building a Win32API Application
CS 1253 Visual Programming Unit I Windows Environment
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
GUI Socket Application
Presentation transcript:

Introduction

Windows Programming 2  Windows –32-bit preemptive multitasking and multithreading graphical operating systems –GUI(graphical user interface) or graphical windowing environment –Virtualizes hardware of graphics display devices i.e. Windows includes a graphics programming language(GDI) –Provides a wealth of function calls that an application can take advantage of, mostly to implement its user interface and display text and graphics on video display. –Win32 API encompasses all the function calls that an application program can make use of an operating system, as well as definitions of associated data types and structures. –API functions are implemented in dynamic- link libraries, or DLLs. (KERNEL32.DLL, USER32.DLL, GDI32.DLL) –the API is not just a library, but also implies a particular program architecture.

Windows Programming 3  Language Options –Using C and the native APIs is not the only way to write programs for Windows. offers you the best performance, the most power, and the greatest versatility in exploiting the features of Windows. provides you with a deeper understanding of Windows internals. –Microsoft Visual Basic, Borland Delphi –Microsoft Visual C++ with Microsoft Foundation Class Libraries(MFC)  API Documentation – (MSDN Library Online)

Windows Programming 4  Unicode –Each character in Unicode is 16-bit wide. –WINNT.H defines TCHAR type and TEXT macro to be used generically for both ASCII char and Unicode char. –Whether the identifier UNICODE is defined or not defines which char code is used in the program.

Windows Programming 5  An Architectural Overview –Event-driven programming Event is any kind of action occurred in the system.(Enter the key, Mouse click, Window move, Window resize……..) When an event occurs, a corresponding code is performed –Object-oriented programming A window can be viewed as an object (data + procedures) The window(object) receives the user input in the form of messages A message is predefined data structure that has the information about an event. Every window has an associated “window procedure”. A “window instance” is created based on a “window class” which defines the window procedure that processes messages to the window Windows sends a message to a window by calling a its window procedure. The window procedure does some processing based on the message and then returns control to Windows.

Windows Programming 6 When a Windows program begins execution, Windows creates a “message queue” for the program. This message queue stores messages to all the windows a program might create. A window application includes a short chunk of code called “message loop” to retrieve these messages from the queue and dispatch them to the appropriate window procedure. There are some messages that are sent directly to the window procedure without being placed in the message queue.

Windows Programming 7  Windows Architecture Message 변환 Main Memory 2. get message 1. Mouse keyboard 외부입력 Windows System Message queue Program Message queue Window instance 사용자 응용 프로그램 WinMainWindow Procedure.. window class 4. callback message loop 3. dispatch message

Windows Programming 8  Scenario WinMain WindowsWndProc GetMessage DispatchMessage WndProc CreateWindow MouseClick message 를 Queue 에 넣는다 *

Windows Programming 9  The First Windows Program – Hellowin program – 별첨 소스코드 참조  WinMain 함수의 역할 – 프로그램 실행시 사용할 window 의 class 구조를 정의하고 이를 Windows 에 등록한다. – 정의된 window class 로부터 window instance 를 생성한다. 이 때 생성된 window instance 구조는 화면상에 window 를 표현하기 위한 정보들의 모임이다. –Window class 구조는 window 의 기본 틀에 대한 정보, 즉 icon 의 모양, 배경 화면, 사용되는 기본 커서의 모양 등이 정의되며 window instance 는 class 에서 주어진 기본 틀에 대하여 window 를 직접 화면에 그리기 위한 정보를 갖는다.

Windows Programming 10 –Window instance 생성하면 Windows 는 응용 프로그램에게 window handle 을 넘겨준다. – 화면상에 나타나는 1 개의 window 에 1 개의 window instance 가 할당되며, 1 개의 window class 로부터는 여러 개의 window instance 가 만들어 진다. –message 처리를 위해 다음과 같은 형태의 Message Loop 를 실행한다 while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); }

Windows Programming 11  Window procedure 의 역할 –Window procedure 는 Windows 에 의하여 호출되며 이 때 하나의 message 가 전달된다. – 전달된 message 의 종류에 따라 처리해야 할 일을 처리한다.  Windows program 의 작성 – 모든 응용 프로그램에서 WinMain 은 거의 동일하다. – 따라서 window procedure 를 작성하는 경우, 하는 일은 어떤 message 가 전달되었을 때 어떤 일을 해야 하는 가를 기술하는 작업이 된다.

Windows Programming 12  Windows 프로그래머가 정확히 알아야 할 내용 –Mouse 나 keyboard 의 조작에 대하여 어떤 message 들이 window procedure 로 전달되는가 ? ( 약 100 여 가지의 서로 다른 message 종류가 있음 ) – 어떤 message 가 전달되는 경우 그 message 안에 어떤 정보들이 함께 전달되는가 ? – 내가 처리하고자 하는 기능을 처리하기 위해서는 Windows 가 제공하는 함수 중 어떤 함수를 사용해야 하는가 ? ( 대략 수천개의 함수가 있음 )  The Header Files –WINDOWS.H is a master include file that includes other Windows header files, some of which also include other header files. WINDEF.H Basic type definition WINNT.H Type definition for Unicode support. WINBASE.H Kernel functions WINUSER. H User interface functions WINGDI.H Graphics device interface functions

Windows Programming 13  Message 의 처리 typedef struct tagMSG { HWND hwnd; UNIT message; WPARAM wParam; LPARAM lParam; DWORD time; POINT pt; } MSG; typedef struct tagPOINT { LONG x; LONG y; } POINT;

Windows Programming 14 –hwnd message 를 발생시킨 window 의 handle –message message identifier, 어떤 message 인지를 표시하기 위한 message 의 번호. Windows 가 생성하는 모든 message 의 번호는 에 WM_ 형태의 symbolic constant 로 정의되어 있음. –wParam, lParam 32-bit message parameter 로서 의미와 값은 message 종류에 따라 다르다. –time message 가 message queue 에 저장된 시간 –pt message 발생 시점에서의 mouse 위치 X, Y 좌표

Windows Programming 15  Queued and Nonqueued Message –Queued Message message queue 에 저장되어지는 message WinMain 의 message loop 의 GetMessage 함수의 실행에 의하여 message queue 로부터 인출되고 DispatchMesssage 함수에 의하여 window procedure 에 전달된다.(PostMessage) Keyboard, Mouse, timer 로부터 발생되는 message, WM_PAINT, WM_QUIT message –Nonqueued Message queue 에 저장되지 않고 바로 Windows 로 전달된 후 Windows 에 의하여 window procedure 로 전달되는 message.(SendMessage) queued message 가 아닌 나머지 message

Windows Programming 16 –SendMessage 함수 임의로 nonqueued message 를 발생시킴 –PostMessage 함수 임의로 queued message 를 발생시킴 – 일반적으로 WinMain 과 window procedure 는 순차적으로 ( 교대로 ) 실행된다고 보아도 됨. 즉 DispatchMessage 함수에 의하여 window procedure 로 message 가 전달되면 그 message 의 처리가 끝나 window procedure 가 return 하여야 DispatchMessage 함수도 return 하게 됨. –Windows 가 제공하는 API 함수 중 많은 함수가 SendMessage 함수를 이용하여 message 를 발생시킴. 예 ) CreateWindow -> WM_CREATE ShowWindow -> WM_SIZE, WM_SHOWWINDOW UpdateWindow -> WM_PAINT

Windows Programming 17 – 한번의 keyboard 나 mouse 조작에 의해서 순차적으로 여러 개의 message 가 발생되는 경우가 많음 예 ) Mouse 로 window title bar 의 close button 을 누른 경우 1) WM_SYSCOMMAND -> window procedure 2) window procedure 내에 WM_SYSCOMMAND message 처리 routine 이 없는 경우 3) DefWindowProcedure 가 WM_CLOSE message 발생 4) window procedure 내에 WM_CLOSE message 처리 routine 이 없는 경우 5) DefWindowProcedure 가 WM_DESTROY message 발생 6) window procedure 가 PostQuitMessage 함수를 이용 WM_QUIT message 를 Message Queue 에 저장 7) WinMain 의 GetMessage 함수가 WM_QUIT message 를 읽으면 WinMain 의 message loop 의 실행이 끝남 window procedure DefWindowProcedure WM_SYSCOMM AND window procedure DefWindowProcedure WM_CLOS E