Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. ///=============================
  3.  
  4. #define MB_OK 0
  5. #define MB_OKCANCEL 1
  6. #define MB_ABORTRETRYIGNORE 2
  7. #define MB_YESNOCANCEL 3
  8. #define MB_YESNO 4
  9. #define MB_RETRYCANCEL 5
  10.  
  11. #define IDOK 1
  12. #define IDCANCEL 2
  13. #define IDABORT 3
  14. #define IDRETRY 4
  15. #define IDIGNORE 5
  16. #define IDYES 6
  17. #define IDNO 7
  18.  
  19. ///=============================
  20.  
  21. #define LANG_EN
  22.  
  23. #ifdef LANG_RU
  24. char BTN_OK[]={"OK"};
  25. char BTN_CANCEL[]={"Žâ¬¥­ "};
  26. char BTN_ABORT[]={"à¥ªà â¨âì"};
  27. char BTN_RETRY[]={"®¢â®à¨âì"};
  28. char BTN_INGNORE[]={"ˆ£­®à¨à®¢ âì"};
  29. char BTN_NO[]={"¥â"};
  30. #endif
  31.  
  32. #ifdef LANG_EN
  33. char BTN_OK[]={"OK"};
  34. char BTN_CANCEL[]={"Cancel"};
  35. char BTN_ABORT[]={"Abort"};
  36. char BTN_RETRY[]={"Retry"};
  37. char BTN_INGNORE[]={"Ignore"};
  38. char BTN_NO[]={"No"};
  39. #endif
  40.  
  41. ///=============================
  42.  
  43. kol_struct_import *MSG_BOX_IMPORT = NULL;
  44. int (* _stdcall mb_create)(char *m, char* t);
  45.  
  46. char msg[1024];
  47. char thread[1024];
  48.  
  49.  
  50. ///=============================
  51.  
  52. char MessageBox(char *text, char *caption, int type)
  53. {
  54.  
  55. int i, j;
  56.  
  57. if (MSG_BOX_IMPORT == NULL)
  58.         {
  59.         MSG_BOX_IMPORT = kol_cofflib_load("/sys/lib/Msgbox.obj");
  60.         if (MSG_BOX_IMPORT == NULL)
  61.                 kol_exit();
  62.  
  63.         mb_create = kol_cofflib_procload (MSG_BOX_IMPORT, "mb_create");
  64.                 if (mb_create == NULL)
  65.                         kol_exit();
  66.  
  67.         }
  68.  
  69. msg[0] = 255;
  70. msg[1] = 0;
  71.  
  72. for (i = 2, j = 0; ;i++, j++)
  73.         {
  74.         msg[i] = caption[j];
  75.         if (0 == msg[i])
  76.                 break;
  77.         }
  78.  
  79. i++;
  80. msg[i] = 0;
  81.  
  82. for (j = 0; ;i++, j++)
  83.         {
  84.         msg[i] = text[j];
  85.         if (0 == msg[i])
  86.                 break;
  87.         }
  88.  
  89. i++;
  90. msg[i] = 0;
  91.  
  92. switch (type)
  93.         {
  94.         case MB_OK:
  95.                 for (j = 0; ;i++, j++)
  96.                         {
  97.                         msg[i] = BTN_OK[j];
  98.                         if (0 == msg[i])
  99.                                 break;
  100.                         }
  101.                 break;
  102.  
  103.         case MB_OKCANCEL:
  104.                 for (j = 0; ;i++, j++)
  105.                         {
  106.                         msg[i] = BTN_OK[j];
  107.                         if (0 == msg[i])
  108.                                 break;
  109.                         }
  110.  
  111.                 i++;
  112.                 msg[i] = 0;
  113.  
  114.                 for (j = 0; ;i++, j++)
  115.                         {
  116.                         msg[i] = BTN_CANCEL[j];
  117.                         if (0 == msg[i])
  118.                                 break;
  119.                         }
  120.                 break;
  121.  
  122.         default:
  123.                 break;
  124.  
  125.         }
  126. i++;
  127. msg[i] = 0;
  128.  
  129. mb_create(msg, thread+1024);
  130.  
  131. for (;;)
  132.         {
  133.         if ( (unsigned char) msg[0] != 255 )
  134.                 switch (type)
  135.                         {
  136.                         case MB_OK:
  137.                                 if (msg[0] == 1)
  138.                                         return IDOK;
  139.                                 else
  140.                                         return 0;
  141.                                 break;
  142.  
  143.                         case MB_OKCANCEL:
  144.                                 switch(msg[0])
  145.                                         {
  146.                                         case 1:
  147.                                                 return IDOK;
  148.                                         case 2:
  149.                                                 return IDCANCEL;
  150.                                         default:
  151.                                                 return 0;
  152.                                         };
  153.                                 break;
  154.  
  155.                         default:
  156.                                 return 0;
  157.  
  158.                         };
  159.  
  160.         kol_sleep(10);
  161.         }
  162.  
  163.  
  164. }
  165.  
  166. ///=============================
  167.  
  168.