DirectInput SetCursorProperties出错

C/C++ code

HRESULT hres;
    hres = DirectInput8Create(GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID *)&lpDI, NULL);
    if(FAILED(hres))
        return FALSE;

    hres = lpDI->CreateDevice(GUID_SysMouse, &lpMouse,NULL);
    if(FAILED(hres))
        return FALSE;

    hres = lpMouse->SetDataFormat(&c_dfDIMouse);
    if(FAILED(hres))
        return FALSE;

    hres = lpMouse->SetCooperativeLevel(hWnd,DISCL_EXCLUSIVE | DISCL_FOREGROUND);
    if(FAILED(hres))
        return FALSE;

    hMouseEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    if(!hMouseEvent)
        return FALSE;

    hres = lpMouse->SetEventNotification(hMouseEvent);
    if(FAILED(hres))
        return FALSE;

    DIPROPDWORD dipdw;
    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
    dipdw.diph.dwObj = 0;
    dipdw.diph.dwHow = DIPH_DEVICE;
    dipdw.dwData = 16; // 预定义为16
    hres = lpMouse->SetProperty(DIPROP_BUFFERSIZE,&dipdw.diph);
    if(FAILED(hres))
        return FALSE;

    

    D3DXIMAGE_INFO imageInfo;
    hres=D3DXGetImageInfoFromFile("Resource\\Picture\\cursor.bmp",&imageInfo);

    if(FAILED(hres))
        return FALSE;

    D3DLOCKED_RECT dlr;


    hres = d3d::GetDevice()->CreateOffscreenPlainSurface(imageInfo.Width, imageInfo.Height,imageInfo.Format,D3DPOOL_DEFAULT,&lpDSCursor,NULL);

    if(FAILED(hres))
        return FALSE;
    hres =D3DXLoadSurfaceFromFile(lpDSCursor, NULL, NULL, "Resource\\Picture\\cursor.bmp", NULL, D3DX_FILTER_NONE, 0xFF000000, NULL);
    if(FAILED(hres))
        return FALSE;

    SetCursor( NULL );
    hres = d3d::GetDevice()->SetCursorProperties(0, 0, lpDSCursor);
    if(FAILED(hres))
        return FALSE;


    

    d3d::GetDevice()->ShowCursor(TRUE);
    
    lpMouse->Acquire();

    return TRUE;


hres = d3d::GetDevice()->SetCursorProperties(0, 0, lpDSCursor); 这一步就出错了 初学DX 所以搞几天都不明白错哪

作者: DeityCallMe   发布时间: 2011-06-16

来个人帮帮忙回答下啊...

作者: DeityCallMe   发布时间: 2011-06-16