|
|
我编写了以下一段代码:
IDirect3DSurface9* g_MouseCursor;
D3DXGetImageInfoFromFile(L"02.jpg", &ImageInfo);
hr = DirectDev.GetDirectDevice()->CreateOffscreenPlainSurface(ImageInfo.Width ,
ImageInfo.Height, ImageInfo.Format , D3DPOOL_DEFAULT, &g_MouseCursor,NULL);
if (FAILED(hr))
{
MessageBox(hWnd,_T("载入鼠标样式失败"),NULL,NULL);
return false;
}
hr = D3DXLoadSurfaceFromFile(g_MouseCursor, NULL, NULL, _T("02.jpg"),
NULL, D3DX_FILTER_NONE, 0xFF000000, NULL);
if (FAILED(hr))
{
MessageBox(hWnd,_T("载入鼠标样式失败"),NULL,NULL);
return false;
}
hr = DirectDev.GetDirectDevice()->SetCursorProperties(1,1, g_MouseCursor);
if (FAILED(hr))
{
MessageBox(hWnd,_T("设置鼠标样式失败"),NULL,NULL);
return false;
}
DirectDev.GetDirectDevice()->SetCursorPosition(0,0,D3DCURSOR_IMMEDIATE_UPDATE);
DirectDev.GetDirectDevice()->ShowCursor(true);
鼠标协调级别设置的是DISCL_BACKGROUND | DISCL_NONEXCLUSIVE
但是在运行时“DirectDev.GetDirectDevice()->SetCursorPosition(0,0,D3DCURSOR_IMMEDIATE_UPDATE);”总是返回错误。
这是怎么回事?
谢谢! |
|