⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dvbteletextsubtitlespropertiespage1.cpp

📁 Teletext module usually used in the DVB area.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
/* 

(C) Luke Paton 2004.

Copyright notice:

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/
//------------------------------------------------------------------------------

#include "stdafx.h"

// Eliminate two expected level 4 warnings from the Microsoft compiler.
// The class does not have an assignment or copy operator, and so cannot
// be passed by value.  This is normal.  This file compiles clean at the
// highest (most picky) warning level (-W4).
#pragma warning(disable: 4511 4512)

#include "DVBTeletextSubtitles.h"
#include "DVBSubtitlesFilter.h"
#include "DVBTeletextSubtitlesPropertiesPage1.h"
#include "resource.h"    // ids used in the dialog

//
// CreateInstance
//
// Override CClassFactory method.
// Set lpUnk to point to an IUnknown interface on a new CDVBTeletextSubtitlesPropertiesPage1 object
// Part of the COM object instantiation mechanism
//
CUnknown * WINAPI CDVBTeletextSubtitlesPropertiesPage1::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
{
    ASSERT(phr);
    
    CUnknown *punk = new CDVBTeletextSubtitlesPropertiesPage1(lpunk, phr);

    if (punk == NULL) {
        if (phr)
            *phr = E_OUTOFMEMORY;
    }

    return punk;
}


//
// CDVBTeletextSubtitlesPropertiesPage1::Constructor
//
// Constructs and initialises a CDVBTeletextSubtitlesPropertiesPage1 object
//
CDVBTeletextSubtitlesPropertiesPage1::CDVBTeletextSubtitlesPropertiesPage1(LPUNKNOWN pUnk, HRESULT *phr)
:
    CBasePropertyPage(NAME("DVB Teletext Subtitles Property Page\0"),pUnk, IDD_PROPERTIES, IDS_PROJNAME)
{
    ASSERT(phr);
	InitCommonControls();
}

//
// SetDirty
//
// Sets m_hrDirtyFlag and notifies the property page site of the change
//
void CDVBTeletextSubtitlesPropertiesPage1::SetDirty()
{
    m_bDirty = TRUE;

    if (m_pPageSite)
        m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
}

//
// SetClean
//
// Sets m_hrDirtyFlag and notifies the property page site of the change
//
void CDVBTeletextSubtitlesPropertiesPage1::SetClean()
{
    m_bDirty = FALSE;

    if (m_pPageSite)
        m_pPageSite->OnStatusChange(PROPPAGESTATUS_CLEAN);

}


//
// OnReceiveMessage
//
// Override CBasePropertyPage method.
// Handles the messages for our property window
//
INT_PTR CDVBTeletextSubtitlesPropertiesPage1::OnReceiveMessage
(
	HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
)
{
    switch (uMsg)
    {
        case WM_INITDIALOG:
        {
            return (LRESULT)1;
        }

		case WM_NOTIFY :
			{
				LPNMHDR pnmh = (LPNMHDR)lParam; 

				if 
				(
					(
						(wParam == IDC_SUBTITLE_DELAY_TIME)
						||
						(wParam == IDC_SUBTITLE_DELAY_RANGE)
					)
					&&
					(pnmh->code == NM_RELEASEDCAPTURE)
				)
				{
					HWND hwnd_subtitle_delay_time = GetDlgItem(m_hwnd, IDC_SUBTITLE_DELAY_TIME);
					m_pIDVBTeletextSubtitles->set_SubtitleDelayTime(::SendMessage(hwnd_subtitle_delay_time, TBM_GETPOS, 0, 0));

					HWND hwnd_subtitle_delay_range = GetDlgItem(m_hwnd, IDC_SUBTITLE_DELAY_RANGE);
					m_pIDVBTeletextSubtitles->set_SubtitleDelayRange(::SendMessage(hwnd_subtitle_delay_range, TBM_GETPOS, 0, 0));

					m_pIDVBTeletextSubtitles->RefreshDisplay();
				}
			}
			break;

        case WM_COMMAND:
        {
            if ((HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == CBN_SELCHANGE))
			{
				SetDirty();
			}

			if (HIWORD(wParam) == BN_CLICKED)
			{
				switch (LOWORD(wParam))
				{
				case IDC_TRANSPARENT :
				case IDC_OPAQUE :
					m_pIDVBTeletextSubtitles->set_TextMode(LOWORD(wParam) == IDC_OPAQUE);
					SetDirty();
					break;

                case IDC_HEADING_LINE :
					m_pIDVBTeletextSubtitles->set_DisplayHeadingLine(SendMessage(GetDlgItem(m_hwnd, IDC_HEADING_LINE), BM_GETCHECK, 0, 0) == BST_CHECKED);
					SetDirty();
					break;

				case IDC_READ_FILE :
					{
						OnApplyChanges();

                        CComBSTR file;
                        m_pIDVBTeletextSubtitles->get_File(&file);
						CComBSTR wfile_path = file;
						m_pIDVBTeletextSubtitles->ReadTeletextTransportStreamFile(wfile_path);
						OnActivate();
					}
					break;

				case IDC_BACKGROUND_COLOUR :
                case IDC_BLACK_COLOUR :
                case IDC_RED_COLOUR :
                case IDC_GREEN_COLOUR :
                case IDC_YELLOW_COLOUR :
                case IDC_BLUE_COLOUR :
                case IDC_MAGENTA_COLOUR :
                case IDC_CYAN_COLOUR :
                case IDC_WHITE_COLOUR :
						SetColour((colour_types)(Colour_Background + LOWORD(wParam) - IDC_BACKGROUND_COLOUR));
					break;

				case IDC_KEY_COLOUR :
					SetColour(Colour_Key);
					break;

				}
			}

            if ((HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) == IDC_SUBTITLES_PAGE))
            {
                OnSelChangeSubtitlesPage();
            }

            if ((HIWORD(wParam) == CBN_SELCHANGE) && (LOWORD(wParam) == IDC_SUBTITLES_SUBPAGE))
            {
                OnSelChangeSubtitlesSubPage();
            }

            return (LRESULT)1;
        }
    }

    return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
}

void
CDVBTeletextSubtitlesPropertiesPage1::SetColour(colour_types colour_index)
{
	CHOOSECOLOR choose_colour;
	memset(&choose_colour, 0, sizeof(choose_colour));
	choose_colour.lStructSize = sizeof(choose_colour);

	m_pIDVBTeletextSubtitles->get_Colour(colour_index, (LONG*)&choose_colour.rgbResult);
	choose_colour.hwndOwner = m_hwnd;

	COLORREF defaults[16] = {0};
	defaults[0] = RGB(0, 0, 0);
	defaults[1] = RGB(0, 0, 16);
	defaults[2] = RGB(0, 16, 0);
	defaults[3] = RGB(0, 16, 16);
	defaults[4] = RGB(16, 0, 0);
	defaults[5] = RGB(16, 0, 16);
	defaults[6] = RGB(16, 16, 0);
	defaults[7] = RGB(16, 16, 16);
	defaults[8] = RGB(0, 0, 0);
	defaults[9] = RGB(0, 0, 32);
	defaults[10] = RGB(0, 32, 0);
	defaults[11] = RGB(0, 32, 32);
	defaults[12] = RGB(32, 0, 0);
	defaults[13] = RGB(32, 0, 32);
	defaults[14] = RGB(32, 32, 0);
	defaults[15] = RGB(32, 32, 32);

	choose_colour.lpCustColors = defaults;

	choose_colour.Flags = CC_RGBINIT | CC_SOLIDCOLOR;

	if (ChooseColor(&choose_colour))
	{
		m_pIDVBTeletextSubtitles->set_Colour(colour_index, choose_colour.rgbResult);
		m_pIDVBTeletextSubtitles->RefreshDisplay();
	}
}


//
// OnConnect
//
// Override CBasePropertyPage method.
// Notification of which object this property page should display.
// We query the object for the INullIPP interface.
//
// If cObjects == 0 then we must release the interface.
// Set the member variable m_pPin to the upstream output pin connected
// to our input pin (or NULL if not connected).
//
HRESULT
CDVBTeletextSubtitlesPropertiesPage1::OnConnect(IUnknown *pUnknown)
{
    ASSERT(m_pIDVBTeletextSubtitles == NULL);
    CheckPointer(pUnknown,E_POINTER);

	m_pIDVBTeletextSubtitles = pUnknown;
    if (m_pIDVBTeletextSubtitles == NULL)
    {
        return E_NOINTERFACE;
    }

    ASSERT(m_pIDVBTeletextSubtitles);
    ASSERT(!m_pPin);

    // return (m_pIDVBTeletextSubtitles->get_IPin(&m_pPin));
	return S_OK;

} // OnConnect

//
// OnDisconnect
//
// Override CBasePropertyPage method.
// Release the private interface, release the upstream pin.
//
HRESULT CDVBTeletextSubtitlesPropertiesPage1::OnDisconnect()
{
    // Release of Interface

    if (m_pIDVBTeletextSubtitles == NULL)
        return E_UNEXPECTED;

	m_pIDVBTeletextSubtitles.Release();

    //
    // Release the pin interface that we are holding.
    //
    if (m_pPin)
    {
        m_pPin.Release();
    }

    return NOERROR;

} // OnDisconnect


//
// Activate
//
// We are being activated
//
HRESULT CDVBTeletextSubtitlesPropertiesPage1::OnActivate()
{
	long teletext_pid;
	HRESULT hr = m_pIDVBTeletextSubtitles->get_TeletextPid(&teletext_pid);
	if (!SUCCEEDED(hr))
	{
		return hr;
	}

	CComboBox combo = GetDlgItem(m_hwnd, IDC_TELETEXT_PID);
	combo.ResetContent();

	CComPtr<IEnumPIDMap> enum_map;
	hr = m_pIDVBTeletextSubtitles->get_InputPidMap(&enum_map);
	if (SUCCEEDED(hr))
	{
	    enum_map->Reset();

	    PID_MAP pid_map;
	    ULONG received = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -