none
Console Programs wont work on VISTA or Windows 7 properly but runs fine on XP

    Question

  • Hello, I made a small console program that used the ascii to draw color images. Its compiled on windows xp in VSC++2008.

    When I run the release on an XP machine all is well. But some of my users using Vista and Win7 complain of the following things:

    - Line artifacts in the wake of images that move (I assume it has something to do with SetConsoleTextAttribute() with a BackGround index of 0/black)

    - ESC Keys wont work, (using GetKeyState())

    - Window wont Auto resize. using :

    SMALL_RECT smRct;
    
    smRct.Top = 0;
    
    smRct.Left = 1; // why cant this be ZERO initially!!!!!!!!!??!
    
    smRct.Right = SCREENWIDTH ;
    
    smRct.Bottom = SCREENHEIGHT; 	 
    
    SetConsoleWindowInfo(hOUT_a,1,&smRct);
    
    

     

    Like I said when the exe is run on windows XP all is well. But on any VISTA or Windows7 machine the user gets the above issues.

     

    I've tried to do some research and I can tell you that:

    - I havent used any #define WINVER

     - There are no issues at compile time, only runtime (and none fatal)

    Specifically I'd like to know if windows Vista and Win7 Handles (no pun intended) the console differently than XP. For instance in terms of their lowlevel functions or libraries. and should I be using any other functions or doing any of this differently?

    Thanks for any help.

    I'm not sure if this is the best place to post this so moderator feel free to mod away 

     

    • Moved by Yi Feng Li Thursday, February 24, 2011 8:49 AM Compatibility Issue (From:Visual C++ Express Edition)
    Tuesday, February 22, 2011 6:57 PM

All replies

  • Off-topic here. Looks like a good quesion for the application compatiblity  programming forum at http://social.msdn.microsoft.com/Forums/en-US/windowscompatibility/threads

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, February 22, 2011 7:48 PM
  • Hi Glinka,

    It is hard to say the changes with XP console and Vista/7. We need know the specific code of your application, and want to know which specific functions do you use. I think there are many changes in the console and the lowlevel libraries, but cannot to know which changes can affect your output.

    Sincerely,

     


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, February 25, 2011 2:47 AM
  • Hi,

     

    Could you please elaborate more on the issue that you are facing?  Also could you sent a minimal repro sample code of the issue that you are facing?

     

    Thanks.


    bill boyce
    Monday, February 28, 2011 1:13 PM
  • Sorry guys,  I was away.

    The issue concerns this game http://meganetstudios.com/dl/cptnrth18102010demo/2010Oct18-CaptainEarthDEMO.zip

    If you run it on an XP computer all is well and it runs fine. But I've been getting complaints from users using higher versions of windows that there are artifacts being left on the screen at some parts here are some of their quotes:

     

    "...I saw many vertical black lines on the right side of things that animated to the left.  Basically they left a vertical line trail.  They never went away.  Plus the ESC key doesn't seem to work for me.
    I ran it on Win7 64-bit PC..."

    -------------------------------------------------------------------------------

    [img] http://www.goliathforge.com/_gForge/external/cptEarth_bug.jpg [/img]

    "Screenshot taken on Win7 64bit (1440x900 res) no alt+enter functionality, but esc is keyboard functional (not mouse).

    On Vista 64bit, no vertical lines but still no alt+enter to fullscreen and keyboard esc to menu same. It didn't auto size the window from standard console size rectangle.

    On WinXP 32bit all good. No vertical lines, window auto resizes to square window, alt+enter functions and esc brings up lower menu. "

    -------------------------------------------------------------------------------

    " ... yes what he shows is exactly what I'm seeing also.
    My win7 64 bit was
    3840x1600.  That's a dual screens at 1920x1600.
    Video card: XFX NVidia GeForce gfx 470  1.2GB"

    -------------------------------------------------------------------------------

     

    This was my attempted answer:

    Could you show me a screen shot, I've never seen this before, but from what you say I think I know what it is. Do you also have another computer with xp, could you see how it runs on there.

    The esc key might be some new feature in windows 7, where a macro disabling 'system keys' is set by default. thats the only thing I can think of. Its not the case with xp or vista I dont think.

    Could I see a screen shot. what parts of the game does it happen at? is it at 'all' places where 'anything' moves to the left from off the right screen.
    I have no way to test this as I cant create that issue with xp.

    It might be the functions that resize the screen buffer for the window or, the way 64bit sizes arrays that initialized for(int x){ary[][][x++]}. well im guessing.

     

    As you can tell I really didnt know what to say

    Im pretty much sure the problem is in the Display() Function which draws everything to the screen.

    Here is a code paste of it: http://codepaste.net/ou1mqf   (I wasnt sure if there was a char limit on the forum here)

    The Function takes a string as one of its arguments and displays the sprite of that name. It creates a 2 dimensional array of the width and height of the image in size. then the programmer assings a Hex value into each array element. The hex number contains color information and the ascii char type... 0xABCD would specify ascii char AB  (ie:171)  with a color index of CD (205).

    After the array is populated the next stage of the function is to cycle through each element and parse its value then print it using SetConsoleTextAttribute(hOUT, color_index) , printf() and gotoxy().

    At some parts where there is no solid 'pixel' (ie:char) the function should print what is on a below layer.(transparent)

    Once drawn the sprite is displayed for a few milliseconds to allow the user to see it then it is erased and redrawn.

    'BG[][][]' is an array that stores all hex values curently on the screen

    the most significant dimension stores the layer (int) specifier

    when the display function encounters an 0x0000 image hex value, it will print the hex value at the behind layer (usually layer 0).

    the hex value there is usually that of the sky, as the sky is printed and assigned to BG at the startup of the level and never redrawn to.

    (so a sprite moving across the sky will redraw the sky as it passes)

     

    Thats all I can say, Im really not sure what it could be. I'm hoping one of you expert will say "aha" or "well no wonder" or something like that. also Is this method not recommended based on what you know of the design of the console window. and is there any way to print a char to the screen that would be faster than printf(). I measured printf() to be more than 2wice as fast as cout.

    Thanks

     Edit: I used the GetKeyState() function to detect the keys.

    Wednesday, March 02, 2011 8:48 AM
  • Hi,

    In review with colleages and time involved your issue falls into a category that we are not able to resolve using the forums. This would require a more in-depth level of support.There are various types of support options . Please visit the below link to see the support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Also Alliance and Premier VSIP membership includes a complimentary MSDN subscription, which includes 4 professional support incidents. These can be used to initialize a support request with Microsoft's Customer Support Services. Some versions of Visual Studio include a number of free support incidents as well. See the "Technical Support Incidents" topic for details.


    Thanks

     

    Wednesday, March 02, 2011 5:21 PM
  • Thanks, I was hoping it would be one of those obvious things. my solution will be to specify windows XP as the target OS and using higher versions of windows is done at their own risk. I see your position.

    Thank you both!

    Thursday, March 03, 2011 12:51 AM