So as I understand it to implement RAII properly, if I where to call CreateFont
, I'd wrap that in a class with CreateFont
in the constructor and DeleteObject
in the destructor, so it cleans it up when it goes out of scope.
First question is, won't I end up with ALOT of classes doing that? Especially since the class only has a constructor and destructor.
Second question is, what if I'm calling the CreateFont class in the WndProc, that goes out of scope constantly. So am I supposed to do all my calls to CreateFont
or like LoadBitmap
in the WndMain?
I'm used to calling those functions in WM_CREATE
and cleaning them up in WM_DESTROY
.
Window
,Device
,Painter
,Font
,Bitmap
, ... classes. It follows the one class, one responsibility principle. You end up with lots of easy to use classes. – Matelda