Quanta Confidential QUANTA WBU Study Report 1 昭正 2008/08/01.

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.
Further Programming for 3D applications CE Introduction to Further Programming for 3D application Bob Hobbs Faculty of Computing, Engineering and.
6. 마우스.
Building an MFC Application Using the Wizard. Terms Solution – A container for related projects – An executable or DLL – May be constructed from multiple.
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.
QT – Introduction C++ GUI Programming with Qt 4
Douglas Boling President Boling Consulting Inc. SESSION CODE: WEM304.
CSE3AGT Paul Taylor Stupid Conventions! l = Long p = Pointer h = handle g = global wnd = Windows WM = Windows Message d3d = Direct3D hr = HRESULT.
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.
1 Windows GDI Programming CIS 487/587 Bruce R. Maxim UM-Dearborn.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
Presentation Outline Introduction Painting and Repainting GDI.
Bitmap (Chapter 15).
Registering a window class Windows allows many styles of window to be created. To tell Windows to create a window as you want it you need to define a class.
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,
Creating a DirectX Project A DirectPLay Chat Program.
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.
9. 메뉴와 기타 자원. 1. 자원 – 아이콘, 커서, 메뉴, 대화상자는 모두 Windows 의 자원이다. – 자원은 데이터로 생각할 수 있으며, 프로그램의 EXE 파일에 저장된 다. – 실행 가능한 프로그램의 데이터 영역에는 존재하지 않는다. 자원은 프로그램 소스코드에.
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.
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.
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.
Programming windows with MFC Chapter 2 - Drawing in a Window
Presentation Outline Introduction Painting and Repainting GDI.
Windows Programming Lecture 10.
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
Graphic Device Interface
Windows Programming Lecture 12
Windows Programming Lecture 13
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
19.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
GUI Socket Application
Chapter 14 Drawing in a Window
Chapter 16 Drawing in a Window
Presentation transcript:

Quanta Confidential QUANTA WBU Study Report 1 昭正 2008/08/01

Quanta Confidential QUANTA WBU -2- 大綱 簡介 WinMain 流程 簡介原始範例結構 背景填色 繪製圖片 1 繪製圖片 2

Quanta Confidential QUANTA WBU -3- #define dim(x) (sizeof(x) / sizeof(x[0])) const TCHAR szAppName[] = TEXT ("Shapes"); const struct decodeUINT MainMessages[] = { WM_PAINT, DoPaintMain, WM_DESTROY, DoDestroyMain, };

Quanta Confidential QUANTA WBU -4- WinMain int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { // Initialize this instance. hwndMain = InitInstance(hInstance, lpCmdLine, nCmdShow); // Application message loop while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } // Instance cleanup return TermInstance (hInstance, msg.wParam); }

Quanta Confidential QUANTA WBU -5- InitInstance // InitInstance - Instance initialization HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow){ WNDCLASS wc; // Register application main window class. wc.lpfnWndProc = MainWndProc; // Callback function wc.lpszClassName = szAppName; // Window class name // Create main window. hWnd = CreateWindowEx (WS_EX_NODRAG, // Ex Style szAppName, // Window class TEXT("Shapes"), // Window title WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, NULL,NULL,hInstance,NULL); // Standard show and update calls ShowWindow (hWnd, nCmdShow); UpdateWindow (hWnd); return hWnd; }

Quanta Confidential QUANTA WBU -6- MainWndProc // MainWndProc - Callback function for application window LRESULT CALLBACK MainWndProc (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { // Search message list to see if we need to handle this // message. If in list, call procedure. for (i = 0; i < dim(MainMessages); i++) { if (wMsg == MainMessages[i].Code) return (*MainMessages[i].Fxn)(hWnd, wMsg, wParam, lParam); } return DefWindowProc (hWnd, wMsg, wParam, lParam); } WM_QUIT

Quanta Confidential QUANTA WBU -7- DoPaintMain LRESULT DoPaintMain (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { // 主程式 }

Quanta Confidential QUANTA WBU -8- BeginPaint //The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT structure with information about the painting. HDC BeginPaint( HWND hwnd, // handle to window LPPAINTSTRUCT lpPaint // paint information );

Quanta Confidential QUANTA WBU -9- EndPaint //The EndPaint function marks the end of painting in the specified window. This function is required for each call to the BeginPaint function, but only after painting is complete. BOOL EndPaint( HWND hWnd, // handle to window CONST PAINTSTRUCT *lpPaint // paint data );

Quanta Confidential QUANTA WBU -10- DoPaintMain { PAINTSTRUCT ps; RECT rect; HDC hdc; HBRUSH hBr; TCHAR szText[128]; GetClientRect (hWnd, &rect); hdc = BeginPaint (hWnd, &ps); // 繪圖程式碼:背景填色、繪圖 1 、繪圖 2 EndPaint (hWnd, &ps); return 0; } WM_DESTROY

Quanta Confidential QUANTA WBU -11- 背景填色 hBr = (HBRUSH) GetStockObject (DKGRAY_BRUSH); FillRect(hdc,&rect,hBr); //DeleteObject(hBr);

Quanta Confidential QUANTA WBU -12- 繪製圖片 1 HBITMAP hBitmap,hOldBitmap; BITMAP bmp; HDC hdcMem; TCHAR sz[]=TEXT("\\bitmap1.bmp"); hBitmap=SHLoadDIBitmap((LPCTSTR)sz); hdcMem=CreateCompatibleDC(hdc); hOldBitmap=(HBITMAP) SelectObject(hdcMem,hBitmap); GetObject(hBitmap,sizeof(BITMAP),&bmp); BitBlt(hdc,rect.left,rect.top,bmp.bmWidth,bmp.bmHeight, hdcMem,0,0,SRCCOPY); SelectObject(hdcMem,hOldBitmap); DeleteObject (hOldBitmap); DeleteDC(hdcMem);

Quanta Confidential QUANTA WBU -13- 繪製圖片 2 hBitmap=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_ BITMAP1)); hdcMem=CreateCompatibleDC(hdc); hOldBitmap= (HBITMAP) SelectObject(hdcMem,hBitmap); GetObject(hBitmap,sizeof(BITMAP),&bmp); BitBlt(hdc,rect.left,rect.top,bmp.bmWidth,bmp.bmHeight, hdcMem,0,0,SRCCOPY); SelectObject(hdcMem,hOldBitmap); DeleteObject (hOldBitmap); DeleteDC(hdcMem); DoPaintMain

Quanta Confidential QUANTA WBU -14- DoDestroyMain // DoDestroyMain - Process WM_DESTROY message for window LRESULT DoDestroyMain (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { PostQuitMessage (0); return 0; } WinMain

Quanta Confidential QUANTA WBU -15- TermInstance // TermInstance - Program cleanup int TermInstance (HINSTANCE hInstance, int nDefRC) { return nDefRC; } WinMain

Quanta Confidential QUANTA WBU -16- #include #include // For all that Windows stuff #include "shapes.h" // Program-specific stuff #include "resource.h"

Quanta Confidential QUANTA WBU -17- decodeUINT struct decodeUINT { // Structure associates UINT Code; // messages // with a function. LRESULT (*Fxn)(HWND, UINT, WPARAM, LPARAM); };

Quanta Confidential QUANTA WBU -18- LRESULT typedef LONG_PTR LRESULT;

Quanta Confidential QUANTA WBU -19- WNDCLASS //This structure contains the window class attributes that are registered by the RegisterClass function. typedef struct _WNDCLASS { UINT style; WNDPROC lpfnWndProc; int cbClsExtra; int cbWndExtra; HANDLE hInstance; HICON hIcon; HCURSOR hCursor; HBRUSH hbrBackground; LPCTSTR lpszMenuName; LPCTSTR lpszClassName; } WNDCLASS;

Quanta Confidential QUANTA WBU -20- PAINTSTRUCT //This structure contains information that an application uses to paint the client area of a window owned by that application. typedef struct tagPAINTSTRUCT { HDC hdc; BOOL fErase; RECT rcPaint; BOOL fRestore; BOOL fIncUpdate; BYTE rgbReserved[32]; } PAINTSTRUCT;

Quanta Confidential QUANTA WBU -21- RECT //This structure defines the coordinates of the upper-left and lower-right corners of a rectangle. typedef struct _RECT { LONG left; LONG top; LONG right; LONG bottom; } RECT;

Quanta Confidential QUANTA WBU -22- HDC

Quanta Confidential QUANTA WBU -23- HBRUSH

Quanta Confidential QUANTA WBU -24- TCHAR

Quanta Confidential QUANTA WBU -25- GetClientRect //The GetClientRect function retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower- right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0). BOOL GetClientRect( HWND hWnd, LPRECT lpRect );

Quanta Confidential QUANTA WBU -26- GetStockObject //The GetStockObject function retrieves a handle to one of the stock pens, brushes, fonts, or palettes. HGDIOBJ GetStockObject( int fnObject // stock object type );

Quanta Confidential QUANTA WBU -27-

Quanta Confidential QUANTA WBU -28- FillRect //This function fills a rectangle using the specified brush. This function fills the rectangle's left and top borders, but excludes the right and bottom borders. int FillRect( HDC hDC, CONST RECT* lprc, HBRUSH hbr );

Quanta Confidential QUANTA WBU -29- 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 );

Quanta Confidential QUANTA WBU -30- HBITMAP

Quanta Confidential QUANTA WBU -31- BITMAP //This structure defines the type, width, height, color format, and bit values of a bitmap. typedef struct tagBITMAP { LONG bmType; LONG bmWidth; LONG bmHeight; LONG bmWidthBytes; WORD bmPlanes; WORD bmBitsPixel; LPVOID bmBits; } BITMAP;

Quanta Confidential QUANTA WBU -32- SHLoadDIBitmap

Quanta Confidential QUANTA WBU -33- CreateCompatibleDC //This function creates a memory device context (DC) compatible with the specified device. HDC CreateCompatibleDC( HDC hdc );

Quanta Confidential QUANTA WBU -34- GetObject //This function obtains information about a specified graphics object. Depending on the graphics object, the function places a filled-in BITMAP, DIBSECTION, LOGBRUSH, LOGFONT, or LOGPEN structure into a specified buffer. int GetObject( HGDIOBJ hgdiobj, int cbBuffer, LPVOID lpvObject );

Quanta Confidential QUANTA WBU -35- sizeof //This function returns the size, in bytes, of the specified resource. DWORD SizeofResource( HMODULE hModule, HRSRC hResInfo );

Quanta Confidential QUANTA WBU -36- BitBlt //This function transfers pixels from a specified source rectangle to a specified destination rectangle, altering the pixels according to the selected raster operation (ROP) code. BOOL BitBlt( HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop );

Quanta Confidential QUANTA WBU -37- DeleteDC //This function deletes the specified device context (DC). BOOL DeleteDC( HDC hdc );

Quanta Confidential QUANTA WBU -38- DeleteObject //This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. After the object is deleted, the specified handle is no longer valid. BOOL DeleteObject( HGDIOBJ hObject );

Quanta Confidential QUANTA WBU -39- LoadBitmap //This function loads the specified bitmap resource from the executable file for a module. HBITMAP LoadBitmap( HINSTANCE hInstance, LPCTSTR lpBitmapName );

Quanta Confidential QUANTA WBU -40- MAKEINTRESOURCE //This macro converts an integer value to a resource type compatible with Windows resource-management functions. This macro is used in place of a string containing the name of the resource. LPTSTR MAKEINTRESOURCE( WORD wInteger; );

Quanta Confidential QUANTA WBU -41- GetMessage //This function retrieves a message from the calling thread's message queue and places it in the specified structure. BOOL GetMessage( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax );

Quanta Confidential QUANTA WBU -42- TranslateMessage //This function translates virtual-key messages into character messages. The character messages are posted to the calling thread's message queue, to be read the next time the thread calls the GetMessage or PeekMessage function. BOOL TranslateMessage( const MSG* lpMsg );

Quanta Confidential QUANTA WBU -43- DispatchMessage //This function dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function. LONG DispatchMessage( const MSG* lpmsg );

Quanta Confidential QUANTA WBU -44- CreateWindowEx //This function creates an overlapped, pop-up, or child window with an extended style; otherwise, this function is identical to the CreateWindow function. HWND CreateWindowEx( DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam );

Quanta Confidential QUANTA WBU -45- ShowWindow //This function sets the specified window's show state. BOOL ShowWindow( HWND hWnd, int nCmdShow );

Quanta Confidential QUANTA WBU -46- UpdateWindow //This function updates the client area of the specified window by sending a WM_PAINT message to the window if the window's update region is not empty.WM_PAINT UpdateWindow sends a WM_PAINT message directly to the window procedure of the specified window, bypassing the application queue. If the update region is empty, no message is sent. BOOL UpdateWindow( HWND hWnd );

Quanta Confidential QUANTA WBU -47- DefWindowProc //This function calls the default window procedure to provide default processing for any window messages that an application does not process. This function ensures that every message is processed. DefWindowProc is called with the same parameters received by the window procedure. LRESULT DefWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );

Quanta Confidential QUANTA WBU -48- PostQuitMessage //This function indicates to Windows that a thread has made a request to terminate (quit). It is typically used in response to a WM_DESTROY message. void PostQuitMessage( int nExitCode );