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


C++ Ucs2String::assign方法代码示例

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


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

示例1: orig

LRESULT CALLBACK ZLWin32ApplicationWindow::TextEditParameter::ComboBoxCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	TextEditParameter &parameter =
		*(TextEditParameter*)GetWindowLong(hWnd, GWL_USERDATA);

	if ((uMsg == WM_COMMAND) && (HIWORD(wParam) == CBN_SELCHANGE)) {
		HWND comboBox = parameter.myComboBox;
		const int index = SendMessage(comboBox, CB_GETCURSEL, 0, 0);
		const int length = SendMessage(comboBox, CB_GETLBTEXTLEN, index, 0);
		ZLUnicodeUtil::Ucs2String buffer;
		if (length > 0) {
			buffer.assign(length + 1, '\0');
			SendMessage(comboBox, CB_GETLBTEXT, index, (LPARAM)&buffer.front());
			buffer.pop_back();
		}
		std::string value;
		ZLUnicodeUtil::ucs2ToUtf8(value, buffer);
		parameter.setValue(value);

		parameter.myApplication.doAction(parameter.myParameterItem.actionId());
		SetFocus(parameter.myMainWindow);
	}

	WndProc orig = parameter.myOriginalComboBoxCallback;
	return orig(hWnd, uMsg, wParam, lParam);
}
开发者ID:justsoso8,项目名称:fbreader,代码行数:25,代码来源:ZLWin32ApplicationWindow.cpp

示例2: GetWindowTextLengthW

std::string ZLWin32ApplicationWindow::TextEditParameter::internalValue() const {
	int len = GetWindowTextLengthW(myComboBox);
	if (len == 0) {
		return "";
	}
	static ZLUnicodeUtil::Ucs2String buffer;
	buffer.assign(len + 1, '\0');
	GetWindowTextW(myComboBox, (WCHAR*)::wchar(buffer), len + 1);
	buffer.pop_back();
	std::string text;
	ZLUnicodeUtil::ucs2ToUtf8(text, buffer);
	return text;
}
开发者ID:justsoso8,项目名称:fbreader,代码行数:13,代码来源:ZLWin32ApplicationWindow.cpp


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