void AwtTextField::_SetEchoChar(void *param) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); SetEchoCharStruct *secs = (SetEchoCharStruct *)param; jobject self = secs->textfield; jchar echo = secs->echoChar; AwtTextField *c = NULL; PDATA pData; JNI_CHECK_PEER_GOTO(self, ret); c = (AwtTextField *)pData; if (::IsWindow(c->GetHWnd())) { c->SendMessage(EM_SETPASSWORDCHAR, echo); // Fix for 4307281: force redraw so that changes will take effect VERIFY(::InvalidateRect(c->GetHWnd(), NULL, FALSE)); } ret: env->DeleteGlobalRef(self); delete secs; }
/* Create a new AwtTextField object and window. */ AwtTextField* AwtTextField::Create(jobject peer, jobject parent) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject target = NULL; AwtTextField* c = NULL; try { PDATA pData; AwtCanvas* awtParent; JNI_CHECK_PEER_GOTO(parent, done); awtParent = (AwtCanvas*)pData; JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done); target = env->GetObjectField(peer, AwtObject::targetID); JNI_CHECK_NULL_GOTO(target, "null target", done); c = new AwtTextField(); { DWORD style = WS_CHILD | WS_CLIPSIBLINGS | ES_LEFT | ES_AUTOHSCROLL | (IS_WIN4X ? 0 : WS_BORDER); DWORD exStyle = IS_WIN4X ? WS_EX_CLIENTEDGE : 0; if (GetRTL()) { exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR; if (GetRTLReadingOrder()) exStyle |= WS_EX_RTLREADING; } jint x = env->GetIntField(target, AwtComponent::xID); jint y = env->GetIntField(target, AwtComponent::yID); jint width = env->GetIntField(target, AwtComponent::widthID); jint height = env->GetIntField(target, AwtComponent::heightID); c->CreateHWnd(env, L"", style, exStyle, x, y, width, height, awtParent->GetHWnd(), reinterpret_cast<HMENU>(static_cast<INT_PTR>( awtParent->CreateControlID())), ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), peer); c->m_backgroundColorSet = TRUE; /* suppress inheriting parent's color. */ c->UpdateBackground(env, target); c->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(1, 1)); /* * Fix for BugTraq Id 4260109. * Set the text limit to the maximum. */ c->SendMessage(EM_SETLIMITTEXT); } } catch (...) { env->DeleteLocalRef(target); throw; } done: env->DeleteLocalRef(target); return c; }