Jump to content
  • Advertisement
Sign in to follow this  

MFC project with DirectInput

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I create a MFC project in VS2008. And I want to use DirectInput in this project. But I met a problem of Unepected error encountered when I SetCooperativeLevel in keyboard and mouse. Can MFC project use the DirectInput? I should use what value of SetCooperativeLevel for keyboard and mouse.
void DirectInput::DirectInputInit(HINSTANCE AppInstance,HWND hWnd)
	ZeroMemory(mKeyboardState, sizeof(mKeyboardState));
	ZeroMemory(&mMouseState, sizeof(mMouseState));

	HR(DirectInput8Create(AfxGetInstanceHandle(), DIRECTINPUT_VERSION, 
		IID_IDirectInput8, (void**)&mDInput, 0));

	HR(mDInput->CreateDevice(GUID_SysKeyboard, &mKeyboard, 0));
	HR(mKeyboard->SetCooperativeLevel(m_hWnd, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND));

	HR(mDInput->CreateDevice(GUID_SysMouse, &mMouse, 0));
	HR(mMouse->SetCooperativeLevel(m_hWnd, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND));
[Edited by - akira32 on July 29, 2008 2:32:52 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!