Queued and Nonqueued Messages

Slides:



Advertisements
Similar presentations
1 Windows Programming CIS 577 Bruce R. Maxim UM-Dearborn.
Advertisements

Computer Graphics1 Windows NT Graphics Interface.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
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)
Building a Win32API Application Raw access to the API.
MFC Workshop: Intro to MFC. What is MFC? Microsoft Foundation Classes C++ wrappers to the Windows SDK An application framework A useful set of extensions.
GVE, Hallym University, Song, Chang Geun, Ph.D. 컴퓨터 그래픽스 응용 한림대학교 컴퓨터공학부 송 창근.
INTRODUCTION TO VC++ As the Microsoft Windows 3.X and then 5.5 operating system was becoming popular, many programmers were interested in creating graphical.
Win32 API Programming Event-driven, graphics oriented Example: User clicks mouse over a program’s window area (an event) -- – Windows decodes HW signals.
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.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
Lecture Two Event Handling Keyboard and Mouse Input.
Windows Programming Text and Fonts This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep.
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.
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.
1 Windows GDI Programming CIS 487/587 Bruce R. Maxim UM-Dearborn.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Presentation Outline Introduction Painting and Repainting GDI.
Chapter2: Drawing a Window. Review: Introducing MFC.
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,
Quanta Confidential QUANTA WBU Study Report 1 昭正 2008/08/01.
Chapter2: Drawing a Window
Programming Input Devices. Getting the device state Schemes for processing input – Polling – Callbacks Ways to intercept messages from input devices –
GAM666 – Introduction To Game Programming ● DirectDraw, the 2D component of DirectX, uses the term “surface” to mean an area of memory in which pixel data.
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.
Learning Programming Windows API Morpheus Feb-28, 2008.
Drawing in Windows. To help with drawing on the Windows operating system, Microsoft created the Graphical Device Interface, abbreviated as GDI. – It is.
Introduction To GDI GDI Definition : It is a interface present in windows which provide function and related structures that an application can use to.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Windows Programming Lecture 14. WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT.
Standard Operating Procedure
Presentation Outline Introduction Painting and Repainting GDI.
Clocks, I/O devices, Thin Clients, and Power Management
Chapter 8: Writing Graphical User Interfaces
Interfacing.
Windows Programming Lecture 09.
Building a Win32API Application
Chapter 1 Hello, MFC.
Windows Programming Model
CS 3305 System Calls Lecture 7.
Aspect-Oriented Programming
CSC461 Lecture 8: Input Devices
A keyboard generates two scan codes when the user types a key
Introduction to Computer Graphics with WebGL
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
I/O in C Lecture 6 Winter Quarter Engineering H192 Winter 2005
Windows Controls & Concepts
Made by Aistė Augustinaitė Software Engineering 3 group
Graphic Device Interface
Introduction to Classes and Objects
Windows Programming Lecture 13
Isaac Gang University of Mary Hardin-Baylor
Software Design Lecture : 10
Building a Win32API Application
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
PHP Forms and Databases.
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
Classes and Objects Systems Programming.
SPL – PS3 C++ Classes.
Introduction to Classes and Objects
Presentation transcript:

Queued and Nonqueued Messages The queued messages are primarily those that result from user input in the form of keystrokes (such as the WM_KEYDOWN and WM_KEYUP messages), characters that result from keystrokes (WM_CHAR), mouse movement (WM_MOUSEMOVE), and mouse−button clicks (WM_LBUTTONDOWN). Queued messages also include the timer message (WM_TIMER), the repaint message (WM_PAINT), and the quit message (WM_QUIT). Visit for more Learning Resources

Nonqueued messages Often result from calling certain Windows functions. For example, when WinMain calls CreateWindow, Windows creates the window and in the process sends the window procedure a WM_CREATE message. When WinMain calls ShowWindow, Windows sends the window procedure WM_SIZE and WM_SHOWWINDOW messages. When WinMain calls UpdateWindow, Windows sends the window procedure a WM_PAINT message.

TextOut (hdc, x, y, psText, iLength) ; An Introduction to GDI To paint the client area of your window, you use Windows' Graphics Device Interface (GDI) functions. TextOut (hdc, x, y, psText, iLength) ; TextOut writes a character string to the client area of the window. The psText argument is a pointer to the character string iLength is the length of the string in characters. The x and y arguments define the starting position of the character string in the client area. The hdc argument is a "handle to a device context” A handle, is simply a number that Windows uses for internal reference to an object. With that device context handle you are free to paint your client area and make it as beautiful or as ugly as you like.

Device Context(DC) DC is really just a data structure maintained internally byGDI. A device context is associated with a particular display device, such as a video display or a printer. For a video display, a device context is usually associated with a particular window on the display.

Getting a Device Context Handle Method One-use this method when you process WM_PAINT messages Two functions are involved: BeginPaint and EndPaint. These two functions require the handle to the window, which is passed to the window procedure as an argument, and the address of a structure variable of type PAINTSTRUCT, which is defined in the WINUSER.H header file. Windows programmers usually name this structure variable ps and define it within the window procedure like so: PAINTSTRUCT ps ; While processing a WM_PAINT message, the window procedure first calls BeginPaint. The BeginPaint function generally causes the background of the invalid region to be erased in preparation for painting. The value returned from BeginPaint is the device context handle. This is commonly saved in a variable named hdc.

The program may then use GDI functions, such as TextOut, that require the handle to the device context. A call to EndPaint releases the device context handle. Typically, processing of the WM_PAINT message looks like this: case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; [use GDI functions] EndPaint (hwnd, &ps) ; return 0 ;

If a window procedure does not process WM_PAINT messages, it must pass the WM_PAINT message to DefWindowProc, which is the default window procedure located in Windows. DefWindowProc processes WM_PAINT messages with the following code: case WM_PAINT: BeginPaint (hwnd, &ps) ; EndPaint (hwnd, &ps) ; return 0 But don't do this: return 0 ; // WRONG !!!

DC: Method Two For more detail contact us It useful to paint part of the client area (for other purposes )while processing messages other than WM_PAINT To get a handle to the device context of the client area of the window, you call GetDC to obtain the handle and ReleaseDC after you're done with it: hdc = GetDC (hwnd) ; [use GDI functions] ReleaseDC (hwnd, hdc) ; Unlike BeginPaint,GetDC does not validate any invalid regions. If you need to validate the entire client area, you can call ValidateRect (hwnd, NULL) ; For more detail contact us