Solved

CRgn::CreateFromPath() works / works not

Posted on 1997-08-11
8
773 Views
Last Modified: 2013-11-19
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.
0
Comment
Question by:ericj040697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 

Author Comment

by:ericj040697
ID: 1303511
Edited text of question
0
 
LVL 4

Expert Comment

by:davmarc
ID: 1303512
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.
0
 

Author Comment

by:ericj040697
ID: 1303513
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
davmarc earned 300 total points
ID: 1303514
I understand your disappointment, but that's it.
KB article Q125697 "Primitives Supported by Paths Under Windows 95" clearly states that all other Win32 primitives are ignored if used in a path under Windows 95.
I don't think there is a good solution - Bezier curves might be used to fake other curves someway but it would be a really painful process.

I wonder why you rejected my previous answer.
After all, it is the correct response to your question about why your code works partially under Win95.

Davide Marcato.
0
 
LVL 4

Expert Comment

by:davmarc
ID: 1303515
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.
0
 

Author Comment

by:ericj040697
ID: 1303516
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
0
 
LVL 4

Expert Comment

by:davmarc
ID: 1303517
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.
0
 

Author Comment

by:ericj040697
ID: 1303518
Thanks, Davide, I'll got it.

Eric
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java ^ examples 8 75
Problem to event 3 123
unix example issues 18 114
how to use laptop or pad camera in vb.net windows application 2 131
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question