当前位置: 首页>>代码示例>>C++>>正文


C++ Guid::CreateNew方法代码示例

本文整理汇总了C++中Guid::CreateNew方法的典型用法代码示例。如果您正苦于以下问题:C++ Guid::CreateNew方法的具体用法?C++ Guid::CreateNew怎么用?C++ Guid::CreateNew使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guid的用法示例。


在下文中一共展示了Guid::CreateNew方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FormatFilename

//tstd::tstring FormatFilename(const SYSTEMTIME& systemTime, const tstd::tstring& inputFormat,
//														 const tstd::tstring& windowTitle, bool preview, )
tstd::tstring FormatFilename(ScreenshotNamingData& namingData, bool useLocalTime, const tstd::tstring& inputFormat, bool preview)
{
	int guidIndex = 0;
	int userTextIndex = 0;

	tstd::tstringstream outputStream;

	for (tstd::tstring::size_type pos = 0; pos < inputFormat.length(); ++pos)
	{
		tstd::tchar_t currentCharacter = inputFormat[pos];

		if (currentCharacter == TEXT('%'))
		{
			tstd::tchar_t nextCharacter = inputFormat[++pos];

			switch (nextCharacter)
			{
      case 'a':
        outputStream << ((namingData.UsableTime(useLocalTime).wHour >= 12) ? _T("PM") : _T("AM"));
        break;

				case TEXT('m'):
          outputStream << Format().ui<10,2>(namingData.UsableTime(useLocalTime).wMonth).Str();
					break;
				case TEXT('M'):
					outputStream << MonthNameFromNumber(namingData.UsableTime(useLocalTime).wMonth);
					break;
				case TEXT('d'):
          outputStream << Format().ui<10,2>(namingData.UsableTime(useLocalTime).wDay).Str();
					break;
				case TEXT('D'):
					outputStream << WeekdayNameFromNumber(namingData.UsableTime(useLocalTime).wDayOfWeek);
					break;
				case TEXT('y'):
					outputStream << Format().ui<10,2>(namingData.UsableTime(useLocalTime).wYear % 100).Str();
					break;
				case TEXT('Y'):
					outputStream << Format().ui<10,4>(namingData.UsableTime(useLocalTime).wYear).Str();
					break;
				case TEXT('h'):
					outputStream << Format().ui<10,2>(namingData.UsableTime(useLocalTime).wHour).Str();
					break;
				case TEXT('H'):
					outputStream << Format().ui<10,2>(namingData.UsableTime(useLocalTime).wHour % 12).Str();
					break;
				case TEXT('c'):
					if (namingData.UsableTime(useLocalTime).wHour == 0)
						outputStream << TEXT("AM");
					else
						outputStream << (namingData.UsableTime(useLocalTime).wHour >= 12) ? TEXT("PM") : TEXT("AM");
					break;
				case TEXT('i'):
          outputStream << Format().ui<10,2>(namingData.UsableTime(useLocalTime).wMinute).Str();
					break;
				case TEXT('s'):
          outputStream << Format().ui<10,2>(namingData.UsableTime(useLocalTime).wSecond).Str();
					break;
				case TEXT('w'):
				case TEXT('t'):
					{
						if (preview)
						{
							if (nextCharacter == 'w')
								outputStream << "(window title)";
							else
								outputStream << "(your_text_here)";
						}
						else
						{
							if(userTextIndex >= namingData.userStrings.size())
							{
								CTextPromptDlg dlg(TEXT("Enter filename text"),
									TEXT("Enter a name or word to be used in your screenshot's filename"),
									(nextCharacter == 'w') ? namingData.windowTitle : TEXT(""));

								if (dlg.DoModal() == IDOK)
								{
									namingData.userStrings.push_back(dlg.GetText());
								}
								else
								{
									namingData.userStrings.push_back(L"");
								}
							}

							outputStream << StripBadFilenameChars(namingData.userStrings[userTextIndex]);

							userTextIndex ++;
						}
					}
					break;
				case TEXT('g'):
					{
						if(guidIndex >= namingData.guids.size())
						{
							Guid g;
							g.CreateNew();
							namingData.guids.push_back(g);
//.........这里部分代码省略.........
开发者ID:thenfour,项目名称:screenie,代码行数:101,代码来源:utility.cpp


注:本文中的Guid::CreateNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。