Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DirectInput Fatal Error call from a small framework, compiles fine

1 view
Skip to first unread message

zyrolasting

unread,
Sep 23, 2008, 5:26:10 PM9/23/08
to
DirectX9.0c August
Visual Studio 2008
Windows Vista

I am using a DirectInput framework that I downloaded to study.
Everything in it works correctly except for the following function.

POINT DirectInput::DIMouseHandler(void)
{
POINT p;

HRESULT hr;
//Clear out the mouse structure
memset(&m_diMouseState, 0, sizeof(m_diMouseState));

//Get the scoop from the mouse
if(FAILED(hr = m_diMouse->GetDeviceState(sizeof(m_diMouseState),(LPVOID)
&m_diMouseState)))
{
//Maintain control of mouse
if(hr == DIERR_INPUTLOST)
m_diMouse->Acquire();
}

p.x = m_diMouseState.lX;
p.y = m_diMouseState.lY;

return p;
}

Everything runs fine to it's call, and the compiler never complains.
However, when I start the app Vista immediately tells me the program hit a
fatal error.

This is how I try to use it.

POINT mousePos = g_pDI->DIMouseHandler();
OR
POINT mousePos = (g_pDI->DIMouseHandler());

//Attempt to use mousePos.x and mousPos.y

Commenting that call makes the program run smoothly again, (minus the mouse
of course)
I'm a novice, so I'm out of ideas. What did I miss?

Phil Taylor[MS]

unread,
Sep 24, 2008, 5:19:37 PM9/24/08
to
where is m_diMouse initialized?

where is g_pDI initialized?

what does the debugger show when you examine these variables at runtime by
stepping into the program?

"zyrolasting" <zyrol...@discussions.microsoft.com> wrote in message
news:B3B1063C-9D63-4847...@microsoft.com...

0 new messages