【VC开源代码栏目提醒】:本文主要为网学会员提供didcfgview.cpp,希望对需要didcfgview.cpp网友有所帮助,学习一下!
//-----------------------------------------------------------------------------
// File: didcfgview.cpp
//
// Desc: Interface for retrieving and rendering DirectInput Device
// configuration view( implemenation ). Feel free to use
// this class as a starting point for adding extra functionality.
//
//
// Copyright (c) 1999-2000 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#include <d3d8.h>
#include <d3dx8tex.h>
#include <assert.h>
#include <tchar.h>
#include "didcfgview.h"
#include "dxutil.h"
//-----------------------------------------------------------------------------
// Name: DIDCfgView()
// Desc: constructor
//-----------------------------------------------------------------------------
DIDCfgView::DIDCfgView()
: m_lpViewManager( NULL ),
m_lpCalloutManager( NULL ),
m_bIsInit( FALSE ),
m_nView( DIDCV_INVALID_ID ),
m_lpDidImgHeader( NULL ),
m_lpCustomViewInfo( NULL ),
m_lpDIDevice( NULL ),
m_bCanBeCollapsed( FALSE ),
m_bIsCollapsed( FALSE ),
m_lpDiaf( NULL ),
m_crFore( RGB( 0xff, 0xff, 0xff ) ),
m_crBack( RGB( 0x0, 0x0, 0x0 ) ),
m_crHighlight( RGB( 0x33, 0x33, 0x33 ) ),
m_crHighlightLine( RGB( 0x99, 0xff, 0x0 ) ),
m_hFont( NULL )
{
_tcscpy( m_tszDefaultText, TEXT( "- - -" ) );
ZeroMemory( &m_ptOrigin, sizeof( POINT ) );
}
//-----------------------------------------------------------------------------
// Name: ~DIDCfgView()
// Desc: destructor
//-----------------------------------------------------------------------------
DIDCfgView::~DIDCfgView()
{
CleanUp();
if( m_hFont )
{
// free the font
DeleteObject( m_hFont );
m_hFont = NULL;
}
}
//-----------------------------------------------------------------------------
// Name: Init()
// Desc: initializes the DIDCfgView object with a DirectInputDevice8
// reference. upon successful completion of this functions, image
// and callout data for the device should be successfully retrieved,
// loaded, and processed, ready to be used.( ultimately, after optionally
// setting the action format, callout state, performing hit tests, etc -
// the image can be drawn by calling RenderView(). ) this Init()
// must be called successfully before anything else can be used.
//-----------------------------------------------------------------------------
HRESULT DIDCfgView::Init( LPDIRECTINPUTDEVICE8 lpDidev )
{
HRESULT hr;
// always start clean
CleanUp();
// sanity check
if( NULL == lpDidev )
{
return DIERR_INVALIDPARAM;
}
// allocate objects
hr = InitAlloc();
if( FAILED( hr ) )
{
CleanUp();
return hr;
}
// retrieve the image info from DirectInput
hr = InitImageInfoRetrieve( lpDidev );
if( FAILED( hr ) )
{
// no device image on system, let's build our own
hr = InitCustomViews( lpDidev );
if( FAILED( hr ) )
{
CleanUp();
return hr;
}
// keep a reference for custom views, since we might
// need the device to reconstruct collapsed views
m_lpDIDevice = lpDidev;
m_lpDIDevice->AddRef();
}
else
{
// process the image info from DirectInput
hr = InitImageInfoProcess();
if( FAILED( hr ) )
{
CleanUp();
return hr;
}
}
m_bIsInit = TRUE;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CleanUp()
// Desc: resets the cfgview object, freeing memory and other resources
// this method is idempotent.
//-----------------------------------------------------------------------------
VOID DIDCfgView::CleanUp()
{
m_bIsInit = FALSE;
m_nView = -1;
m_bCanBeCollapsed = FALSE;
m_bIsCollapsed = FALSE;
if( m_lpDidImgHeader )
{
// free array
SAFE_DELETE_ARRAY( m_lpDidImgHeader->lprgImageInfoArray );
// free the imginfoheader
delet
上一篇:
bdzxunit.pas
下一篇:
促进教育公平 构建和谐社会