На главную

On-line справка по Win32 API

Написать письмо
БЕСПЛАТНАЯ ежедневная online лотерея! Выигрывай каждый день БЕСПЛАТНО!
Список всех статей A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z | Скачать Вниз

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.

void 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;



Пригласи друзей и счет твоего мобильника всегда будет положительным!
Предыдущая статья
 
Сайт Народ.Ру Интернет
Следующая статья
Пригласи друзей и счет твоего мобильника всегда будет положительным!

Чертеж Маркеров



Вы можете использовать линию функций, чтобы делать маркерами. Маркер является символом отцентрированным над точкой. Рисуя приложения использовать маркеры, чтобы определять отправные пункты, заканчивающие точки, и управляющие точки. Приложения Электронной таблицы используют маркеры, чтобы определять интересующим вопросам на диаграмме или графе.

В кодовом образце следующего, определенная прикладная функция Маркера создает маркер используя MoveToEx и функции LineTo. Эти функции делают двумя intersecting линии, 20 пикселей на длине, отцентрированной над координатами курсора.

недействительный Маркер(ДЛИННЫЙ x, ДЛИННЫЙ y, HWND hwnd)
{
hdc HDC;

hdc = GetDC(hwnd);
MoveToEx(hdc, (int) x - 10, (int) y, (LPPOINT) НЕДЕЙСТВИТЕЛЬНЫЙ);
LineTo(hdc, (int) x + 10, (int) y);
MoveToEx(hdc, (int) x, (int) y - 10, (LPPOINT) НЕДЕЙСТВИТЕЛЬНЫЙ);
LineTo(hdc, (int) x, (int) y + 10);
ReleaseDC(hwnd, hdc);
}


Окно хранит координаты курсора в параметре lParam сообщения WM_LBUTTONDOWN когда потребитель нажимает левую кнопку мыши. Следующее кода демонстрирует как приложение получает эти координаты, определяет лежат они в пределах своей области клиента и передают им в функцию Маркера, чтобы делать маркером.

/* Дуга-чертеж Линии- и переменные */

статический BOOL bCollectPoints;
статическая ТОЧКА ptMouseDown[32];
статический int индекс;
УКАЗЫВАЕТ ptTmp;
rc RECT;

случай WM_LBUTTONDOWN:


если (bCollectPoints && индекс < 32){

/* Создайте регион из клиента area. */

GetClientRect(hwnd, &rc);
hrgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);

ptTmp = MAKEPOINTS((ТОЧКИ ЗНАЧИТЕЛЬНО *) lParam);

ptMouseDown[index].x = (ДОЛГО (ДЛИНОЙ)) ptTmp.x;
ptMouseDown[index].y = (ДОЛГО (ДЛИНОЙ)) ptTmp.y;

/* Протестируйте удар на клиенте rectangle. */

если (PtInRegion(hrgn, ptMouseDown[index].x, ptMouseDown[index].y)) {

/* Если удар происходит, запишите мышь coords. */

Маркер(ptMouseDown[index].x, ptMouseDown[index].y, hwnd);
индекс++;
}

}
прерывание;



Вверх Version 1.3, Oct 26 2010 © 2007, 2010, mrhx Вверх
 mrhx software  Русский перевод OpenGL  Русский перевод Win32 API
 
Используются технологии uCoz