How to initialize an independent display using CreateDC

已答覆 How to initialize an independent display using CreateDC

  • Monday, April 11, 2005 7:47 AM
     
     

    I am trying to initialise a second display as an independent display on my machine using:

       CreateDC("\\\\.\\DISPLAY2", NULL, NULL, &demode);

    but I keep getting error code 0x709.

    • The "\\\\.\\DISPLAY2" is the string returned from EnumDisplayDevices
    • The devmode structure has been initiailised with basic information about the display (height, width, freq, color depth) which I know works with ChangeDisplaySettings if I extend the desktop onto the second display.

    The error code is described as "The printer name is invalid. " in visual studio. I can get everything to work fine if the Windows desktop is extended onto the second display, but I want to avoid this situtation.

    I have also tried enumerating the display settings, which populates the devmode structure, but this does not work either.

    According to the MSDN pages (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/monitor_4mr7.asp) on using multiple monitors as independent displays this should work, however it does not.

    Can anyone help?

All Replies

  • Monday, April 11, 2005 1:48 PM
    Moderator
     
     
    Is the output of EnumDisplayDevices really "DISPLAY_DEVICE_ATTACHED_TO_DESKTOP" "FALSE" for the DISPLAY2 ?

    Your example is also incomplete.. you should also show the part of setting the "demode".

    For an example see: Independent Displays
    http://www.realtimesoft.com/multimon/programming/independent_displays.asp
  • Thursday, April 14, 2005 7:32 AM
     
     Answered

    I tried looking at the example and modified the code, but I still got the same error. I was just about to post you the text of the full test program when I noticed the following text on the link:

    Single-chipset dualhead cards on Windows 98/Me and XP: due to a limitation in the operating system support for this type of display adapter, it is not possible to create independent displays on such a card. CreateDC will fail and GetLastError returns ERROR_INVALID_PRINTER_NAME.

    Would have been nice to find this in the MSDN documentation, could have saved me hours of research!

    Thanks for your help.

  • Thursday, April 14, 2005 9:49 AM
     
     
    ezhxra@discussions.microsoft.com wrote:

    I tried looking at the example and modified the code, but I still got the same error. I was just about to post you the text of the full test program when I noticed the following text on the link:

    Single-chipset dualhead cards on Windows 98/Me and XP: due to a limitation in the operating system support for this type of display adapter, it is not possible to create independent displays on such a card. CreateDC will fail and GetLastError returns ERROR_INVALID_PRINTER_NAME.

    Would have been nice to find this in the MSDN documentation, could have saved me hours of research!

    I try to post this the the apropriate private MS newsgroup; so it can be added in an future update of the documentation.

    -- 
    Greetings
      Jochen
     
       My blog about Win32 and .NET
       http://blog.kalmbachnet.de/
  • Tuesday, April 19, 2005 3:42 PM
     
     
    Is there any fix available from Windows XP for this problem ? Please let me know. Thanks in advance.
  • Wednesday, May 11, 2005 3:08 AM
     
     
    Has anyone found a work-round yet?  This is causing me some pain!

  • Wednesday, May 11, 2005 6:19 AM
    Moderator
     
     
    The behaviour is by design. You need to add a second display-adapter.

    Greetings
      Jochen
  • Wednesday, May 11, 2005 2:45 PM
     
     
    Jochen,

    Thanks for your advice. But question is not adding second display adaptor, but using this second adaptor even if its not enabled (ie desktop extended or cloned to this second adaptor). We would like to use this adaptor without enabling it through display properties.


    Regards,
    Sudhir
  • Wednesday, May 11, 2005 3:40 PM
    Moderator
     
     
    I mean you need to add a second "physical" display adapter! (so you need 2 graphic cards!)

    Greetings
      Jochen
  • Wednesday, May 11, 2005 3:54 PM
     
     
    Jochen,

    Can we do something at driver level? I mean will writing a Filter driver can enable this second display adaptor through application? so that we can use s-video port on second display adaptor to send output to TV or other monitor.

    Thanks