词条 | LineDDA |
释义 | LineDDA The LineDDA function determines which pixels should be highlighted for a line defined by the specified starting and ending points. BOOL LineDDA( int nXStart, // x-coordinate of starting point int nYStart, // y-coordinate of starting point int nXEnd, // x-coordinate of ending point int nYEnd, // y-coordinate of ending point LINEDDAPROC lpLineFunc, // callback function LPARAM lpData // application-defined data ); Parameters nXStart [in] Specifies the x-coordinate, in logical units, of the line's starting point. nYStart [in] Specifies the y-coordinate, in logical units, of the line's starting point. nXEnd [in] Specifies the x-coordinate, in logical units, of the line's ending point. nYEnd [in] Specifies the y-coordinate, in logical units, of the line's ending point. lpLineFunc [in] Pointer to an application-defined callback function. For more information, see the LineDDAProc callback function. lpData [in] Pointer to the application-defined data. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Windows NT/2000/XP: To get extended error information, call GetLastError. Remarks The LineDDA function passes the coordinates for each point along the line, except for the line's ending point, to the application-defined callback function. In addition to passing the coordinates of a point, this function passes any existing application-defined data. The coordinates passed to the callback function match pixels on a video display only if the default transformations and mapping modes are used. Requirements Windows NT/2000/XP: Included in Windows NT 3.1 and later. Windows 95/98/Me: Included in Windows 95 and later. Header: Declared in Wingdi.h; include Windows.h. Library: Use Gdi32.lib. 如果在VC中实现比较简单的动画效果,也许很多人会选用Timer控件,其实API函数中有一个LineDDA,用这个函数实现简单的动画效果还是比较不错的。因为是API函数,所以很一般化,因此很多语言都可以用它来实现简单的动画。 该函数的原型如下: BOOL LineDDA(int nXStart, int nYStart, int nXEnd, int nYEnd, LINEDDAPROC lpLineFunc, LPARAM lpData); 参数说明如下: nXStart:起点的X值 nYStart:起点的Y值 nXEnd:终点的X值 nYEnd:终点的Y值 lpLineFunc:回调函数的地址 lpData:用户自定义参数(这个参数会传给回调函数) 这个函数和动画其实没什么关系,它的功能就是计算出连接两点的线段上的每一个屏幕像素的坐标,这两个点的坐标已经在函数的前四个参数中给出。每计算出一个坐标,该函数就会调用第五个参数所指的回调函数,我们可以在回调函数中完成一些简单的操作,以实现动画效果。 回调函数的原型是: VOID CALLBACK LineDDAProc(int X, int Y, LPARAM lpData); 前两个参数是点的坐标,第三个参数就是由LineDDA传过来的自定义参数,是由我们自己指定的,传什么都行。 :) LineDDA 函数在VB中的声明是: Public Declare Function LineDDA Lib "gdi32.dll" (ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal lpLineDDAProc As Long, ByVal lParam As Long) As Long 其回调用函数原型为: Public Sub LineDDAProc(ByVal X As Long, ByVal Y As Long, ByVal lpData As Long) |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。