home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / APP / WIN98 / SOURCEC / WIN98.C next >
C/C++ Source or Header  |  2002-01-14  |  3KB  |  163 lines

  1. /*
  2.  * Win98 - a fun program
  3.  */
  4. #include <cflib.h>
  5. #include <stdio.h>
  6. #include "win98.h"
  7. #ifndef FALSE
  8. #define FALSE    0
  9. #define TRUE    1
  10. #endif
  11.  
  12. #ifdef __MTAES__
  13. #define wind_create_grect(a,b)    wind_create(a,b)
  14. #define wind_calc_grect(a,b,c,d)    wind_calc(a,b,c,d)
  15. #define wind_open_grect(a,b)        wind_open(a,b)
  16. #define wind_set_str(a,b,c)        wind_set_string(a,b,c)
  17. extern int rc_intersect(GRECT *r1, GRECT *r2);
  18. #endif
  19.  
  20.  
  21. /* --------------------------------------------------------------------------- */
  22. OBJECT    *objdial;
  23. int        quit;
  24. int        msg[8], vdi_handle;
  25. int        event, msx, msy, mbutton, kstate, mclick, kreturn, win_handle;
  26. int        modal = FALSE;
  27. int        id = 1, pts = 10;
  28.  
  29. static void handle_msg(int *msg);
  30.  
  31. /* --------------------------------------------------------------------------- */
  32.  
  33.  
  34. void win_msg(int *msg)
  35. {
  36.     if (msg[3] == win_handle)
  37.     {
  38.         switch (msg[0])
  39.         {
  40.             case WM_CLOSED :
  41.                 wind_close(win_handle);
  42.                 break;
  43.             case WM_BOTTOMED:
  44.                 wind_set(win_handle, WF_BOTTOM, 0, 0, 0, 0);
  45.                 break;
  46.             case WM_NEWTOP:
  47.             case WM_TOPPED:
  48.                 wind_set(win_handle, WF_TOP, 0, 0, 0, 0);
  49.                 break;
  50.             case WM_MOVED:
  51.                 wind_set(win_handle, WF_CURRXYWH, msg[4], msg[5], msg[6], msg[7]);
  52.                 break;
  53.             case WM_SIZED:
  54.                 wind_set(win_handle, WF_CURRXYWH, msg[4], msg[5], msg[6], msg[7]);
  55.                 break;
  56.         }
  57.     }
  58. }
  59.  
  60. /* --------------------------------------------------------------------------- */
  61.  
  62. void win98_dial(void)
  63. {
  64.     void    *mdial;
  65.     int    close = FALSE;
  66.     int    id, exit_obj;
  67.     mdial = open_mdial(objdial, 0);
  68.     while (!close)
  69.     {
  70.         exit_obj = do_mdial(mdial);
  71.         switch (exit_obj)
  72.         {
  73.             case 14:
  74.             case 12:
  75.                 do_walert(1, 3, "[0][Unknown system failure #04676A56$46|Aborting registration procedure.][OK]",  " Error ");
  76.                 quit = TRUE;
  77.                 close = TRUE;
  78.                 break;
  79.             case VALIDATE :
  80.                 do_walert(1, 3, "[0][Invalid key. Please re-enter.][OK]",  " Error ");
  81.                 break;
  82.         }
  83.         if (get_flag(objdial, exit_obj, EXIT))
  84.             set_state(objdial, exit_obj, SELECTED, FALSE);
  85.         if (!close)
  86.             redraw_mdobj(mdial, exit_obj);
  87.     }
  88.     close_mdial(mdial);
  89. }
  90.  
  91. static void handle_msg(int *msg)
  92. {
  93.     if (!message_wdial(msg))
  94.     {
  95.     }
  96. }
  97.  
  98. /* --------------------------------------------------------------------------- */
  99.  
  100. int main(void)
  101. {
  102.     OBJECT    *tree;
  103.  
  104. #ifdef __MTAES__
  105.     GRECT        n = {0,0,0,0};
  106.     EVNTDATA    ev;
  107. #endif
  108.     
  109.     init_app("win98.rsc");
  110.     rsrc_gaddr(R_TREE, INFO, &objdial);
  111.     fix_dial(objdial);
  112.  
  113.     /* Callback für modale Fensterdialoge, Fenster-Alerts usw. */
  114.     set_mdial_wincb(handle_msg);
  115.     quit = FALSE;
  116.     win98_dial();
  117.     while (!quit)
  118.     {
  119.         mbutton = 0;
  120. #ifdef __MTAES__
  121.         event = evnt_multi(MU_MESAG|MU_BUTTON|MU_KEYBD,
  122.                                     1, 1, 1, 
  123.                                     0, &n, 0, &n,
  124.                                     msg, 0, &ev,
  125.                                     &kreturn, &mclick);
  126.         msx = ev.x;
  127.         msy = ev.y;
  128.         mbutton = ev.bstate;
  129.         kstate = ev.kstate;
  130. #else
  131.         event = evnt_multi(MU_MESAG|MU_BUTTON|MU_KEYBD,
  132.                                     1, 1, 1, 
  133.                                     0, 0, 0, 0, 0,
  134.                                     0, 0, 0, 0, 0,
  135.                                     msg, 0,
  136.                                     &msx, &msy, &mbutton, &kstate,
  137.                                     &kreturn, &mclick);
  138. #endif
  139.  
  140.         if (msg[0]==AP_TERM)
  141.                 quit = TRUE;
  142.  
  143.         if (event & MU_BUTTON) 
  144.         {
  145.             if (!click_wdial(mclick, msx, msy, kstate, mbutton))
  146.                 ;
  147.         }        
  148.         if (event & MU_KEYBD)
  149.         {
  150.             if (!key_wdial(kreturn, kstate))
  151.             {
  152.                 
  153.             }
  154.         }
  155.     } 
  156.     wind_close(win_handle);
  157.     wind_delete(win_handle);
  158.     v_clsvwk(vdi_handle);
  159.  
  160.     exit_app(0);
  161.     return 0;
  162. }
  163.