mirror of
https://github.com/reactos/reactos.git
synced 2024-09-09 20:30:04 +00:00
FIX:memory leak - font objects got create for every WM_PAINT message and never deleted
svn path=/trunk/; revision=3591
This commit is contained in:
parent
c6002facd3
commit
a98d50ca9b
|
@ -1,6 +1,7 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HFONT tf;
|
||||
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int WINAPI
|
||||
|
@ -48,6 +49,10 @@ WinMain(HINSTANCE hInstance,
|
|||
return(1);
|
||||
}
|
||||
|
||||
/*tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");*/
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
|
@ -56,6 +61,8 @@ WinMain(HINSTANCE hInstance,
|
|||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
/*DeleteObject(tf);*/
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
|
@ -63,18 +70,16 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
HFONT tf;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
SelectObject(hDC, tf);
|
||||
tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||
SelectObject(hDC, tf);
|
||||
TextOut(hDC, 10, 10, "Hello World from ReactOS!",
|
||||
strlen("Hello World from ReactOS!"));
|
||||
TextOut(hDC, 10, 10, "Hello World from ReactOS!", strlen("Hello World from ReactOS!"));
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
|
||||
|
@ -85,6 +90,5 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
default:
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue