BOOL CMainWindow::OnEraseBkgnd (CDC* pDC)
{
CRect rect;
GetClientRect (&rect); CPalette* pOldPalette;
if ((HPALETTE) m_palette != NULL) {
pOldPalette = pDC->SelectPalette (&m_palette, FALSE);
pDC->RealizePalette ();
} DoGradientFill (pDC, &rect); if ((HPALETTE) m_palette != NULL)
pDC->SelectPalette (pOldPalette, FALSE);
return TRUE;
}(HPALETTE) m_palette != NULL
上面这种用法我觉得有点不适应,为什么能用一个HPALETTE来转换一个CPalette对象呢?HANDLE是不是一个标识?
还是一个HPALETTE Handler与它对应的类型有很大的关系,如这样:
#define CPalette HPALETTE或者这样struct {
HPALETTE Hpl;
// other member;
}CPalette;WINDEF.h 里面有这样一段代码:
typedef HINSTANCE HMODULE; /* HMODULEs can be used in place of HINSTANCEs */
#if !defined(_MAC) || !defined(GDI_INTERNAL)
DECLARE_HANDLE(HPALETTE);
DECLARE_HANDLE(HPEN);
#endif
关于以上问题,谁能帮我解释一下,谢谢!!!
以下是MSDN的描述:
Use this operator to get the attached Windows GDI handle of the CPalette object.operator HPALETTE( ) const;
Return Value
If successful, a handle to the Windows GDI object represented by the CPalette object; otherwise NULL.Res
This operator is a casting operator, which supports direct use of an HPALETTE object.For more information about using graphic objects, see the article Graphic Objects in the Platform SDK.
我是有用MSDN的,只是没有Ryanwen所查的程序那么细和准。我只是查到一个Handle.我想问一下你,你平时是怎样查的呢? 谢谢