Graphics Laboratory Korea University

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.
Guidelines for working with Microsoft Visual Studio.Net.
Guidelines for working with Microsoft Visual Studio 6.
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.
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.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
Lecture Two Event Handling Keyboard and Mouse Input.
QT – Introduction C++ GUI Programming with Qt 4
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.
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.
Assign one variable to each group of radio buttons To do this, assign one integer variable to the first radio button in each group. All the subsequent.
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 –
1 Programming and Software Engineering. 2 Software Development We can define two main classes of software: User-written software solve a particular problem,
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.
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.
Presentation Outline Introduction Painting and Repainting GDI.
Windows Programming Lecture 10.
Programming Input Devices
Windows Programming Lecture 09.
Window.
Building a Win32API Application
18 & 19.
Chapter 1 Hello, MFC.
Windows Programming Model
Aspect-Oriented Programming
Windows Programming using Dev C++
Queued and Nonqueued Messages
The program in traditional OS
Windows Controls & Concepts
Windows Programming Lecture 12
Windows Programming Lecture 13
Two ways to discuss color 1) Addition 2) Subtraction
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
What Color is it?.
21-22.
19.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
GUI Socket Application
OpenGL Programming – Day 1
Presentation transcript:

Graphics Laboratory Korea University Windows Programming Graphics Laboratory Korea University

Microsoft Visual C++ 6.0

File  New

New Project

Win32 Application (1/2)

Win32 Application (2/2)

Workspace

New File

Workspace  FileView

“main.cpp”

#include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // global variables char *szClassName = "Draw2DClass"; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { // Registers the window class WNDCLASSEX wcex; wcex.cbSize = sizeof(wcex); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(NULL,IDI_APPLICATION); wcex.hIconSm = NULL; wcex.hCursor = LoadCursor(NULL,IDC_ARROW); wcex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wcex.lpszMenuName = NULL; wcex.lpszClassName = szClassName; RegisterClassEx(&wcex); // Create the main window HWND hWnd = CreateWindow(szClassName, "Draw in 2D", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); if (!hWnd) return FALSE; ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); // Main message loop MSG msg; while (GetMessage(&msg, NULL, 0, 0)) TranslateMessage(&msg); DispatchMessage(&msg); } UnregisterClass(szClassName, wcex.hInstance); return msg.wParam;

Window Message Handling /* * WndProc: to process messages for the main window */ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; switch (message) case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;

Build

Execute

Draw Points /* * WndProc: to process messages for the main window */ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; register int i, j; switch (message) case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... for(i=-5; i<=5; i++) for(j=-5; j<=5; j++) SetPixel(hdc, 400+i, 300+j, RGB(255, 0, 0)); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;

Result – Draw Points

Mouse Event Handing (1/2) LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; register int i, j; switch (message) case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... for(i=-5; i<=5; i++) for(j=-5; j<=5; j++) SetPixel(hdc, 400+i, 300+j, RGB(255, 0, 0)); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;

Mouse Event Handing (1/2) int point[2] = { -5, -5 }; LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; register int i, j; switch (message) case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... for(i=-5; i<=5; i++) for(j=-5; j<=5; j++) SetPixel(hdc, point[0]+i, point[1]+j, RGB(255, 0, 0)); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); case WM_LBUTTONDOWN: point[0] = LOWORD(lParam); point[1] = HIWORD(lParam); InvalidateRect(hWnd, NULL, FALSE); default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0;

Result – Mouse Event Handling

Insert  Resource

Resources

Menu (1/6)

Menu (2/6)

Menu (3/6)

Menu (4/6)

Menu (5/6)

Menu (6/6)

Save Resources

Include Resources (1/3)

Include Resources (2/3)

Include Resources (3/3)

Result – Menu

Menu Event Handling

Result – Menu Event Handling

Miscellanies Check / Uncheck a item of menu CheckMenuItem(GetMenu(hWnd), ID_PRIM_LINE, MF_CHECKED); CheckMenuItem(GetMenu(hWnd), ID_PRIM_LINE, MF_UNCHECKED); Enable / Disable a item of menu EnableMenuItem(GetMenu(hWnd), ID_PRIM_LINE, MF_ENABLED); EnableMenuItem(GetMenu(hWnd), ID_PRIM_LINE, MF_GRAYED); COLORREF GetPixel( int x, int y ) const; COLORREF SetPixel( int x, int y, COLORREF crColor );

RGB Color Model R G B Color Colors are additive 0.0 0.0 0.0 Black 1.0 Red 0.0 1.0 0.0 Green 0.0 0.0 1.0 Blue 1.0 1.0 0.0 Yellow 1.0 0.0 1.0 Magenta 0.0 1.0 1.0 Cyan 1.0 1.0 1.0 White

Insert  Resource

Dialog Box (1/5)

Dialog Box (2/5)

Dialog Box (3/5)

Dialog Box (4/5)

Dialog Box (5/5)

New Menu

Dialog Callback Function (1/2)

Dialog Callback Function (2/2)

Dialog Creation

Result – Dialog Box

Debug