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.

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.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
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.
Lecture Two Event Handling Keyboard and Mouse Input.
QT – Introduction C++ GUI Programming with Qt 4
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.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
Menu Messages  Besides the all-important WM_COMMAND message, window provides five other messages at various stages of menu selection:  WM_SYSCOMMAND.
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.
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,
Quanta Confidential QUANTA WBU Study Report 1 昭正 2008/08/01.
Mouse events, Advanced camera control George Georgiev Telerik Corporation
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,
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.
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 11
Windows Programming Lecture 10.
Programming Input Devices
Interfacing.
Windows Programming Lecture 09.
Window.
Building a Win32API Application
18 & 19.
Windows Programming Model
Aspect-Oriented Programming
Windows Programming using Dev C++
Queued and Nonqueued Messages
The program in traditional OS
Windows Programming Lecture 12
28.
Windows Programming Lecture 13
Building a Win32API Application
Windows Programming Lecture 15
19.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
GUI Socket Application
Presentation transcript:

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 used by programmer, it provides a fascinating insight into the windows mouse messages’ internal machniations.  M_NCHITTEST originates in the USER.EXE module, which sends this message to the top most window overlying any mouse event. When you move the mouse, windows detects that movement, and determines the new mouse location.

 The window receive the WM_NCHITTEST message with the mouse cursors’s screen co-ordinates as lparam. Wparam is not used.  wParam not used(0).  Lparam:- mouse co-ordinates, relative to the top-left corner of the screen. Loword contains the x co- ordinates, HIWORD contains the y- cordinates.

Window Activation: WM_MOUSEACTIVATE  A window procedure gets a WM_MOUSEACTIVATE whenever its window is not activate and a mouse button is clicked over it.  If a program creates multiple windows, user could switch between them the mouse. In that event, the window being activated would receive this message.  Wparam:- will contain the handle of the window’s original granparent.  WM_ACTIVATE will tell you whatever any window is being activated or inactivated through whatever means.

The mouse cursor Many window applications including window’s own applications such as the program manager, file manager, and task manager use a standard arrow-shaped cursor. This doesn’t necessarily have to be so. Program get their first opportunity to customize their mouse cursor. The register class function requires a pointer to a WNDCLASS structure, which contain a mouse cursor handle:-

typedef struct tagWNDCLASS { UINT style; WNDPROC lpfnWndProc; int cbClsExtra; int cbWndExtra; HINSTANCE hinstance; HICON hicon; HCURSOR hcursor;  Obtaining the cursor handles:- The easiest way to mouse cursor handle is by using the LoadCursor() function:-  LoadCursor( hinst, pszCursor);

changing mouse cursor The window API provides a simple function which can be used to change the mouse cursor: SetCursor(hcursor)

Code for changing the mouse cursor #include"resource.h" #include"afxwin.h" #include"windows.h" HWND hwndMainWindow; HINSTANCE hinstance; int nCurrentCursor; LPSTR lpszCursorId[]= { IDC_ARROW, IDC_IBEAM, IDC_WAIT, IDC_CROSS, IDC_UPARROW, IDC_SIZE, IDC_ICON }; #define CURSOR_COUNT(sizeof(lpszCursorId)/sizeof(LPSTR)) LPSTR lpszCursorName[]= { "Arrow", "Ibeam", "Wait","Cross","Up Arrow","Size","Icon"}; HWND hwndButtons[CURSOR_COUNT]={0};

long WindowProc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp); int _stdcall WinMain(HINSTANCE h, HINSTANCE hp, char *r, int i) { MSG msg; WNDCLASS wc; if(!hp) { wc.style=CS_HREDDRAW|CS_VREDDRAW|CS_DBLCLKS; wc.lpfnWndProc=WindowProc; wc.cbClsExtra=0; wc.cbWndExtra=0; wc.hInstance=h; wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); wc.hCursor=NULL; wc.lpszClassName="my"; RegisterClass(&wc); }

hwndMainWindow=CreateWindow("my","hello",WS_OVERLAPPED WINDOW,CW_USEDEFAULT,NULL,NULL,h,NULL); ShowWindow(hwndMainWindow,3); UpdateWindow(hwndMainWindow); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; }

long WindowProc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) { int i, cxbuttonsize, cybuttonsize; RECT rect; POINT pt; switch(message) { case WM_CREATE: for(i=0;i<CURSOR_COUNT;i++) { hwndButtons[i]=CreateWindow("BUTTON",lpszCursorName[i], WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,0,0,h,0); } return 0;

case WM_COMMAND: nCurrentCursor=wp; GetClientRect(hwnd,&rect); pt.x=rect.left; pt.y=rect.top; ClientToScreen(hwnd,&pt); SetCursorPos(pt.x+10,pt.y+10); return 0; case WM_MOUSEMOVE: SetCursor(LoadCursor(NULL,lpszCursorId[nCurrentCursor])); return 0;

case WM_PAINT: SetCursor(LoadCursor(NULL,lpszCursorId[nCurrentCursor])); GetClientRect(hwnd,&rect); cxbuttonsize=rect.right; cybuttonsize=rect.bottom; for(i=0;i<CURSOR_COUNT;i++) { MoveWindow(hwndButtons[i],0,rect.bottom+i*cybuttonsize,cxbuttonsize, cybuttonsize,FALSE); SendMessage(hwndButtons[i],WM_PAINT,0,0); } case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,message,wp,lp); }