Address 6.


81 views
Uploaded on:
Category: Home / Real Estate
Description
Address 6 The Design Interface and Mouse Occasions THE Essentials The engineering of a fundamental Windows application will in 99% of cases perform screen yield in the WM_PAINT message handler. With graphical info by means of MOUSE Occasions we need to adjust this and perform yield as required.
Transcripts
Slide 1

Address 6 The Graphics Interface and Mouse Events

Slide 2

THE BASICS The structural planning of a fundamental Windows application will in 99% of cases perform screen yield in the WM_PAINT message handler. With graphical information through MOUSE EVENTS we need to alter this and perform yield as needed. At the point when considering graphical yield this must be done in a gadget free way. To begin with accordingly we must take a gander at the ideas connected with gadget freedom.

Slide 3

Device Context In taking care of WM_PAINT the preparing is taken care of between the calls to: BeginPaint() .... EndPaint (). This is to permit the application to get the Device Context. The Device Context (DC) has two vital components permitting a specific application to corresponded with a particular physical gadgets. Any DC is connected with a specific physical gadget.

Slide 4

DC The genuine programming interface to for case a SVGA show connector is arranged into a specific establishment of ‘95 ‘98 or ‘NT. This physical commute programming is of no significance to the structural engineering of a windows application. An application must be outlined with the full comprehension that it is to impart all its graphical yield through a DC. Different DC’s exist in any framework the other most regular DC is the one connected with the printer.

Slide 5

DC The Device Driver or Interface to the physical presentation and so forth is the bit of programming inside of a windows framework assigned as a VxD. The second real capacity of the DC is a spot holder and compartment for the capacity of an arrangement of graphical qualities, for example, shading, pen size, brushes (fill examples) et cetera. Properties can be adjusted once the application has entry to the DC.

Slide 6

DC To comprehend the idea of DC we can consider it a craftsman being told to do something on to a canvas. The application itself does not know how to put the physical paint on the canvas, the craftsman takes the directions from the application and utilizing the hardware he/she is holding performs the real visual activities.

Slide 7

GRAPHICS OBJECTS Graphics articles are shockingly theoretical elements. WHY ARE GRAPHICS OBJECTS NECESSARY? Inside of Windows to really draw design shapes is relatively straightforward. To draw a rectangle, takes five contentions, four characterize the measurements, the fifth determines the DC. The DC embodies each part of the drawing procedure obliged, width, shade of framework, example of the inside and the destination i.e. Screen or Printer.

Slide 8

WHAT ARE THE OBJECTS? Gatherings of illustrations qualities are epitomized into items and put away inside of the DC. These conceptual elements are called illustrations items Drawing a line for occasion is controlled by an article called a PEN. Filling the inside of an article is controlled by an item called a BRUSH.

Slide 9

Objects To change or select a specific trademark Either utilize a STOCK item one that exists inside of Windows or another arrangement of trademark are CREATED. The PEN article has the fundamental attributes Line Style Line width Color STOCK Pens - BLACK_PEN, WHITE_PEN and NULL_PEN.

Slide 10

Stock Items and Brushes The benefits of STOCK things is they as of now exist and don\'t require any extra framework asset. Utilizing CREATE, to manufacture an one of a kind PEN offers about an endless mixed bag of PENS, however utilizes framework asset. The BRUSH article has the essential qualities Solid or Hatch Pattern Color STOCK Brushes incorporate BLACK_BRUSH, WHITE_BRUSH and NULL_BRUSH

Slide 11

Color Careful thought to the shading ability of the framework the application is prone to keep running on is imperative. It is normal practice to join the applications code connected with graphical yield between the presentation and the printer. In the event that screen has a shading palette capacity of 256 and the printer just 16 this may bring about outline bargains.

Slide 12

Color SPECIFICATION Windows ‘95 ‘98 and ‘NT address the issue of indicating a shading tone that can not be managed by the physical gadget by changing the shading to a best match. Considering so as to shade pictures or shading printing is indicated the three\'s measure essential hues RED, GREEN and BLUE.

Slide 13

COLORREF - 32 bit esteem 3 x 8 bit qualities determine the essential shading force. The estimation of every 8 bit shading force can be from 0 to 255 so this offers ascend to the accessibility of 256 shades of red blended with 256 shades of green and 256 shades of blue a sum of 16,777,216 tints of shading. Keeping in mind the end goal to disentangle the choice and set up of COLORREF a full scale exists RGB that develops the COLORREF 32 bits effectively.

Slide 14

COLORREF VALUES Typical RGB Values. Colour Red Green Blue Red Green Blue Black 0 0 0 Red 255 0 0 Green 0 255 0 Blue 0 0 255 Yellow 255 255 0 Magenta 255 0 255 Cyan 0 255 255 Dark Gray 128 128 128 Olive 128 128 0 Orange 255 128 0 White 255 255 255

Slide 15

WARNING ON Color If an application determines a RBG(175,37,76) it is delicately unless the framework running the application has a complex showcase connector that this will be meant something far easier RGB(255,0,128) and perhaps subject to the presentation connector some dithering may happen. The good to this notice is; unless you are doing photographic control applications don’t attempt and select complex shading tones they presumably won’t be accessible on the dominant part of frameworks. The last point before we take a gander at HOW we interface with the client permitting graphical information MOUSE occasions and so forth. Is what are drawing modes?

Slide 16

BackGround and so on. On the off chance that an application determines draw a line, it anticipates that this line will show up on for occasion the screen (we will accept the DC indicated is the screen). The line ought to show up in the line style, width and shading determined by the PEN chose into the DC. On the other hand, the universe of realistic drawing is not as straightforward as that. Shouldn\'t something be said about the foundation ? This may be an assortment of hues either strong or united and the line may vanish in specific areas on the grounds that the PEN shading and the foundation shading are the same.

Slide 17

WHAT CAN WE DO The answer in Windows and numerous other graphical based GUI’s is to have Drawing Modes or Raster Operations. This is another arrangement of properties held in the DC which decide how the graphical operation is to be performed.

Slide 18

ROP’s There are an endless exhibit of these some are extremely dark yet taking a gander at the most widely recognized we can distinguish ROP Constant Line Drawn on foundation Color R2_Black Always Black R2_White Always White R2_NOP Same as foundation so imperceptible R2_NOT Inverse of foundation so constantly obvious R2_COPYPEN Same as Pen Color (default) R2_NOTCOPYPEN Inverse of Pen Color

Slide 19

MORE ON ROP’s The most well-known is R2_COPYPEN, (the default) essentially utilizes the Pen Color indicated. R2_NOT is essential it draws as the foundation\'s converse so is constantly unmistakable regardless of what shading or scope of hues on the foundation. Obviously the converse of Black is White and the backwards of White is Black, however things do get convoluted when the foundation is some other shading.

Slide 20

R2_NOT An intriguing component of R2_NOT is that on the off chance that we draw one line then draw over that line again it will vanish following the reverse\'s opposite get us back to the first foundation shading. This is an extremely straightforward however essential thought, that w will examine all the more completely when w look in a minute at gaining drawing data from the client by means of the Mouse occasions.

Slide 21

The Mouse and User Events User Input. You utilize the mouse or tracker ball to demonstrate indicates on the screen draw and drag illustrations objects. We have as of now seen that by exemplifying the properties for the real drawing components Windows can give a basic arrangement of API’s to put geometric components; lines, circles and rectangles on the screen.

Slide 22

WM_MOUSEMOVE lParam in the 16 bit environment contains in the low word the X-co-ordinate and the high word the Y-co-ordinate. 16 bits 16 bits lParam High Word Y-coordinate Low Word X-coordinate

Slide 23

STANDARD MACRO’s Two standard macros are accessible to remove these unsigned whole number esteem effectively LOWORD() and HIWORD() wParam demonstrates conveys data on whether the client has squeezed mouse keys or any extraordinary keys. wParam Constant Meaning in WM_MOUSEMOVE MK_LBUTTON Left Button was down MK_RBUTTON Right Button was down MK_MBUTTON Middle Button was down MK_CONTROL CTRL key on console down MK_SHIFT SHIFT key on console down

Slide 24

Typical MOUSE CONTROL So a regularly you can test wParam with code of the structure if (wParam & MK_LBUTTON) This will be genuine if the mouse moved while the client held the left catch. To light a solitary Pixel on the screen when the client moves the mouse with the left catch held we would require a bit of code of the structure

Slide 25

SOME TYPICAL CODE if (wParam & MK_LBUTTON) { hDC = GetDC(hWnd);/Get the default screen DC for this Window /hWnd is the windows handle returned amid /make window. SetPixel (hDC, LOWORD(lParam),/X-coordinate HIWORD(lParam),/Y-coordinate RGB(0,0,0)); /Color for Pixel for this situation Black ReleaseDC(hWnd,hDC);/Release the DC } This code being the move to make on receipt of a WM_MOUSEMOVE message in the message taking care of system for the specific window.

Slide 26

DRAW A LINE Now we could basically utilize the Pixels to lay down a meaningful boundary however this would be monotonous for the client and it doesn\'t offer the client the opportunity to alter the line\'s course. in the event that (wParam & MK_LBUTTON) { hDC = GetDC(hWnd);/Get the default screen DC for this Window /hWnd is the windows handle returned amid /make win

Recommended
View more...