GDI+

Hello,

I am a beginner in C++ and trying to learn the WIN32 API and GDI+ to make a simple drawing program like paint. So far i have learned how to make a window and how resources work i have created a custom cursor, horizontal menu and a toolbar menu.

Now i want to start and play with GDI+ to make my toolbar actually do something. I can draw a line by hardcoding it in te WM_PAINT part of the wndProc. It uses BeginPaint() and EndPaint().

Then i wanted to see if i could add a line when i pressed a button on the toolbar. I hardcoded it in the WM_COMMAND section of wndProc. In the first try i made a copy of the code that was in the WM_PAINT section changing only the coords of the line but this did not work. Then i used GetDc() and ReleaseDc(). This worked, the line was added to the drawing.

BUT: This second line disappears everytime something gets over it or the window is moved outside the screen.

- How to let drawings stay in the window? Do i need to create a backbuffer bitmap?
- Does BeginPaint() erase the whole drawing?

Am i missing something? Any help is really appreciated.
Last edited on
Hi kbw,

Thx for the reply. I have come across the website "http://www.winprog.org/". Thats where i have learned some basic things.

It is mostly win32 API related, not GDI+ related. Or do i have to learn more about win32 before i should begin with GDI+?
Last edited on
The website does have a section about GDI.
I just didn't saw it or thought it wont be able to answer my questions.

The information is really usefull and it does consern using a bitmap as a buffer.
I allready knew the concept of a back buffer because i have done little try outs with directX9 a while ago.

Thx for somehow pointing me to the right direction.
Last edited on
closed account (z05DSL3A)
One thing to note, do not get confussed between GDI and GDI+.
Topic archived. No new replies allowed.