checks.cpp Tolto include windows.h colors.cpp Tolto include windows.h controls.cpp Aggiunto cambiamento del font runtime dei TText_control execp.cpp Tolto include windows.h form.cpp Tolto include windows.h mask.cpp Corretta formattazione di due righe maskfld.cpp Aggiunto messaggio CHECK msksheet.cpp Tolto include windows.h relapp.cpp Tolto include windows.h strings.pp Corretto CHECK della TFixed_string::format() viswin.cpp Tolto include windows.h window.cpp Tolto include windows.h xvtility.cpp Corretto calcolo altezza righe delle maschere git-svn-id: svn://10.65.10.50/trunk@4085 c028cbd2-c16b-5b4b-a496-9718f37d4682
320 lines
7.9 KiB
C++
Executable File
320 lines
7.9 KiB
C++
Executable File
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#ifdef XVT
|
|
#define XVT_INCL_NATIVE
|
|
#define STRICT
|
|
#include <xvt.h>
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
#include <keys.h>
|
|
#else
|
|
#include <xvtility.h>
|
|
#endif
|
|
#include <applicat.h>
|
|
#endif /* XVT */
|
|
|
|
|
|
#include <checks.h>
|
|
|
|
#define buildmsg() char msg[256];va_list argptr;va_start(argptr,fmt);vsprintf(msg,fmt,argptr);va_end(argptr)
|
|
|
|
#ifndef FOXPRO
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg fatal_box | Crea una finestra di ERRORE FATALE con il relativo messaggio
|
|
int fatal_box(
|
|
const char* fmt, ...) // @parm Messaggio da stampare nella finestra
|
|
// (il formato e' come nella printf del C)
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con il bottone OK
|
|
// Il programma viene interrotto al momento in cui si e' verificato
|
|
// l'errore.
|
|
{
|
|
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_dm_post_fatal_exit("%s", msg);
|
|
else
|
|
{
|
|
fprintf(stderr, "%s\n", msg);
|
|
getchar();
|
|
exit(1);
|
|
}
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg error_box | Crea una finestra di ERRORE con il relativo messaggio
|
|
int error_box(
|
|
const char* fmt, // @parm Messaggio da stampare nella finestra
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con il bottone OK
|
|
// e l'icona punto esclamativo.
|
|
{
|
|
buildmsg();
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
MessageBeep(MB_ICONEXCLAMATION);
|
|
MessageBox(GetFocus(), msg, "ERRORE", MB_OK | MB_ICONEXCLAMATION);
|
|
#else
|
|
beep();
|
|
if (xvt_running()) xvt_dm_post_error("%s", msg);
|
|
else
|
|
{
|
|
fprintf(stderr, "%s\n", msg);
|
|
getchar();
|
|
}
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg warning_box | Crea una finestra di ATTENZIONE con il relativo messaggio
|
|
int warning_box(
|
|
const char* fmt, // @parm Messaggio da stampare nella finestra
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con il bottone OK
|
|
// e l'icona punto di domanda.
|
|
{
|
|
buildmsg();
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
MessageBeep(MB_ICONQUESTION);
|
|
MessageBox(GetFocus(), msg, "ATTENZIONE", MB_OK | MB_ICONQUESTION);
|
|
#else
|
|
beep();
|
|
xvt_dm_post_note("%s", msg);
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg message_box | Crea una finestra di INFORMAZIONE con relativo il messaggio
|
|
int message_box(
|
|
const char* fmt, // @parm Messaggio da stampare nella finestra
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con il bottone OK
|
|
// e l'icona informazioni.
|
|
{
|
|
buildmsg();
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
MessageBox(GetFocus(), msg, "INFORMAZIONE", MB_OK | MB_ICONINFORMATION);
|
|
#else
|
|
xvt_dm_post_note("%s", msg);
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg sorry_box | Crea una finestra di SCUSE con il relativo messaggio
|
|
int sorry_box(
|
|
const char* fmt, // @parm Messaggio da stampare nella finestra
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con il bottone OK
|
|
// e l'icona informazioni.
|
|
{
|
|
buildmsg();
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
MessageBeep(MB_ICONINFORMATION);
|
|
MessageBox(GetFocus(), msg, "SPIACENTE", MB_OK | MB_ICONINFORMATION);
|
|
#else
|
|
xvt_dm_post_note("%s", msg);
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
// @doc EXTERNAL
|
|
|
|
// @msg yesno_box | Crea una finestra di RICHIESTA con il relativo messaggio
|
|
int yesno_box(
|
|
const char* fmt, // @parm Messaggio da stampare nella finestra
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con i bottni SI e NO
|
|
// e l'icona col punto di domanda.
|
|
//
|
|
// @rdesc Ritorna il risultato della richiesta:
|
|
//
|
|
// @flag 1 | Se viene premuto il taso SI
|
|
// @flag 0 | Se viene premuto il taso NO
|
|
//
|
|
// @xref <m yesnocancel_box> <m yesnofatal_box>
|
|
{
|
|
buildmsg();
|
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
MessageBeep(MB_ICONQUESTION);
|
|
int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNO | MB_ICONQUESTION);
|
|
return r == IDYES;
|
|
#else
|
|
ASK_RESPONSE r = xvt_dm_post_ask((char*) "Si", (char*) "No", NULL, "%s", msg);
|
|
return r == RESP_DEFAULT;
|
|
#endif
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg yesnofatal_box | Crea una finestra di RICHIESTA con il relativo
|
|
// messaggio, ma permette di terminare il programma
|
|
int yesnofatal_box(
|
|
const char* fmt, // @parm Messaggio da stampare nella finestra
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con i bottoni SI e NO
|
|
// e l'icona col punto di domanda.
|
|
// <nl>A differenza della <m yesno_box> permette di terminare il programma
|
|
// se viene premuto il tasto SI
|
|
//
|
|
// @rdesc Ritorna il risultato della richiesta:
|
|
//
|
|
// @flag 1 | Se viene premuto il tasto SI
|
|
// @flag 0 | Se viene premuto il tasto NO
|
|
//
|
|
// @xref <m yesno_box> <m yesnofatal_box>
|
|
{
|
|
buildmsg();
|
|
|
|
#ifdef DBG
|
|
char s[256]; sprintf(s, "%s\nContinuare ugualmente?", msg);
|
|
const int ret = yesno_box("%s", s);
|
|
if (!ret) fatal_box(msg);
|
|
#else
|
|
fatal_box("%s", msg);
|
|
#endif
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg yesnocancel_box | Crea una finestra di RICHIESTA con il relativo messaggio
|
|
int yesnocancel_box(
|
|
const char* fmt, // @parm Messaggio da stampare nella finestra
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
// @comm Se si opera in ambiente Windows crea la finestra con i bottoni SI e NO
|
|
// e l'icona col punto di domanda.
|
|
//
|
|
// @rdesc Ritorna il risultato della richiesta:
|
|
//
|
|
// @flag K_YES | Se viene premuto il tasto SI
|
|
// @flag K_NO | Se viene premuto il tasto NO
|
|
// @flag K_ESC | Se viene premuto il tosto ESC
|
|
//
|
|
// @xref <m yesno_box> <m yesnofatal_box>
|
|
{
|
|
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_dm_post_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
|
|
}
|
|
|
|
// @doc EXTERNAL
|
|
|
|
// @msg __trace | Permette di mandare dei messaggi nel file trace.log
|
|
int __trace(
|
|
const char* fmt, // @parm Messaggio da stampare
|
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
|
|
|
// @comm Usato in fase di debug, permette di vedere se il programma ha
|
|
// fatto certe operazioni (deve essere definito il simbolo TRC in
|
|
// fase di compilazione).
|
|
//
|
|
// @rdesc Ritorna non 0 se riesca ad aprire il file trace.log
|
|
{
|
|
buildmsg();
|
|
FILE* f = fopen("trace.log", "a");
|
|
if (f != NULL)
|
|
{
|
|
fprintf(f, "%s\n", msg);
|
|
fclose(f);
|
|
}
|
|
|
|
return f != NULL;
|
|
}
|
|
|
|
#else // FOXPRO
|
|
|
|
#include <windows.h>
|
|
#include <pro_ext.h>
|
|
|
|
int error_box(const char* fmt, ...)
|
|
{
|
|
buildmsg();
|
|
MessageBeep(MB_ICONEXCLAMATION);
|
|
_UserError(msg);
|
|
return 0;
|
|
}
|
|
|
|
int fatal_box(const char* fmt, ...)
|
|
{
|
|
buildmsg();
|
|
MessageBeep(MB_ICONHAND);
|
|
MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL);
|
|
_UserError(msg);
|
|
return 0;
|
|
}
|
|
|
|
int message_box(const char* fmt, ...)
|
|
{
|
|
buildmsg();
|
|
MessageBeep(MB_ICONINFORMATION);
|
|
_UserError(msg);
|
|
return 0;
|
|
}
|
|
|
|
int yesnofatal_box(const char* fmt, ...)
|
|
{
|
|
buildmsg();
|
|
MessageBeep(MB_ICONHAND);
|
|
MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL);
|
|
_UserError(msg);
|
|
return 0;
|
|
}
|
|
#endif // FOXPRO
|
|
|