95
96 /*
97 * Create a new AwtDialog object and window.
98 */
99 AwtDialog* AwtDialog::Create(jobject peer, jobject parent)
100 {
101 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
102
103 jobject background = NULL;
104 jobject target = NULL;
105 AwtDialog* dialog = NULL;
106
107 try {
108 if (env->EnsureLocalCapacity(2) < 0) {
109 return NULL;
110 }
111
112 PDATA pData;
113 AwtWindow* awtParent = NULL;
114 HWND hwndParent = NULL;
115 target = env->GetObjectField(peer, AwtObject::targetID);
116 JNI_CHECK_NULL_GOTO(target, "null target", done);
117
118 if (parent != NULL) {
119 JNI_CHECK_PEER_GOTO(parent, done);
120 awtParent = (AwtWindow *)(JNI_GET_PDATA(parent));
121 hwndParent = awtParent->GetHWnd();
122 } else {
123 // There is no way to prevent a parentless dialog from showing on
124 // the taskbar other than to specify an invisible parent and set
125 // WS_POPUP style for the dialog. Using toolkit window here. That
126 // will also excludes the dialog from appearing in window list while
127 // ALT+TAB'ing
128 // From the other point, it may be confusing when the dialog without
129 // an owner is missing on the toolbar. So, do not set any fake
130 // parent window here.
131 // hwndParent = AwtToolkit::GetInstance().GetHWnd();
132 }
133 dialog = new AwtDialog();
134
135 {
136 int colorId = COLOR_3DFACE;
137 DWORD style = WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN;
138 if (hwndParent != NULL) {
139 style |= WS_POPUP;
140 }
767 } /* extern "C" */
768
769
770 /************************************************************************
771 * DialogPeer native methods
772 */
773
774 extern "C" {
775
776 /*
777 * Class: sun_awt_windows_WDialogPeer
778 * Method: create
779 * Signature: (Lsun/awt/windows/WComponentPeer;)V
780 */
781 JNIEXPORT void JNICALL
782 Java_sun_awt_windows_WDialogPeer_createAwtDialog(JNIEnv *env, jobject self,
783 jobject parent)
784 {
785 TRY;
786
787 PDATA pData;
788 AwtToolkit::CreateComponent(self, parent,
789 (AwtToolkit::ComponentFactory)
790 AwtDialog::Create);
791 JNI_CHECK_PEER_CREATION_RETURN(self);
792
793 CATCH_BAD_ALLOC;
794 }
795
796 /*
797 * Class: sun_awt_windows_WDialogPeer
798 * Method: _show
799 * Signature: ()V
800 */
801 JNIEXPORT void JNICALL
802 Java_sun_awt_windows_WDialogPeer_showModal(JNIEnv *env, jobject self)
803 {
804 TRY;
805
806 jobject selfGlobalRef = env->NewGlobalRef(self);
807
808 AwtToolkit::GetInstance().SyncCall(AwtDialog::_ShowModal,
809 (void *)selfGlobalRef);
810 // selfGlobalRef is deleted in _ShowModal
811
|
95
96 /*
97 * Create a new AwtDialog object and window.
98 */
99 AwtDialog* AwtDialog::Create(jobject peer, jobject parent)
100 {
101 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
102
103 jobject background = NULL;
104 jobject target = NULL;
105 AwtDialog* dialog = NULL;
106
107 try {
108 if (env->EnsureLocalCapacity(2) < 0) {
109 return NULL;
110 }
111
112 PDATA pData;
113 AwtWindow* awtParent = NULL;
114 HWND hwndParent = NULL;
115
116 target = env->GetObjectField(peer, AwtObject::targetID);
117 JNI_CHECK_NULL_GOTO(target, "null target", done);
118
119 if (parent != NULL) {
120 JNI_CHECK_PEER_GOTO(parent, done);
121 awtParent = (AwtWindow *)pData;
122 hwndParent = awtParent->GetHWnd();
123 } else {
124 // There is no way to prevent a parentless dialog from showing on
125 // the taskbar other than to specify an invisible parent and set
126 // WS_POPUP style for the dialog. Using toolkit window here. That
127 // will also excludes the dialog from appearing in window list while
128 // ALT+TAB'ing
129 // From the other point, it may be confusing when the dialog without
130 // an owner is missing on the toolbar. So, do not set any fake
131 // parent window here.
132 // hwndParent = AwtToolkit::GetInstance().GetHWnd();
133 }
134 dialog = new AwtDialog();
135
136 {
137 int colorId = COLOR_3DFACE;
138 DWORD style = WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN;
139 if (hwndParent != NULL) {
140 style |= WS_POPUP;
141 }
768 } /* extern "C" */
769
770
771 /************************************************************************
772 * DialogPeer native methods
773 */
774
775 extern "C" {
776
777 /*
778 * Class: sun_awt_windows_WDialogPeer
779 * Method: create
780 * Signature: (Lsun/awt/windows/WComponentPeer;)V
781 */
782 JNIEXPORT void JNICALL
783 Java_sun_awt_windows_WDialogPeer_createAwtDialog(JNIEnv *env, jobject self,
784 jobject parent)
785 {
786 TRY;
787
788 AwtToolkit::CreateComponent(self, parent,
789 (AwtToolkit::ComponentFactory)
790 AwtDialog::Create);
791
792 CATCH_BAD_ALLOC;
793 }
794
795 /*
796 * Class: sun_awt_windows_WDialogPeer
797 * Method: _show
798 * Signature: ()V
799 */
800 JNIEXPORT void JNICALL
801 Java_sun_awt_windows_WDialogPeer_showModal(JNIEnv *env, jobject self)
802 {
803 TRY;
804
805 jobject selfGlobalRef = env->NewGlobalRef(self);
806
807 AwtToolkit::GetInstance().SyncCall(AwtDialog::_ShowModal,
808 (void *)selfGlobalRef);
809 // selfGlobalRef is deleted in _ShowModal
810
|