Tolto il bottone di stampa dalle finestre di visualizzazione Adattati checks per FOXPRO Resi meno ridicoli i messaggi corrispondenti a F11 e F12 (mi mancheranno) git-svn-id: svn://10.65.10.50/trunk@941 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			219 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			219 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <stdarg.h>
 | |
| #include <stdio.h>
 | |
| #include <stdlib.h>
 | |
| 
 | |
| #ifdef FOXPRO
 | |
| #undef XVT_OS
 | |
| #include <pro_ext.h>
 | |
| #endif
 | |
| 
 | |
| #ifdef XVT_OS
 | |
| #include <xvt_os.h>
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
| #include <windows.h>
 | |
| #include <keys.h>
 | |
| #else
 | |
| #include <xvtility.h>
 | |
| #endif
 | |
| #include <applicat.h>
 | |
| #endif /* XVT_OS */
 | |
| 
 | |
| 
 | |
| #include <checks.h>
 | |
| 
 | |
| #define buildmsg() char msg[256];va_list argptr;va_start(argptr,fmt);vsprintf(msg,fmt,argptr);va_end(argptr)
 | |
| 
 | |
| #ifdef XVT_OS
 | |
| 
 | |
| int fatal_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
|   MessageBeep(MB_ICONHAND);
 | |
|   MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL);
 | |
| 
 | |
|   if (xvt_running())
 | |
|     main_app().stop_run();
 | |
|   else
 | |
|     exit(1);
 | |
| #else
 | |
|   beep();
 | |
|   if (xvt_running()) xvt_fatal("%s", msg);
 | |
|   else
 | |
|   {
 | |
|     fprintf(stderr, "%s\n", msg);
 | |
|     getchar();
 | |
|     exit(1);
 | |
|   }
 | |
| #endif
 | |
| 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| 
 | |
| int error_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
|   MessageBeep(MB_ICONEXCLAMATION);
 | |
|   MessageBox(GetFocus(), msg, "ERRORE", MB_OK | MB_ICONEXCLAMATION);
 | |
| #else
 | |
|   beep();
 | |
|   if (xvt_running()) xvt_error("%s", msg);
 | |
|   else
 | |
|   {
 | |
|     fprintf(stderr, "%s\n", msg);
 | |
|     getchar();
 | |
|   }
 | |
| #endif
 | |
| 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| 
 | |
| int warning_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
|   MessageBeep(MB_ICONQUESTION);
 | |
|   MessageBox(GetFocus(), msg, "ATTENZIONE", MB_OK | MB_ICONQUESTION);
 | |
| #else
 | |
|   beep();
 | |
|   xvt_note("%s", msg);
 | |
| #endif
 | |
| 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| 
 | |
| int message_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
|   MessageBox(GetFocus(), msg, "INFORMAZIONE", MB_OK | MB_ICONINFORMATION);
 | |
| #else
 | |
|   xvt_note("%s", msg);
 | |
| #endif
 | |
| 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| int sorry_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
|   MessageBeep(MB_OK);
 | |
|   MessageBox(GetFocus(), msg, "SPIACENTE", MB_OK | MB_ICONINFORMATION);
 | |
| #else
 | |
|   xvt_note("%s", msg);
 | |
| #endif
 | |
| 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| int yesno_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
|   int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNO | MB_ICONQUESTION);
 | |
|   return r == IDYES;
 | |
| #else
 | |
|   ASK_RESPONSE r = xvt_ask((char*) "Si", (char*) "No", NULL, "%s", msg);
 | |
|   return r == RESP_DEFAULT;
 | |
| #endif
 | |
| }
 | |
| 
 | |
| 
 | |
| int yesnofatal_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #ifdef DBG  
 | |
|   char s[256]; sprintf(s, "%s\nContinuare ugualmente?", msg);
 | |
|   const int ret = yesno_box("%s", s);
 | |
|   if (!ret) fatal_box("");
 | |
| #else
 | |
|   fatal_box("%s", msg);
 | |
| #endif
 | |
| 
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| 
 | |
| int yesnocancel_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN
 | |
|   int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNOCANCEL | MB_ICONQUESTION);
 | |
|   if (r == IDYES) r = K_YES;
 | |
|   else
 | |
|     if (r == IDNO) r = K_NO;
 | |
|     else
 | |
|       r = K_ESC;
 | |
|   return r;
 | |
| #else
 | |
|   ASK_RESPONSE r = xvt_ask((char*) "Si", (char*) "No", (char*) "Annulla", "%s", msg);
 | |
|   if (r == RESP_DEFAULT) r = K_YES;
 | |
|   else
 | |
|     if (r == RESP_2) r = K_NO;
 | |
|     else
 | |
|       r = K_ESC;
 | |
|   return r;
 | |
| #endif
 | |
| }
 | |
| 
 | |
| int __trace(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
|   FILE* f = fopen("trace.log", "a");
 | |
|   if (f != NULL)
 | |
|   {
 | |
|     fprintf(f, "%s\n", msg);
 | |
|     fclose(f);
 | |
|   }
 | |
|   
 | |
|   return f != NULL;  
 | |
| }
 | |
| 
 | |
| #endif // XVT_OS
 | |
| 
 | |
| 
 | |
| #ifdef FOXPRO
 | |
| 
 | |
| int error_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
|   _UserError(msg);
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| int fatal_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
|   _UserError(msg);
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| int message_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
|   _UserError(msg);
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| int yesnofatal_box(const char* fmt, ...)
 | |
| {
 | |
|   buildmsg();
 | |
|   _UserError(msg);
 | |
|   return 0;
 | |
| }
 | |
| #endif // FOXPRO
 | |
| 
 |