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


C++ XString::GetBuffer方法代码示例

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


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

示例1: CustomItemOptionsDlgProc

LRESULT WINAPI CustomItemOptionsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
		case WM_INITDIALOG:
			{
				SHINITDLGINFO shidi;

				shidi.dwMask = SHIDIM_FLAGS;
				shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
				shidi.hDlg = hDlg;
				SHInitDialog(&shidi);

				LoadSettings();
				
				SendMessage(GetDlgItem(hDlg, IDC_LEFT_FORMAT), WM_SETTEXT, NULL, (LPARAM) g_xsLeftFormat.GetBuffer());
				SendMessage(GetDlgItem(hDlg, IDC_RIGHT_FORMAT), WM_SETTEXT, NULL, (LPARAM) g_xsRightFormat.GetBuffer());

				HWND hWndTextSize = GetDlgItem(hDlg, IDC_TEXT_SIZE);

				InitializeComboBox(hWndTextSize);
				SendMessage(hWndTextSize, CB_ADDSTRING, NULL, (LPARAM) _T("System Default"));

				for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++)
				{
					TCHAR szNumber[1];
					
					_itot(i, szNumber, 10);
					
					SendMessage(hWndTextSize, CB_ADDSTRING, NULL, (LPARAM) szNumber);
					//SendMessage(hWndTextSize, CB_ADDSTRING, NULL, (LPARAM) szNumber);
				}
				SendMessage(hWndTextSize, CB_SETCURSEL, (WPARAM) g_iTextSize, NULL);
			}
			return TRUE; 
	        
		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK) {
				TCHAR szBuffer[MAX_LOADSTRING];

				SendMessage(GetDlgItem(hDlg, IDC_LEFT_FORMAT), WM_GETTEXT, (WPARAM) MAX_LOADSTRING, (LPARAM) szBuffer);
				g_xsLeftFormat = szBuffer;

				SendMessage(GetDlgItem(hDlg, IDC_RIGHT_FORMAT), WM_GETTEXT, (WPARAM) MAX_LOADSTRING, (LPARAM) szBuffer);
				g_xsRightFormat = szBuffer;

				g_iTextSize = SendMessage(GetDlgItem(hDlg, IDC_TEXT_SIZE), CB_GETCURSEL, NULL, NULL);

				SaveSettings();

				EndDialog(hDlg, LOWORD(wParam));

				return TRUE;
			}
			return FALSE;
	}

    return FALSE;
}
开发者ID:PedroLamas,项目名称:TodayTime,代码行数:58,代码来源:TodayTime.cpp

示例2: LoadFile

/* load a file */
BOOL MyAppWindow :: LoadFile ( char * p)
{
   // is there already a file loaded or has the user entered some text?
   if(loaded == FALSE && saved == TRUE)
      {
         //no, we load the file in the window of the current thread
         XFile loadfile;

         /* now open the file, fail if given filename is not existing */
         /* open the file for read-access, dont allow any other programm to use the file while it is open*/
         if( loadfile.Open( p, XFILE_FAIL_IF_NEW | XFILE_OPEN_EXISTING, XFILE_SHARE_DENYWRITE | XFILE_READONLY ) == 0)
           {
              XString s;

              loading = TRUE;

              //how large is the file?
              XFileInfo info;
              loadfile.GetFileInfo( &info );
              LONG size = info.GetFileSize();

              //read the complete file
              loadfile.Read ( (PVOID) s.GetBuffer(info.GetFileSize() + 1), size);
              s.ReleaseBuffer( info.GetFileSize() );

              //set the XString content to the mle
              mle->SetText( s );
              //dontïforget to close the file
              loadfile.Close();
              loaded = TRUE;
              path = p;
              mle->SetFocus();
              GetText( &s );
              s+= " - ";
              s+= p;
              SetText( s );

              loading = FALSE;

              return TRUE;
            }
         else
            {
               XMessageBox( p, "couldnït open File!", MB_OK|MB_ERROR);
               return FALSE;
            }
      }
   else
     {
         //there is a file loaded, or the user has entered some text, so
         // we create a new window and load the file
//         XResource res( IDM_MAIN, ((MyApp*) GetProcess())->GetResourceLibrary());
         MyAppWindow * win = new MyAppWindow( IDM_MAIN );
         win->LoadFile(p);
         return TRUE;
     }
}
开发者ID:OS2World,项目名称:LIB-Open_Object_Library,代码行数:58,代码来源:sample1.cpp

示例3: SaveSettings

void SaveSettings() {
	HKEY hKey;
	TCHAR szRegistryKey[MAX_LOADSTRING], szTextSizeKey[MAX_LOADSTRING];
	TCHAR szLeftFormatKey[MAX_LOADSTRING], szRightFormatKey[MAX_LOADSTRING];

	LoadString(g_hInstance, IDS_REGISTRY, szRegistryKey, MAX_LOADSTRING);
	LoadString(g_hInstance, IDS_LEFTFORMAT, szLeftFormatKey, MAX_LOADSTRING);
	LoadString(g_hInstance, IDS_RIGHTFORMAT, szRightFormatKey, MAX_LOADSTRING);
	LoadString(g_hInstance, IDS_TEXTSIZE, szTextSizeKey, MAX_LOADSTRING);

	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegistryKey, 0, 0, &hKey) == ERROR_SUCCESS) {
		RegSetValueEx(hKey, szLeftFormatKey, 0, REG_SZ, (BYTE *) g_xsLeftFormat.GetBuffer(), g_xsLeftFormat.Length() * sizeof(TCHAR));
		RegSetValueEx(hKey, szRightFormatKey, 0, REG_SZ, (BYTE *) g_xsRightFormat.GetBuffer(), g_xsRightFormat.Length() * sizeof(TCHAR));
		RegSetValueEx(hKey, szTextSizeKey, 0, REG_DWORD, (BYTE *) &g_iTextSize, sizeof(int));

		RegCloseKey (hKey);
	}
}
开发者ID:PedroLamas,项目名称:TodayTime,代码行数:18,代码来源:TodayTime.cpp

示例4: GetBuffer

void GetBuffer()
{
	XString str = L"Hello";
	wchar_t* p = str.GetBuffer(20);
	wcscpy_s(p, 20, L"Hello World");
	str.ReleseBuffer();
	str += L"!";

	wprintf(L"%s\n", str.GetString());
}
开发者ID:kippler,项目名称:Samples,代码行数:10,代码来源:main.cpp

示例5: PaintMe

void PaintMe(HWND hwnd)
{
	HDC hDC;
	PAINTSTRUCT ps;
	RECT rcWindow;
	HFONT hSysFont, hFont, hFontOld;
	LOGFONT lfFont;
	COLORREF crText;
	TCHAR szTextBuffer[50], szTextBuffer2[50], szInternetTime[5];
	XString xsTextBuffer;
	int iFontSizePixel;
	
	GetWindowRect(hwnd, &rcWindow);
	OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top);

	hDC = BeginPaint(hwnd, &ps);
	SetBkMode(hDC, TRANSPARENT);

	if (bSelected == TRUE) {
		HBRUSH hBrush = GetSysColorBrush(COLOR_HIGHLIGHT);

		FillRect(hDC, &rcWindow, hBrush);

		DeleteObject(hBrush);
	}

	if (g_iTextSize == 0)
	{
		SHGetUIMetrics(SHUIM_FONTSIZE_PIXEL, &iFontSizePixel, sizeof(iFontSizePixel), NULL);
	}
	else
	{
		iFontSizePixel = MulDiv(g_iTextSize + MIN_FONT_SIZE - 1, DRA::LogPixelsY(), 72);
	}

	hSysFont = (HFONT) GetStockObject(SYSTEM_FONT);
	GetObject(hSysFont, sizeof(LOGFONT), &lfFont);
	//memset(&lfFont, 0, sizeof(LOGFONT));
	lfFont.lfWeight = FW_SEMIBOLD;
	lfFont.lfHeight = -iFontSizePixel;
	hFont = CreateFontIndirect(&lfFont);
	hFontOld = (HFONT) SelectObject(hDC, hFont);

	crText = SendMessage(GetParent(hwnd), TODAYM_GETCOLOR, (WPARAM) TODAYCOLOR_TEXT, NULL);
	SetTextColor(hDC, crText);

	InflateRect(&rcWindow, -2, 0);

	_itot(g_iInternetTime, szInternetTime, 10);
	//_ttoi

	_tcscpy(szTextBuffer, _T("a\0"));
	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, g_xsLeftFormat.Replace(_T("'"), _T("'''")).GetBuffer(), szTextBuffer, sizeof szTextBuffer);
	GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, szTextBuffer, szTextBuffer2, sizeof szTextBuffer2);
	xsTextBuffer = XString(szTextBuffer2).Replace(_T("@"), XString(_T("@"), szInternetTime));
	DrawText(hDC, xsTextBuffer.GetBuffer(), -1, &rcWindow, DT_VCENTER | DT_LEFT);

	_tcscpy(szTextBuffer, _T("a\0"));
	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, g_xsRightFormat.Replace(_T("'"), _T("'''")).GetBuffer(), szTextBuffer, sizeof szTextBuffer);
	GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &g_stLocalTime, szTextBuffer, szTextBuffer2, sizeof szTextBuffer2);
	xsTextBuffer = XString(szTextBuffer2).Replace(_T("@"), XString(_T("@"), szInternetTime));
	DrawText(hDC, xsTextBuffer.GetBuffer(), -1, &rcWindow, DT_VCENTER | DT_RIGHT);

	SelectObject(hDC, hFontOld);
	DeleteObject(hFont);

	EndPaint(hwnd, &ps);
}
开发者ID:PedroLamas,项目名称:TodayTime,代码行数:68,代码来源:TodayTime.cpp


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