Click here to Skip to main content
16,011,374 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: flash movies... Pin
pépé12-Aug-02 22:02
pépé12-Aug-02 22:02 
GeneralFreeing GDI Resources Pin
Stew11-Aug-02 5:47
Stew11-Aug-02 5:47 
GeneralRe: Freeing GDI Resources Pin
Chris Losinger11-Aug-02 6:22
professionalChris Losinger11-Aug-02 6:22 
GeneralRe: Freeing GDI Resources Pin
Stew11-Aug-02 14:32
Stew11-Aug-02 14:32 
GeneralRe: Freeing GDI Resources Pin
Chris Losinger11-Aug-02 14:33
professionalChris Losinger11-Aug-02 14:33 
GeneralRe: Freeing GDI Resources Pin
Stew11-Aug-02 14:42
Stew11-Aug-02 14:42 
GeneralRe: Freeing GDI Resources Pin
Chris Losinger11-Aug-02 14:44
professionalChris Losinger11-Aug-02 14:44 
GeneralRe: Freeing GDI Resources Pin
Stew11-Aug-02 14:53
Stew11-Aug-02 14:53 
Here is the Constructor:

CLine::CLine(CPoint Start, CPoint End, COLORREF aColor, int aWidth, int aStyle, int aType, int aRouteType)
{
m_StartPoint = Start;
m_EndPoint = End;
m_Color = aColor;
m_Width = aWidth;
m_Style = aStyle;
m_StartPointRect = (0,0,0,0);
m_EndPointRect = (0,0,0,0);
m_Type = aType;
m_RouteType = aRouteType;
m_StartPointRect = CRect(m_StartPoint.x-3, m_StartPoint.y-3, m_StartPoint.x+3, m_StartPoint.y+3);
m_EndPointRect = CRect(m_EndPoint.x-3, m_EndPoint.y-3, m_EndPoint.x+3, m_EndPoint.y+3);

TermRectRgnPts[0] = CPoint(m_EndPoint.x, m_EndPoint.y - RADIUS);
TermRectRgnPts[1] = CPoint(m_EndPoint.x + RADIUS, m_EndPoint.y);
TermRectRgnPts[2] = CPoint(m_EndPoint.x, m_EndPoint.y + RADIUS);
TermRectRgnPts[3] = CPoint(m_EndPoint.x - RADIUS, m_EndPoint.y);

m_RouteTermRect = CRect(m_EndPoint.x - RADIUS, m_EndPoint.y - RADIUS, m_EndPoint.x + RADIUS, m_EndPoint.y + RADIUS);

m_EnclosingRect = CRect(Start, End);
m_EnclosingRect.NormalizeRect();

m_StartPtScreenPct.XPercent = 0.0;
m_StartPtScreenPct.YPercent = 0.0;
m_EndPtScreenPct.XPercent = 0.0;
m_EndPtScreenPct.YPercent = 0.0;

}




Here is the Draw Function:

void CLine::Draw(CDC* pDC, int aStyle, int aWidth, CElement* pElement, int aRouteType)
{
//Create a pen and initialize it to the object color and line width of 1 pixel
CPen aPen;
COLORREF aColor = m_Color;

m_DC = pDC;

if(this == pElement)
{
aColor = SELECT_COLOR;
m_Style = aStyle;
m_Width = aWidth;
//m_Width = 0;
}
if(!aPen.CreatePen(PS_SOLID, m_Width, aColor))
{
// Pen creation failed. Abort the program
AfxMessageBox("Pen creation failed drawing a line", MB_OK);
AfxAbort();
}

unsigned Type1[4];
int c1 = GetPattern(Type1, true, m_Width, aStyle);

CPen *pOldPen;

SetPattern(Type1, c1);
{
// do drawing inside path for win95/8 compatibility
pDC->BeginPath();
MoveTo(m_StartPoint);
LineTo(m_EndPoint);
pDC->EndPath();

LOGBRUSH lbrush;
lbrush.lbStyle = BS_SOLID;
lbrush.lbColor = aColor;
CPen Pen(PS_GEOMETRIC | PS_SOLID |
(true ?
(PS_JOIN_ROUND | PS_ENDCAP_ROUND):
(PS_JOIN_MITER | PS_ENDCAP_FLAT) ) , m_Width, &lbrush);
pOldPen = m_DC->SelectObject(&Pen);
pDC->StrokePath();
pDC->SelectObject(pOldPen);
aPen.DeleteObject();

// make pen and stroke path
//DrawPathOutline(aColor);
}

pOldPen = pDC->SelectObject(&aPen);

/*pDC->MoveTo(m_StartPoint);
pDC->LineTo(m_EndPoint);*/

if (aRouteType != 0)
{
int Xv, Yv;
int Xp, Yp;
int C = 14;
double Xprime, Yprime;
CPoint PerpEndPoint, PerpStartPoint;

Xv = m_EndPoint.x - m_StartPoint.x;
Yv = m_EndPoint.y - m_StartPoint.y;

Xp = Yv;
Yp = (-1) * Xv;

Xprime = ( Xp / sqrt( Xp * Xp + Yp * Yp )) * C / 2;
Yprime = ( Yp / sqrt( Xp * Xp + Yp * Yp )) * C / 2;

PerpStartPoint.x = (long)(m_EndPoint.x + Xprime);
PerpStartPoint.y = (long)(m_EndPoint.y + Yprime);
PerpEndPoint.x = (long)(m_EndPoint.x - Xprime);
PerpEndPoint.y = (long)(m_EndPoint.y - Yprime);

if (aRouteType == ROUTE_TYPE_PASS)
{
CArray <cpoint, cpoint=""> ArrowPointArray;
CPoint ArrowPoint;
LPPOINT test;
tagPOINT *PerpStart, *PerpEnd, *Arrow;

ArrowPoint.x = (long)(((Xv / sqrt( Xv * Xv + Yv * Yv)) * C/2) + m_EndPoint.x);
ArrowPoint.y = (long)(((Yv / sqrt( Xv * Xv + Yv * Yv)) * C/2) + m_EndPoint.y);

ArrowPointArray.Add(PerpStartPoint);
ArrowPointArray.Add(PerpEndPoint);
ArrowPointArray.Add(ArrowPoint);

/* Draw the route terminator for blocking routes */
pDC->BeginPath();
pDC->MoveTo(PerpStartPoint);
pDC->LineTo(PerpEndPoint);
pDC->LineTo(ArrowPoint);
pDC->LineTo(PerpStartPoint);
pDC->EndPath();

}
else
{
/* Draw the route terminator for blocking routes */
pDC->BeginPath();
pDC->MoveTo(PerpStartPoint);
pDC->LineTo(PerpEndPoint);
pDC->EndPath();
}

// make pen and stroke path
DrawPathOutline(aColor);
}

pDC->SelectObject(pOldPen);
delete[] m_Pattern;
aPen.DeleteObject();
}
GeneralRe: Freeing GDI Resources Pin
Chris Losinger11-Aug-02 14:58
professionalChris Losinger11-Aug-02 14:58 
GeneralRe: Freeing GDI Resources Pin
Stew11-Aug-02 15:17
Stew11-Aug-02 15:17 
GeneralRe: Freeing GDI Resources Pin
Chris Losinger11-Aug-02 16:32
professionalChris Losinger11-Aug-02 16:32 
GeneralRe: Freeing GDI Resources Pin
Mustafa29-Jun-03 18:11
Mustafa29-Jun-03 18:11 
GeneralRe: Freeing GDI Resources Pin
cmk29-Jun-03 18:17
cmk29-Jun-03 18:17 
GeneralInternetworking with TCP/IP Vol. III Client-Server Programming and Applications-Windo Pin
smallcoder11-Aug-02 4:36
smallcoder11-Aug-02 4:36 
GeneralRe: Internetworking with TCP/IP Vol. III Client-Server Programming and Applications-Windo Pin
Ancient Dragon11-Aug-02 10:58
Ancient Dragon11-Aug-02 10:58 
GeneralRe: Internetworking with TCP/IP Vol. III Client-Server Programming and Applications-Windo Pin
cmk29-Jun-03 18:21
cmk29-Jun-03 18:21 
GeneralTSR kind... Pin
fdmanana11-Aug-02 4:12
fdmanana11-Aug-02 4:12 
GeneralRe: TSR kind... Pin
Chris Losinger11-Aug-02 5:03
professionalChris Losinger11-Aug-02 5:03 
GeneralGetWindowExt Pin
Space Ace11-Aug-02 4:00
Space Ace11-Aug-02 4:00 
GeneralRe: GetWindowExt Pin
Chris Losinger11-Aug-02 5:05
professionalChris Losinger11-Aug-02 5:05 
GeneralRe: GetWindowExt Pin
Space Ace11-Aug-02 8:13
Space Ace11-Aug-02 8:13 
GeneralRe: GetWindowExt Pin
Chris Losinger11-Aug-02 8:19
professionalChris Losinger11-Aug-02 8:19 
GeneralRe: GetWindowExt Pin
Space Ace11-Aug-02 10:42
Space Ace11-Aug-02 10:42 
Generalcrash when exiting with system menu Pin
nss11-Aug-02 3:03
nss11-Aug-02 3:03 
GeneralRe: crash when exiting with system menu Pin
Hans Ruck11-Aug-02 4:00
Hans Ruck11-Aug-02 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.