本文整理汇总了C++中AwtTextComponent::GetText方法的典型用法代码示例。如果您正苦于以下问题:C++ AwtTextComponent::GetText方法的具体用法?C++ AwtTextComponent::GetText怎么用?C++ AwtTextComponent::GetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AwtTextComponent
的用法示例。
在下文中一共展示了AwtTextComponent::GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PDATA
JNIEXPORT jstring JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_getText (JNIEnv *env,
jobject thisObj)
{
CHECK_PEER_RETURN(thisObj);
int len;
AwtTextComponent* c = PDATA(AwtTextComponent, thisObj);
len = c->GetTextLength();
jstring js;
if (len == 0) {
// Make java null string
jchar *jc = new jchar[0];
js = env->NewString(jc, 0);
delete [] jc;
ASSERT(!env->ExceptionCheck());
} else {
#ifndef UNICODE
char* buffer = new char[len+1];
c->GetText(buffer, len+1);
AwtTextComponent::RemoveCR(buffer);
js = env->NewString(buffer, wcslen(buf)); // convert to unicode. right???
delete[] buffer;
#else
TCHAR *buffer = new TCHAR[len+1];
c->GetText(buffer, len+1);
AwtTextComponent::RemoveCR(buffer);
js = TO_JSTRING((LPWSTR)buffer);
//js = env->NewString(buffer, wcslen(buffer));
delete[] buffer;
#endif
}
return js;
}
示例2: _GetText
jstring AwtTextComponent::_GetText(void *param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject self = (jobject)param;
AwtTextComponent *c = NULL;
jstring result = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
c = (AwtTextComponent *)pData;
if (::IsWindow(c->GetHWnd()))
{
int len = ::GetWindowTextLength(c->GetHWnd());
if (len == 0) {
/* Make java null string */
jchar *jc = new jchar[0];
result = env->NewString(jc, 0);
delete [] jc;
} else {
WCHAR* buf = new WCHAR[len + 1];
c->GetText(buf, len + 1);
c->RemoveCR(buf);
result = JNU_NewStringPlatform(env, buf);
delete [] buf;
}
}
ret:
env->DeleteGlobalRef(self);
if (result != NULL)
{
jstring globalRef = (jstring)env->NewGlobalRef(result);
env->DeleteLocalRef(result);
return globalRef;
}
else
{
return NULL;
}
}