Just for the record: it's perfectly fine and safe to do that. They will be kept alive as long as they are selected and will be deleted, once a different object is selected or the DC is deleted.
Am 12.04.2015 um 18:29 schrieb cwittich@svn.reactos.org:
Author: cwittich Date: Sun Apr 12 16:29:36 2015 New Revision: 67177
URL: http://svn.reactos.org/svn/reactos?rev=67177&view=rev Log: [SNDREC32] do not delete objects which are still selected into a DC
Modified: trunk/reactos/base/applications/sndrec32/sndrec32.cpp
Modified: trunk/reactos/base/applications/sndrec32/sndrec32.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sndrec32/... ============================================================================== --- trunk/reactos/base/applications/sndrec32/sndrec32.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/sndrec32/sndrec32.cpp [iso-8859-1] Sun Apr 12 16:29:36 2015 @@ -352,6 +352,7 @@ PAINTSTRUCT ps; HDC hdc; HPEN pen;
HPEN oldpen;
unsigned int max_h = (cli.bottom / 2); unsigned int samples;
@@ -366,7 +367,7 @@ /* Initialize hdc objects */ hdc = BeginPaint(hWnd, &ps); pen = (HPEN)CreatePen(PS_SOLID, 1, WAVEBAR_COLOR);
SelectObject(hdc, (HBRUSH)pen);
oldpen = (HPEN) SelectObject(hdc, (HBRUSH)pen); if (AUD_OUT->current_status() == snd::WAVEOUT_PLAYING) { samples = AUD_OUT->tot_samples_buf();@@ -412,6 +413,7 @@ LineTo(hdc, WAVEBAR_CX, cli.bottom / 2); }
SelectObject(hdc, oldpen); DeleteObject( pen ); EndPaint( hWnd, &ps ); break;@@ -437,6 +439,7 @@ PAINTSTRUCT ps; HDC hdc; HFONT font;
HFONT oldfont; long long slid_samp = 0;
/* Checking for global pointers to buffer and io audio devices */
@@ -774,7 +777,7 @@ case WM_PAINT: hdc = BeginPaint(hWnd, &ps); font = CreateFontIndirect(&s_info.lfMenuFont);
SelectObject(hdc, font);
oldfont = (HFONT) SelectObject(hdc, font); SetBkMode(hdc, TRANSPARENT); if (AUD_IN->current_status() == snd::WAVEIN_RECORDING)@@ -877,6 +880,7 @@ _tcslen(str_tmp), 0);
SelectObject(hdc, oldfont); DeleteObject(font); EndPaint(hWnd, &ps); break;