Jump to content
  • Advertisement
Sign in to follow this  
KittyRa

DirectDraw - SetCooperativeLevel( )

This topic is 4846 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 build my project everything is fine (0 errors, 0 warnings), but when I run it a message box comes up saying that SetCooperativeLevel() failed. Does anyone know why? Here's the code:
// create a directdraw7 object  
    if (FAILED(DirectDrawCreateEx(NULL, (void**)&lpdd, IID_IDirectDraw7, NULL)))
        return 0;
     
    // set display mode 
    if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0)))
    {
    // error 
    MessageBox(NULL, "Failed to Set Display Mode!",    
                 "Error -- lpdd->SetDisplayMode()",
                  MB_OK | MB_ICONEXCLAMATION);

    return 0;
    } // end if

	
    // set cooperative level to fullscreen 
    if (FAILED(lpdd->SetCooperativeLevel(main_window_handle, 
                                      DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE |DDSCL_ALLOWREBOOT)))
    {
    // error 
    MessageBox(NULL, "Failed to Set Cooperative Level!",
                 "Error -- lpdd->SetCooperativeLevel()",
                  MB_OK | MB_ICONEXCLAMATION);

    return 0;
    }

Share this post


Link to post
Share on other sites
Advertisement
SetCooperativeLevel must be called before SetDisplayMode.

If that doesn't solve your problem, please post the HRESULT returned when the API fails.

Share this post


Link to post
Share on other sites
That didn't really work but it did work when I took away the FAILED() macro and put it before SetDisplayMode() but I'm not sure if that's because now I'm not testing for failure.

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!