Code:
m_hWindow = ::CreateWindowEx( WS_EX_CONTROLPARENT,
"WindowClass",
TITLE,
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
| WS_MINIMIZEBOX | WS_VISIBLE,
(DesktopSize.right - m_dwWindowWidth)/2,
(DesktopSize.bottom - m_dwWindowHeight)/2,
m_dwWindowWidth,
m_dwWindowHeight,
NULL,
NULL,
::GetModuleHandle( NULL ),
NULL );
//
// Do some UI processing and get option choices from the user
//
...
//
// Get the information for the secondary display
//
DISPLAY_DEVICE sDisplayDevice = {sizeof(sDisplayDevice)};
DEVMODE sDevMode;
BOOL bReturn = ::EnumDisplayDevices( NULL, // device name
m_dwMonitorIndex, // Selected Monitor
(PDISPLAY_DEVICE) &sDisplayDevice, // device information
NULL); // reserved
bReturn = ::EnumDisplaySettings( sDisplayDevice.DeviceName, // display device
ENUM_CURRENT_SETTINGS, // graphics mode
(LPDEVMODE) &sDevMode // graphics mode settings
);
sDevMode.dmFields = 0;
sDevMode.dmFields |= DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
sDevMode.dmPelsWidth = m_dwWidth;
sDevMode.dmPelsHeight = m_dwHeight;
LONG lReturn = ::ChangeDisplaySettingsEx( sDisplayDevice.DeviceName, // display device
(LPDEVMODE) &sDevMode,
NULL,
(CDS_UPDATEREGISTRY),
NULL );
// Get back settings !
bReturn = ::EnumDisplaySettings( sDisplayDevice.DeviceName, // display device
ENUM_CURRENT_SETTINGS, // graphics mode
(LPDEVMODE) &sDevMode ); // graphics mode settings
// Hide the options window
::SetWindowPos( m_hWindow,
NULL,
m_dwWindowWidth/2,
m_dwWindowHeight/2,
m_dwWindowWidth,
m_dwWindowHeight,
SWP_HIDEWINDOW );
// Create the window on which we will do 3D rendering
m_hDXWindow = ::CreateWindowEx( WS_EX_CONTROLPARENT,
"WindowClass",
TITLE,
WS_POPUP & ~WS_THICKFRAME & ~WS_BORDER | WS_VISIBLE | WS_EX_TOPMOST,
sDevMode.dmPosition.x,
sDevMode.dmPosition.y,
m_dwWidth,
m_dwHeight,
NULL,
NULL,
::GetModuleHandle( NULL ),
NULL );
// Fill the present parameters
::ZeroMemory( &m_PresentParameters, sizeof( m_PresentParameters ) );
m_PresentParameters.Windowed = m_bWindowed;
// Discard last displayed frame - Faster and supports multisampling
m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
// Depth/Stencil Format
m_PresentParameters.EnableAutoDepthStencil = true;
m_PresentParameters.AutoDepthStencilFormat = m_DepthStencilFormat;
m_PresentParameters.hDeviceWindow = m_hDXWindow; // Window handle
//Disable vsync
m_PresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_ONE;//D3DPRESENT_INTERVAL_DEFAULT;//D3DPRESENT_INTERVAL_IMMEDIATE;
m_PresentParameters.BackBufferCount = 2; // Triple buffering
m_PresentParameters.BackBufferWidth = m_dwWidth; // Screen Width
m_PresentParameters.BackBufferHeight = m_dwHeight; // Screen Height
m_PresentParameters.BackBufferFormat = m_ColorFormat; // Color Depth
m_PresentParameters.MultiSampleType = m_MultiSampling; // Multi-Sampling
// Create the Device
m_pDirect3DObject->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
m_hDXWindow,
m_dwVertexProcessing,
&m_PresentParameters,
&m_pDirect3DDevice );
Thanks in advance