CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2010
    Posts
    33

    Getting ideas for a graph

    I'm trying to figure out the easiest and best way to perform this task:

    I have two PGM (portable gray map) images and i need to put one above the other in a MFC window. Then I need to link them with lines and draw some circles in them.

    I thought of using a modal window and a picture box like a canvas (container). Then using DC (device context) to draw on it in the OnPaint event of the window. The PGM format has to be read, I think I cannot escape this manual duty..

    All of this sound a bit complicated and (possibly) messy.

    Someone has a better idea? I ask here before I start this job because I'm not an expert like most of you.

  2. #2
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: Getting ideas for a graph

    Well, you probably need to create an owner-drawn static control and do the drawing yourself. In there you need to create a memory device context (or DC) for the one provided by the OS and then use it to combine two of your PGM images. I'm not sure if GDI (or even GDI+) can support those. If so, I'll let someone else explain it. If not, and that's how I'd do it, I would read both PGM's into memory and then combine them. You can find stuff online on the PGM specification, like this one for instance. Then you will need to convert it into pixels visible by the DC. For that you may want to obtain a DIB Section to the memory DC you got earlier by using the CreateDIBSection and then write your combined PGM data into it directly. After that you will need to transfer the resulting data from a memory DC into the one provided for the static control using BitBlt() or maybe even StretchBlt() to enable stretching for different static control sizes.

  3. #3
    Join Date
    May 2010
    Posts
    33

    Re: Getting ideas for a graph

    Excepted for the CreateDIBSection the method is almost what I thought: thanks!

    I need to draw on the OnPaint event right?

  4. #4
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: Getting ideas for a graph

    No, you set the SS_OWNERDRAW flag and override WM_DRAWITEM notifications (or the MFC analog) for the static control.

  5. #5
    Join Date
    May 2010
    Posts
    33

    Re: Getting ideas for a graph

    Thank you, if I have more troubles I'll let you know

  6. #6
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: Getting ideas for a graph

    **

  7. #7
    Join Date
    Jul 2010
    Posts
    8

    Re: Getting ideas for a graph


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