ericj040697
asked on
CRgn::CreateFromPath() works / works not
I am using CreateFromPath() to create regions for graphical objects like lines, rectangles, circles, ellipses and arcs. The function works fine under NT3.51 but not under Windows 95. I am using VC4.2.
The parameters are:
pVu, a pointer to the View
m_Rect, a CRect object
m_Pt1, m_Pt2, two CPoint objects
Here is the code:
CPaintDC dc( pVu );
LOGBRUSH lb;
lb.lbStyle = BS_SOLID;
lb.lbColor = RGB( 0, 0, 0 );
CPen RgnPen( PS_GEOMETRIC | PS_SOLID , 10, &lb );
CPen* pOldPen = dc.SelectObject( &RgnPen );
dc.BeginPath();
dc.Arc( m_Rect, m_Pt1, m_Pt2 );
dc.EndPath();
dc.WidenPath();
m_pRgn->CreateFromPath( &dc );
ASSERT( m_pRgn->m_hObject );
dc.SelectObject( pOldPen );
I have the same problem with
dc.BeginPath();
dc.Ellipse( m_Rect );
dc.EndPath();
while
dc.BeginPath();
dc.MoveTo ...
dc.LineTo ...
dc.EndPath();
works fine under both operating systems.
The parameters are:
pVu, a pointer to the View
m_Rect, a CRect object
m_Pt1, m_Pt2, two CPoint objects
Here is the code:
CPaintDC dc( pVu );
LOGBRUSH lb;
lb.lbStyle = BS_SOLID;
lb.lbColor = RGB( 0, 0, 0 );
CPen RgnPen( PS_GEOMETRIC | PS_SOLID , 10, &lb );
CPen* pOldPen = dc.SelectObject( &RgnPen );
dc.BeginPath();
dc.Arc( m_Rect, m_Pt1, m_Pt2 );
dc.EndPath();
dc.WidenPath();
m_pRgn->CreateFromPath( &dc );
ASSERT( m_pRgn->m_hObject );
dc.SelectObject( pOldPen );
I have the same problem with
dc.BeginPath();
dc.Ellipse( m_Rect );
dc.EndPath();
while
dc.BeginPath();
dc.MoveTo ...
dc.LineTo ...
dc.EndPath();
works fine under both operating systems.
The problem is that Windows 95 has a very limimted support for paths. It can record only the following functions:
CloseFigure(), ExtTextOut(), LineTo(), MoveToEx(), PolyBezier(), PolyBezierTo(), Polygon(), Polyline(), PolylineTo(), PolyPolygon(), PolyPolyline(), and TextOut().
Windows NT suptrs more GDI functions instead (e.g. arcs).
By the way, while working with paths in Windows 95 be always careful because Win95 is able to treat only 16 bit coordinates.
Davide Marcato.
CloseFigure(), ExtTextOut(), LineTo(), MoveToEx(), PolyBezier(), PolyBezierTo(), Polygon(), Polyline(), PolylineTo(), PolyPolygon(), PolyPolyline(), and TextOut().
Windows NT suptrs more GDI functions instead (e.g. arcs).
By the way, while working with paths in Windows 95 be always careful because Win95 is able to treat only 16 bit coordinates.
Davide Marcato.
ASKER
Davide:
I am disappointed. What shall I do? I have arcs, ellipses and circles. I might be able to make the thing work for ellipses/circles by using the rectangle, but arcs... The arc can be very small compared to the bounding rectangle. There must be a better solution. Do you know of any?
Eric
I am disappointed. What shall I do? I have arcs, ellipses and circles. I might be able to make the thing work for ellipses/circles by using the rectangle, but arcs... The arc can be very small compared to the bounding rectangle. There must be a better solution. Do you know of any?
Eric
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have some good news that might help you.
Give a look at KB article Q125693 "SAMPLE: AngleArc in Windows 3.1, Win32s, and Windows 95". It provides the source code of a function to draw "anglearcs" using only LineTo() as primitive GDI call, hence you should be able to use it in paths too.
Davide Marcato.
Give a look at KB article Q125693 "SAMPLE: AngleArc in Windows 3.1, Win32s, and Windows 95". It provides the source code of a function to draw "anglearcs" using only LineTo() as primitive GDI call, hence you should be able to use it in paths too.
Davide Marcato.
ASKER
Davide:
Thanks for helping! I looked at the article. I don't understand this:
Under MORE INFORMATION, 2nd paragraph, the second sentence reeds:
"While both of these methods will work on any Windows platform, the second (AngleArc2) will be substantially faster due to the fact that it uses the Arc() function..."
How can they use the Arc() function, if it doesn't work?
Eric
Thanks for helping! I looked at the article. I don't understand this:
Under MORE INFORMATION, 2nd paragraph, the second sentence reeds:
"While both of these methods will work on any Windows platform, the second (AngleArc2) will be substantially faster due to the fact that it uses the Arc() function..."
How can they use the Arc() function, if it doesn't work?
Eric
They are speaking in general, not specifically abou paths.
Arc() does work correclty under Windows 95, it just cannot be used when defining paths.
Hence you should try AngleArc1() that calls LineTo().
Davide Marcato.
Arc() does work correclty under Windows 95, it just cannot be used when defining paths.
Hence you should try AngleArc1() that calls LineTo().
Davide Marcato.
ASKER
Thanks, Davide, I'll got it.
Eric
Eric
ASKER