Microsoft KB Archive/305158

= PRB: Screen Goes Black When Using DirectDraw With Multiple Monitors =

Article ID: 305158

Article Last Modified on 4/4/2006

-

APPLIES TO

 Microsoft DirectX 7.0, when used with:  Microsoft Windows 98 Standard Edition

 Microsoft Windows 98 Second Edition 

-



This article was previously published under Q305158



SYMPTOMS
The primary screen goes black when you call SetCooperativeLevel on a secondary monitor when you are using full-screen, exclusive mode in DirectDraw. If you are calling SetCooperativeLevel to go into full-screen, exclusive mode on a secondary monitor and that monitor is not attached to the desktop, the primary monitor will be covered by a full-screen, topmost black window.



CAUSE
When you call SetCooperativeLevel with the DDSCL_FULLSCREEN and DDSCL_EXCLUSIVE flags, a window must be specified in the first parameter. Each device that is to hold a full-screen DirectDraw surface must be represented by a DirectDraw object and a device window. A device window will be created by DirectDraw when you call SetCooperativeLevel with the DDSCL_CREATEDEVICEWINDOW flag. The device window will be sized to fit the screen and appear on top of all other windows. Because the secondary monitor is not attached to the desktop, Windows cannot draw the device window on that monitor and continues to draw the window on the primary monitor, filling up the screen.



RESOLUTION
The recommended way to work around to this problem is to always attach any monitor that will use DirectDraw to the desktop. If, however, you want to have a nonprimary monitor detached from the desktop, then you must hide all device windows created through the use of the ShowWindow(hwnd, SW_HIDE) call.

<div class="moreinformation_section">

MORE INFORMATION
You must obtain the handle to the device window for your DirectDraw object in order to hide it. If you specify the DDSCL_CREATEDEVICEWINDOW flag, then DirectDraw will create that window but will not give you the handle. You can obtain the handle by calling FindWindow with the string &quot;DirectDrawDeviceWnd&quot; for the window name. You should call ShowWindow with SW_HIDE right after you call SetCooperativeLevel for each monitor not attached to the desktop. For example, the following code will properly hide the DirectDraw device window for a secondary monitor detached from the desktop. The window will remain hidden while the application is running. m_pDD->SetCooperativeLevel(hMain, DDSCL_SETFOCUSWINDOW |        DDSCL_CREATEDEVICEWINDOW | DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE |        SCL_FULLSCREEN);

HWND hWnd; hWnd = FindWindow(0,&quot;DirectDrawDeviceWnd&quot;); ShowWindow(hWnd, SW_HIDE);

Keywords: kbmultimon kbdirectdraw kbgdi kbprb kbdisplay kbdswgdi2003swept KB305158

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.