Esempio n. 1
0
//*****************************************************************************************
void CFontItem::OnClickButton (CPoint /*point*/)
{
	CBCGPGridCtrl* pGridCtrl = GetOwnerList();
	ASSERT_VALID (pGridCtrl);

	ASSERT_VALID (this);
	ASSERT_VALID (m_pWndInPlace);
	ASSERT (::IsWindow (m_pWndInPlace->GetSafeHwnd ()));

	m_bButtonIsDown = TRUE;
	Redraw ();

	CFontDialog dlg (&m_lf);

	if (m_Color != (COLORREF)-1)
	{
		dlg.m_cf.rgbColors = m_Color;
	}

	if (dlg.DoModal () == IDOK)
	{
		dlg.GetCurrentFont (&m_lf);
		m_Color = dlg.GetColor ();

		if (m_pWndInPlace != NULL)
		{
			m_pWndInPlace->SetWindowText (FormatProperty ());
		}
		else
		{
			m_varValue = (LPCTSTR) FormatProperty ();
		}
	}

	if (m_pWndInPlace != NULL)
	{
		m_pWndInPlace->SetFocus ();
	}
	else
	{
		pGridCtrl->SetFocus ();
	}

	m_bButtonIsDown = FALSE;
	Redraw ();
}
Esempio n. 2
0
void CMyBCGPProp::GetResultShort(CString& strValue)
{
	if (m_lstShortOptions.GetCount() == 0)
	{
		return;
	}

	CString strShort;
	if (IsList())
	{
		POSITION pos = m_lstShortOptions.FindIndex(GetSelectedOption());
		if (pos == NULL)
		{
			ASSERT(FALSE);
			return;
		}

		strShort = m_lstShortOptions.GetAt(pos);
	}
	else
	{
		strShort = m_lstShortOptions.GetHead();
	}

	if (!strShort.IsEmpty())
	{
		CString strFormatProperty = FormatProperty();
		if (IsText())
		{
			if (!strFormatProperty.IsEmpty())
			{
				strValue += STR_SHORT_PREFIX + strShort + STR_SHORT_TEXT_FALG + strFormatProperty;
			}
		} 
		else
		{
			strValue += STR_SHORT_PREFIX + strShort
				+ (IsList() ? _T("") : FormatProperty());
		}

		if (m_pBuddyProp)
		{
			strValue += m_pBuddyProp->FormatProperty();
		}
	}
}
Esempio n. 3
0
FormatProperty ItemFormat::getPropertyByHeader( quint8 header ) const
{
	for( FormatPropertyVector::const_iterator it = properties.begin(); it != properties.end(); it++ )
	{
		FormatProperty itemProperty = (*it);
		if( itemProperty.header == header )
			return itemProperty;
	}

	return FormatProperty();
}
Esempio n. 4
0
FormatProperty ItemFormat::getPropertyByBase( quint8 base ) const
{
	for( FormatPropertyVector::const_iterator it = properties.begin(); it != properties.end(); it++ )
	{
		FormatProperty itemProperty = (*it);
		if( itemProperty.base == base )
			return itemProperty;
	}

	return FormatProperty();
}
Esempio n. 5
0
static std::string GenerateProperties(const Item &item) {
    std::string text;
    bool first = true;
    for (auto &property : item.text_properties()) {
        if (!first)
            text += "<br>";
        first = false;
        text += FormatProperty(property);
    }

    return text;
}
Esempio n. 6
0
BOOL CBoundedNumberSubProp::OnUpdateValue()
{
	ASSERT_VALID(this);
	ASSERT_VALID(m_pWndInPlace);
	ASSERT_VALID(m_pWndList);
	ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd()));

	BOOL bRet = TRUE;
	CString strText;
	m_pWndInPlace->GetWindowText(strText);

	BOOL bIsChanged = FormatProperty() != strText;
	if (bIsChanged)
	{
		int nItem = _ttoi(strText);
		if ((nItem < m_nMinValue) || (nItem > m_nMaxValue))
		{
			static BOOL bRecursedHere = FALSE;
			if (bRecursedHere)
				return TRUE;
			bRecursedHere = TRUE;

			CString strMessage;
			strMessage.Format(_T("Value must be between %d and %d."), m_nMinValue, m_nMaxValue);
			AfxMessageBox(strMessage);

			bRecursedHere = FALSE;
			return FALSE;
		}

		bRet = CMFCPropertyGridProperty::OnUpdateValue();

		if (m_pParent != NULL)
		{
			m_pWndList->OnPropertyChanged(m_pParent);
		}
	}

	return bRet;
}
ULONG
DumpSimpleType(
    __in PEVENT_RECORD Event,
    __in PTRACE_EVENT_INFO EventInfo,
    __in PEVENT_PROPERTY_INFO Property,
    __in USHORT PropertyIndex,
    __inout PPROCESSING_CONTEXT LogContext
)

/*++

Routine Description:

    This routine iterates over each property member in the
    simple property and passes it to the property formatting
    function FormatProperty().  In case of single simple types,
    only one iteration is performed.

Arguments:

    Event - Supplies the structure representing an event.

    EventInfo - Supplies the event meta-information.

    Property - Supplies the property information about the simple property
               to be decoded.

    PropertyIndex - Supplies the index of the property to be decoded.

    LogContext - Supplies the structure that persists contextual information
                 across callbacks.

Return Value:

    ERROR_SUCCESS - Success.

    Win32 error code - Failure in obtaining the resulting map association for the property
                       or in formatting the property data.

--*/

{
    ULONG Status = ERROR_SUCCESS;
    PEVENT_MAP_INFO EventMapInfo = NULL;
    USHORT ArrayCount;
    USHORT PropertyLength;
    USHORT InType = Property->nonStructType.InType;
    USHORT OutType = Property->nonStructType.OutType;
    PPROCESSING_DATA_CONTEXT DataContext = &LogContext->DataContext;
    PBYTE Data = (PBYTE)Event->UserData + DataContext->UserDataOffset;

    //
    // Get the number of property elements. In the case where the property
    // is an array, the number of array members is stored in ArrayCount;
    // otherwise ArrayCount = 1.
    //

    ArrayCount = GetArrayCount(Property, DataContext->ReferenceValues);

    //
    // There are two special cases where the ArrayCount is equivalent to
    // the PropertyLength.
    //

    if (((InType == TDH_INTYPE_UNICODECHAR) || (InType == TDH_INTYPE_ANSICHAR)) &&
            (OutType == TDH_OUTTYPE_STRING)) {

        PropertyLength = ArrayCount;
        ArrayCount = 1;

    } else {

        PropertyLength = GetPropertyLength(Property, DataContext->ReferenceValues);
    }

    Status = CheckForMap(Event, EventInfo, Property, LogContext, &EventMapInfo);
    if (Status != ERROR_SUCCESS) {
        return Status;
    }

    //
    // Iterate through each member of the array represented by the simple property.
    // In the case of a simple single property, just format its data (ArrayCount = 1).
    //

    for (USHORT Counter = 0; Counter < ArrayCount; Counter++) {

        Status = FormatProperty(Event,
                                EventInfo,
                                EventMapInfo,
                                Property,
                                PropertyLength,
                                PropertyIndex,
                                LogContext);

        if (Status != ERROR_SUCCESS) {
            return Status;
        }

        //
        // The formatted property value is stored in DataContext->Buffer.
        //

        if (ArrayCount > 1) {
            VPrintFToFile(FALSE, LogContext,
                          L"\r\n\t\t<Data Name=\"%s[%d]\">%s</Data>",
                          TEI_PROPERTY_NAME(EventInfo, Property),
                          Counter,
                          (PWSTR)DataContext->Buffer);
        } else {
            VPrintFToFile(FALSE, LogContext,
                          L"\r\n\t\t<Data Name=\"%s\">%s</Data>",
                          TEI_PROPERTY_NAME(EventInfo, Property),
                          (PWSTR)DataContext->Buffer);
        }
    }


    if (ArrayCount == 1) {

        //
        // This is single simple single type (not an array), with the value stored
        // in the Data variable (computed in FormatProperty). As it may be
        // referenced later, as some property length or array count, it should be cached
        // for eventual further useage.
        //

        SaveReferenceValues(Property, PropertyIndex, Data, DataContext);
    }

    return Status;
}
ULONG
FormatProperty(
    __in PEVENT_RECORD Event,
    __in PTRACE_EVENT_INFO EventInfo,
    __in_opt PEVENT_MAP_INFO EventMapInfo,
    __in PEVENT_PROPERTY_INFO Property,
    __in USHORT PropertyLength,
    __in ULONG PropertyIndex,
    __inout PPROCESSING_CONTEXT LogContext
)

/*++

Routine Description:

    This routine prepares the formatting of the raw byte data contained
    in the property buffer. First, the offset from Event->UserData is calculated.
    Then the data in that offset is passed for concrete formatting in
    GetFormattedBuffer() or FormatMapToString(). These methods return the
    formatted  buffer and the amount of binary data consumed and use the amount
    of data consumed to advance the current data offset.

Arguments:

    Event - Supplies the structure representing an event.

    EventInfo - Supplies the event meta-information.

    Property - Supplies the property information about the simple property
               to be decoded.

    PropertyLength - Supplies the length of the simple property to be decoded.

    PropertyIndex - Supplies the index of the property to be decoded.

    LogContext - Supplies the structure that persists contextual information
                 across callbacks.

Return Value:

    ERROR_SUCCESS - Success

    Win32 error code - Formatting the property data failed.

--*/

{
    ULONG Status = ERROR_SUCCESS;
    PPROCESSING_DATA_CONTEXT DataContext = &LogContext->DataContext;
    ULONG BufferSize = DataContext->BufferSize;
    USHORT PointerSize;
    ULONG DataLeft;
    FPTR_TDH_FORMATPROPERTY TdhFormatPropertyPtr = NULL;

    DataContext->BinDataLeft = Event->UserDataLength - DataContext->UserDataOffset;
    PBYTE Data = (PBYTE)Event->UserData + DataContext->UserDataOffset;

    //
    // If no more data, just fill the buffer with one non-printable UNICODE_NULL.
    //

    if (DataContext->BinDataLeft == 0) {
        Status = NullToBuffer(DataContext->Buffer, DataContext->BufferSize, &DataContext->BinDataConsumed);
        if (Status == ERROR_SUCCESS) {
            UpdateRenderItem(DataContext);
        }
        return Status;
    }

    //
    // Get the pointer size on the machine where the event was fired.
    // Will be needed later when decoding certain types of properies.
    //

    if ((Event->EventHeader.Flags & EVENT_HEADER_FLAG_64_BIT_HEADER) != 0) {
        PointerSize = sizeof(ULONGLONG);
    } else if ((Event->EventHeader.Flags & EVENT_HEADER_FLAG_32_BIT_HEADER) != 0) {
        PointerSize = sizeof(ULONG);
    } else {
        PointerSize = (USHORT)LogContext->PointerSize;
    }

    do {

        if (Status == ERROR_INSUFFICIENT_BUFFER) {

            Status = ResizeBuffer(&DataContext->Buffer,
                                  &DataContext->BufferSize,
                                  ((DataContext->BufferSize / MIN_PROP_BUFFERSIZE) + 1) * MIN_PROP_BUFFERSIZE);

            if (Status != ERROR_SUCCESS) {
                return Status;
            }
        }

        //
        // Check if the Windows 7 TDH API routine, TdhFormatProperty(), is avaliable.
        //

        if ((LogContext->TdhDllHandle != NULL)) {
            TdhFormatPropertyPtr = LogContext->FormatPropertyPtr;
        }

        if (TdhFormatPropertyPtr != NULL) {

            //
            // The decoding process is on Windows 7 or later. In Windows 7, the TDH API
            // is updated with several new functions. One of them is TdhFormatProperty, which
            // deals with all valid TDH InTypes and OutTypes, and formats them properly.
            // In order to get the sample to compile on both Vista and Windows 7, load the
            // TdhFormatProperty() dynamically.
            //

            Status = (*TdhFormatPropertyPtr)(EventInfo,
                                             EventMapInfo,
                                             PointerSize,
                                             Property->nonStructType.InType,
                                             Property->nonStructType.OutType,
                                             PropertyLength,
                                             DataContext->BinDataLeft,
                                             Data,
                                             &BufferSize,
                                             (PWSTR)DataContext->Buffer,
                                             &DataContext->BinDataConsumed);

        } else {

            //
            // The operating system is prior to Windows 7. The formatting for each
            // InType and OutType property must be handled manually.
            //

            if (EventMapInfo == NULL) {

                //
                // This property has no map associated with it.  Directly pass the buffer
                // referenced by the current offset for formatting to GetFormattedBuffer().
                // According to the in- and out-types of the property, proper formatting will
                // be performed.
                //

                Status = GetFormattedBuffer(Data,
                                            DataContext->BinDataLeft,
                                            PropertyLength,
                                            PointerSize,
                                            Property->nonStructType.InType,
                                            Property->nonStructType.OutType,
                                            DataContext->Buffer,
                                            DataContext->BufferSize,
                                            &DataContext->BinDataConsumed);
            } else {

                //
                // This property has map associated with it. The map key value is
                // in the Data buffer pointed by the property. It is a number pointing to
                // some resource. GetFormattedMapValue() will find and format both the key
                // and its resource value and will return the formatted value as result.
                //

                Status = GetFormattedMapValue(Data,
                                              DataContext->BinDataLeft,
                                              EventMapInfo,
                                              Property->nonStructType.InType,
                                              DataContext->Buffer,
                                              DataContext->BufferSize,
                                              &DataContext->BinDataConsumed);
            }
        }

    } while (Status == ERROR_INSUFFICIENT_BUFFER);

    if (Status == ERROR_EVT_INVALID_EVENT_DATA) {

        //
        // There can be cases when the string represented by the buffer Data, is
        // not aligned with the event payload (i.e. it is longer than the actual data left).
        // Just copy and format the last DataContext->BinDataLeft bytes from the payload.
        //

        if (Property->nonStructType.InType == TDH_INTYPE_UNICODESTRING) {
            DataLeft = DataContext->BinDataLeft;
            if (DataContext->BufferSize < DataLeft) {
                Status = ResizeBuffer(&DataContext->Buffer,
                                      &DataContext->BufferSize,
                                      ((DataContext->BufferSize / MIN_PROP_BUFFERSIZE) + 1) * MIN_PROP_BUFFERSIZE);

                if (Status != ERROR_SUCCESS) {
                    return Status;
                }
            }
            RtlCopyMemory(DataContext->Buffer, Data, DataLeft);
            DataContext->Buffer[DataLeft] = 0;
            DataContext->Buffer[DataLeft + 1] = 0;
            DataContext->BinDataConsumed = (USHORT)DataLeft;
            Status = ERROR_SUCCESS;

        } else if (Property->nonStructType.InType == TDH_INTYPE_ANSISTRING) {
            DataLeft = DataContext->BinDataLeft;
            BufferSize = (DataLeft + 1) * sizeof(WCHAR);
            if (DataContext->BufferSize < BufferSize) {

                Status = ResizeBuffer(&DataContext->Buffer,
                                      &DataContext->BufferSize,
                                      ((DataContext->BufferSize / MIN_PROP_BUFFERSIZE) + 1) * MIN_PROP_BUFFERSIZE);

                if (Status != ERROR_SUCCESS) {
                    return Status;
                }
            }

            DataContext->BinDataConsumed = (USHORT)MultiByteToWideChar(CP_ACP,
                                           0,
                                           (PSTR)Data,
                                           DataLeft,
                                           (PWSTR)DataContext->Buffer,
                                           DataLeft);

            DataLeft *= sizeof(WCHAR);
            DataContext->Buffer[DataLeft] = 0;
            DataContext->Buffer[DataLeft + 1] = 0;
            Status = ERROR_SUCCESS;

        } else if (EventMapInfo != NULL) {

            //
            // The integer key stored in Data was not matched as a valid map key entry.
            // Just try to print the formatted integer stored in Data.
            //

            Status = FormatProperty(Event,
                                    EventInfo,
                                    NULL,
                                    Property,
                                    PropertyLength,
                                    PropertyIndex,
                                    LogContext);

        }
    }

    if (Status == ERROR_SUCCESS) {
        DataContext->UserDataOffset += DataContext->BinDataConsumed;
        UpdateRenderItem(DataContext);
    }

    return Status;
}
Esempio n. 9
0
BOOL CBoundedNumberPairProp::OnUpdateValue()
{
	ASSERT_VALID(this);
	ASSERT_VALID(m_pWndInPlace);
	ASSERT_VALID(m_pWndList);
	ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd()));

	CString strText;
	m_pWndInPlace->GetWindowText(strText);

	BOOL bIsChanged = FormatProperty() != strText;

	if (bIsChanged)
	{
		CString strDelimeter(_T(","));

		for (int i = 0; !strText.IsEmpty() && i < GetSubItemsCount(); i++)
		{
			CString strItem = strText.SpanExcluding(strDelimeter);
			if (strItem.GetLength() + 1 > strText.GetLength())
			{
				strText.Empty();
			}
			else
			{
				strText = strText.Mid(strItem.GetLength() + 1);
			}
			strItem.TrimLeft();
			strItem.TrimRight();

			int nItem = _ttoi(strItem);
			if ((i == 0) && ((nItem < m_nMinValue1) || (nItem > m_nMaxValue1)))
			{
				static BOOL bRecursedHere = FALSE;
				if (bRecursedHere)
					return TRUE;
				bRecursedHere = TRUE;

				CString strMessage;
				strMessage.Format(_T("Height value must be between %d and %d."), m_nMinValue1, m_nMaxValue1);
				AfxMessageBox(strMessage);

				bRecursedHere = FALSE;
				return FALSE;
			}
			else if ((i == 1) && ((nItem < m_nMinValue2) || (nItem > m_nMaxValue2)))
			{
				static BOOL bRecursedHere = FALSE;
				if (bRecursedHere)
					return TRUE;
				bRecursedHere = TRUE;

				CString strMessage;
				strMessage.Format(_T("Width value must be between %d and %d."), m_nMinValue2, m_nMaxValue2);
				AfxMessageBox(strMessage);

				bRecursedHere = FALSE;
				return FALSE;
			}
		}

		return CMFCPropertyGridProperty::OnUpdateValue();
	}

	return TRUE;
}