No it isn't.
If you do not restore the GDI objects you have modified with SelectObject, you may lead Windows to use the GDI object you leave in the DC in other programs, or in repainting your window later.
This can be a very bad thing.
Also, you will keep some system GDI resourse allocated decreasing Windows performance, if you do not restore them.
GDI.EXE memory is limited for GDI objects to 64 kb as far as I know.
s-)
Blessed is he who in the name of justice and good will, shepards the week through the valley of darkness...
thx, but U write there bout no creating that object in on draw method. What about on paint? I'm creating 24*60 rectangles, each with other brush, so I do
still after drawin about 20*60 more rectangles in other method, the window gets crazy, all my_setted(formated) fonts get lost, all my colors, etc.
system works, about 140MB of memory is used(normally without this prog 120), but when I want to do printScreen to clipboard and save this pic, it gives me a big memorry error with bitmap saving. but there's still 100mb of memory free and I hope, that NT does use whole memory, not like in dos... ;-(
OnPaint is same thing like OnDraw from this point of view.
Attention, this is not about the amount of memory that you have avaialble on your computer. it is about the memory alocated to GDI.EXE or gdi32.EXE (windows manager for DCs)
To see this memory used by the system open System or Resource Meter from the Programs->Accessories.
My only solution to this tipe of problem was to declare the brushes as members of the view. I didn't have problems than. Not only one bit was waisted. But the class readabily has fallen anyway.
Hope this help, s-)
Blessed is he who in the name of justice and good will, shepards the week through the valley of darkness...
thx.
2 more things, i didn't know about
1) when I use CDC dc(this);dc.whatever, it's ok, because dc is automatically destroyed on the end of the function. But when I do CDC *dc=GetDC();(that's the way I do it), I have to put ReleaseDC(dc);somewhere on the end of the function, and I didn't.
2)What about using CPaintDC in OnPaint method instead of normal CDC? I saw it in few progs, now I'm browsing msdn to get the difference between CDC and CPaintDC.
1. ReleaseDC - I do not know exactly the meaning of this function. However I use it too because that's what they say in MSDN.
In my opinion, I think that once you get a pointer to an existing DC with GetDC there wouldn't be no need for ReleaseDC. Any way if you want to see what is happening go with the debug on the line with ReleaseDC and "Step in".
2. CPaintDC is used for printing, CDC is used for screen operations. s-)
Blessed is he who in the name of justice and good will, shepards the week through the valley of darkness...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.