使用HFONT对象设置控件字体后是否可以直接删除?
Can I delete an HFONT object directly after using it to set the font of a control?
我正在这样设置 "BUTTON"
控件的字体:
HFONT hFont = CreateFont(16, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma");
SendMessage(hButton1, WM_SETFONT, (WPARAM)hFont, TRUE);
调用SendMessage()
后可以直接删除hFont
,还是需要先销毁hButton1
?
来自MSDN:
The application should call the DeleteObject
function to delete the font when it is no longer needed; for example, after it destroys the control.
所以你应该先销毁你的控件。
我正在这样设置 "BUTTON"
控件的字体:
HFONT hFont = CreateFont(16, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma");
SendMessage(hButton1, WM_SETFONT, (WPARAM)hFont, TRUE);
调用SendMessage()
后可以直接删除hFont
,还是需要先销毁hButton1
?
来自MSDN:
The application should call the
DeleteObject
function to delete the font when it is no longer needed; for example, after it destroys the control.
所以你应该先销毁你的控件。