📄 freebusycallrecorddisplayitem.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include "FreeBusyCallRecordDisplayItem.h"
#include "Resource.h"
#include "InfoApp.hpp"
#include "Common.hpp"
#include "PaintHelper.hpp"
#include "Layout.hpp"
const UINT c_siPhoneNumber = 4;
const UINT c_siStartDate = 5;
const UINT c_siDuration = 6;
CFreeBusyCallRecordDisplayItem::CFreeBusyCallRecordDisplayItem(
IVoIPCallRecord * piRecord
)
{
ASSERT(piRecord);
m_cpCallRecord = piRecord;
}
CFreeBusyCallRecordDisplayItem::~CFreeBusyCallRecordDisplayItem()
{
}
BOOL CFreeBusyCallRecordDisplayItem::GetHeight(
UINT * pfHeight
)
{
PREFAST_ASSERT(pfHeight);
*pfHeight = HasFreeBusyData() ?
(Layout_t::FreeBusyItemHeight() + Layout_t::FreeBusyCallRecordExtraHeight()) :
(Layout_t::FreeBusyItemHeight());
return TRUE;
}
HRESULT CFreeBusyCallRecordDisplayItem::DrawMain(
HDC hdc,
const RECT * prc
)
{
PREFAST_ASSERT(prc);
RECT rcDraw = *prc;
HRESULT hr = S_OK;
if (m_cpCallRecord == NULL)
{
ASSERT(FALSE);
return E_INVALIDARG;
}
hr = DrawCallLogDetail(hdc, &rcDraw);
if (SUCCEEDED(hr))
{
rcDraw.top += Layout_t::FreeBusyCallRecordExtraHeight();
hr = CFreeBusyDisplayItem::DrawMain(hdc, &rcDraw);
}
return hr;
}
HRESULT CFreeBusyCallRecordDisplayItem::DrawCallLogDetail(
HDC hdc,
const RECT *prc
)
{
PREFAST_ASSERT(prc);
HRESULT hr = S_OK;
RECT rcDraw = *prc;
WCHAR wszBuffer[MAX_PATH] = L"";
PaintHelper_t paint;
hr = paint.Attach(hdc);
if (FAILED(hr))
{
ASSERT(FALSE);
return hr;
}
paint.SetFont(PHGetFont(phfInformationText));
rcDraw.top += Layout_t::FreeBusyCallRecordExtraHeight();
rcDraw.left += Layout_t::FreeBusyMarginWidth();
UINT c_rgSubitemsToDraw[] =
{
c_siPhoneNumber,
c_siStartDate,
c_siDuration
};
for (INT i = 0; i < _countof(c_rgSubitemsToDraw); i++)
{
wszBuffer[0] = 0;
GetSubItemText(c_rgSubitemsToDraw[i], wszBuffer, _countof(wszBuffer));
if (wszBuffer[0])
{
hr = paint.DrawText(
wszBuffer,
-1,
&rcDraw,
DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS
);
ASSERT(SUCCEEDED(hr));
}
rcDraw.top += Layout_t::FreeBusyCallRecordExtraOffset();
}
paint.End();
return hr;
}
HRESULT CFreeBusyCallRecordDisplayItem::GetText(
WCHAR * wszBuffer,
INT cchBuffer
)
{
PREFAST_ASSERT(wszBuffer);
//Get text on this item means get the uri to dial
ce::auto_bstr bstrUri;
HRESULT hr = S_OK;
wszBuffer[0] = 0;
hr = m_cpCallRecord->get_URI(&bstrUri);
if (SUCCEEDED(hr))
{
StringCchCopy(
wszBuffer,
cchBuffer,
bstrUri
);
}
return hr;
}
HRESULT CFreeBusyCallRecordDisplayItem::GetSubItemText(
int idxSubItem,
WCHAR * wszBuffer,
UINT cchBuffer
)
{
PREFAST_ASSERT(wszBuffer);
HRESULT hr = S_OK;
WCHAR wszFormat[MAX_PATH] = L"";
const WCHAR *c_wszResString = NULL;
SYSTEMTIME st = {0};
wszBuffer[0] = 0;
ce::auto_bstr bstrUri;
VoIPCallType vctType = e_vctInvalid;
switch (idxSubItem)
{
case CFreeBusyDisplayItem::c_siDisplayName :
case CFreeBusyDisplayItem::c_siFreeBusyStatus:
case CFreeBusyDisplayItem::c_siFreeBusyData :
case CFreeBusyDisplayItem::c_siBoundaries :
return CFreeBusyDisplayItem::GetSubItemText(idxSubItem, wszBuffer, cchBuffer);
case c_siPhoneNumber:
hr = m_cpCallRecord->get_URI(&bstrUri);
if (FAILED(hr))
{
return hr;
}
hr = StringCchCopy(
wszFormat,
_countof(wszFormat),
bstrUri
);
if (FAILED(hr))
{
return hr;
}
hr = m_cpCallRecord->get_CallType(&vctType);
if (FAILED(hr))
{
return hr;
}
switch (vctType)
{
case e_vctOutgoing:
c_wszResString = CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_FMT_CALLRECORD_CALLEDTO);
break;
case e_vctIncoming:
case e_vctMissed:
c_wszResString = CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_FMT_CALLRECORD_CALLEDFROM);
break;
default:
ASSERT(FALSE);
return E_INVALIDARG;
break;
}
if (!c_wszResString)
{
ASSERT(FALSE);
return E_FAIL;
}
StringCchPrintf(
wszBuffer,
cchBuffer,
c_wszResString,
wszFormat
);
break;
case c_siStartDate:
c_wszResString = CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_FMT_CALLRECORD_START);
if (! c_wszResString)
{
ASSERT(FALSE);
return E_FAIL;
}
//get the starting time time
hr = m_cpCallRecord->get_StartTime(&st);
if (FAILED(hr))
{
return hr;
}
//Store the start time (H:M:S) to the out buffer
hr = CommonUtilities_t::ToHR(GetDateFormat(
LOCALE_SYSTEM_DEFAULT,
DATE_SHORTDATE,
&st,
NULL,
wszFormat,
MAX_PATH
));
if (FAILED(hr))
{
return hr;
}
StringCchPrintf(
wszBuffer,
cchBuffer,
c_wszResString,
wszFormat
);
break;
case c_siDuration:
c_wszResString = CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_FMT_CALLRECORD_DURATION);
if (c_wszResString == NULL)
{
ASSERT(FALSE);
return E_FAIL;
}
hr = m_cpCallRecord->get_StartTime(&st);
//Fill in the out buffer with the duration
hr = CommonUtilities_t::ToHR(GetTimeFormat(
LOCALE_SYSTEM_DEFAULT,
TIME_NOSECONDS,
&st,
NULL,
wszFormat,
MAX_PATH
));
if (FAILED(hr))
{
return hr;
}
StringCchPrintf(
wszBuffer,
cchBuffer,
c_wszResString,
wszFormat
);
break;
default:
hr = S_FALSE;
break;
}
return hr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -