3

Is is possible to show an application on only one display, if the display is cloned? My goal is to develop a timer that is shown on the laptop display during a presentation but not on the projector.

I'm looking for something like windows' "Identify displays" feature, which displays numbers 1 and 2 on the different displays, even in cloned mode.

Thanks

Edit

I discovered a possible duplicate to this question. The accepted answer in this case was to use Screens.AllScreens to discover the number of screens. This is not enough in my case. A comment on the accepted answer links to a thread about directly painting on the desktop. I tried this with the following code, but the text appeared on both displays. The code to get the Hdc of the input is from an article about screen captures. I'm not sure what to set for the other parameters (they are IntPtr.Zero in the article)

[DllImport("gdi32.dll")]
static extern IntPtr CreateDC(IntPtr lpszDriver, string lpszDevice, IntPtr lpszOutput, IntPtr lpszInitData);

[DllImport("gdi32.dll")]
static extern IntPtr DeleteDC(IntPtr hdc);

private void PaintOnDesktop(string stringToPrint, Font font, Brush brush, PointF position) {
    string deviceName = Screen.AllScreens[0].DeviceName;
    IntPtr targetHdc = CreateDC(IntPtr.Zero, deviceName, IntPtr.Zero, IntPtr.Zero);
    using (Graphics g = Graphics.FromHdc(targetHdc)) {
        g.DrawString(stringToPrint, font, brush, position);
    }
    DeleteDC(targetHdc);
}

Edit 2

Apparently there is no way to do this in C#, so I changed the C# tag to device driver.

Community
  • 1
  • 1
Flogo
  • 1,673
  • 4
  • 20
  • 33
  • I suspect there is absolutely no way to do this in usermode. Even if it's possible at all, you'll have to hack around the display drivers. I think it's a bad idea anyway to violate the user's configuration. Maybe what you really want is to temporarily switch to non-cloned mode and then back? – Roman Starkov Jan 21 '12 at 11:52
  • Thanks for your reply. I don't think switching back and forth between cloned and non-cloned mode is possible. I would like to have a timer on my laptop screen that updates every second. I reckon this would lead to extreme flickering. Any idea how I could use the drivers directly? It would not be necessary to print the whole application to one of the displays. printing text would be ok, too. – Flogo Jan 21 '12 at 11:59
  • I see what you're after. It really kind of does make sense to leave it cloned. Hope you can find a way to do this, but be ready for a plan B. (No, I don't know how one might do this with a custom display driver) – Roman Starkov Jan 21 '12 at 12:01

1 Answers1

1

The only way to achieve this effect would be to "clone" the screen "manually", i.e. outside of utilizing this feature of the driver, which would of course induce some lag. UltraMon has a feature like this, designed for video cards or OS's that don't support multiple-monitor cloning. It's basically done by screenshotting the desktop rapidly and displaying it on a form on another (extended) monitor.

The lag induced is only present on one of the monitors, so in your case if this is for a presentation, I would suggest making "your" monitor (probably the primary one on your laptop) the recipient of the lag, so the audience doesn't see it. You can then of course draw a timer form on top of either screen.

Drew Alden
  • 108
  • 7
  • Thanks for your answer. I'm still hoping someone can add some information of how to achieve this via the driver. This would be a much cleaner option, the way I see it. I reckon it should be possible, since the Windows dialog does it. Maybe I should remove the c# tag? – Flogo Mar 06 '12 at 11:03