Fijate si el siguiente código te sirve (no es mio, yo hice uno pero más complejo
y en Builder C++)
Arrow.cpp
//--------------------------------------------------------------
/*
ARROWSTRUCT a;
// setup arrows
a.nWidth = 10;
a.fTheta = 30.0f;
a.bFill = true;
MoveTo(100, 100);
ArrowTo(m_hDC, 200, 100, &a);
*/
#include "Arrow.h"
#include <math.h>
//-----------------------------------------------------------------------
void ArrowTo(HDC hDC, int x, int y, ARROWSTRUCT *pA)
{
POINT ptTo = {x, y};
ArrowTo(hDC, &ptTo, pA);
}
//-----------------------------------------------------------------------
void ArrowTo(HDC hDC, const POINT *lpTo, ARROWSTRUCT *pA)
{
POINT pFrom, pBase, aptPoly[3];
float vecLine[2], vecLeft[2], fLength, th, ta;
MoveToEx(hDC, 0, 0, &pFrom);
aptPoly[0].x = lpTo->x;
aptPoly[0].y = lpTo->y;
vecLine[0] = (float) aptPoly[0].x - pFrom.x;
vecLine[1] = (float) aptPoly[0].y - pFrom.y;
vecLeft[0] = -vecLine[1];
vecLeft[1] = vecLine[0];
fLength = (float) sqrt(vecLine[0] * vecLine[0] + vecLine[1] * vecLine[1]);
th = pA->nWidth / (2.0f * fLength);
ta = pA->nWidth / (2.0f * (tanl(pA->fTheta*57.29578) / 2.0f) * fLength);
pBase.x = (int) (aptPoly[0].x + -ta * vecLine[0]);
pBase.y = (int) (aptPoly[0].y + -ta * vecLine[1]);
aptPoly[1].x = (int) (pBase.x + th * vecLeft[0]);
aptPoly[1].y = (int) (pBase.y + th * vecLeft[1]);
aptPoly[2].x = (int) (pBase.x + -th * vecLeft[0]);
aptPoly[2].y = (int) (pBase.y + -th * vecLeft[1]);
MoveToEx(hDC, pFrom.x, pFrom.y, NULL);
if(pA->bFill){
LineTo(hDC, aptPoly[0].x, aptPoly[0].y);
Polygon(hDC, aptPoly, 3);
}
else {
LineTo(hDC, pBase.x, pBase.y);
LineTo(hDC, aptPoly[1].x, aptPoly[1].y);
LineTo(hDC, aptPoly[0].x, aptPoly[0].y);
LineTo(hDC, aptPoly[2].x, aptPoly[2].y);
LineTo(hDC, pBase.x, pBase.y);
MoveToEx(hDC, aptPoly[0].x, aptPoly[0].y, NULL);
}
}
//---------------------------------------------------------------------------------------------------
Arrow.h
#ifndef _ARROW_H_
#define _ARROW_H_
#include <windows.h>
// ARROWSTRUCT
//
// Defines the attributes of an arrow.
typedef struct tARROWSTRUCT {
int nWidth; // width (in pixels) of the full base of the arrowhead
float fTheta; // angle (in radians) at the arrow tip between the two
// sides of the arrowhead
bool bFill; // flag indicating whether or not the arrowhead should be
// filled
} ARROWSTRUCT;
// ArrowTo()
//
// Draws an arrow, using the current pen and brush, from the current position
// to the passed point using the attributes defined in the ARROWSTRUCT.
void ArrowTo(HDC hDC, int x, int y, ARROWSTRUCT *pArrow);
void ArrowTo(HDC hDC, const POINT *lpTo, ARROWSTRUCT *pArrow);
#endif
Saludos desde Baires, JuanC