The program in traditional OS

Slides:



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

1 Windows Programming CIS 577 Bruce R. Maxim UM-Dearborn.
Computer Graphics1 Windows NT Graphics Interface.
QT – Introduction C++ GUI Programming with Qt 4 Blanchette and Summerfield, Ch. 1 Miller, 2004.
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
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.
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)
Building a Win32API Application Raw access to the API.
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.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Getting Started The structure of a simple wxWidgets program, Look at where and how a wxWidgets application starts and ends, how to show the main window,
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Java Programming, Second Edition Chapter Five Input and Selection.
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.
Douglas Boling President Boling Consulting Inc. SESSION CODE: WEM304.
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.
Winsock Programming Blocking and Asynchronous Sockets for Windows.
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.
Additional Control Structures. Chapter 9 Topics Switch Statement for Multi-way Branching Do-While Statement for Looping For Statement for Looping Using.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
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.
Presentation Outline Introduction Painting and Repainting GDI.
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.
Programming Input Devices. Getting the device state Schemes for processing input – Polling – Callbacks Ways to intercept messages from input devices –
Creating a DirectX Project A DirectPLay Chat Program.
1 Programming in C++ Dale/Weems/Headington Chapter 9 Additional Control Structures (Switch, Do..While, For statements)
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
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.
Andy Wigley Device Application Development MVP APPA Mundi Ltd SESSION CODE: WEM309.
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)
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
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 11
Windows Programming Lecture 10.
Visual Programming Lecture 1 & 2
Windows Programming Lecture 09.
Window.
Building a Win32API Application
18 & 19.
Windows Programming Model
Windows Programming using Dev C++
Windows Programming Lecture 12
28.
Windows Programming Lecture 13
Govt. Polytechnic,Dhangar
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
21-22.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2011
GUI Socket Application
OpenGL Programming – Day 1
Presentation transcript:

The program in traditional OS WinAPI Basics The program in traditional OS

WinAPI Basics The program in Windows In Windows, the interaction between the program and the OS is a message-based interaction. It’s the Windows that calls the program continuously. In Windows the program consists of 2 parts: WinMain( ) is called first and interacts with the OS getting the Messages in Message Loop from Message Queue and sending them to the second part of program. Window CallBack Function ( ) processes the Messages. Here you write your program’s main body.

Message based interaction of Windows & Application WinAPI Basics Message based interaction of Windows & Application

Windows Skeleton Program WinAPI Basics WinMain ( ) { Define a window structure Register the window structure Create the window Display the window Run the message loop } WindowFunc ( ) Switch ( message ) case message 1 : _ _ _ case message 2 : default : /* A minimal windows skeleton program. */ #include <windows.h>   LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode) { Windows Skeleton Program char szWinName[] = "MyWin"; /* name of windows class */ HWND hwnd; MSG msg; WNDCLASSEX wcl; /* Define a window class. */ wcl.cbSize = sizeof(WNDCLASSEX); wcl.hInstance = hThisInst; /* handle to this instance */ wcl.lpszClassName = szWinName; /* window class name */ wcl.lpfnWndProc = WindowFunc; /* window function */ wcl.style = 0; /* default style */ wcl.hIcon = LoadIcon(NULL,IDI_APPLICATION);/*std icon */ wcl.hIconSm= LoadIcon(NULL,IDI_WINLOGO);/*small icon */ wcl.hCursor= LoadCursor(NULL,IDC_ARROW);/*cursor style */ wcl.lpszMenuName = NULL; /* no menu */ wcl.cbClsExtra = 0; /* no extra */ wcl.cbWndExtra = 0; /* information needed */ /* Make the window background white. */ wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); if(!RegisterClassEx(&wcl)) return 0; /* Now that a window class has been registered, ** a window can be created. */ hwnd = CreateWindow( szWinName, /* name of window class */ "Windows Skeleton Program", /* title */ WS_OVERLAPPEDWINDOW, /* window style:normal */ CW_USEDEFAULT, /* X coordinate - let windows decide */ CW_USEDEFAULT, /* Y coordinate - let windows decide */ CW_USEDEFAULT, /* width - let windows decide */ CW_USEDEFAULT, /* height- let windows decide */ HWND_DESKTOP, /* no parent window */ NULL, hThisInst, /*handle of this instance of the program */ NULL /* no additional arguments */ ); /* This function is called by Windows OS and ** is passed message from the message queue. *********************************************/ LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: /* terminate the program */ PostQuitMessage(0); break; default: /* Let Windows NT process any messages ** not specified in the preceding switch ** statement. */ return DefWindowProc(hwnd, message, wParam,lParam); } return 0; If you compile the above program in VS2008 then you’ll get compile error related to Unicode usage of strings. Either you should change the project settings from Unicode to Multibyte Or, which is more desirable, redefine the strings to Unicode by Compiler directives TEXT, __T, L or using the types wchar_t, TCHAR instead of char. Example - wc.lpszClassName = L"minwindowsapp"; /* Display the window. */ ShowWindow(hwnd, nWinMode); // Setup to show window UpdateWindow(hwnd); // Request to update window /* Create the message loop. */ while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); /* allow use of keyboard */ DispatchMessage(&msg); /*return control to windows */ } return msg.wParam;