home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / winevt.cxx < prev    next >
C/C++ Source or Header  |  1995-04-04  |  20KB  |  672 lines

  1.  
  2.  
  3.  
  4. /*
  5.  *
  6.  *          Copyright (C) 1994, M. A. Sridhar
  7.  *  
  8.  *
  9.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  10.  *     to copy, modify or distribute this software  as you see fit,
  11.  *     and to use  it  for  any  purpose, provided   this copyright
  12.  *     notice and the following   disclaimer are included  with all
  13.  *     copies.
  14.  *
  15.  *                        DISCLAIMER
  16.  *
  17.  *     The author makes no warranties, either expressed or implied,
  18.  *     with respect  to  this  software, its  quality, performance,
  19.  *     merchantability, or fitness for any particular purpose. This
  20.  *     software is distributed  AS IS.  The  user of this  software
  21.  *     assumes all risks  as to its quality  and performance. In no
  22.  *     event shall the author be liable for any direct, indirect or
  23.  *     consequential damages, even if the  author has been  advised
  24.  *     as to the possibility of such damages.
  25.  *
  26.  */
  27.  
  28.  
  29.  
  30. //  MS/Windows-specific stuff
  31.  
  32. #if defined(__GNUC__)
  33. #pragma implementation
  34. #endif
  35.  
  36.  
  37. #include "ui/cntroler.h"
  38. #include "ui/menu.h"
  39. #include "ui/btngroup.h"
  40.  
  41. #include <ctl3d.h>
  42.  
  43.  
  44. static struct {
  45.     UINT message;
  46.     UI_EventType yaclEvent;
  47. } TransTable [] = {
  48.     WM_SETFOCUS,        Event_GetFocus,
  49.     WM_KILLFOCUS,       Event_LoseFocus,
  50.     WM_LBUTTONDOWN,     Event_LButtonPress,
  51.     WM_LBUTTONUP,       Event_LButtonRelease,
  52.     WM_LBUTTONDBLCLK,   Event_LButtonDblClk,
  53.     WM_MBUTTONDOWN,     Event_MButtonPress,  
  54.     WM_MBUTTONUP,       Event_MButtonRelease, 
  55.     WM_MBUTTONDBLCLK,   Event_MButtonDblClk, 
  56.     WM_RBUTTONDOWN,     Event_RButtonPress,
  57.     WM_RBUTTONUP,       Event_RButtonRelease, 
  58.     WM_RBUTTONDBLCLK,   Event_RButtonDblClk,
  59.     WM_CHAR,            Event_KeyTyped,
  60.     WM_MOUSEMOVE,       Event_MouseMove,
  61.     WM_CLOSE,           Event_CloseDown,
  62.     WM_INITMENU,        Event_GetFocus,
  63.     WM_INITMENUPOPUP,   Event_GetFocus,
  64.     WM_MENUSELECT,      Event_GetFocus,
  65.     WM_MOVE,            Event_Reconfigure,
  66.     WM_SIZE,            Event_Reconfigure,
  67.     WM_PAINT,           Event_Paint,
  68.     WM_COMMAND,         Event_Select,
  69.     //    BM_SETCHECK,        Event_Select,
  70.     WM_VSCROLL,         Event_None, // Set by special handling
  71.     WM_HSCROLL,         Event_None, // Set by special handling
  72.     0,                  Event_Other
  73. };
  74.  
  75.  
  76. long FAR PASCAL _export YACLWindowProc (HWND, unsigned, WORD, LONG);
  77. long FAR PASCAL _export YACLDialogProc (HWND, unsigned, WORD, LONG);
  78.  
  79. bool UI_Controller::_DoOneEvent (NativeEventStruct& msg, UI_Event& e)
  80. {
  81.     // Process a single native event, return its translation in e. Return
  82.     // TRUE if everything is ok, FALSE if the termination filter said YES.
  83.  
  84.     bool dsp = FALSE;
  85.     dsp =  TranslateNativeEvent (msg, e);
  86.  
  87.     // Now here's a major HACK to handle tabs:
  88.     bool disp = (msg.message != WM_CHAR || msg.wParam != '\011');
  89.     if (!disp && e._origin) {
  90.         disp = (e._origin->_style & ES_MULTILINE) ||
  91.             (CL_String (e._origin->WindowClass()).InLowerCase() != "edit");
  92.         // A tab sent to a single-line edit control would cause a beep, so
  93.         // we don't dispatch it.
  94.     }
  95.  
  96.     // Windows requires cursor setting on every mouse move, otherwise
  97.     // it reverts to the window class cursor! (see the documentation
  98.     // for the SetCursor call) Setting of cursor on every move
  99.     // can only be avoided if we use a NULL for the window class
  100.     // cursor; but if we do that, we'll not able to set our mouse
  101.     // cursor when the mouse moves out of the client area and back in,
  102.     // because we have no way of knowing when the mouse has moved out
  103.     // of the client area. There's also the problem that cursor shape
  104.     // changes on click. 
  105.  
  106.     if (msg.message == WM_SETCURSOR  || msg.message == WM_MOUSEMOVE) {
  107.         if (_inWaitState)
  108.             SetCurrentCursor (_defaultCursor);
  109.         else {
  110.             POINT p;
  111.             GetCursorPos (&p);
  112.             HWND hWnd = WindowFromPoint (p);
  113.             UI_VisualObject* dest = (*this)[hWnd];
  114.             if (dest)
  115.                 SetCurrentCursor (dest->Cursor());
  116.         }
  117.     }
  118.  
  119.     if (disp && msg.message != WM_SETCURSOR)
  120.         DispatchMessage (&msg);
  121.  
  122.     if (e._origin && dsp && _viewTree
  123.         && _visualObjMap.IncludesKey (e._origin->_handle)) { 
  124.     //       ^^^^^^^^^^^^^^^^^^^^^^^
  125.     // These tests are is needed because it is possible that the
  126.     // DispatchMessage call above generated events that destroyed the
  127.     // tree or e._origin or both.
  128.         if ( !_eventFilter || _eventFilter->Execute (e, 0) ) {
  129.             if (e._origin->WindowClass() != _YACLWindowClassName)
  130.                 DispatchNativeEvent (e);
  131.             // We don't dispatch events from a VisualObject whose class is
  132.             // YACLWindowClassName, because those are done by the
  133.             // WindowProc.
  134.         }
  135.         if (_termination && _termination->Execute (e, 0))
  136.             return FALSE;
  137.     }
  138.     DispatchSoftEvents();
  139.     return TRUE;
  140. }
  141.  
  142. bool UI_Controller::ProcessNativeEvents ()
  143. {
  144.     NativeEventStruct msg;
  145.     while (_root && GetMessage (&msg, NULL, 0, 0) ) {
  146.         TranslateMessage (&msg);
  147.         UI_Event e (Event_None, NULL);
  148.         if (!_DoOneEvent (msg, e))
  149.             return FALSE;
  150.     }
  151.     return TRUE;
  152. }
  153.  
  154.  
  155. void UI_Controller::FlushEventQueue ()
  156. {
  157.     NativeEventStruct msg;
  158.     while (_root &&  PeekMessage (&msg, NULL, 0, 0, PM_REMOVE));
  159. }
  160.  
  161.  
  162. void UI_Controller::DispatchPendingEvents ()
  163. {
  164.     DispatchSoftEvents ();
  165.     NativeEventStruct msg;
  166.     UI_Event e (Event_None, NULL);
  167.     while (_root && PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)
  168.            && _DoOneEvent (msg, e));
  169. }
  170.  
  171.  
  172.  
  173. bool UI_Controller::DispatchNativeEvent ( UI_Event& e )
  174. {
  175.     if (!_root)
  176.         return TRUE;
  177.     bool ret_val = TRUE;
  178.     switch (e.Type ()) {
  179.     case Event_MouseMove:
  180.         if ( _current != e.Destination () ) {
  181.             // The mouse entered a different visual obj
  182.             if ( _current ) {
  183.                 UI_Event leave (Event_ViewLeave, _current);
  184.                 DispatchEvent (&leave);
  185.             }
  186.             _current = e.Destination ();
  187.             UI_Event enter (Event_ViewEnter, e.Destination ());
  188.             ret_val = DispatchEvent (&enter);
  189.         }
  190.         ret_val = DispatchEvent (&e);
  191.         break;
  192.  
  193.     default:
  194.         ret_val = DispatchEvent (&e);
  195.         break;
  196.     }
  197.     return ret_val;
  198. }
  199.  
  200.  
  201.  
  202.  
  203. // We need a MenuEntry class to maintain the _menuMap object. This is a map
  204. // of <menu item id, parent handle> pairs to menu item objects. This is the
  205. // only way we can decode the destination of a menu event.
  206.  
  207. class MenuEntry: public CL_Object {
  208.  
  209. public:
  210.     MenuEntry (UI_ViewID id, UI_ViewHandle handle)
  211.     : _id (id), _handle (handle) {};
  212.  
  213.     ~MenuEntry () {};
  214.  
  215.     short Compare (const CL_Object& o) const;
  216.  
  217.     const char* ClassName () const {return "MenuEntry";};
  218.     
  219. private:
  220.     UI_ViewID _id;
  221.     UI_ViewHandle _handle;
  222. };
  223.  
  224. short MenuEntry::Compare (const CL_Object& o) const
  225. {
  226.     const MenuEntry& entry = (const MenuEntry&) o;
  227.     if (_handle == entry._handle) 
  228.         return _id == entry._id ? 0 : (_id < entry._id ? -1 : 1);
  229.     return _handle < entry._handle ? -1 : 1;
  230. }
  231.  
  232.  
  233.  
  234. bool UI_Controller::MenuItemCreated (UI_MenuItem* item)
  235.     // Called from the MenuItem::_PrivateInitialize
  236. {
  237.     MenuEntry* entry = new MenuEntry
  238.         (item->_id, item->Container().Parent()->ViewHandle());
  239.     return _menuMap.Add (entry, (long) item);
  240. }
  241.  
  242.  
  243. bool UI_Controller::MenuItemDestroyed (UI_MenuItem* item)
  244.     // Called from the MenuItem destructor
  245. {
  246.     MenuEntry entry (item->_id, item->Container().Parent()->ViewHandle());
  247.     CL_PtrIntAssoc a = _menuMap.Remove (&entry);
  248.     return a.value != 0;
  249. }
  250.  
  251.  
  252. bool UI_Controller::TranslateNativeEvent (NativeEventStruct& msg, UI_Event& e)
  253. {
  254.     e._nativeEvent = new NativeEventStruct;
  255.     *(NativeEventStruct*)(e._nativeEvent) = msg;
  256.     e.curPos = UI_Rectangle (LOWORD (msg.lParam), HIWORD (msg.lParam), 0, 0);
  257.     e._metaKey = (msg.lParam & (1L << 29)) ? TRUE : FALSE;
  258.     e._shiftKey = (GetKeyState (VK_SHIFT) & 0x8000) ? TRUE : FALSE;
  259.     e._ctrlKey  = (GetKeyState (VK_CONTROL) & 0x8000) ? TRUE : FALSE;
  260.  
  261.  
  262.     UI_VisualObject* view = NULL;
  263.     for (short i = 0; TransTable [i].message != 0; i++) {
  264.         if (TransTable [i].message == msg.message)
  265.             break;
  266.     }
  267.     e._type = TransTable[i].yaclEvent;
  268.     UI_ViewHandle window_key;
  269.     if (msg.message == WM_INITMENU || msg.message == WM_INITMENUPOPUP) {
  270.         window_key = (long) msg.wParam;
  271.         e.param = msg.wParam;
  272.     }
  273.     else if (msg.message == WM_VSCROLL || msg.message == WM_HSCROLL) {
  274.         window_key = HIWORD (msg.lParam);
  275.         e.param = LOWORD (msg.lParam);
  276.         switch (msg.wParam) {
  277.         case SB_BOTTOM:
  278.             e._type = Event_ScrollToEnd;
  279.             break;
  280.  
  281.         case SB_ENDSCROLL:
  282.             e._type = Event_FinishScroll;
  283.             break;
  284.  
  285.         case SB_LINEDOWN:
  286.             e._type = Event_ScrollForwardLine;
  287.             break;
  288.  
  289.         case SB_PAGEDOWN:
  290.             e._type = Event_ScrollForwardPage;
  291.             break;
  292.  
  293.         case SB_LINEUP:
  294.             e._type = Event_ScrollBackwardLine;
  295.             break;
  296.  
  297.         case SB_PAGEUP:
  298.             e._type = Event_ScrollBackwardPage;
  299.             break;
  300.  
  301.         case SB_THUMBPOSITION:
  302.             e._type = Event_ScrollToPosition;
  303.             break;
  304.  
  305.         case SB_THUMBTRACK:
  306.             e._type = Event_Scroll;
  307.             break;
  308.         }
  309.     }
  310.     else
  311.         window_key = (long) msg.hwnd;
  312.     view = (UI_VisualObject *) _visualObjMap [window_key];
  313.     e._origin = e._dest = view;
  314.  
  315.     switch (msg.message) {
  316.     case WM_MOVE: {
  317.         long w = 0, h = 0;
  318.         if (view) {
  319.             w = view->_shape.Width();
  320.             h = view->_shape.Height();
  321.         }
  322.         e.curPos = UI_Rectangle (LOWORD (msg.lParam), HIWORD
  323.                                  (msg.lParam), w, h);
  324.         break;
  325.     }
  326.  
  327.     case WM_SIZE: {
  328.         long x = 0, y = 0;
  329.         if (view) {
  330.             x = view->_shape.Left();
  331.             y = view->_shape.Top();
  332.         }
  333.         e.curPos = UI_Rectangle (x, y, LOWORD (msg.lParam), HIWORD
  334.                                  (msg.lParam));
  335.         switch (msg.wParam) {
  336.         case SIZE_MINIMIZED:
  337.             e._type = Event_Iconify;
  338.             break;
  339.             
  340.         case SIZE_MAXIMIZED:
  341.             e._type = Event_FullScreen;
  342.             break;
  343.             
  344.         case SIZE_RESTORED:
  345.             e._type = (view && view->IsIconified()) ? Event_Deiconify
  346.                 : Event_Reconfigure;
  347.             break;
  348.             
  349.         default:
  350.             e._type = Event_Reconfigure;
  351.             break;
  352.         }
  353.         break;
  354.     }
  355.  
  356.     case WM_CHAR:
  357.         e.key = msg.wParam;
  358.         break;
  359.         
  360.     default:
  361.         break;
  362.     }
  363.     // Now process the menu messages
  364.     
  365.     if (msg.message == WM_MENUSELECT) {
  366.         MenuEntry entry (msg.wParam, msg.hwnd);
  367.         UI_MenuItem* itm = (UI_MenuItem*) _menuMap[&entry];
  368.         if (LOWORD (msg.lParam) == 0xffff && HIWORD (msg.lParam) == 0) {
  369.             // Menu closed
  370.             e._type = Event_LoseFocus;
  371.             e._origin = e._dest = itm;
  372.             _focus = NULL;
  373.         }
  374.         else {
  375.             if (_focus) {
  376.                 UI_Event loseFocus (Event_LoseFocus, _focus, _focus);
  377.                 DispatchEvent (&loseFocus);
  378.             }
  379.             e._type = Event_GetFocus;
  380.             e._origin = e._dest = _focus = itm;
  381.             e.param = msg.wParam;
  382.         }        
  383.     }
  384.     else if (msg.message == WM_COMMAND) {
  385.         if (LOWORD (msg.lParam) == 0) {
  386.             // Message from a menu: Event_Select
  387.             MenuEntry entry (msg.wParam, msg.hwnd);
  388.             UI_MenuItem* itm = (UI_MenuItem*) _menuMap[&entry];
  389.             e._origin = e._dest = itm;
  390.             e.param = msg.wParam; // Set the menu id
  391.         }
  392.         else {
  393.             // Message from a control
  394.             e._origin = e._dest = (UI_VisualObject*)
  395.                 _visualObjMap  [LOWORD (msg.lParam)];
  396.             switch (HIWORD (msg.lParam)) {
  397.             case LBN_SELCHANGE:
  398.             // case CBN_SELCHANGE:
  399.             // windows.h defines CBN_SELCHANGE == LBN_SELCHANGE!!
  400.             case BN_CLICKED:
  401.                 e._type = Event_Select;
  402.                 break;
  403.  
  404.             default:
  405.                 e._type = Event_Other;
  406.                 break;
  407.             }
  408.         }
  409.     }
  410.     return e._dest != NULL;
  411. }
  412.  
  413.  
  414.  
  415. void UI_Controller::_MakeWindowsInterface (const UI_Event& e)
  416. {
  417.     // We don't create the interface for the child of a composite if the
  418.     // composite was built from a resource under MS/Windows
  419.  
  420.     bool b = TRUE;
  421.     UI_VisualObject* origin = e.Origin();
  422.     UI_VisualObject* parent = origin->_parent;
  423.     bool res = parent && parent->CreatedViaResource ();
  424.     if (!parent || !res)
  425.         b = origin->MakeVisualElement ();
  426.     if (b && origin->ViewHandle ()) {
  427.         Register (origin);
  428.         if (!res)
  429.             ShowWindow (origin->ViewHandle (), 
  430.                         origin->_visible ? SW_SHOW : SW_HIDE
  431.                         );
  432.     }
  433.     origin->_PrivateInitialize ();
  434.     origin->Initialize ();
  435. }
  436.  
  437.  
  438. long UI_Controller::WindowProc ( HWND hWnd, unsigned message,
  439.                                  WORD wParam, LONG lParam)
  440. {
  441.     UI_Event e (Event_None, NULL);
  442.     NativeEventStruct msg;
  443.     msg.hwnd = hWnd;
  444.     msg.message = message;
  445.     msg.lParam = lParam;
  446.     msg.wParam = wParam;
  447.     TranslateNativeEvent (msg, e);
  448.     UI_VisualObject* v = e.Origin ();
  449.     long retVal = 0;
  450.     switch (message) {
  451.     case WM_SETTEXT:
  452.     case WM_NCPAINT:
  453.     case WM_NCACTIVATE:
  454.         if (!v || !v->Has3DLook()) 
  455.             retVal = DefWindowProc (hWnd, message, wParam, lParam);
  456.         else {
  457.             SetWindowLong (hWnd, DWL_MSGRESULT,
  458.                            Ctl3dDlgFramePaint (hWnd, message, wParam, lParam));
  459.             retVal = TRUE;
  460.         }
  461.         break;
  462.         
  463.         
  464.     case WM_CTLCOLOR: {
  465.         if (!v || !v->Has3DLook())
  466.             retVal = DefWindowProc (hWnd, message, wParam, lParam);
  467.         else {
  468.             HBRUSH hbr = Ctl3dCtlColorEx  (message, wParam, lParam);
  469.             if (hbr)
  470.                 retVal = hbr;
  471.             else
  472.                 retVal =_buttonFaceBrush;
  473.         }
  474.         break;
  475.     }
  476.         
  477.     case WM_COMMAND:
  478.         retVal = DefWindowProc (hWnd, message, wParam, lParam);
  479.         if (HIWORD(lParam) == 0) {
  480.             // Menu item was selected; now make it lose focus:
  481.             UI_Event event (Event_LoseFocus, e._origin, e._origin);
  482.             DispatchEvent (&event);
  483.         }
  484.         break;
  485.         
  486.  
  487.     case WM_PAINT: {
  488.         // Clear out any invalid area:
  489.         PAINTSTRUCT ps;
  490.         HDC hdc = BeginPaint (hWnd, &ps);
  491.         HBRUSH hbr = v && v->Has3DLook() ? _buttonFaceBrush
  492.             :  GetStockObject (WHITE_BRUSH);
  493.         FillRect (hdc, &ps.rcPaint, hbr);
  494.         EndPaint (hWnd, &ps);
  495.         retVal = 0;
  496.         break;
  497.     }
  498.         
  499.     case WM_ERASEBKGND:
  500.         // When a previously obscured window is unobscured, Windows sends a
  501.         // WM_PAINT, a WM_NCPAINT and a WM_ERASEBKGND, *in that order*. So
  502.         // if we call DefWindowProc in response to the WM_ERASEBKGND, the
  503.         // previously painted area is erased! So we don't call
  504.         // DefWindowProc, but instead:
  505.         retVal = 1; // Pretend we processed the message
  506.         break;
  507.  
  508.     case WM_CLOSE:
  509.         retVal = 0;
  510.         break;
  511.         
  512.     default:
  513.         retVal = DefWindowProc (hWnd, message, wParam, lParam);
  514.         break;
  515.     }
  516.     if (!_eventFilter || _eventFilter->Execute (e, 0) )
  517.         DispatchNativeEvent (e);
  518.     return retVal;
  519. }
  520.  
  521.  
  522.  
  523. long UI_Controller::DialogProc (HWND hWnd, unsigned message,
  524.                                 WORD wParam, LONG lParam)
  525. {
  526.     UI_Event e (Event_None, NULL);
  527.     NativeEventStruct msg;
  528.     msg.hwnd = hWnd;
  529.     msg.message = message;
  530.     msg.lParam = lParam;
  531.     msg.wParam = wParam;
  532.     TranslateNativeEvent (msg, e);
  533.     if ( !_eventFilter || _eventFilter->Execute (e, 0) ) {
  534.         DispatchNativeEvent (e);
  535.     }
  536.     if (message == WM_COMMAND && HIWORD(lParam) == 0) {
  537.         // Menu item was selected; now make it lose focus:
  538.         UI_Event event (Event_LoseFocus, e._origin, e._origin);
  539.         DispatchEvent (&event);
  540.     }
  541.     switch (message) {
  542.     case WM_SETTEXT:
  543.     case WM_NCPAINT:
  544.     case WM_NCACTIVATE:
  545.         SetWindowLong (hWnd, DWL_MSGRESULT,
  546.                        Ctl3dDlgFramePaint (hWnd, message, wParam, lParam));
  547.         return TRUE;
  548.         
  549.         
  550.     case WM_CTLCOLOR: {
  551.         HBRUSH hbr = Ctl3dCtlColorEx  (message, wParam, lParam);
  552.         if (hbr)
  553.             return hbr;
  554.         return _buttonFaceBrush;
  555.     }
  556.         
  557.     case WM_COMMAND:
  558.         if (HIWORD(lParam) == 0) {
  559.             // Menu item was selected; now make it lose focus:
  560.             UI_Event event (Event_LoseFocus, e._origin, e._origin);
  561.             DispatchEvent (&event);
  562.         }
  563.         break;
  564.         
  565.     }
  566.     return 0;
  567. }
  568.  
  569. long UI_Controller::BtnGroupProc (HWND hWnd, unsigned msg,
  570.                                   WORD wParam, LONG lP)
  571. {
  572.     int low = GetProp (hWnd, BTNGROUP_PROPERTY1);
  573.     int hi  = GetProp (hWnd, BTNGROUP_PROPERTY2);
  574.     UI_ButtonGroup* group = (UI_ButtonGroup*) _visualObjMap[hWnd];
  575.     if (low == 0 || hi == 0 || !group)
  576.         return DefWindowProc (hWnd, msg, wParam, lP);
  577.     FARPROC realProc = (FARPROC) MAKELONG (low, hi);
  578.     long retVal = 0L;
  579.     switch (msg) {
  580.     case WM_ERASEBKGND: {
  581.         RECT rect;
  582.         GetClientRect (hWnd, &rect);
  583.         HBRUSH brush = CreateSolidBrush
  584.             (GetSysColor (group->Has3DLook() ? COLOR_BTNFACE  :
  585.                           COLOR_WINDOW));
  586.         FillRect ((HDC) wParam, &rect, brush);
  587.         DeleteObject (brush);
  588.         // Now just call the real proc, pretending that no painting was
  589.         // done, and let it do its thing:
  590.         break;
  591.     }
  592.  
  593.  
  594.     case WM_CTLCOLOR: {
  595.         if (group && group->Has3DLook()) {
  596.             HBRUSH hbr = Ctl3dCtlColorEx  (msg, wParam, lP);
  597.             if (hbr)
  598.                 retVal =  hbr;
  599.         }
  600.         else
  601.             retVal = CallWindowProc (realProc, hWnd, msg, wParam, lP);
  602.         break;
  603.     }
  604.  
  605.     default:
  606.         retVal = CallWindowProc (realProc, hWnd, msg, wParam, lP);
  607.         break;
  608.     }
  609.     MSG mesg;
  610.     mesg.hwnd = hWnd;
  611.     mesg.message = msg;
  612.     mesg.lParam = lP;
  613.     mesg.wParam = wParam;
  614.     UI_Event e (Event_None, NULL);
  615.     TranslateNativeEvent (mesg, e);
  616.     DispatchNativeEvent (e);
  617.     return retVal;
  618. }
  619.  
  620.  
  621.  
  622. // MS Windows window manager messages caught here
  623.  
  624. long FAR PASCAL _export YACLWindowProc (HWND hwnd, unsigned msg, WORD
  625.                                         wParam, LONG lp)
  626. {
  627.    return _TheApplication->Controller().WindowProc (hwnd, msg, wParam, lp);
  628. }
  629.  
  630.  
  631.  
  632. long FAR PASCAL _export YACLDialogProc  (HWND h, unsigned m, WORD w, LONG l)
  633.     // (HWND, unsigned, WORD, LONG)
  634. {
  635.     return _TheApplication->Controller().DialogProc (h, m, w, l);
  636. }
  637.  
  638.  
  639. long FAR PASCAL _export YACLBtnGroupProc (HWND h, unsigned m,
  640.                                       WORD w, LONG l)
  641. {
  642.     return _TheApplication->Controller().BtnGroupProc (h, m, w, l);
  643. }
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650. void initApplicationMS(HANDLE hInst)
  651. {
  652.     WNDCLASS wc;
  653.  
  654.     wc.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
  655.     wc.lpfnWndProc   = (WNDPROC) YACLWindowProc;
  656.     wc.cbClsExtra    = NULL;
  657.     wc.cbWndExtra    = NULL;
  658.     wc.hInstance     = hInst;
  659.     wc.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
  660.     wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
  661.     wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  662.     wc.lpszMenuName  = NULL;
  663.     wc.lpszClassName = _YACLWindowClassName;
  664.     if ( !RegisterClass (&wc) )
  665.         CL_Error::Warning ("UI_Controller: RegisterClass '%s' failed!",
  666.                            wc.lpszClassName);
  667. }
  668.  
  669.  
  670.  
  671.  
  672.