Thread: brought over from the c++ board... windows graphics help.

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    18

    brought over from the c++ board... windows graphics help.

    hey, i am working on a dialog based mfc app, and am starting to get into graphics for the first time. I have never used them, and can not find any good tutorials around. Here is what i have done so far and what i think i need to do.

    I have made a picture control, assigned it a member variable and all. I imagine i will have to somehow iniatiate a image object, assign it to the control, then i will have to draw it into the box. But how?

    And i am going to add a twist or 2 to it.

    The filename is going to come from an editbox elsewhere on the dialog. I can't imagine this will be hard to do, just open up a variable name, not a hard coded name, but it means the image will have to be somehow dynamic. Will this be different for me?

    And finally, i will be wanting to do more then bitmaps. JPegs and Gifs are all in my sights. I understand that by default, mfc only supports bitmaps, but have been looking around the net and found a good msdn article that claims to take all the trouble out of using different formats. However, again with my lack of graphics knowledge, i still feel lost.

    I am using c++ to do this (in case you did not know by now, ms vc6.0) . Any help anyone can give me would be GREAT. thanks again.

    cow
    cow

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    It's quite easy. I suggest you do the following:

    1) Use a static frame for the picture

    2) Derive a child class thusly:

    Code:
    class CImageWnd : public CStatic{
    public:
      // Constructors, destructor, copy constructor and assignment op
      // Remember, your assignment op should call the base version.
      // If you don't want copy or assignment, make them protected
      OnPaint();
      // OnPaint() is where you do the magic
    private:
      // Data members.
    };
    3) Create a member of the child class, and do this in the dialog's DoDataExchange:

    DDX_Control(pDX, IDC_NAME, m_name);

    4) Implement the child class' OnPaint. I usually start off with something that just fills the paint area blue. You can do what you like.

    5) I recommend using either MFC's CImage, or a good third party graphics library like http://www.paintlib.de/paintlib/ . Paintlib has more power, and it's got a pretty decent interface.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  2. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  3. How to make graphics (windows)
    By Anauj in forum C Programming
    Replies: 2
    Last Post: 03-16-2003, 02:04 PM
  4. Windows Graphics
    By Neandrake in forum Windows Programming
    Replies: 3
    Last Post: 01-16-2002, 05:25 PM