Exemple #1
0
/******************************Public*Routine******************************\
* WinMain
*
*
* Windows recognizes this function by name as the initial entry point
* for the program.  This function calls the application initialization
* routine, if no other instance of the program is running, and always
* calls the instance initialization routine.  It then executes a message
* retrieval and dispatch loop that is the top-level control structure
* for the remainder of execution.  The loop is terminated when a WM_QUIT
* message is received, at which time this function exits the application
* instance by returning the value passed by PostQuitMessage().
*
* If this function must abort before entering the message loop, it
* returns the conventional value NULL.
*
\**************************************************************************/
int PASCAL
WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLineOld,
    int nCmdShow
    )
{
    USES_CONVERSION;

    HRESULT hres = CoInitialize(NULL);
    if(hres == S_FALSE)
    {
        CoUninitialize();
    }

    if(!hPrevInstance)
    {
        if(!InitApplication(hInstance))
        {
            return FALSE;
        }
    }

    /*
    ** Perform initializations that apply to a specific instance
    */
    if(!InitInstance(hInstance, nCmdShow))
    {
        return FALSE;
    }

    /* Verify that the VMR is present on this system */
    if(!VerifyVMR())
        return FALSE;

    /*
    ** Acquire and dispatch messages until a WM_QUIT message is received.
    */
    int iRet = DoMainLoop();
    QzUninitialize();
    return iRet;
}
Exemple #2
0
int PASCAL WinMain(HINSTANCE hInstC, HINSTANCE hInstP, LPSTR lpCmdLine, int nCmdShow)
{
    MSG msg={0};
    WNDCLASS wc;
    USES_CONVERSION;

    // Initialize COM
    if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
    {
        Msg(TEXT("CoInitialize Failed!\r\n"));
        return FALSE;
    }

    // Verify that the VMR is present on this system
    if(!VerifyVMR())
        return FALSE;

    // Was a filename specified on the command line?
    if(lpCmdLine[0] != '\0')
    {
        USES_CONVERSION;
        _tcsncpy(g_szFileName, A2T(lpCmdLine), NUMELMS(g_szFileName));        
    }

    // Register the window class
    ZeroMemory(&wc, sizeof wc);
    ghInst = wc.hInstance = hInstC;
    wc.lpfnWndProc   = WndMainProc;
    wc.lpszClassName = CLASSNAME;
    wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hIcon         = LoadIcon(hInstC, MAKEINTRESOURCE(IDI_TICKER));
    if(!RegisterClass(&wc))
    {
        Msg(TEXT("RegisterClass Failed! Error=0x%x\r\n"), GetLastError());
        CoUninitialize();
        exit(1);
    }

    // Create the main window.  The WS_CLIPCHILDREN style is required.
    ghApp = CreateWindow(CLASSNAME, APPLICATIONNAME,
                         WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE,
                         CW_USEDEFAULT, CW_USEDEFAULT,
                         DEFAULT_PLAYER_WIDTH, DEFAULT_PLAYER_HEIGHT,
                         0, 0, ghInst, 0);

    if(ghApp)
    {
        // Save menu handle for later use
        ghMenu = GetMenu(ghApp);
        EnableTickerMenu(FALSE);

        // Set default dynamic text if user wants to display dynamic text
        // instead of a static bitmap image
        _tcsncpy(g_szAppText, BLEND_TEXT, NUMELMS(g_szAppText));
        g_dwTickerFlags = DEFAULT_MARK;

        // If a media file was specified on the command line, open it now.
        // (If the first character in the string isn't NULL, post an open clip message.)
        if (g_szFileName[0] != 0)
            PostMessage(ghApp, WM_COMMAND, ID_FILE_INITCLIP, 0);

        // Main message loop
        while(GetMessage(&msg,NULL,0,0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    else
    {
        Msg(TEXT("Failed to create the main window! Error=0x%x\r\n"), GetLastError());
    }

    // Finished with COM
    CoUninitialize();

    return (int) msg.wParam;
}
Exemple #3
0
/******************************Public*Routine******************************\
* OpenMovie
*
\**************************************************************************/
HRESULT
CMpegMovie::OpenMovie(
    TCHAR *lpFileName, BOOL bWin9xCompatible
    )
{
    USES_CONVERSION;
    IUnknown        *pUnk;
    HRESULT         hres;
    WCHAR           FileName[MAX_PATH];

    wcscpy(FileName, T2W(lpFileName));

    hres = CoInitialize(NULL);
    if(hres == S_FALSE)
        CoUninitialize();

	if ( bWin9xCompatible || !VerifyVMR() ) {

		//----------------------------------------------------
		// If video must be compatible with Win9x or 
		//  VMR don't exist on the system use old style movie.
		//----------------------------------------------------


		// Get the interface for DirectShow's GraphBuilder
		hres = CoCreateInstance( CLSID_FilterGraph, 
								NULL, CLSCTX_INPROC_SERVER, 
                         IID_IGraphBuilder, (void **)&m_Gb );

		if( SUCCEEDED(hres) )
		{
			// Have the graph builder construct its the appropriate graph automatically
			hres = m_Gb->RenderFile(FileName, NULL);
			if ( FAILED(hres) ) {
				m_Gb->Release(); m_Gb = NULL;
				return hres;
			}

			// QueryInterface for DirectShow interfaces
			hres = m_Gb->QueryInterface(IID_IMediaControl, (void **)&m_Mc);
			if ( FAILED(hres) ) {
				m_Mc->Release(); m_Mc = NULL;
				m_Gb->Release(); m_Gb = NULL;
				return hres;
			}

			hres = m_Gb->QueryInterface(IID_IMediaEventEx, (void **)&m_Me);
			if (m_Me) m_Me->SetNotifyWindow(NULL, 0, 0);

			hres = m_Gb->QueryInterface(IID_IMediaSeeking, (void **)&m_Ms);
			if ( FAILED(hres) ) {
				m_Ms->Release(); m_Ms = NULL;
				m_Me->Release(); m_Me = NULL;
				m_Mc->Release(); m_Mc = NULL;
				m_Gb->Release(); m_Gb = NULL;
				return hres;
			}

			// Query for video interfaces, 
			//  which may not be relevant for audio files.
			hres = m_Gb->QueryInterface(IID_IVideoWindow, (void **)&m_Vw);
			if ( FAILED(hres) ) {
				m_Vw = NULL;
			}
			hres = m_Gb->QueryInterface(IID_IBasicVideo, (void **)&m_Bv);
			if ( FAILED(hres) ) {
				m_Bv = NULL;
			}
			
		
			// Query for audio interfaces, which may not be relevant for video-only files
			hres = m_Gb->QueryInterface(IID_IBasicAudio, (void **)&m_Ba);
			if ( FAILED(hres) ) {
				m_Ba = NULL;
			}


			if ( m_Vw )
			{
				m_Vw->put_Visible(OAFALSE);
				m_Vw->put_AutoShow(OAFALSE);
            m_Vw->put_Owner((OAHWND)m_hwndApp);
				m_Vw->put_MessageDrain((OAHWND)m_hwndApp);
            m_Vw->put_WindowStyle( WS_CHILD | WS_CLIPSIBLINGS 
					| WS_CLIPCHILDREN );

			}

			m_bWin9xCompatible = TRUE;			

		}

		return hres;


	} else {

		//------------------------------------------
		//We can play using new WinXp WMR technique.
		//------------------------------------------

    hres = CoCreateInstance(
        CLSID_FilterGraph,
        NULL,
		  CLSCTX_INPROC_SERVER,
        IID_IUnknown,
        (LPVOID *)&pUnk);

    if(SUCCEEDED(hres))
    {
        m_Mode = MOVIE_OPENED;
        hres = pUnk->QueryInterface(IID_IFilterGraph, (LPVOID *)&m_Fg);
        if(FAILED(hres))
        {
            pUnk->Release();
            return hres;
        }

        hres = AddVideoMixingRendererToFG();
        if(FAILED(hres))
        {
            m_Fg->Release(); m_Fg = NULL;
            return hres;
        }

        hres = pUnk->QueryInterface(IID_IGraphBuilder, (LPVOID *)&m_Gb);
        if(FAILED(hres))
        {
            pUnk->Release();
            m_Fg->Release(); m_Fg = NULL;
            m_Wc->Release(); m_Wc = NULL;
            return hres;
        }

        hres = m_Gb->RenderFile(FileName, NULL);
        if(FAILED(hres))
        {
            pUnk->Release();
            m_Fg->Release(); m_Fg = NULL;
            m_Wc->Release(); m_Wc = NULL;
            m_Gb->Release(); m_Gb = NULL;
            return hres;
        }

        hres = pUnk->QueryInterface(IID_IMediaControl, (LPVOID *)&m_Mc);
        if(FAILED(hres))
        {
            pUnk->Release();
            m_Fg->Release(); m_Fg = NULL;
            m_Wc->Release(); m_Wc = NULL;
            m_Gb->Release(); m_Gb = NULL;
            return hres;
        }

		  // Query audio control
		  hres = m_Gb->QueryInterface(IID_IBasicAudio, (LPVOID *)&m_Ba);
		  if (FAILED(hres))
		  {
			  m_Ba = NULL;
		  }

        //
        // Not being able to get the IMediaEvent interface doesn't
        // necessarly mean that we can't play the graph.
        //
        pUnk->QueryInterface(IID_IMediaEventEx, (LPVOID *)&m_Me);
			if (m_Me) m_Me->SetNotifyWindow(NULL, 0, 0);

        pUnk->QueryInterface(IID_IMediaSeeking, (LPVOID *)&m_Ms);
        pUnk->Release();

		  m_bWin9xCompatible = FALSE;

        return S_OK;
    }
    else
    {
        m_Fg = NULL;
    }

    return hres;

	}
}
Exemple #4
0
/******************************Public*Routine******************************\
* WinMain
*
*
* Windows recognizes this function by name as the initial entry point
* for the program.  This function calls the application initialization
* routine, if no other instance of the program is running, and always
* calls the instance initialization routine.  It then executes a message
* retrieval and dispatch loop that is the top-level control structure
* for the remainder of execution.  The loop is terminated when a WM_QUIT
* message is received, at which time this function exits the application
* instance by returning the value passed by PostQuitMessage().
*
* If this function must abort before entering the message loop, it
* returns the conventional value NULL.
*
\**************************************************************************/
int PASCAL
WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLineOld,
    int nCmdShow
    )
{
    USES_CONVERSION;
    LPTSTR lpCmdLine = A2T(lpCmdLineOld);

    HRESULT hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    if(hres == S_FALSE)
    {
        CoUninitialize();
        return FALSE;
    }

    if(!hPrevInstance)
    {
        if(!InitApplication(hInstance))
        {
            return FALSE;
        }
    }

    /*
    ** Perform initializations that apply to a specific instance
    */
    if(!InitInstance(hInstance, nCmdShow))
    {
        return FALSE;
    }

    /* Verify that the VMR is present on this system */
    if(!VerifyVMR())
        return FALSE;

    /* Look for options */
    while(lpCmdLine && (*lpCmdLine == '-' || *lpCmdLine == '/'))
    {
        if ((lpCmdLine[1] == 'P') || (lpCmdLine[1] == 'p'))
        {
            g_bPlay = TRUE;
            lpCmdLine += 2;
        }
        else
        {
            break;
        }
        while(lpCmdLine[0] == ' ')
        {
            lpCmdLine++;
        }
    }

    if(lpCmdLine != NULL && lstrlen(lpCmdLine) > 0)
    {
        ProcessOpen(lpCmdLine, g_bPlay);
        SetPlayButtonsEnableState();
    }

    /*
    ** Acquire and dispatch messages until a WM_QUIT message is received.
    */
    return DoMainLoop();
}