// Create the main window. The WS_CLIPCHILDREN style is required.
ghApp = CreateWindow(CLASSNAME, APPLICATIONNAME,
WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT,
DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT,
0, 0, hIns, 0);
if(ghApp)
{
// Create DirectShow graph and start capturing video
hr = CaptureVideo();
if (FAILED (hr))
{
CloseInterfaces();
::DestroyWindow(ghApp);
}
else
{
// Don't display the main window until the DirectShow
// preview graph has been created. Once video data is
// being received and processed, the window will appear
// and immediately have useful video data to display.
// Otherwise, it will be black until video data arrives.
::SetWindowPos(hWnd,HWND_BOTTOM,rc.left,rc.top,rc.Width(),rc.Height (),SWP_DRAWFRAME);
::ShowWindow(ghApp, TRUE);
}
case WM_WINDOWPOSCHANGED:
sst.ChangePreviewState(! (::IsIconic(hwnd)));
break;
case WM_CLOSE:
// Hide the main window while the graph is destroyed
::ShowWindow(sst.ghApp, SW_HIDE);
sst.CloseInterfaces(); // Stop capturing and release interfaces
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
// Pass this message to the video window for notification of system changes
if (sst.g_pVW)
sst.g_pVW->NotifyOwnerMessage((long) hwnd, message, wParam, lParam);