Screen resolution

This is a discussion on Screen resolution within the Windows Programming forums, part of the Platform Specific Boards category; How can I stop an application launched with CreateProcess() from resizing my screen resolution to 640x480? Or how do I ...

  1. #1
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293

    Screen resolution

    How can I stop an application launched with CreateProcess() from resizing my screen resolution to 640x480? Or how do I resize it back quickly?

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    just have a program running in the background that checks any change in the current desktop dimensions, then if they change, set them back to the original settings that you wanted.

  3. #3
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    How do I set them back? The program that called CreateProcess() will still be running ...

  4. #4
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    Code:
     DEVMODE dmScreenSettings;		// Device Mode
     memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
     dmScreenSettings.dmSize=sizeof(dmScreenSettings);  // Size Of The Devmode Structure
     dmScreenSettings.dmPelsWidth = width;	// Selected Screen Width
     dmScreenSettings.dmPelsHeight = height;	// Selected Screen Height
     dmScreenSettings.dmBitsPerPel = bits;	 // Selected Bits Per Pixel
     dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
     // Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
     if(ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
     {
      char temp[1024];
      sprintf(temp,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?\n%dx%d",width,height);
      if(MessageBox(NULL,temp,"ERROR",MB_YESNO|MB_ICONEXCLAMATION)==IDNO)
      {
       MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
       return FALSE;
      }
     }
    from NeHe's OpenGL tutorials, should work perfectly fine. Just change width/height/bits to the settings you want.

    For testing if the resolution changes, you'll have to just set a timer to the program to check every half second or any amount of time to see if it changed. There's many ways of determining the desktop resolution, you should be able to find a way very easily (I don't have any code in my library for doing that, sorry)

  5. #5
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Well I can just use the GetSystemMetrics() to get the dimensions, just needed the actual code for changing resolution... cheers for that!

  6. #6
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Ok, well what I was trying didn't work.
    Here's the scenario -

    I just got a new laptop, it's widescreen. I want to play starcraft (like my favourite old time game) but it looks a little weird because it get's stretched out on the x-axis. I've tried just setting the resolution back but it doesn't really seem to work, I just get a black game window with nothing in it...

    It runs on direct x 5, is there perhaps a way I can hook any calls it'll make to set the screen resolution??

  7. #7
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    i believe what's happening is when you try to force it to change the screen resolution, it's losing focus to the drawing area for the game, and it causes it to not be able to render correctly anymore. I can't really think of any way to manipulate DirectX to force it to change resolutions while in another program and not lose focus to the ddraw stuff. Is there anything hardware related that you could change possibly?

  8. #8
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    I don't think so..

  9. #9
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    well, then i don't think there's any way to really fix it software-wise, unless you can make the game run in windowed mode, but I don't think you can do that with starcraft. Possibly someone else here knows a trick to get this working. Sorry I couldn't be too much help.

  10. #10
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    There has to be a way, I have another patch that does actually resize it into a window but the cursor easily moves out of the window and so you can't really scroll the view (like when you move to the top, you scroll up the map, down you scroll down etc ... if you haven't played it or any similar rts games before ) ..


    I don't think there are any command lines you can pass or config settings you can edit to make it run windowed ...

  11. #11
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    i can't remember, but doesn't starcraft have arrow key scrolling? So you could just use the arrow keys to scroll around. I'm not sure if that's in there or not though, I know it's in AOE and RoN....

  12. #12
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    I think I have come up with a new solution.. Just going to try it out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ubuntu screen resolution
    By lruc in forum Tech Board
    Replies: 13
    Last Post: 11-27-2008, 05:03 PM
  2. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 04:56 PM
  3. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM
  4. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 03:41 AM
  5. Screen Resolution
    By C_Coder in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 12-21-2001, 08:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21