Subversion Repositories Kolibri OS

Rev

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