Jump to content
  • Advertisement
Sign in to follow this  
winston123

how to get keyboard/mouse input priority from MFC win32 message?

This topic is 4066 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

how to get keyboard/mouse input priority from MFC win32 message? I established a MFC program with Dialog model. then create direct3d device, with this main dialog to show direct3d graphics, the project works fine. now I want to import the directinput mechanics to replace the win32 keyboard/mouse response function. this is my directinput code snippet:
Quote:
if(FAILED(DirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&g_pIDirectInput,NULL))){ MessageBox(NULL,"failed to create IDIRECTINPUT8 interface.","warning",MB_OK|MB_ICONINFORMATION); return false; } if(FAILED(g_pIDirectInput->CreateDevice(GUID_SysKeyboard,&m_pKeyboardDevice,NULL))){ MessageBox(NULL,"failed to create input device.","warning",MB_OK|MB_ICONINFORMATION); InputRelease(); return false; } if(FAILED(m_pKeyboardDevice->SetDataFormat(&c_dfDIKeyboard))){ MessageBox(NULL,"failed to set data format for keyboard.","warning",MB_OK|MB_ICONINFORMATION); InputRelease(); return false; } if(FAILED(m_pKeyboardDevice->SetCooperativeLevel(hWnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE))){ MessageBox(NULL,"failed to set keyboard cooperativelevel.","warning",MB_OK|MB_ICONINFORMATION); InputRelease(); return false; } HRESULT RT=m_pKeyboardDevice->Acquire(); if(FAILED(RT)) { if(RT== DIERR_INVALIDPARAM) MessageBox(NULL,"failed to acquare keyboard access right, invalid parameters.","warning",MB_OK|MB_ICONINFORMATION); else if(RT==DIERR_NOTINITIALIZED) MessageBox(NULL,"failed to acquare keyboard access right,no intialization.","warning",MB_OK|MB_ICONINFORMATION); else if(RT==DIERR_OTHERAPPHASPRIO) MessageBox(NULL,"failed to acquare keyboard access right,other application has priority.","warning",MB_OK|MB_ICONINFORMATION); InputRelease(); return false; }
I put the code above into Mydialog::InitDialog(), get
Quote:
failed to acquare keyboard access right,other application has priority.
I realized maybe the code should not put there,since it says the window message (MFC) already got the keyboard access right. then where should I put it? even i change the parameter to Execlusive right, it get the same result SetCooperativeLevel(hWnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE) anybody familiar with MFC? could you give me some hint? thanks a lot. winston.

Share this post


Link to post
Share on other sites
Advertisement
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!