Just to make sure - is the following ok? (in WM_PAINT)
Reason for asking: many samples uses return value of BeginPaint in
separate LONG variable, hDC = BeginPaint, but ps.hDC is the same. Must
be possible to use that one directly and save 4 bytes, in other words?
Also, many samples uses separate variables to hold old pens and brushes,
but SelectObject returns previously selected, so that should not be
needed? More bytes to save there. Above sample shows no leaks and works
fine for me, but since its GDI mystery stuff, I feel I have to ask..
------------------
Code:
LOCAL ps AS PaintStruct, hBrush AS LONG, hPen AS LONG CALL BeginPaint(hWnd, ps) hBrush = CreateSolidBrush(colorBrush) 'hBrush is new brush hPen = CreatePen(style, width, colorPen) 'same with pen hBrush = SelectObject(ps.hDC, hBrush) 'select new brush - original brush is returned to hBrush hPen = SelectObject(ps.hDC, hPen) 'Draw something hBrush = SelectObject(ps.hDC, hBrush) 'select original back - new brush is returned to hBrush hPen = SelectObject(ps.hDC, hPen) 'same with pen DeleteObject hBrush 'now we can delete the new objects DeleteObject hPen EndPaint hWnd, ps
separate LONG variable, hDC = BeginPaint, but ps.hDC is the same. Must
be possible to use that one directly and save 4 bytes, in other words?
Also, many samples uses separate variables to hold old pens and brushes,
but SelectObject returns previously selected, so that should not be
needed? More bytes to save there. Above sample shows no leaks and works
fine for me, but since its GDI mystery stuff, I feel I have to ask..

------------------
Comment