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

📄 configselect.cpp

📁 完整的基于Conxant平台的USB电视棒的WIN驱动程序。
💻 CPP
字号:
/*+++ *******************************************************************\ 
* 
*  Copyright and Disclaimer: 
*  
*     --------------------------------------------------------------- 
*     This software is provided "AS IS" without warranty of any kind, 
*     either expressed or implied, including but not limited to the 
*     implied warranties of noninfringement, merchantability and/or 
*     fitness for a particular purpose.
*     --------------------------------------------------------------- 
*   
*     Copyright (c) 2008 Conexant Systems, Inc. 
*     All rights reserved. 
*
\******************************************************************* ---*/ 

//Ignore warnings for deprecated functions used in DXSDK headers
#pragma warning(disable : 4996)
#include <streams.h>
#pragma warning(default : 4996)
#include <stdio.h>
#include <commctrl.h>
#include "resource.h"    // ids used in the dialog
#include <ks.h>
#include <ksmedia.h>     //DDK include file
#include <ksproxy.h>

#include "Configselect.h"
#include "..\inc\CxPolarisControl.h"

typedef enum
{
    CONFIG0 = 0,
    CONFIG1 = 1,
    CONFIG2 = 2
}USB_CONFIG;

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

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

//**********************************************************************
// AudioPin::Constructor
// Constructs and initialises a AudioPin object
//**********************************************************************
Configselect::Configselect(LPUNKNOWN pUnk, HRESULT *phr)
    : CBasePropertyPage(
        NAME("Configuration Select Property"),
        pUnk,
        IDD_CONFIG_SELECT,           //Dialog ID
        IDS_CONFIG_SELECT_TITLE),
        _p_property_set(NULL)
{
    ASSERT(phr);

} // (constructor) CGeneralProperties

//**********************************************************************
// OnConnect
// Override CBasePropertyPage method.
//**********************************************************************
HRESULT Configselect::OnConnect(IUnknown *p_unknown)
{
    // For the proxy, we query the interface on it's output pin
    ASSERT(_p_property_set == NULL);
    
    // Cast our owner to a filter (our owner should be the proxy filter)
    IBaseFilter *p_filter = (IBaseFilter*)p_unknown;
    // Query the proxy filter for the interface that allows us to control the iVAC
    if (FAILED(p_filter->QueryInterface(IID_IKsPropertySet,(void **)&_p_property_set)))
    {
        DbgLog((LOG_TRACE, 0, TEXT("Failed to Query the proxy's interface")));
        return E_NOINTERFACE;
    }
    
    return NOERROR;
} // OnConnect



HRESULT Configselect::OnDisconnect()
{
    // Release of Interface
    if (_p_property_set == NULL)
        return E_UNEXPECTED;
    
    _p_property_set->Release();
    _p_property_set = NULL;
    
    return NOERROR;
} // OnDisconnect


HRESULT Configselect::OnActivate()
{
    HRESULT return_value = NOERROR;
     DWORD bytes_returned;

    //Get the current USB config from the driver
    CXPOLARIS_USB_CONFIG usb_cofig = CXPOLARIS_USB_CONFIG0;
    if (FAILED(_p_property_set->Get(
        PROPSETID_CXPOLARIS_CONTROL_USB_CONFIG_PROPERTIES, 
        CXPOLARIS_USB_COFIG_CONTROL, 
        &usb_cofig, 
        sizeof(CXPOLARIS_USB_CONFIG),
        &usb_cofig, 
        sizeof(CXPOLARIS_USB_CONFIG),
        &bytes_returned)))
    {
        return_value = E_FAIL;
    }
    
    
    USB_CONFIG usb_cofig2 = CONFIG0;
    switch(usb_cofig)
    {
    case CXPOLARIS_USB_CONFIG0:
        usb_cofig2 = CONFIG0;
        break;
        
    case CXPOLARIS_USB_CONFIG1:
        usb_cofig2 = CONFIG1;
        break;
        
     case CXPOLARIS_USB_CONFIG2:
        usb_cofig2 = CONFIG2;
        break;
     
    }
        
    //Select the current config in the list box
    SendDlgItemMessage(m_Dlg, IDC_CONFIGSELECT, CB_SETCURSEL, usb_cofig2, 0);

    
    return S_OK; 
} // Activate


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

        case WM_COMMAND:
        {
            switch(HIWORD(wParam))
            {
    
            case LBN_SELCHANGE:
            case EN_CHANGE:     //Edit box change    
                SetDirty();
                break;
            default:
                return (LRESULT) 1;
            }
        }
    }

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

} // OnReceiveMessage

void Configselect::SetDirty()
{
    m_bDirty = TRUE;
    if (m_pPageSite)
    {
        m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
    }

} // SetDirty

HRESULT Configselect::OnApplyChanges()
{
    HRESULT return_value = NOERROR;

    //Get the current selection from the dialog	
    USB_CONFIG usb_cofig2 = (USB_CONFIG)SendDlgItemMessage(m_Dlg, IDC_CONFIGSELECT, CB_GETCURSEL, 0, 0);
    
    
    CXPOLARIS_USB_CONFIG usb_cofig = CXPOLARIS_USB_CONFIG0; 
    
    switch(usb_cofig2)
    {
    case CONFIG0:
        usb_cofig = CXPOLARIS_USB_CONFIG0;
        break;
    case CONFIG1:
        usb_cofig = CXPOLARIS_USB_CONFIG1;
        break;
    case CONFIG2:
        usb_cofig = CXPOLARIS_USB_CONFIG2;
        break;
    
    }
    
    //Set the value
    if (FAILED(_p_property_set->Set(
        PROPSETID_CXPOLARIS_CONTROL_USB_CONFIG_PROPERTIES, 
        CXPOLARIS_USB_COFIG_CONTROL,  
        &usb_cofig, 
        sizeof(CXPOLARIS_USB_CONFIG), 
        &usb_cofig, 
        sizeof(CXPOLARIS_USB_CONFIG))))
    {
        return_value = E_FAIL;
    }

/////////////////////////////////////////////////////////////////////////////////
    m_bDirty = FALSE;  // the page is now clean

    return return_value;
}

void Configselect::FillListBox()
{
    TCHAR szBuffer[200];
    //Fill the configuration select list box

    int i;
    for (i = IDS_CONFIG0; i <= IDS_CONFIG2; i++)
    {
        LoadString(g_hInst, i, szBuffer, 200);
        SendDlgItemMessage(
            m_Dlg, 
            IDC_CONFIGSELECT, 
            CB_INSERTSTRING, 
            -1, 
            (LPARAM)szBuffer);
    }

}
//////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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