// Author & Date: Almut Branner 12 May 2003 // Purpose: Replace this static control with this window // Inputs: // rcParentWindow - the window this is going to be placed into // rcNewWindow - the window that is to be created // nControlID - the ID of the control (from the resource editor) void ReplaceWindowControl(const CWnd &rcParentWindow, CWnd &rcNewWindow, int nControlID) { CWnd *pStatic = rcParentWindow.GetDlgItem(nControlID); // For debug mode ASSERT(pStatic != 0); // For released code if (pStatic == 0) return; CRect rctWindowSize; DWORD frmstyle = pStatic->GetStyle(); DWORD frmexstyle = pStatic->GetExStyle(); pStatic->GetWindowRect(rctWindowSize); // Get window coord. rcParentWindow.ScreenToClient(rctWindowSize); // change to client coord. pStatic->DestroyWindow(); CWnd *pParent = const_cast<CWnd *>(&rcParentWindow); rcNewWindow.CreateEx(frmexstyle, NULL, NULL, frmstyle, rctWindowSize, pParent, nControlID); // Use for debugging // AllocConsole(); }
int CKSFileDialog::DoModal() { ASSERT_VALID(this); DWORD nOffset = lstrlen(m_ofn.lpstrFile)+1; memset(m_ofn.lpstrFile+nOffset, 0, (m_ofn.nMaxFile-nOffset)*sizeof(TCHAR)); HWND hWndFocus = ::GetFocus(); BOOL bEnableParent = FALSE; //m_ofn.hwndOwner = PreModal(); CWnd dummy; dummy.CreateEx(NULL,AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),NULL,NULL,CRect(0,0,0,0),NULL,NULL); dummy.CenterWindow(); CRect rect; dummy.GetWindowRect(rect); dummy.SetWindowPos(NULL, rect.left-230, rect.top-180, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); dummy.ShowWindow(SW_HIDE); m_ofn.hwndOwner=dummy.GetSafeHwnd(); if (m_ofn.hwndOwner==NULL) m_ofn.hwndOwner=PreModal(); if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { bEnableParent = TRUE; ::EnableWindow(m_ofn.hwndOwner, FALSE); } _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); ASSERT(pThreadState->m_pAlternateWndInit == NULL); m_ofn.lpfnHook = NULL; m_ofn.lpTemplateName = NULL; int nResult; if (m_bOpenFileDialog) nResult = ::GetOpenFileName(&m_ofn); else nResult = ::GetSaveFileName(&m_ofn); if (nResult) ASSERT(pThreadState->m_pAlternateWndInit == NULL); pThreadState->m_pAlternateWndInit = NULL; // WINBUG: Second part of special case for file open/save dialog. if (bEnableParent) ::EnableWindow(m_ofn.hwndOwner, TRUE); if (::IsWindow(hWndFocus)) ::SetFocus(hWndFocus); PostModal(); return nResult ? nResult : IDCANCEL; }
// **************************************************************************** // // Function Name: SubclassControl( ) // // Description: Subclass control obtains the default style information // from the control to subclass, and uses this to create // a similar control based on CWnd, instead of the type // of control in the dialog template. // // Returns: Nothing // // Exceptions: None // // **************************************************************************** // BOOLEAN SubclassControl( CWnd* pParent, UINT nControlID, CWnd& ctlChild ) { // Get the control we're stealing... CWnd* pCtl = pParent->GetDlgItem( nControlID ); CRect rcCtl; CString strText ; // // Determine all the information of the control we're // stealing, so we can use it in the creation of the new control. // DWORD dwStyle = pCtl->GetStyle() ; // Style DWORD dwExStyle = pCtl->GetExStyle() ; // Extended pCtl->GetWindowText( strText ) ; // Window Text pCtl->GetWindowRect( rcCtl ) ; // Screen Position pParent->ScreenToClient( rcCtl ) ; BOOLEAN fResult = FALSE ; // // Create the new control with all the settings // of the control we are replacing. // if (ctlChild.CreateEx( dwExStyle, NULL, strText, dwStyle, rcCtl.left, rcCtl.top, rcCtl.Width(), rcCtl.Height(), pParent->m_hWnd, (HMENU) nControlID ) ) { // Set the z order of the control ctlChild.SetWindowPos( pCtl, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE ) ; } // // Okay, we have everything we need so destroy // the control that we are replacing. // pCtl->DestroyWindow(); return fResult ; }
void CDlgSelectMode::OnTestButton() { CWnd wndTestWindowedMode; UpdateData( TRUE); // apply wanted display mode settings CDisplayMode dm; enum GfxAPIType gfxAPI; ApplySettings( &dm, &gfxAPI); // try to set wanted display mode PIX pixSizeI = dm.dm_pixSizeI; PIX pixSizeJ = dm.dm_pixSizeJ; BOOL bDisplayModeSet = _pGfx->SetDisplayMode( GAT_OGL, 0, pixSizeI, pixSizeJ, dm.dm_ddDepth); if( !bDisplayModeSet) { AfxMessageBox( L"Unable to setup full screen display. Test mode failed."); return; } //--------------------------- Open window for testing windowed display mode // draw ports and viewports needed for printing message CDrawPort *pDrawPort; CViewPort *pViewPort; // get the windows dimensions for this display int iScreenX = ::GetSystemMetrics(SM_CXSCREEN); // screen size int iScreenY = ::GetSystemMetrics(SM_CYSCREEN); // open window of display mode size const wchar_t *strWindowClass = AfxRegisterWndClass( CS_OWNDC|CS_NOCLOSE); wndTestWindowedMode.CreateEx( WS_EX_TOPMOST, strWindowClass, L"Test mode", WS_POPUP|WS_VISIBLE, 0,0, iScreenX,iScreenY, m_hWnd, 0); // create window canvas _pGfx->CreateWindowCanvas( wndTestWindowedMode.m_hWnd, &pViewPort, &pDrawPort); // if screen or window opening was not successful if( pViewPort == NULL) { AfxMessageBox( L"Unable to setup full screen display. Test mode failed."); return; } // show test mode screen ShowTestModeScreen( pDrawPort, pViewPort); // get starting time CTimerValue tvStart = _pTimer->GetHighPrecisionTimer(); // loop forever FOREVER { // get current time CTimerValue tvCurrent = _pTimer->GetHighPrecisionTimer(); // get time difference in seconds CTimerValue tvElapsed = tvCurrent - tvStart; // three seconds passed? if( tvElapsed.GetSeconds() > 5.0f) break; } // destroy windowed canvas _pGfx->DestroyWindowCanvas( pViewPort); pViewPort = NULL; // destroy window wndTestWindowedMode.DestroyWindow(); // restore old mode _pGfx->ResetDisplayMode(); if( AfxMessageBox( L"Did You see displayed message correctly?", MB_YESNO) == IDYES) { GetDlgItem( IDOK)->SetFocus(); // set focus to apply button } else { AfxMessageBox( L"Mode is not valid and it is rejected. Choose another one."); } Invalidate( FALSE); }
BOOL CReportCameraWorker::StartCapturePhoto() { CString strOutputFileName; strOutputFileName = GetCaptureFileName(_T("jpg")); if (m_ReportCameraConfig.m_CaptureDevicePath.GetLength() < 1) { TRACE(_T("CReportCameraWorker::StartCaptureVideo no capture device selected\n")); return FALSE; } ////////////////////////////////////////////////////////////////////////// USES_CONVERSION; CString options; options = _T("--play-and-exit --no-osd --intf dummy --dummy-quiet --no-video-deco --aspect-ratio auto"); options += _T(" --no-fullscreen"); // options += _T(" --vout-filter \"\""); ////options += _T(" --width 640 --height 480"); CString video_input; video_input.Format(_T("dshow:// :dshow-vdev=\"%s\""), m_ReportCameraConfig.m_CaptureDevicePath); int iOutputFormat = 0/*m_wndOutputFormat.GetCurSel()*/; CString transcode; CString transcode_out_params; CString one_param; profile video_profile = video_profile_value_list[iOutputFormat]; transcode_out_params.Format(_T("vcodec=%s,scale=%d"), A2T(video_profile.video_codec), video_profile.scale); if(video_profile.video_bitrate > 0) { one_param.Format(_T(",vb=%d"), video_profile.video_bitrate); transcode_out_params += one_param; } one_param.Format(_T(",acodec=%s,ab=%d,channels=%d,samplerate=%d"), A2T(video_profile.audio_codec), video_profile.audio_bitrate, video_profile.channels, video_profile.samplerate ); transcode_out_params += one_param; transcode.Format(_T("transcode{%s}:standard{access=file,mux=%s,dst=\"%s\"}"), transcode_out_params, A2T(video_profile.Container), strOutputFileName ); CString command_line; //command_line.Format(_T("%s %s :dshow-fps=5 --sout=#duplicate{dst=display,dst={%s}"), options, video_input, transcode); command_line.Format(_T("%s %s :dshow-fps=5 --sout=#duplicate{dst=display,dst={%s}"), options, video_input, transcode); CString sout_arg; // dont show on screen/windows/etc //sout_arg.Format(_T("--sout=#duplicate{dst=display,dst={%s}"), transcode); //sout_arg.Format(_T("--sout=#duplicate{dst={%s}"), transcode); sout_arg.Format(_T("--sout=#duplicate{dst=display"), transcode); const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ // "--plugin-path=E:\\TEMP\\VLC-1.0.5\\plugins\\", T2A(sout_arg.GetBuffer(0)) }; #if 1 for (int i = 0; i < sizeof(vlc_args) / sizeof(vlc_args[0]); i++) { TRACE( _T("%d - %s\n"), i, A2T(vlc_args[i])); } #endif /* init vlc modules, should be done only once */ m_inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); if (m_inst == NULL) { return FALSE; } /* Create a new item */ //m_m = libvlc_media_new (m_inst, "E:/Media/2/1.avi", &m_ex); m_m = libvlc_media_new_path (m_inst, T2A(video_input)); if (m_m == NULL) { libvlc_release(m_inst); m_inst = NULL; return FALSE; } /* Create a media player playing environment */ m_mp = libvlc_media_player_new_from_media (m_m); if (m_mp == NULL) { libvlc_media_release(m_m); m_m = NULL; libvlc_release(m_inst); m_inst = NULL; return FALSE; } /* No need to keep the media now */ libvlc_media_release (m_m); m_m = NULL; //m_wndCaptureWindow.CreateEx(0, ) CRect rect(0, 0, 800, 600); CWnd *pWnd = new CWnd; pWnd->CreateEx(/*WS_EX_TOPMOST | */WS_EX_TOOLWINDOW, m_CaptureWndClass, _T("CaptureWindow"), WS_POPUP | WS_CHILD, rect, NULL, 0); pWnd->ShowWindow(SW_HIDE); //libvlc_media_player_set_hwnd(m_mp, m_wndCaptureWindow.GetSafeHwnd()); libvlc_media_player_set_hwnd(m_mp, pWnd->GetSafeHwnd()); /* play the media_player */ int iplay = libvlc_media_player_play (m_mp); if (iplay == -1) { libvlc_media_player_release (m_mp); m_mp = NULL; libvlc_release(m_inst); m_inst = NULL; return FALSE; } m_bCaptureStarted = TRUE; TRACE(_T("CReportCameraWorker::StartCapturePhoto m_bCaptureStarted = TRUE\n")); return TRUE; }