Thread: My Paint Program - try it and rate it!

  1. #1
    Registered User actionbasti's Avatar
    Join Date
    Dec 2002
    Posts
    48

    My Paint Program - try it and rate it!

    Hi,

    OK, here is a new little program I wrote. I would like to get some feedback ... The purpose for this program was to learn!

    Its a Win32 application.. so you have to use that to compile it
    I also used MS Visual C++ 6.0 on WinXP Pro


    Code:
    The code is i a txt file... (for upload reasons.. so reaname it or paste it in your compiler)


  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    I wrote something very similar a while ago. If you want to fix that nasty screen-clearing "feature", just have all of your code write to a bitmap in memory and bitblt() that to your screen. I think that was how I fixed it, anyhow.

  3. #3
    Registered User actionbasti's Avatar
    Join Date
    Dec 2002
    Posts
    48

    ...

    Quote Originally Posted by -KEN-
    just have all of your code write to a bitmap in memory and bitblt() that to your screen

    Yes, this is my plan..., I had been thinking about how I could do that this morning ... that is a great way ... however this is going to be for version 2 or so, now I will advance to other things.. lol

    thanks for the tip ! I appreciate all input.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    You have a lot of GDI leaks.

    Any brush, font, bitmap or pen ect you create must be destroyed before you create another in its global variable. Currently you just over-write the last hPen ect. The memory allocated to this object is lost and will soon stop the PC being able to redraw.

    If you use SelectObject(), in most cases, you must select the object out before you can delete the object.
    That is ensure you return the hdc to exactly the way you 'got' it.

    hOriginalPen= SelectObject(hdc, hPen);
    //use
    SelectObject(hdc, hOriginalPen);
    DeleteObject(hPen);

    for the double buffering look at the CreateCompatible...() functions ie CreateCompatibleBitmap()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Nice!

    I wrote something like that in VB a long time ago. An idea I used was to use 3 scrollbars and 4 statics to make a custom color.

    One static combined the position of the 3 scrolls (ie in range 0 - 255) to make the final color and next to each scroll I had a static showing the individual components ...

  6. #6
    Registered User actionbasti's Avatar
    Join Date
    Dec 2002
    Posts
    48

    Lightbulb leaks

    Quote Originally Posted by novacain
    The memory allocated to this object is lost and will soon stop the PC being able to redraw.


    Yeah, I was wondering why the program did some wiered things with the graphics after a while of using it... I have the same problem with those memory leaks in a game that I wrote.

    Thanks for the tip on how to delete those objects... I appreciate all help soo much!

    Sebastian

Popular pages Recent additions subscribe to a feed