CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: EMF and GetPath

  1. #1
    Join Date
    Sep 1999
    Location
    USA
    Posts
    178

    EMF and GetPath

    I have a question regarding Playing back emf files and using the GetPath function after the playback is completed.

    What I would like to do is capture the paths that the PlayMetaFile function writes to the screen. However when I run the code below, instead of returning the number of points that were drawn, GetPath returns -1.

    According to MSDN, -1 is returned by GetPath when you supply a 3rd parameter to GetPath which is less than the number of points in the path.
    However if you pass in a 0 (as in my case), it should return the number of points that the path contains. Below is the code I am using. Does anyone know what I may be doing wrong?

    [this code is executed in the OnDraw event handler)

    Code:
    CDerivativesViewDoc* pDoc = (CDerivativesViewDoc*)this->GetDocument();
    RECT rcRect;
    GetClientRect(&rcRect);
    HENHMETAFILE meta_file = pDoc->GetMetaFile();
    pDC->BeginPath();
    pDC->PlayMetaFile(meta_file,&rcRect);
    pDC->EndPath();
    
    //the function below always returns a -1 !!!!!!!
    int nPoints = pDC->GetPath(NULL,NULL,0);
    if(nPoints > 0)
    {
         //do somethign else
    }

  2. #2
    Join Date
    Jun 2005
    Posts
    1,255

    Re: EMF and GetPath

    I suppose that the problem comes from:

    pDC->PlayMetaFile(meta_file,&rcRect);

    This line places your metafile into the display context.
    Is your metafile put at the same time in your path?

    I have not checked with a program, but in my old MS help file, I read that the only functions that can be used to put points in a path are:

    AngleArc LineTo Polyline
    Arc MoveToEx PolylineTo
    ArcTo Pie PolyPolygon
    Chord PolyBezier PolyPolyline
    CloseFigure PolyBezierTo Rectangle
    Ellipse PolyDraw RoundRect
    ExtTextOut Polygon TextOut

    So maybe a simple test would be to replace PlayMetafile by a LineTo and see if you get a number with GetPath.

  3. #3
    Join Date
    Sep 1999
    Location
    USA
    Posts
    178

    Re: EMF and GetPath

    I have previously performed the test using LineTo and yes I was able to receive a correct number of points from there.

    I had a feeling that EMF may not generate a path but I wasn't sure and thought that since I was getting a -1 from GetPath(), that I was doing something wrong.

    Is there another way to retrieve the points from an EMF file?

    I know you can Enumerate the records in an EMF but I seem to get extremely large coordinates which are way outside the valid range of my View.

    Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured