Sixth lesson: drawing function
First, bit operation
A few days ago, in a far farther, it is so far, and some netizens will ask some of the contents of the relevant position. I didn't pay attention to this link at first, and I think it is estimated that everyone can know. It is not the case now. The contents of the "WIN32 API Developer Guide" also talked about the contents of the operation, but it was part of an icon in the beginning. So, I think, I'm not familiar with friends, you can answer, learn or deepen some understandings from the following. The question of this netizen is very serious, and I have to answer it carefully. The following is a paragraph of the letter: "NOT" "AND" "OR" usage? (Because the information just talks about "True" "false", please trouble you) Well, get the following conclusions:
12 and 15 = 12 'simplified --- Return small 12 or 15 = 15' return big
12 and 16 = 0 'Returns zero ?? 12 or 16 = 28' Back to add ??
NOT 12 = -13 '(Removal of Parts 1) The opposite NOT 100 = -101' (Take Some Parts 1)
The following is my reply content: (a lot of changes and processes have been made to the original text.) Is a bit operation operator. For example, 3 and 1 = 1, why is the result equal to 1? The reason is this. 3 is equivalent to 11 (2), 1 is equal to 01 (2) (here only two digits, actually 8 bits, 16 bits, and 32 bits, etc.)
AND is the awareness of 斖 . In binary data, 1 represents true (TRUE), 0 represents false. Its operational rules are: in the corresponding bits of the two numbers, if the two bits are at the same time 1, otherwise it is 0. Specifically, 11 and 01, the first base is 1, thus getting 1, and the previous one (11) is 1, and the other (01) is 0, which does not conform to 斖 睌The requirements were required, resulting in 0. This 11 and 01 is equal to 01. Binary 01 is a decimal 1. Therefore, it can be judged that 3 and 1 = 1. I don't know, I haven't learned it? I don't have any example, such as: 12 and 15 = 12. Why is it equal to 12?
Let us analyze it. First convert each data into a 2-based number, as follows: 12 = 1100 15 = 1111
This starts from the left to press the 斖 斖 斖 1, otherwise 0 brain 蚓 缘 缘? 100. Recommended as follows:
1110
1111 and
1100
We know that binary 1100 is equal to decimal 12, so you can draw 12 and 15 = 12 conclusions.
Let's take a look at the OR operation. It's of course "or" awareness. Among the two numbers, one can get 1 as long as one is 1, so-called: This is equal to 1 or that is equal to 1, anyway, one is 1, otherwise 0. See you again:
12 or 15 = 15 A similar step as described above:
12 = 1100 15 = 1111
Then follow the rules just told, you can do the following calculations:
1100
1111 or
1111
We know that the binary 1111 is equal to the decimal 15, so it can be obtained by the conclusion of 12 or 15 = 15
OR operation is generally used for bit settings. For example, (now I am an example, do not necessarily this), a value represents a form of a form, we are generally called style bit data. The first bit = 1 indicates that the form has a title bar, and the second bit is equal to 1 indicates that the form has a scroll bar. Others also represent other information, but now we only discuss these two bits. Now, we must make the form not only have title columns, but also want it to have scroll bars, generally taken the way to get this form bit data of this form with a particular function (in Win32, actual form style Bit data is often the LONG type data), such as we get a style bit data myWindowStyle = 12, of course, is equal to 1100 (binary). It is zero to see its first and second digits, indicating that the current form does not have a title bar and a scroll bar. To make the form have a title bar and a scroll bar, we need to make its first and second digits into 1. Two constants are required for this purpose. Of course, this constant is naturally provided by the API text! This is an example, and there is no content in the text! CONST WS_CAPTION = 1Const WS_VScroll = 2
(Note: 1 = 0001, 2 = 0010)
Now we can set a specific bit through the OR operation. Made as follows:
MyWindowStyle = MyWindowStyle or WS_CAPTION or WS_CAPTION The result will be equal to myWindowStyle = 15, i.e., 1111. (1100 OR 0010 OR 0001 = 1111) Finally, we transfer this data to the actual form processing function via a function, the form of the form changes, turns into a window with a title bar and scroll bar. body. In this way, OR becomes a bit like "simultaneous", such as: having a scroll bar while having the title bar. But actual operations are still expressed or. Don't be confused.
The NOT operator is a bit strange. If you speculate in air, it is likely to guess 1 to get 0, 0 get 1. So is it this? In fact, this is true. But the following facts will make some friends surprised: NOT 12 = -13 Because of the following rules, NOT 12, that is, NOT 1100 seems to be equal to 0011, i.e., 3, can be -13. So how do you explain this fact? In fact, usually we are in front of the numbers? 敾 - 敾 硎 硎 硎 诩 慊 惺 脭 1 indicates negative). If you consider problems at 8, 12 should be 00001100. Then, after the NOT operation, it should be 11110011.
So, how should 11110011 explain? That see, the first 1 of the left is a description symbol, but the remaining 7 digits, that is, 1110011 is not equal to 13? It should be equal to 115. -115? What is this? It turns out that this is involved in complement calculation problems. The calculation rule of the complement is like this. If the first bit (high segment) is 0, the positive number is indicated, and the numerical portion is represented by other points; but if the first bit is 1, the negative number, the numerical portion can be obtained by the following algorithm: the total number of data bit setting data x is n, each bay is represented as X1, X2. . . XN, then xi = 2 ^ (N-1) -0x2. . . XN (Note: This is the definition of integer completion, decimalization definitions are different, readers can read materials on their own materials)
That is, 11110011 = - (2 ^ 7-01110011) = - (10000000-01110011) = - (00001101) = - 13 So trouble? Don't worry, have a good calculation rule, this is: in the original data Add the symbol to reverse the symbol. So this is very well understood. Ture = -1 in VB. NOT (-1) = 0, NOT 0 = -1, you have been able to understand this. Therefore, NOT TURE = Flase, NOT FLASE = TURE. But in the IF judgment statement, you should carefully use the NOT operator. The IF statement will regard all the data that does not equal 0 as TURE (condition is established). It is necessary to advice you, if you can't determine a data n (not logical data) is definitely one data between -1 or 0 two numbers (but I still don't recommend this room), don't use NOT operations Symbol (this is my recommended). For example, when n = 1, if 1 Then is good, if not -1 then is all like a condition, it is true to meet the requirements of the IF statement. Many API functions are returned. And there is no logical data in the API function, but I haven't seen it so far. So IF NOT N THEN should be written into the form of IF n <> 0 THEN or IF N = 0 THEN. Especially in the API, keep in mind that there is millions in API. Now go back and want to think about And and OR operations. Excuse me, do you have a complement operation there? Also exists. Just we have not discussed a negative number. You can study yourself, it's easy to understand. Well, let's continue to discuss our Not. Of course, the following calculation is nothing to add one?
NOT 12 = -1 × (12 1) = -13
NOT 13 = -1 × (-13 1) = 12 Now, please don't want to think about anything, don't think about the little girl who is not working on the street during the day, remember such a Important: NOT operator is commonly used to clear the position operation operation with the AND operator. For example: x% = x% and (NOT & H0001%) The first bit of setting data X% (X% refers to data x) of the Integer data type is 0.
An example is given. The following operations are used to clear the bit 9 x% = x% and (not & h0200%) why. Because, & h0200% = 0000000100000000, huh, don't have one more? So why do you have this result? I don't want to go deep into it here. Because, I have already said it, as long as you consider these rules, you can figure out the mystery of it. There are other operators in the bit operation, such as XOR, etc., what is interested, what is good. In addition, in the future, you may encounter such a noun such a 敼庹 ぴ ぴ, is not something else, it is a bit operation. All right. Next, look back on the above content, let's take a look at the actual application. The program code given below is the code content of an attached application in the tutorial. The functionality of this program is to make the small circle of the radio box control to the left and right. Probably, you have already thought about it.
Option expedition
Private Declare Function GetWindowLong & Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) Private Declare Function SetWindowLong & Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long ) Private const BS_LEFTTEXT & = & H20 &
Private Sub Command1_Click (INDEX AS INTEGER) DIM F &, DL & F & = getWindowlong (option1.hwnd, gwl_style) Debug.print F & 'Set up one
IF index = 0 THEN F & = F & OR BS_LEFTTEXT ELSE F & = F & AND NOT BS_LEFTTEXT End IF Debug.print F & 'Here, set a DL & = SetWindowlong (Option1.hWnd, GWL_Style, F &) Option1.Refresh End Sub
In fact, it is very simple, F & = getWindowlong (Option1.hWnd, GWL_Style) is used to get the style bit data F &. Then, in conjunction with the above, the first is: F & = F & OR BS_LEFTText The role of F & = F & or BS_LEFTText is to set the data F &'s sixth bit of 1. This is because & H20 & = 000000000000000000000000000000000000000 (Note: Back "This data is long integer data, a total of 32 bits)
Secondly, the "NOT operator is commonly used in the" NOT operator in combination with the AND operator ", that is, the F &'s sixth bit is restored to 0. F & = F & AND NOT BS_LEFTTEXT can see the NOT operator's priority than the AND 大 (first calculating NOT). Finally, put the changed style bit data back to the control :DL & = setWindowl (Option1.hwnd, GWL_Style, F &)
In order to facilitate observation, in the above code, I specifically added two lines of Debug.Print F & adjustable code. I think, you should know what the program will run as follows (two Command1 are clicked, index = 0 and index = 1):
1409359876 1409359908 1409359908 1409359876
It can be seen that during the first click process (index = 0), the data becomes 1409359908 from 1409359876, and then recovered from 1409359908 from 1409359908 during the second clicks (INDEX = 1), now you can compare these two data. (You can use the scientific calculator provided by Windows to see: 10 Enter to 2), as follows:
1409359876 = 1010100000000010010000000000100 1409359908 = 1010100000000010010000000100100 Is it a so-called water stone out? Second, create a GDI drawing object
Today we have to discuss the most interesting part in the Win32 API - complete the graphic output with the drawing function. It can be said that all previously described content is preparation for this course. At that time, we used some draw functions in some test programs, which may be a little unhealthy understanding at the time. There is no relationship, as long as you have come here, and there is a little inunding memory for the previous content, it is already enough. Because each of the previous contents must be combined with the content in this class to form a complete understanding. After reading the current tutorial, look back in several tutorials, the problem will become clearer, transparent.
We have already said that the drawings in Windows are in the device scene. There are two types of equipment scenarios, one is the associated equipment scene, which is said to be associated with the device scene, just because the device scene is associated with a window. The associated awareness is that as long as you draw in this device scenario, then the drawing content is automatically reflected (display) in the form, making you can see. Then another device scenario is a device scene that is not associated. Of course, as you have already guessed, this kind of equipment scene, even if you painted the picture, it will not be displayed in the window. So, what is the difference between these two equipment scenes? In fact, there is no difference, probably the same relationship with married and unmarried, one has a wife, and there is no wife, but it is like this.
Since the drawing content in the device scene that does not associate with the window is not seen, then what is the purpose? Hey, don't look at it, a lot of images need to be processed in this equipment scene, the purpose is In order to make you see the processing of graphics. When the graphics are finished, the completed image can be transferred to the device scene that has been associated with the window once, allowing it to display. Of course, the effect is better. Then, before the real drawing, we must learn how to make a pen, color. Is it? The drawing always has to choose a pen or paint brush, and have to take into account what color to draw. Brush and paintings are the most commonly used GDI drawing objects. Among them, the brush is a GDI object that defines how to draw lines. Win32's standard brush has three properties, which are color, width, and linear. The color of the brush is used to define the RGB color of the line, and the colors actually used are related to the device. GDI can automatically select the color closest to the device. The unit of the width attribute is a logical unit. The standard brush can draw line type: solid line, invisible cable and several dotted lines, point line. Note that only the width of the solid line and the invisible line can be greater than 1. Win32 also provides an expansion brush and is ready to contact it later.
The use of the brush is the filling area. It defines a small area (typically 8 × 8 pixels), and then the pattern of this small block is copied to the entire fill area as the Windows 95 desktop background pattern. There are three main types of brush. First, the solid brush. The block diagram is a single colored fixed color, which can be used to determine the color. Second, the pattern brush. At this time, the block diagram is a small bitmap specified by the user, of course, cannot be greater than 8 × 8 pixel points. The last one is a shadow brush. It is said that it is a shadow brush, which is actually constructed from some types of intersections. Which grid line is adopted, it has to be specified by some BS_-specified parameters. So how do you get these brushes or brushes? You can use the API functions listed below. (Related to its function description can be found in APIBROW)
Function, Createbrushindirect creates a brush createDibpatternbrush on a logbrush data structure, creates a brush with a bitmap-independent bitmap, in order to specify the brush style (pattern) CreateDibPatternbrushpt Create a brush with a bitmap that is not related to the device In order to specify a brush pattern (pattern) CreateHatchBrush Creating a brush (shadow pattern) with shaded patterns CreatePatternbrush Create a brush Createpen with a specified style, width and color Creating a brush CreatepenIndirectire Creating a brush CreateSolidbrush based on the specified Logpen structure Create a brush ExtCreatepen with solid color Creating an extension brush (decorative or geometric) getStockObject gets an inherent object (stock). This is a red solid brush, a brush width of 3 pixels, a brush width, a brush, a brush, and a brush width, a brush, a brush, a brush width Dim Newpen as longprivate const ps_solid = 0Newpen & = Createpen (PS_SOLID, 3, RGB (255, 0, 0) Note: The definition of the PS_SOLID constant represents a solid line example 2: Creating a shadow brush Logbrush structure is as follows :Private Type Logbrush LBStyle As Longnd Type The following code 餍 Create a brush style for shadow (BS_HATCHED), Shadow type is a red brush of cross cross (HS_CROSS). Dim brushinfo as logbrushbrushinfo.lbstyle = BS_HATCHED
Brushinfo.lbcolor = RGB (255, 0) brushinfo.lbhatch = HS_CROSSNEWBRUSH = Createbrushindirect (Brushinfo)
Example 3: Create a brush with solid color (this example is red) Newbrush = CreateSolidbrush (VBRED)
Similarly, with several other functions, the corresponding GDI drawing object can be created according to its usage. Now, you know more about these functions and, you can understand the examples. Later, we combine the actual examples to explore the usage of these functions.
Third, pick up and put the brush (GDI object)
Now I feel like a student of a group of paintings, although I don't paint. The first is to practice the basic skill, how to pick up the brush and put the brush, this may be the painting professional students first to learn? Of course, how to choose and delete GDI draw objects more broadly. After creating a GDI object handle (NewBrush, NewPen, etc. in the previous example), in order to use them, we must use the SelectObjectH API function to select them into the appropriate device scenario. A device scene at a moment, only one object in each type, such as a brush and a bitmap, etc. The usage of the SelectObjecth function is very simple, it is necessary to remember that after this is called, if the old object handle will be returned. You need to save it. Of course, this process only needs to attach the return value to a LONG type variable. Such as :oldpen & = selectObject (Picture1.hdc, Newpen &)
What should I do next? Putting, this classmate said: drawing. How to draw it? No, no, don't worry, this problem, we stay in the next section to discuss, now you only need to remember, here you can draw some round, rectangular, add multilateral operation. So, what should I do after the drawing operation? The answer is: I should set the old drawing object to the device scene. Made as follows:
SelectObject Picture1.hdc, Oldpen &
In this way, the device scenario will be restored to the status of our previously drawing objects. Because we can't determine what kind of drawing objects will be used by other drawing functions. Therefore, put the original drawing object is a good policy. However, if you want to select another object for the device scene, this step can be left behind. Then there is no need to save the old object handle during this time, this is because the handle of the old object returned by the SelectObject function is the handle of our choice. The drawing is also finished, the equipment scene has also restored the original situation, then do you have an operation? No, there is a little. You'd better delete the GDI object you created yourself and release the resources you just used. The operation is as follows:
DeleteObject NewPen is actually in fact, you don't delete these object resources, it will be released automatically when the application exits. This is because in Win32, resources are privately available for each application. For this reason, it is also possible to share a GDI object between applications. However, deleting the GDI object you created is still a good program habit. Since you don't have to use it, why bother to take up resources? In addition, you have a tens of millions of remembiced, remember, don't delete the system GDI object that has been selected. Another point, the object returned by the getStockObject function is a system object. Please do not delete it with the deleteObject function, otherwise a very terrible thing will appear - your hard drive will never be used forever. @@ ~ Oh, scare you, actually not so serious. However, I think you are probably not known to know how bad, biased towards bad people? If so, just make better.
OK, the following shows the API function using the GDI object.
The function said that DeleteObject uses this function to delete GDI objects, such as brush, brush, font, bitmap, area, and palette, and more. All system resources used by objects are released Enumjects enumerations that can be used with a brush and brush GetCurrentObject that specifies the device scenario use to get the currently selected object GetObjectAPI of the specified type to obtain a structure for specified objects. The Windows Manual recommends using the name of getObject to reference the function. GetObjectApi is used to avoid confusion with getObjectType with getObjectType. These include bitmaps, brushes, fonts, brushes, and regions. There is only one object to select the device scene. The selected object is used in the drawing operation of the device scene. For example, the currently selected brush determines that the line segment color and style depicted in the device scenario is generally not very common in obtaining information about GDI objects from the system or specified device scenario in the device scenario. In this way, if we want to use a brush and a brush to do some drawings, the approximate step of writing code is like this. Dim NewPen As LongDim NewBrush As LongDim OldPen As LongDim OldBrush As LongNewPen & = CreatePen (PS_SOLID, 3, RGB (255, 0, 0)) * Create brush NewBrush & = CreateSolidBrush (vbRed) * Create brush OldPen & = SelectObject (Picture1.hDC, Newpen &) Add Drawing Operation Code
OldBrush & = SelectObject (Picture1.hDC, NewBrush) 'adding the filling operation codes SelectObject Picture1.hDC, OldPen & SelectObject Picture1.hDC, OldBrush & DeleteObject NewPen & DeleteObject NewBrush & note that, to use the API drawing functions, not necessarily create the Pen and Brush. You can use an existing GDI object to draw a function directly to draw. Remember, there is always a default brush and brush in the device scene, and the problem is that it does not meet your requirements. But I think it is a good habit of choosing a brush before drawing. Some VB functions can also be used. For example, if you want to use a red brush, you can set the forcolor property in red, want to widow the width of the brush, you can set the DrawWidth property.
Fourth, drawing properties and drawing functions
So far, we have learned everything you need to draw. The code given in the previous section describes this. In the code, only the specific drawing code is now missing. This section discusses questions about how to draw. Before contacting the drawing function, you first need to understand the drawing properties. The device scenario defines a series of drawing properties. These plot attributes define how the brush and brush interact with the current content of the window or device surface. For example, the location of the current brush, current background color, arc, and rectangular drawing direction, grating mode of operation, and the like. Although many attribute control functions are given later, it is easier to implement with VB itself and method properties. For example, set the background mode, as long as the Backcolor property of the control is set, it can be done happily. However, if you want to draw in a self-built device scene associated with the window, you must rely on these functions.
Line Grating Operation: We already know that the raster operation is a bit operation. Usually you want to draw a drawing with a brush, it is just a simple drawing to a display or device. In fact, Windows supports 16 different line drawing modes that define how a line is combined with an existing information on the display. These modes are called line grating operations (sometimes called ROP2 mode). And they are introduced as a drawing mode to VisualBasic. ROP2 raster operations are equivalent to setting VB's DrawMode properties. Background mode: shadow brush, dotted brush and text have a background. For shadow brush, it refers to the area between the shadow lines, for the dotted brush, the area between the point and the dashed line. For text, it refers to the background of each character unit. Background mode determines how Windows handles these background regions. It can be opaque or transparent. If it is opaque, the background area is set to the background color; otherwise, if it is transparent, the background area remains primitive. Current location: In VB, you have to draw a straight line. It is actually very simple. You can use the LINE method, and can be expressed in one statement. Such as Line (5, 5) - (10, 10) but is not simple in the API (but not too much trouble). To draw a straight line, you need to set the starting point of the straight line. The MoveToex function is generally used. Then draw straight lines in the next row, such as LINETO 10, 10. The MoveToex function is one of the frequent functions used to determine the starting position before the drawing. .
Drawing property control function
When the function explains the GetarcDirection arc, it is judged that the currently used drawing direction getBKColor gets the specified device scene. The current background color getBkmode is a specified device scene, get the current background fill mode getCurrentPositionEx gets the current brush in the specified device scene. Location GETMITERLIMIT acquires the slope limit of the device scene (MITER) Setting - slope limits refers to the ratio of the specific colors that are the most closest-colored GETPOLYFILLMODE for the designated color, which is the most closest-colored GetPolyFillMode, which is the most close to the specified color. , Get a polygon padding mode. Getrop2 acquires the current drawing mode for the specified device scenario. This can define how to make a plurality of images that are being displayed by MoveToex to specify a new current brush position for the specified device scenario. SetarcDirection Sets the Drawing Direction of Arc SetBKColor Sets the background color for the specified device scene. The background color is used to fill the voids in the shadow brush, a dashed brush, and characters (such as background mode Opaque). Also used during bitmap color conversion. SetBKMode Specifies a shadow brush, a dotted brush, and a fill of the void in the character setmiterlimit Set the current slope limit SetPolyFillMode Set the Polygonal fill mode. SetROP2 Sets the drawing mode of the specified device scene. It is exactly the same as the DrawMode property of the VB.
Compared with VisualBasic, the API provides a more powerful drawing function. The usage of most of the drawing functions is very simple, as long as it is used according to its instructions, it feels that there is no need to add more.
WINDOESAPI drawing function
Function explains Anglearc with a connection arc painting, refer to the annotation Arc painting an arc Arcto draws an arc, and updates the current position Canceldc to cancel the long-term drawing operation in another thread CHORD draw a string (elliptical) Line) Ellipse depicts an ellipse, surrounded by the designated rectangle. The ellipse is depicted with the currently selected brush, and fill the FillRect with the currently selected brush to populate a rectangular floodfill with the specified brush to populate a region in the specified device scene with the currently selected brush. The area is a border with a specified brush defined by color crcolor, which is a border (constitutes a frame), and the width of the border is a logical unit getPixel acquired a specified pixel in the specified device scenario. The current RGB value invertRect is inversion The value of each pixel, which reverses the rectangular LINEDDA specified in a device scenario to draw a sector PIE in the specified line segment draws a fan-shaped Polybezier to draw a or more Bezier curves. Polybezierto Pains a Baizier curve, and sets the current brush position to the final PolyDraw depicting a complex curve, composed of line segments and Baizier curves to depict a polygon, two points or Arbitrary series of three points. Windows will connect the last point to the first point to close the polygon. The polygonal border is depicted with the currently selected brush, and the polygon is populated with the currently selected brush Polyline to draw a series of line segments with the current brush. When using the POLYLINETO function, the current location is set to the end of the last line segment. It does not change POLYLINETO in the POLYLINE function, and sets two or more polygons to draw the current brush position. Depending on the polygon padding mode specified by the SetPolyFillMode function, populate them with the currently selected brushes. Each polygon must be a closed PolyPolygon with the currently selected brush to draw two or more polygons. Depending on the polygon padding mode specified by the SetPolyFillMode function, populate them with the currently selected brushes. Each polygon must be a closed polypolyline to draw two or more polygon Rectangle drawn rectangles with the currently selected brush, and draw a rounded corner with the currently selected brush with the currently selected brush. Rectangular, and filled with the currently selected brush.
X3 and Y3 define an elliptical setpixel for generating rounded elements set a pixel RGB value in the specified device scenario, and returns the color setpixelv of this point setpixelv to set a pixel in the specified device scenario I put the above table. Most of the functions of the function will give the Program1.vbp included in this tutorial. In addition, the Usage of the Bezier curve is more interesting. If you have used 3D Studio 3D animation software to know, many of which draw, especially two-dimensional planar drawings, is the use of Bezier curve technology. The Program3.vbp program included in this tutorial briefly shows the application of this technology. "Frontline" website source code resolution (filter presentation), No. 26 (how to fill in the irregular closure line frame area with a specified color), etc. .
Windows also offers some more special drawing functions that you can use them in Windows to draw controls, title bar, 3D controls, and desktop system objects.
Win32 API Other Drawing Functions
Function explains Drawedge Drawed with a specified style (including 3D effect) to send data directly to the display device driver (used in VB: can be used. But because Escape is available Strong dependence, so unrecognized, try not to use it) DrawFocusRect draws a focus rectangle. This rectangle is done in the style of the flag focus (focus usually represented by a point line). If this function is called again with the same parameters, it means that the delete focus rectangle DrawFrameControl is used to depict a standard control. For example, a frame DrawState that describes a button or scroll bar can be used for an image or drawing operation to apply a variety of effects Gdiflush pay attention to the queue before the drawing operation. Perform any unresolved drawing operation. Note GDIGETBATCHLIMIT judge how many GDI draw commands are located in the queue GDisetbatchlimit specifically how many GDI draw commands can enter the queue PaintDesktop in the specified device scenario depicts the desktop wallpaper pattern
There are several functions here, such as DrawEdge, DrawFrameControl. Use them to draw the appearance of the button control, edit box control, etc. very easily. I have included the usage of common functions to the combo program program2.vbp.
Five, path
It should be said that the path is a higher topic, although it is not difficult to understand. I learned the knowledge of the path from the Dan's "Visual Basic 5.0 Win32 Developer Guide" in the book, in other books, there is no yet. Worse is that there is no handle of the path, so it is not a member of the GDI object. However, I have to remember a little, and there is only one path in any device scene. From this point, even if the path is set, it is also redundant. From my feelings, the path is like a polygonal area of any shape drawn in a device scene (although it is not a region).
One advantage of my experience in the path is that after creating a path, you can convert it to the area. This can be done with the Pathtoregion function. Once this step is successful, it can be handled in the same area after getting the area handle. All in all, we can easily create complex graphics areas via path. Creating a path is very simple. The specific form is as follows: DL & = BeginPath & (out.hdc) (Draw) DL & = EndPath & (Out.hdc) Writing a code in the (drawing) location to draw what kind of path can be formed. However, not any plot functions can generate a path. The function that can be used to generate the path is listed below.
Function Windows NT Windows 95 AngleArc Yes No Arc Yes No ArcTo Yes No Chord Yes No Ellipse Yes No ExtTextOut Yes Yes LineTo Yes Yes MoveToEx Yes Yes Pie Yes No PolyBezier Yes Yes PolyBezierTo Yes Yes PolyDraw Yes No
Polygon YES YES POLY YES YES YES POLYLINETO YES YES POLYPOLYGON YES YES POLYPOLYLINE YES Rectangle Yes No RoundRect Yes No TextOut Yes Yes Yes Yes
After reading this table, I think the user of Windows95 may be a bit heartache: so many functions can not be used! Hey, I can't do it, I have to blame. The following is the API function about the path:
API path function
Function explains AbortPath to discard all paths in the specified device scenario. Create a job based on any path currently ongoing BeginPath launches a path branch. The GDI drawing command executed after this command will automatically become part of the path. The connection to the line segment will be combined. Any ready-made path in the device scenario is cleared. Referring to the table below, where the functions listed can be recorded to the path plosefigure to depict the currently open graphics (turning the current path segment to turkehed) Endpath stop defined a path. If the execution, the BeginPath function call, and all draw operations that occur between this function will be officially to specify any open graphics in the path of the specified device scene, and use the current brush to fill the FLATTENPATH to convert all the curves in a path into line segments. GetPath acquires a series of data defined for the current path to convert the currently selected path to a zone SelectClipPath combines the current path of the device scene to the StrokeAndFillPath in the clip area to turn off all the regions opened on the path to the specified device. . Use the current brush to draw a contour of the path, and use the current brush fill path strokepath to depict the contour of a path with the current brush. Opened graphics will not be closed by this function, it is not yet, it is very simple, please read the Program4.vbp demo, you will be shocked! Wow! This is the path?! Homework
A, make a brush and painting viewer.
Tip:
1 Create a picture box control, draw a rectangle with the current brush (using Rectangle, the mass inside will be automatically populated by the current brush). We must prepare to observe the current brush and the current brush.
2 Set 5 scroll bars to adjust the color of the brush, the width of the brush, the style of the brush (solid line, the dotted entity painting color, shadow drawing style. Creation of the brush can be created with the function cretepen, entity brush creation You can use a function createsolidbrush, and the creation of shadow brush can be used with functions Createhatchbrush. (The creation of the pattern brush is left in the next lesson, you can do it for the time being.)
Through the above ideas, when a scroll bar moves, the image in the picture frame changes accordingly, such as thickening, and dark color.
B, create a class module to mimic the most basic features of the Check control.
Tip:
1 The properties you need to add are Wight, Height, Value properties
2 There is a Click event that needs to be added. You can use the Timer control to make event sources.
3 The appearance of the control can be drawn with the DrawFrameControl function.
Really, I really can't think of a good example. If you have finished learning a bitmap. Please wait, the next period is a bitmap.