Drawing Markers

You can use the line functions to draw markers. A marker is a symbol centered over a point. Drawing applications use markers to designate starting points, ending points, and control points. Spreadsheet applications use markers to designate points of interest on a chart or graph.

In the following code sample, the application-defined Marker function creates a marker by using the MoveToEx and LineTo functions. These functions draw two intersecting lines, 20 pixels in length, centered over the cursor coordinates.

  • oid Marker(LONG x, LONG y, HWND hwnd)

{

HDC hdc;

hdc = GetDC(hwnd);

MoveToEx(hdc, (int) x - 10, (int) y, (LPPOINT) NULL);

LineTo(hdc, (int) x + 10, (int) y);

MoveToEx(hdc, (int) x, (int) y - 10, (LPPOINT) NULL);

LineTo(hdc, (int) x, (int) y + 10);

ReleaseDC(hwnd, hdc);

}

Windows stores the coordinates of the cursor in the lParam parameter of the WM_LBUTTONDOWN message when the user presses the left mouse button. The following code demonstrates how an application gets these coordinates, determines whether they lie within its client area, and passes them to the Marker function to draw the marker.

/* Line- and arc-drawing variables */

static BOOL bCollectPoints;

static POINT ptMouseDown[32];

static int index;

POINTS ptTmp;

RECT rc;

case WM_LBUTTONDOWN:

if (bCollectPoints && index < 32){

/* Create the region from the client area. */

GetClientRect(hwnd, &rc);

hrgn = CreateRectRgn(rc.left, rc.top,

rc.right, rc.bottom);

ptTmp = MAKEPOINTS((POINTS FAR *) lParam);

ptMouseDown[index].x = (LONG) ptTmp.x;

ptMouseDown[index].y = (LONG) ptTmp.y;

/* Test for a hit in the client rectangle. */

if (PtInRegion(hrgn, ptMouseDown[index].x,

ptMouseDown[index].y)) {

/* If a hit occurs, record the mouse coords. */

Marker(ptMouseDown[index].x, ptMouseDown[index].y,

hwnd);

index++;

}

}

break;

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database