Mercurial > dwindows
comparison android/dw.cpp @ 2486:cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 27 Apr 2021 00:16:56 +0000 |
parents | cb5b67154399 |
children | 83f8f4f58a98 |
comparison
equal
deleted
inserted
replaced
2485:a0c493abb872 | 2486:cec43818bd3e |
---|---|
590 * DW_MB_RETURN_YES, DW_MB_RETURN_NO, DW_MB_RETURN_OK, | 590 * DW_MB_RETURN_YES, DW_MB_RETURN_NO, DW_MB_RETURN_OK, |
591 * or DW_MB_RETURN_CANCEL based on flags and user response. | 591 * or DW_MB_RETURN_CANCEL based on flags and user response. |
592 */ | 592 */ |
593 int API dw_messagebox(const char *title, int flags, const char *format, ...) | 593 int API dw_messagebox(const char *title, int flags, const char *format, ...) |
594 { | 594 { |
595 va_list args; | |
596 char outbuf[1025] = {0}; | |
597 JNIEnv *env; | |
598 | |
599 va_start(args, format); | |
600 vsnprintf(outbuf, 1024, format, args); | |
601 va_end(args); | |
602 | |
603 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
604 { | |
605 // Construct a String | |
606 jstring jstr = env->NewStringUTF(outbuf); | |
607 jstring jstrtitle = env->NewStringUTF(title); | |
608 // First get the class that contains the method you need to call | |
609 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
610 // Get the method that you want to call | |
611 jmethodID messageBox = env->GetMethodID(clazz, "messageBox", | |
612 "(Ljava/lang/String;Ljava/lang/String;I)I"); | |
613 // Call the method on the object | |
614 return env->CallIntMethod(_dw_obj, messageBox, jstrtitle, jstr, flags); | |
615 } | |
595 return 0; | 616 return 0; |
596 } | 617 } |
597 | 618 |
598 /* | 619 /* |
599 * Opens a file dialog and queries user selection. | 620 * Opens a file dialog and queries user selection. |