Windows Programming Lecture 12

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 Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Developing an Excel Application
Tutorial 8: Developing an Excel Application
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
PRIMARY, SECONDARY & QUANTITATIVE RESEARCH TASK HYPERLINK APPLICATION PROCEDURE 1.
1 Windows Goodies CIS 577 Bruce R. Maxim UM-Dearborn.
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.
Simple Gui in C++. Project Selecting So Far Registering the window class Creating the window.
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)
GVE, Hallym University, Song, Chang Geun, Ph.D. 컴퓨터 그래픽스 응용 한림대학교 컴퓨터공학부 송 창근.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.
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.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
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.
Lecture Two Event Handling Keyboard and Mouse Input.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Classic Controls Trần Anh Tuấn A. Week 1 How to create a MFC project in VS 6.0 How to create a MFC project in VS 6.0 Introduction to Classic Controls.
Server Core is the preferred deployment configuration.
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.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Lecture 7 Menu, controls, scroll bars. Menu Menu item sends WM_COMMAND message to the application window Menu is attached to window when the window is.
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 –
About Windows Jihoon.Yim About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.
Chapter 7 Controls. 2 Introduction (1/4) Control –Special kind of window –Designed to convey information to the user or to acquire input –Reduce the tedium.
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.
Menus  Menus is a feature which is common to almost every windows applications. It is the one of the most common user interface elements around.  Windows.
Introduction to OpenGL
Chapter 6: FILE I/O and Serialize CFile class. FILE I/O Serialization and the CArchive Class.
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.
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Windows Programming Lecture 14. WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT.
Windows Programming Lecture 11
Graphical User Interface in MATLAB
Chapter 1: An Introduction to Visual Basic 2015
Windows Programming Lecture 10.
Programming Input Devices
Windows Programming Lecture 09.
Window.
18 & 19.
Windows Programming Model
Aspect-Oriented Programming
Developing an Excel Application
Windows Programming using Dev C++
Variables and Arithmetic Operations
The program in traditional OS
Dialogs.
Windows Programming Lecture 13
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
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/19.
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2011
GUI Socket Application
Presentation transcript:

Windows Programming Lecture 12

System Window Classes Till now, we registered a window class before creating a window. A number of window classes are pre-registered / pre-coded in Windows, and their window procedures also are pre-written No call to RegisterClass() before creating such a window

There are two types of System Window Classes Those which can be used by the user processes. Those which can only be used by the system.

User defined window classes are automatically unregistered when application using those classes terminates. System classes cannot be unregistered by user processes.

System/Pre-defined Window Classes (to be used by user processes only) Button pushbutton autocheckbox radio etc. ComboBox Edit ListBox ScrollBar Static

System/Pre-defined Window Classes (to be used by system only) ATOM values #32768 The class for a menu #32769 The class for the desktop window #32770 The class for a dialog box #32771 The class for the task switch window

Styles of system Window class BUTTON BS_AUTOCHECKBOX    BS_AUTORADIOBUTTON    BS_PUSHBUTTON    BS_RADIOBUTTON    BS_DEFPUSHBUTTON    … … …

Example: System Window Classes hWnd = CreateWindow( "BUTTON", "Virtual University", BS_RADIOBUTTON | WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CAPTION, 50, 50, 200, 100, NULL, NULL, hInstance, NULL); while(GetMessage(&msg, NULL, 0, 0) > 0) { if(msg.message == WM_LBUTTONUP) DestroyWindow(hWnd); PostQuitMessage(0); } DispatchMessage(&msg);

GetWindowLong( ) The GetWindowLong() function retrieves information about the specified window.

GetWindowLong( ) LONG GetWindowLong( HWND hWnd, // handle to window int nIndex // offset of value to retrieve ); GWL_WNDPROC GWL_HINSTANCE GWL_STYLE

SetWindowLong( ) The SetWindowLong() function changes an attribute of the specified window.

SetWindowLong( ) LONG SetWindowLong( HWND hWnd, // handle to window int nIndex, // offset of value to set LONG dwNewLong // new value ); GWL_WNDPROC GWL_HINSTANCE GWL_STYLE

Sub-classing Substituting the window procedure for a window class with another. Sub-classing allows you to change the behavior of an existing window, typically a control, by inserting a message map to intercept the window's messages. For example, suppose you have a dialog box with an edit control that you want to accept only non-numeric characters. You could do this by intercepting WM_CHAR messages destined for the edit control and discarding any messages indicating that a numeric character has been entered.

Sub-classing Sub-classing is of two types: Just for one window For all windows in the application created after substitution of the window procedure

Super-classing Super-classing defines a class that adds new functionality to a predefined window class, such as the button or list box controls.

Information About a Window Class GetClassLong() SetClassLong()

GetClassLong() The GetClassLong() function retrieves the specified 32-bit (long) value from the WNDCLASS structure associated with the specified window.

GetClassLong() LONG GetClassLong( HWND hWnd, // handle to window int nIndex // offset of value to retrieve ); GCL_WNDPROC GCL_STYLE

SetClassLong() The SetClassLong() function replaces the specified 32-bit (long) value at the specified offset into the extra class memory or the WNDCLASS structure for the class to which the specified window belongs.

SetClassLong() LONG SetClassLong( HWND hWnd, // handle to window int nIndex, // offset of value to set LONG dwNewLong // new value );

Difference Between SetWindowLong() and SetClassLong() In SetWindowLong(), behavior of a single window is modified. In SetClassLong(), behavior of the window class is modified

Type 1-Subclassing

Sub-classing WNDPROC oldWindowProc; hWnd = CreateWindow("BUTTON", "Virtual University", BS_AUTOCHECKBOX | WS_VISIBLE | WS_OVERLAPPEDWINDOW, 50, 50, 200, 100, NULL, NULL, hInstance, NULL); oldWindowProc = (WNDPROC)SetWindowLong (hWnd, GWL_WNDPROC, (LONG)myWindowProc); while(GetMessage(&msg, NULL, 0, 0) > 0) { DispatchMessage(&msg); } return msg.wParam;

Sub-classing LRESULT CALLBACK myWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) case WM_LBUTTONDOWN: MessageBox (hWnd, "Left mouse button pressed.", "Message", MB_OK); DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); default: return CallWindowProc(oldWindowProc, hWnd, message, wParam, lParam); } return 0;

Type 2-Subclassing

Sub-classing: The Window Procedure LRESULT CALLBACK myWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) case WM_LBUTTONDOWN: MessageBeep(0XFFFFFFFF); break; default: return CallWindowProc(oldWindowProc, hWnd, message, wParam, lParam); } return 0;