Thread: Rotating Screen Probably Simple Fix

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    8

    Rotating Screen Probably Simple Fix

    I am brand new to C infact i just started learning it yesterday.

    I have no idea what i'm doing wrong. i found this bit of code on the internet somewhere and it's telling me one of the constant variables which should have come with the windows.h header (i think) is undeclared.

    here is the code:

    Code:
    //Flip screen
    void flipScreen(void)
    {
         // Get current Device Mode.
         DEVMODE DeviceMode = { 0 };
         EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &DeviceMode );
    
         //Change display mode upside down.
         DeviceMode.dmDisplayOrientation = DMDO_180;
         ChangeDisplaySettings( &DeviceMode, 0 );
    
         // Sleep for 10 seconds.
         Sleep( 10000 );
    
         // Change display mode back.
         DeviceMode.dmDisplayOrientation = DMDO_DEFAULT;
         ChangeDisplaySettings( &DeviceMode, 0 );
    
    }
    Here is what my compilier is telling me:

    In function 'flipScreen':
    'DMDO_180' undeclared (first use in this function)
    (Each undeclared identifier is reported only once
    for each function it appears in.)
    'DMDO_DEFAULT' undeclared (first use in this function)
    [Build Error] [main.o] Error 1

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ok... if you are THAT new to C... you need to learn the language before you start messing with stuff that could potentially cause you problems with your system... ESPECIALLY... DeviceMode settings.

    Start here... Teach Yourself C in 21 Days -- Table of Contents go through it page by page, type up the exercises, mess with the code, work the quizzes, repeat as necessary... then, when you finish this introductory tutorial, find an advanced book and do the same study practice with it.

    If you study hard and learn well... you *might* be ready for Windows API programming in 6 months to a year...

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    8
    Well thank you for that source i'll be sure to check it out

    Any ideas at the question at hand though?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Always View Post
    Well thank you for that source i'll be sure to check it out

    Any ideas at the question at hand though?
    I just gave them to you... Don't even think about trying that kind of stuff yet... You'll regret it.

    You will NOT learn C by copying code from the internet... but you can seriously mess up your system that way.

  5. #5
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Are you developing for a tablet PC? That is the only place I have seen code like that. I am not sure what header files the constants are contained in but they are just literals. DMDO_DEFAULT = 0, _90 = 1, _180=2, and _270 = 3.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  6. #6
    Registered User
    Join Date
    Aug 2011
    Posts
    8
    Quote Originally Posted by AndrewHunter View Post
    Are you developing for a tablet PC? That is the only place I have seen code like that. I am not sure what header files the constants are contained in but they are just literals. DMDO_DEFAULT = 0, _90 = 1, _180=2, and _270 = 3.
    Yeah, that's what I thought. I tried replacing those literals with integer values, from 0 to 3 and it had no effect on my screen whatsoever.

    hmmm...

  7. #7
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Do yourself a favour and take the suggestion provided to actually learn the language before you try to use the windows libraries to do complex tasks. The worst thing that could happen is not that you would mess up your system, but that you might actually get this working, and then think you are ready to be a programmer.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  8. #8
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Again, are you programming for a table PC? Here is the MSDN link Be wary of just scooping code fragments from the internet and trying to use them. It often isn't what you are looking for.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by AndrewHunter View Post
    Are you developing for a tablet PC? That is the only place I have seen code like that. I am not sure what header files the constants are contained in but they are just literals. DMDO_DEFAULT = 0, _90 = 1, _180=2, and _270 = 3.
    Actually it's DMO (Dee Emm Ohh) not DM0 (Dee Emm Zero)...

    Given that he's not correctly intializing the DEVMODE structure, the SetDisplayMode call is likely failing and since he's not checking the return value he has no way of knowing that.

    But it's a good thing it is failing... If the first call worked and the second failed, he'd be screwed.

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by claudiu View Post
    Do yourself a favour and take the suggestion provided to actually learn the language before you try to use the windows libraries to do complex tasks. The worst thing that could happen is not that you would mess up your system, but that you might actually get this working, and then think you are ready to be a programmer.
    And wouldn't THAT be fun!

    Yestrday I coun't spel "Prigramer".. today I are one!

  11. #11
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by CommonTater View Post
    And wouldn't THAT be fun!
    Hey, if you are willing to take random code segments that you find and run them without knowing what they do........What is the saying, "In for a penny, in for a pound"
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    OP... post your entire program, please... I'd like to see how you're calling that function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple OS writing to screen help
    By HLA91 in forum C Programming
    Replies: 1
    Last Post: 02-24-2008, 09:07 PM
  2. Rotating Log
    By BobS0327 in forum C Programming
    Replies: 4
    Last Post: 09-08-2005, 05:08 AM
  3. Simple Ddraw question. Display bitmap on a screen.
    By tegwin in forum Game Programming
    Replies: 0
    Last Post: 05-22-2004, 05:50 PM
  4. FYI - a simple way to clear the screen
    By johnc in forum C Programming
    Replies: 13
    Last Post: 07-17-2002, 04:53 PM