Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sfpiano

DInput and MFC?

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

When I try to initalise my dinput objects, I get this error: SetCooperativeLevel: window may not be a child window My program bails while I''m trying to set the coop level. I''ve tried every combination of foreground, background, exclusive and non-exclusive. I send in the hwnd after I create my window, so I don''t think that''s the problem. And everything else seems to be working fine directx-wise, so I''m pretty sure there''s some MFC complication.

Share this post


Link to post
Share on other sites
Advertisement
BLeH mfc = evil, once you get one setup always use it!

Anyway, if you can post your code that''d be cool, but its probably an improper call or type cast.

Make sure you''re not using SetParentWindow() where you shoudln''t be... sounds like that might be the problem?

Share this post


Link to post
Share on other sites

if(FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION,
IID_IDirectInput8, (void**)&pDI, NULL))){
return E_FAIL;
}
if(FAILED(pDI->CreateDevice(GUID_SysKeyboard,&pKeyboard,NULL))){
return E_FAIL;
}

if(FAILED(pKeyboard->SetDataFormat(&c_dfDIKeyboard))){
return E_FAIL;
}

if(FAILED(pKeyboard->SetCooperativeLevel(hWnd, DISCL_FOREGROUND |
DISCL_EXCLUSIVE))){
return E_FAIL;
}

pKeyboard->Acquire();

Share this post


Link to post
Share on other sites
Hi!

The error msg is clear: you can not initialize dinput for a child window. if you use doc/view arch, and this code you''ve posted belongs to a view, try

pKeyboard->SetCooperativeLevel(AfxGetApp()->GetMainWnd()->h_Wnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)

instead.

I''ve faced the same problem a few days ago (MDI doc/view with directx), that''s how i can solve it.

Regards:
-blemidon-

Share this post


Link to post
Share on other sites

  • 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!