Windows Programming Lecture 14. WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT.

Slides:



Advertisements
Similar presentations
Getting Started with PowerPoint
Advertisements

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.
Simple Gui in C++. Project Selecting So Far Registering the window class Creating the window.
Simple Gui in C++. Project Selecting So Far Registering the window class Creating the window.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 9 1 Microsoft Office FrontPage 2003 Tutorial 9 – Using Layout Tables, Styles, and Office.
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)
Reusing a Presentation with Multimedia
Building a Win32API Application Raw access to the API.
Graphics and Multimedia. Introduction The language contains many sophisticated drawing capabilities as part of namespace System.Drawing and the other.
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.
Microsoft PowerPoint Getting Started Guide Prepared for Towson University Dr. Jeff M. Kenton Amy Chase Martin 2007.
EzWindows API A Graphical Application Programmer Interface JPC and JWD © 2002 McGraw-Hill, Inc.
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.
Chapter2: Drawing a Window. Drawing with the GDI.
CSE3AGT Paul Taylor Stupid Conventions! l = Long p = Pointer h = handle g = global wnd = Windows WM = Windows Message d3d = Direct3D hr = HRESULT.
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.
Graphics Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Microsoft Publisher 2010 Chapter 1 Creating a Flyer.
Presentation Outline Introduction Painting and Repainting GDI.
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
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.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
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.
Our good old first Win32 programme of lecture 8 #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Introduction To GDI GDI Definition : It is a interface present in windows which provide function and related structures that an application can use to.
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Chapter 10 Creating a Template for an Online Form Microsoft Word 2013.
Adobe Photoshop CS5.
Programming windows with MFC Chapter 2 - Drawing in a Window
Presentation Outline Introduction Painting and Repainting GDI.
Windows Programming Lecture 11
PowerPoint Activity 4: Cyber Safety
5/23/2018 Additional Features of WordPad
Windows Programming Lecture 10.
Windows Programming Lecture 09.
Window.
18 & 19.
Graphics and Multimedia
First text statement positioned here at guide intersection
Chapter 7 Advanced Form Techniques
Queued and Nonqueued Messages
Economist Report (Advanced)
Chapter Lessons Use the Macromedia Flash drawing tools
Windows Programming Lecture 13
Otasuke GP-EX! Chapter 1 Menu Screen.
Review: Applying Computer Basics
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
21-22.
19.
对 话 无 界 限 “对话是两个集合出现交集的一个刹那。” “对话是发现共同点的捷径。”.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
Chapter 14 Drawing in a Window
A Graphical Application Programmer Interface
Chapter 16 Drawing in a Window
Presentation transcript:

Windows Programming Lecture 14

WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT message is generated by the system only when any part of application window becomes invalid. Windows always specifies invalid area of any window in terms of a least bounding rectangle, hence, the entire window is not repainted..

WM_PAINT message Only one WM_PAINT message for a window is stored in the message queue at one time. The Invalid Rectangle bounds all parts of a window that need to be redrawn. WM_PAINT is a low priority message. WM_PAINT messages processed after processing all other messages in the message queue.

Conditions under which a WM_PAINT message is always sent Any hidden part of window becomes visible Window is resized (and CS_VREDRAW, CS_HREDRAW style bits were set while registering the window class). Programme scrolls its window InvalidateRect() or InvalidateRgn() is called by the application

Conditions under which a WM_PAINT message may be sent A dialog is dismissed A drop-down menu disappears A tool tip is displayed and then it hides

Conditions under which a WM_PAINT message is never sent An icon is dragged over the window The mouse cursor is moved

InvalidateRect() BOOL InvalidateRect( HWND hWnd, // handle to window CONST RECT *lpRect, // rectangle coordinates BOOL bErase // erase state );

PAINTSTRUCT structure typedef struct tagPAINTSTRUCT { HDC hdc; BOOL fErase; RECT rcPaint; } PAINTSTRUCT, *PPAINTSTRUCT;

Other GDI text output functions int DrawText ( HDC hDC, // handle to DC LPCTSTR lpString, // text to draw int nCount, // text length LPRECT lpRect, // formatting dimensions UINT uFormat // text drawing options );

Other GDI text output functions TabbedTextOut() Writes a character string at a specified location Expands tabs to the values specified in an array of tab stop positions Currently selected font and foreground / background colors are used

Other GDI text output functions LONG TabbedTextOut( HDC hDC, // handle to DC int x, // x-coord of start int y, // y-coord of start LPCTSTR lpString, // character string int nCount, // number of characters int nTabPositions, // number of tabs in array CONST LPINT lpnTabStopPositions, // array of tab positions int nTabOrigin // start of tab expansion );

Primitive Shapes These shapes are geometric forms that are outlined by using the current pen and filled by using the current brush. Example Rectangles Circles Polygons

Primitive Shapes: Rectangle() The Rectangle() function draws a rectangle. The rectangle is outlined by using the current pen and filled by using the current brush. The rectangle is outlined using the currently selected pen and filled using the currently selected brush of the window's device context.

Rectangle() BOOL Rectangle( HDC hdc, // handle to DC int nLeftRect, // x-coord of upper-left corner of rectangle int nTopRect, // y-coord of upper-left corner of rectangle int nRightRect, // x-coord of lower-right corner of rectangle int nBottomRect // y-coord of lower-right corner of rectangle );

Primitive shapes: Polygon() The Polygon() function draws a polygon consisting of two or more vertices connected by straight lines. The polygon is outlined by using the current pen and filled by using the current brush and polygon fill mode. BOOL Polygon( HDC hdc, // handle to DC CONST POINT *lpPoints, // polygon vertices int nCount // count of polygon vertices );

Stock Objects Pre-defined GDI objects in Windows Pens Brushes Fonts Palettes

Stock Objects: GetStockObject() The GetStockObject() function retrieves a handle to one of the stock pens,brushes, fonts, and palettes. HGDIOBJ GetStockObject ( int fnObject );

Some stock object types DKGRAY_BRUSH Dark grey brush. ANSI_FIXED_FONT Windows fixed-pitch (monospace) system font. ANSI_VAR_FONT Windows variable-pitch (proportional space) system font.

SelectObject() The SelectObject() function selects an object into the specified device context (DC). The new object replaces the previous object of the same type. HGDIOBJ SelectObject ( HDC hdc, // handle to DC HGDIOBJ hgdiobj // handle to object );

Sent Messages The SendMessage() function sends the specified message to a window. It calls the window procedure for the specified window and does not return until the window procedure has returned after processing the message.

Posted Messages The PostMessage() function Places (posts) a message in the message queue associated with the thread that created the specified window Returns without waiting for the thread to process the message

Sent messages The SendMessage() function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message. LRESULT SendMessage ( HWND hWnd, // handle to destination window UINT Msg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter );

Posted messages The PostMessage() function places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message. BOOL PostMessage( HWND hWnd, // handle to destination window UINT Msg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter );

PostQuitMessage() When PostQuitMessage() is called, then WM_QUIT message is sent to the application message queue. VOID PostQuitMessage ( int nExitCode // exit code );

nExitCode nExitCode value is used as the wParam parameter of the WM_QUIT message. nExitCode Specifies an application exit code. This value is used as the wParam parameter of the WM_QUIT message.

PeekMessage() The PeekMessage() function dispatches incoming sent messages, checks the thread message queue for a posted message, and retrieves the message (if any exist). BOOL PeekMessage( LPMSG lpMsg, // message information HWND hWnd, // handle to window UINT wMsgFilterMin, // first message UINT wMsgFilterMax, // last message UINT wRemoveMsg // removal options );

PeekMessage() Remove flags PM_NOREMOVE Messages are not removed from the queue after processing by PeekMessage(). PM_REMOVE Messages are removed from the queue after processing by PeekMessage().