老孙一定知道常用的画线算法(DDA)是怎么一回事, LineDDA是用用户的DDA来代替
GDI中的DDA来画某些特殊效果的线(我从来没用过).
从MSDN中查到一段例子, 贴到这里吧:
BOOL LineDDA(
int nXStart, // x-coordinate of line's starting point
int nYStart, // y-coordinate of line's starting point
int nXEnd, // x-coordinate of line's ending point
int nYEnd, // y-coordinate of line's ending point
LINEDDAPROC lpLineFunc, // pointer to callback function
LPARAM lpData // pointer to application-defined data);
The following code fragment draws 50 random Excel-style lines. Note
that the LineProc function must be listed as an EXPORT in the module
definition (DEF) file:
case WM_PAINT:
{
HDC hDC;
int nIndex;
PAINTSTRUCT ps;
hDC = BeginPaint(hWnd, &ps);
for (nIndex = 0; nIndex < 50; nIndex++)
LineDDA(rand() / 110, rand() / 110, rand() / 110,
rand() / 110, lpfnLineProc, (LPSTR)hDC);
EndPaint(hWnd, &ps);
break;
}
void FAR PASCAL LineProc(x, y, lpData)
short x, y; LPSTR lpData; {
static short nTemp = 0;
if (nTemp == 1)
SetPixel((HDC)lpData, x, y, 0L);
nTemp = (nTemp + 1) % 2;
}
从这个例子里面可以看出, lpData实际上是HDC.