示例#1
0
BOOL CWindowsMetaFileControl::Unpack(void)
{
	CString csText;

	BOOL fResult = TRUE;

	TRY
	{
		if (!m_fUnpacked)
		{
			fResult = FALSE;

#ifdef USEWMF
			delete m_pMetaFile;
			m_pMetaFile = NULL;
#endif

			GetWindowText(csText);

			CMlsPropertyString Properties;

			Properties.SetProperties(csText);

			if (CollectAlignmentFlags(Properties, m_nAlignmentFlags))
			{
				if (CollectType(Properties, m_nType))
				{
					switch (m_nType)
					{
						case TYPE_SHAPE:
						{
							// Collect Shape Type

							if (CollectShape(Properties, m_nShape))
							{
								// Collect Shape Color

								if (Properties.AsColor(3, m_clShapeColor))
								{
									m_nStrokeWidth = 0;
									m_clStrokeColor = m_clShapeColor;
									m_fShapeShadow = FALSE;

								/*
								// We want to be able to allow blank (default) propeties.
								// So you could say "|black|||green|" to get a black
								// object with a green shadow.
								*/
									int nCount = Properties.Count();
									if (nCount > 4)
									{
										Properties.AsColor(4, m_clStrokeColor, m_clStrokeColor);
										Properties.AsInt(5, m_nStrokeWidth, 1);
										m_fShapeShadow = Properties.AsColor(6, m_clShapeShadowColor);
									}

									fResult = TRUE;
								}
							}

							break;
						}

						case TYPE_WMF:
						{
#ifdef USEWMF
							// Collect WMF Resource Name

							if (CollectName(Properties, m_csResourceName))
							{
								if (!m_csResourceName.IsEmpty())
								{
									m_pMetaFile = new CWindowsMetaFile;
									ASSERT(m_pMetaFile != NULL);

									if (m_pMetaFile != NULL)
									{
										if (m_pMetaFile->Init(AfxGetResourceHandle(), m_csResourceName, "METAFILE"))
										{
											fResult = TRUE;
										}
									}

								}
							}
#else
							// Needs #define USEWMF!
							ASSERT(FALSE);
#endif

							break;
						}

						case TYPE_BMP:
						{
							// Collect BMP Resource Name

							if (CollectName(Properties, m_csResourceName))
							{
								fResult = TRUE;
							}

							break;
						}

						default:
						{
							ASSERT(FALSE);
							break;
						}
					}
				}
			}
		}
	}
	CATCH_ALL(e)
	{
		fResult = FALSE;
	}
	END_CATCH_ALL

	m_fUnpacked = fResult;

	return fResult;
}
示例#2
0
BOOL CWindowsMetaFileControl::Unpack(void)
{
	CString csText;
	
	BOOL fResult = TRUE;
	
	TRY
	{
		if (!m_fUnpacked)
		{
			fResult = FALSE;
			
			delete m_pMetaFile;
			m_pMetaFile = NULL;
			
			GetWindowText(csText);
			
			if (CollectAlignmentFlags(csText, m_nAlignmentFlags))
			{
				if (CollectType(csText, m_nType))
				{
					switch (m_nType)
					{
						case TYPE_SHAPE:
						{
							// Collect Shape Type
							
							if (CollectShape(csText, m_nShape))
							{
								// Collect Shape Color
								
								if (CollectColor(csText, m_clShapeColor))
								{
									m_fShapeShadow = CollectColor(csText, m_clShapeShadowColor, FALSE);
									
									fResult = TRUE;
								}
							}
								
							break;
						}
						
						case TYPE_WMF:
						{
							// Collect WMF Resource Name
							
							if (CollectName(csText, m_csResourceName))
							{
								if (!m_csResourceName.IsEmpty())
								{
									m_pMetaFile = new CWindowsMetaFile;
									ASSERT(m_pMetaFile != NULL);
									
									if (m_pMetaFile != NULL)
									{
										if (m_pMetaFile->Init(AfxGetResourceHandle(), m_csResourceName, "METAFILE"))
										{
											fResult = TRUE;
										}
									}
								
								}
							}
							
							break;
						}
						
						case TYPE_BMP:
						{
							// Collect BMP Resource Name
							
							if (CollectName(csText, m_csResourceName))
							{
								fResult = TRUE;
							}
							
							break;
						}
						
						default:
						{
							ASSERT(FALSE);
							break;
						}
					}
				}
			}
		}
	}
	CATCH_ALL(e)
	{
		fResult = FALSE;
	}
	END_CATCH_ALL
	
	m_fUnpacked = fResult;
	
	return fResult;
}