Game Programming I. Introduction to Windows Programming. Sample Program hello.cpp. 5 th Week,

Similar documents
Window programming. Programming

We display some text in the middle of a window, and see how the text remains there whenever the window is re-sized or moved.

Windows Programming. 1 st Week, 2011

/*********************************************************************

hinstance = ((LPCREATESTRUCT)lParam)->hInstance obtains the program's instance handle and stores it in the static variable, hinstance.

Course 3D_OpenGL: 3D-Graphics with C++ and OpenGL Chapter 1: Moving Triangles

Designing Interactive Systems II

We take a look at implementing some file menu options: New, Open, Save, Save As and Exit.

Windows Printer Driver User Guide for NCR Retail Printers. B Issue G

Getting Started. 1 st Week, Sun-Jeong Kim. Computer Graphics Applications

Programmer s Manual MM/104 Multimedia Board

Task Toolkit Manual for InduSoft Web Studio v6.1+sp3

Alisson Sol Knowledge Engineer Engineering Excellence June 08, Public version

Tutorial 7: Mouse Input

Chapter 15 Programming Paradigm

Tutorial 9:Child Window Controls

2. On the main menu, click File -> New... or File -> New -> Other... Windows Fundamentals

: Lập trình Win32. Lập trình Win32 API. vncoding.net Page 1. Date : 07/09/2014

4 th (Programmatic Branch ) Advance Windows Programming class

Windows and Messages. Creating the Window

systemove programovanie win32 programovanie

Guide to Good Practice in using Open Source Compilers with the AGCC Lexical Analyzer

Tutorial 3: A Simple Window

LSN 4 GUI Programming Using The WIN32 API

Win32 Multilingual IME Overview for IME Development

Input and Interaction

Programming in graphical environment. Introduction

Introduction to Computer Graphics (CS602) Lecture No 04 Point

Creating a DirectX Project

Review. Designing Interactive Systems II. The Apple Macintosh

Computer Programming Lecture 11 이윤진서울대학교

Modern GUI applications may be composed from a number of different software components.

Animated 3D Worlds Using Java and SketchUp Chonmaphat Roonnapak

Abstract. MSc. Electronics: Computer Graphics. Sept Abstract.

Using DAQ Event Messaging under Windows NT/95/3.1

Aspect-Oriented Programming with C++ and AspectC++ AOSD 2007 Tutorial. Part V Examples. Examples V/1

Windows Programming in C++

HANNAH HOWARD #ABOUTME

Programming In Windows. By Minh Nguyen

Front Panel: Free Kit for Prototyping Embedded Systems on Windows

Advantech Windows CE.net Application Hand on Lab

C Windows 16. Visual C++ VC Borland C++ Compiler BCC 2. Windows. c:\develop

An Introduction to Windows Programming Using VC++ Computer Graphics. Binghamton University. EngiNet. Thomas J. Watson

. DRAFT version 0.681

Game Programming Genesis Part II : Using Resources in Win32 Programs by Joseph "Ironblayde" Farrell

uvi ... Universal Validator Interface Software Developers Kit Revision /29/04 Happ Controls

CS410 Visual Programming Solved Online Quiz No. 01, 02, 03 and 04. For Final Term Exam Preparation by Virtualians Social Network

Application Note QWinTM GUI Kit for Prototyping Embedded Systems on Windows

Digital Storage Oscilloscope. Appendix

Charles River Media. A part of Course Technology, Cengage Learning

MOBILE COMPUTING Practical 1: Graphic representation

CIS 488 Programming Assignment 14 Using Borland s OWL

Hands-On Lab. Multitouch Gestures - Native. Lab version: Last updated: 12/3/2010

MapleStory / Hack Development. By:

x86.virtualizer source code

Multithreading Multi-Threaded Programming. Prof. Lin Weiguo Copyleft 2009~2017, School of Computing, CUC

Detecting USB Device Insertion and Removal Using Windows API

Different Ways of Writing Windows Programs

LAB MANUAL VISUAL PROGRAMMING LAB( CSE 409 F) DEPARTMENT OF COMPUTER SCIECE AND ENGINEERING

IFE: Course in Low Level Programing. Lecture 5

Windows Socket Message-Driven/WSAAsyncSelect Model. Prof. Lin Weiguo Copyleft 2009~2015, College of Computing, CUC

Design of a WWW database server for Atomic Spectroscopy Data

NeHe's. OpenGL Tutorials

A Short Course for REU Students Summer Instructor: Ben Ransford

Introducing MFC. Programming Windows with MFC, Second Edition. Jeff Prosise

arxiv: v1 [physics.med-ph] 22 Aug 2016

Windows Sockets: A Quick And Dirty Primer

Lecture 6 : Multitasking & DLL

Message-Passing Interface for Microsoft Windows 3.1

TỔNG QUAN LẬP TRÌNH MÔI TRƯỜNG WINDOWS. Phạm Thi Vương

Question No: 1 (Marks: 1) - Please choose one For showing Dialog we can use "ShowWindow(...)" function.

ProForth VFX for Windows

CS3283. GUI Programming. Hugh Anderson Department of Computing Science, School of Computing NUS

Based on the following Circuit Cellar Articles. Developing a Mobile Phone Application. The story Spark podcast 49. The articles

Client and Server (DirectX)

Adventures in Messaging

CS1253-VISUAL PROGRAMMING S4 CSE & S6 IT 2 MARKS & 16 MARKS PREPARED BY S.VINILA JINNY, L/CSE Y. JEYA SHEELA, L/IT

On Typesafe Aspect Implementations in C++

Undocumented CreateProcess

SIGMA SIGMAP02 Plugin Developer's Manual

Hands-On Lab. Windows Ribbon - Native. Lab version: Last updated: 12/3/2010

Translating Python to C++ for palmtop software development - 1 Acknowledgments 1 Acknowledgments

CS410 Visual Programming Solved Objective Midterm Papers For Preparation of Midterm Exam

About Win32++ Microsoft Platform SDK Microsoft Windows SDK

Hands-On Lab. Multi-Touch WMTouch - Native. Lab version: Last updated: 12/3/2010

Developing a Prototype Window s Mobile Application

TRƯỜNG ĐẠI HỌC B\CH KHOA H[ NỘI VIỆN CÔNG NGHỆ THÔNG TIN V[ TRUYỀN THÔNG LẬP TRÌNH WINDOWS

LẬP TRÌNH WINDOWS. Mã số: IT4781 Thời lượng: 2 ( ) Học phần tiên quyết: Ngôn ngữ lập trình C, C++ Nội dung. Tài liệu tham khảo

Content. 5: Input/Output. I/O Devices. Principles of I/O hardware. I/O Devices. I/O Devices

SHORT QUESTIONS & ANSWERS

Thecontentsofthismanualdescribetheproduct, BDS-PROLOG forwindows(hereinafter

Key Switch Control Software Windows driver software for Touch Panel Classembly Devices

ADSmartIO Driver Specification for Windows CE

Socket I/Os in Windows. Dae-Ki Kang

zhx.ch 收集整理 MFC for that matter) so you can't build ATL or WTL projects with the Express version. If you are using VC 6, then you need the Platf

Windows Programming. Krzysztof Mossakowski, MSc

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

WTL for MFC Programmers, Part I - ATL GUI Classes By Michael Dunn

Mobile Application Development (Part 1)-Program a Sound-Monitoring Prototype

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

Transcription:

Game Programming I Introduction to Windows Programming 5 th Week, 2007 Sample Program hello.cpp

Microsoft Visual Studio.Net File New Project Visual C++ Win32 Win32 Project

Application Settings Empty project Hello Solution

Adding the Source Code (1) Copying the source code Adding the Source Code (2) Project Add Existing Item

Adding the Source Code (3) Result

Hello World Windows Application (1) #include <windows.h> HWND MainWindowHandle = 0; bool InitWindowsApp(HINSTANCE instancehandle, int show); int Run(); LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, PSTR pcmdline, int nshowcmd) if(!initwindowsapp(hinstance, nshowcmd)) ::MessageBox(0, "Init - Failed", "Error", MB_OK); return Run(); Hello World Windows Application (2) bool InitWindowsApp(HINSTANCE instancehandle, int show) WNDCLASS wc; wc.style = CS_HREDRAW CS_VREDRAW; wc.lpfnwndproc = WndProc; wc.cbclsextra = 0; wc.cbwndextra = 0; wc.hinstance = instancehandle; wc.hicon = ::LoadIcon(0, IDI_APPLICATION); wc.hcursor = ::LoadCursor(0, IDC_ARROW); wc.hbrbackground = static_cast<hbrush>(::getstockobject(white_brush)); wc.lpszmenuname = 0; wc.lpszclassname = "Hello"; if(!::registerclass(&wc)) ::MessageBox(0, "RegisterClass - Failed", 0, 0); return false;

Hello World Windows Application (3) MainWindowHandle = ::CreateWindow( "Hello", "Hello", WS_OVERLAPPEDWINDOW, 0, 0, instancehandle, 0); if(mainwindowhandle == 0) ::MessageBox(0, "CreateWindow - Failed", 0, 0); return false; ::ShowWindow(MainWindowHandle, show); ::UpdateWindow(MainWindowHandle); return true; Hello World Windows Application (4) int Run() MSG msg; ::ZeroMemory(&msg, sizeof(msg)); while(::getmessage(&msg, 0, 0, 0) ) ::TranslateMessage(&msg); ::DispatchMessage(&msg); return msg.wparam;

Hello World Windows Application (5) LRESULT CALLBACK WndProc(HWND windowhandle, UINT msg, WPARAM wparam, LPARAM lparam) switch( msg ) case WM_LBUTTONDOWN: ::MessageBox(0, "Hello, World", "Hello", MB_OK); case WM_KEYDOWN: if( wparam == VK_ESCAPE ) ::DestroyWindow(MainWindowHandle); case WM_DESTROY: ::PostQuitMessage(0); return ::DefWindowProc(windowHandle, msg, wparam, lparam); Exercise Change the main window: the background color the icon the cursor the title the size Change the message box: the title, sentence, and buttons Create another message box when the right button of a mouse is clicked the enter key is pressed

Hint (1) bool InitWindowsApp(HINSTANCE instancehandle, int show) WNDCLASS wc; wc.style = CS_HREDRAW CS_VREDRAW; wc.lpfnwndproc = WndProc; wc.cbclsextra = 0; wc.cbwndextra = 0; wc.hinstance = instancehandle; wc.hicon = ::LoadIcon(0, IDI_APPLICATION); wc.hcursor = ::LoadCursor(0, IDC_ARROW); wc.hbrbackground = static_cast<hbrush>(::getstockobject(white_brush)); wc.lpszmenuname = 0; wc.lpszclassname = "Hello"; if(!::registerclass(&wc)) ::MessageBox(0, "RegisterClass - Failed", 0, 0); return false; Hint (2) MainWindowHandle = ::CreateWindow( "Hello", "Hello", WS_OVERLAPPEDWINDOW, 0, 0, instancehandle, 0); if(mainwindowhandle == 0) ::MessageBox(0, "CreateWindow - Failed", 0, 0); return false; ::ShowWindow(MainWindowHandle, show); ::UpdateWindow(MainWindowHandle); return true;

Hint (3) LRESULT CALLBACK WndProc(HWND windowhandle, UINT msg, WPARAM wparam, LPARAM lparam) switch( msg ) case WM_LBUTTONDOWN: ::MessageBox(0, "Hello, World", "Hello", MB_OK); case WM_KEYDOWN: if( wparam == VK_ESCAPE ) ::DestroyWindow(MainWindowHandle); case WM_DESTROY: ::PostQuitMessage(0); return ::DefWindowProc(windowHandle, msg, wparam, lparam); Result Exercise

연습문제 (1) 메인윈도우를변경하시오. 배경색 아이콘 커서 타이틀 크기 대화상자를변경하시오. 타이틀, 문장, 버튼의종류 다른대화상자를생성하시오. 마우스우측버튼을클릭했을때 Enter 키를눌렀을때 연습문제 (2) 제출방법 2007. 4. 5 수업시간전까지 Exercise에대한프로그램을작성 ( 예 : 학번.cpp ) + 실행결과 ( 본강의자료 10쪽또는20쪽과같은출력이미지, 예 : 학번.jpg ) 2개파일을압축한 학번.zip 을웹에upload 할것