home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xfrmwnd.cpp < prev    next >
C/C++ Source or Header  |  1997-04-05  |  36KB  |  1,255 lines

  1. #include "XFrmwnd.h"
  2. #include "xexcept.h"
  3. #include "XResLib.h"
  4. #include "XMsgBox.h"
  5. #include "XRes.h"
  6. #include "XRect.h"
  7. #include "XString.h"
  8. #include "XFrame.h"
  9. #include "XColor.h"
  10. #include "XCombo.H"
  11. #include "XMLE.h"
  12. #include "XSlider.h"
  13. #include "XEntry.h"
  14. #include "XCheckBx.h"
  15. #include "XPushBtn.h"
  16. #include "XScrlBar.h"
  17. #include "XSpinBtn.h"
  18. #include "XListBox.h"
  19. #include "XCircSld.h"
  20. #include "XGroupBx.h"
  21. #include "XSBitmap.h"
  22. #include "XSIcon.h"
  23. #include "XSText.h"
  24. #include "XSFrame.h"
  25. #include "XValuSet.h"
  26. #include "XIcon.h"
  27. #include "XRadio.h"
  28. #include "XMenuBar.h"
  29. #include "XContain.h"
  30. #include "XProcess.h"
  31. #include "Xcntrevn.h"
  32. #include "XMedia.h"
  33. #include "XTimer.h"
  34. #include "XDragHdl.h"
  35. #include "XDragEvn.h"
  36. #include "XMousHdl.h"
  37. #include "XMousevn.h"
  38. #include "XWindow.h"
  39. #include "XContHdl.h"
  40. #include "XItmDHdl.h"
  41. #include "XBackHdl.h"
  42. #include "XStylHdl.h"
  43. #include "XdefHdl.h"
  44. #include "XTimer.h"
  45. #include "XScrlWnd.h"
  46. #include "XCntEvnt.h"
  47. #include "XCnEdEvn.h"
  48. #include "XCndrEvn.h"
  49. #include "xkeyevnt.h"
  50. #include "xkeybhdl.h"
  51. #include "XItmDEvn.h"
  52. #include "XBackEvn.h"
  53. #include "XNoteBk.h"
  54.  
  55. #include <stdlib.h>
  56. #include <string.h>
  57.  
  58. LONG MAXX = 0;
  59. LONG MAXY;
  60. SHORT cxDlgFrame;
  61. SHORT cyDlgFrame;
  62. SHORT cxBorder;
  63. SHORT cyBorder;
  64. SHORT cxSizeBorder;
  65. SHORT cySizeBorder;
  66.  
  67.  
  68. MRESULT HandleDefault(XWindow * w, ULONG msg, MPARAM mp1, MPARAM mp2, BOOL & handled)
  69. {
  70.     SHORT i;
  71.  
  72.     handled = TRUE;
  73.  
  74.     switch (msg)
  75.     {
  76.     case WM_TIMER:
  77.         {
  78.             handled = FALSE;
  79.             for (i = 0; i < w->handlers; i++)
  80.             {
  81.                 if (w->regHandlers[i]->GetID() == OOL_TIMER)
  82.                 {
  83.                     if (((XTimer *) w->regHandlers[i])->timerID == SHORT1FROMMP(mp1))
  84.                     {
  85.                         ((XTimer *) w->regHandlers[i])->TimerEvent();
  86.                         handled = TRUE;
  87.                         return (MRESULT) handled;
  88.                     }
  89.                 }
  90.             }
  91.         }
  92.         break;
  93.     case WM_HELP:
  94.         if (SHORT1FROMMR(WinSendMsg(WinQueryHelpInstance(w->winhandle), HM_DISPLAY_HELP, MPFROM2SHORT(WinQueryWindowUShort(WinQueryFocus(HWND_DESKTOP), QWS_ID), NULL), MPFROMSHORT(HM_RESOURCEID))) != 0)
  95.         {
  96.             if ((LONG) mp1 > 0)
  97.             {
  98.                 if (SHORT1FROMMR(WinSendMsg(WinQueryHelpInstance(w->winhandle), HM_DISPLAY_HELP, mp1, MPFROMSHORT(HM_RESOURCEID))) != 0)
  99.                     WinSendMsg(WinQueryHelpInstance(w->winhandle), HM_DISPLAY_HELP, MPFROM2SHORT(WinQueryWindowUShort(WinQueryWindow(WinQueryFocus(HWND_DESKTOP), QW_PARENT), QWS_ID), NULL), MPFROMSHORT(HM_RESOURCEID));
  100.             }
  101.             else
  102.                 WinSendMsg(WinQueryHelpInstance(w->winhandle), HM_DISPLAY_HELP, MPFROM2SHORT(WinQueryWindowUShort(WinQueryWindow(WinQueryFocus(HWND_DESKTOP), QW_PARENT), QWS_ID), NULL), MPFROMSHORT(HM_RESOURCEID));
  103.         }
  104.         return 0;
  105.     case WM_CONTROL:
  106.         switch (SHORT2FROMMP(mp1))
  107.         {
  108.         case CN_ENTER:
  109.         case CN_CONTEXTMENU:
  110.         case CN_DRAGOVER:
  111.         case CN_INITDRAG:
  112.         case CN_DROP:
  113.         case CN_EMPHASIS:
  114.         case CN_ENDEDIT:
  115.         case CN_REALLOCPSZ:
  116.         case CN_BEGINEDIT:
  117.             {
  118.                 SHORT i, ms = SHORT2FROMMP(mp1);
  119.                 XWindow *x = (XWindow *) WinQueryWindowPtr(WinWindowFromID(w->GetHandle(), SHORT1FROMMP(mp1)), 0);
  120.  
  121.                 if (!x)
  122.                     break;
  123.  
  124.                 for (i = 0; i < x->handlers; i++)
  125.                 {
  126.                     if (x->regHandlers[i]->GetID() == OOL_CONTAINERHANDLER)
  127.                     {
  128.                         if (ms == CN_DRAGOVER || ms == CN_DROP)
  129.                         {
  130.                             XContainerDragEvent dev(x, mp1, mp2);
  131.  
  132.                             ((XContainerHandler *) x->regHandlers[i])->HandleEvent(&dev);
  133.                             return MRFROM2SHORT(dev.accept, dev.operation);
  134.                         }
  135.                         if (ms == CN_BEGINEDIT || ms == CN_ENDEDIT || ms == CN_REALLOCPSZ)
  136.                         {
  137.                             XContainerEditEvent dev(x, mp1, mp2);
  138.  
  139.                             if (((XContainerHandler *) x->regHandlers[i])->HandleEvent(&dev) == TRUE)
  140.                                 handled = TRUE;
  141.                             else
  142.                                 handled = FALSE;
  143.                             return (MRESULT) handled;
  144.                         }
  145.                         else
  146.                         {
  147.                             XContainerEvent dev((XContainerControl *) x, mp1, mp2);
  148.  
  149.                             if (((XContainerHandler *) x->regHandlers[i])->HandleEvent(&dev) == TRUE)
  150.                                 handled = TRUE;
  151.                             return 0;
  152.                         }
  153.                     }
  154.                 }
  155.             }
  156.             break;
  157.         default:
  158.             {
  159.                 XControlEvent e(w, mp1, mp2);
  160.  
  161.                 handled = FALSE;
  162.             }
  163.         }
  164.         return 0;
  165.     case WM_DRAWITEM:
  166.         {
  167.             handled = FALSE;
  168.             SHORT i;
  169.             POWNERITEM o = (POWNERITEM) mp2;
  170.             XWindow *x = (XWindow *) WinQueryWindowPtr(o->hwnd, 0);
  171.  
  172.             if (x == 0)
  173.             {
  174.                 HWND hwnd = WinQueryWindow(o->hwnd, QW_OWNER);
  175.  
  176.                 while (hwnd)
  177.                 {
  178.                     x = (XWindow *) WinQueryWindowPtr(hwnd, 0);
  179.                     if (x)
  180.                         break;
  181.                     hwnd = WinQueryWindow(hwnd, QW_OWNER);
  182.                 }
  183.                 if (x == 0)
  184.                     break;
  185.             }
  186.             for (i = 0; i < x->handlers; i++)
  187.             {
  188.                 if (x->regHandlers[i]->GetID() == OOL_ITMDRAWHANDLER)
  189.                 {
  190.                     XItemDrawEvent dev(msg, mp1, mp2, ((XItemDrawHandler *) x->regHandlers[i])->type);
  191.  
  192.                     if (((XItemDrawHandler *) x->regHandlers[i])->HandleEvent(&dev) == TRUE)
  193.                         handled = TRUE;
  194.                     return (MRESULT) TRUE;
  195.                 }
  196.             }
  197.         }
  198.         break;
  199.     case WM_COMMAND:
  200.         if (w->DoCommand(SHORT1FROMMP(mp1)) == FALSE)
  201.             handled = FALSE;
  202.         return 0;
  203.     case WM_PRESPARAMCHANGED:
  204.         {
  205.             handled = FALSE;
  206.             for (i = 0; i < w->handlers; i++)
  207.             {
  208.                 if (w->regHandlers[i]->GetID() == OOL_STYLEHANDLER)
  209.                 {
  210.                     XEvent evn((LONG) mp1);
  211.  
  212.                     if (((XStyleHandler *) w->regHandlers[i])->HandleEvent(&evn) == TRUE)
  213.                         handled = TRUE;
  214.                     return (MRESULT) handled;
  215.                 }
  216.             }
  217.         }
  218.         break;
  219.     case CM_PAINTBACKGROUND:
  220.         {
  221.             handled = FALSE;
  222.             for (i = 0; i < w->handlers; i++)
  223.             {
  224.                 if (w->regHandlers[i]->GetID() == OOL_BACKDRAWHANDLER)
  225.                 {
  226.                     XBackgroundDrawEvent dev(msg, mp1);
  227.  
  228.                     if (((XBackgroundDrawHandler *) w->regHandlers[i])->HandleEvent(&dev) == TRUE)
  229.                         handled = TRUE;
  230.                     return (MRESULT) handled;
  231.                 }
  232.             }
  233.         }
  234.         return (MRESULT) FALSE;
  235.     case WM_BUTTON1DOWN:
  236.     case WM_BUTTON1DBLCLK:
  237.     case WM_BUTTON1CLICK:
  238.     case WM_BUTTON1UP:
  239.     case WM_BUTTON2DOWN:
  240.     case WM_BUTTON2DBLCLK:
  241.     case WM_BUTTON2CLICK:
  242.     case WM_BUTTON2UP:
  243.     case WM_BUTTON3DOWN:
  244.     case WM_BUTTON3DBLCLK:
  245.     case WM_BUTTON3CLICK:
  246.     case WM_BUTTON3UP:
  247.     case WM_BEGINDRAG:
  248.     case WM_MOUSEMOVE:
  249.         {
  250.             handled = FALSE;
  251.             for (i = 0; i < w->handlers; i++)
  252.             {
  253.                 if (w->regHandlers[i]->GetID() == OOL_MOUSEHANDLER)
  254.                 {
  255.                     XMouseEvent dev(msg, mp1, mp2);
  256.  
  257.                     ((XMouseHandler *) w->regHandlers[i])->HandleEvent(&dev);
  258.                     break;
  259.                 }
  260.             }
  261.         }
  262.         break;
  263.     case WM_CHAR:
  264.         {
  265.             handled = FALSE;
  266.             for (i = 0; i < w->handlers; i++)
  267.             {
  268.                 if (w->regHandlers[i]->GetID() == OOL_KEYBHANDLER)
  269.                 {
  270.                     XKeyboardEvent dev(SHORT1FROMMP(mp2), SHORT1FROMMP(mp1), CHAR4FROMMP(mp1));
  271.  
  272.                     if (((XKeyboardHandler *) w->regHandlers[i])->HandleEvent(&dev) == TRUE)
  273.                         handled = TRUE;
  274.                     else
  275.                         handled = FALSE;
  276.                     break;
  277.                 }
  278.             }
  279.         }
  280.         break;
  281.     case DM_DISCARDOBJECT:
  282.     case DM_PRINTOBJECT:
  283.     case DM_ENDCONVERSATION:
  284.         {
  285.             char className[5];
  286.  
  287.             WinQueryClassName(w->GetHandle(), 5, (PCH) className);
  288.             className[0] = ' ';
  289.             SHORT classtype = atol(className);
  290.             XContainerControl *cd = NULL;
  291.  
  292.             if (classtype == 37)
  293.             {
  294.                 if (!(w))
  295.                     return (MRESULT) FALSE;
  296.             }
  297.             for (i = 0; i < w->handlers; i++)
  298.             {
  299.                 if (w->regHandlers[i]->GetID() == OOL_DRAGHANDLER)
  300.                 {
  301.                     XDragEvent dev(msg, mp1);
  302.  
  303.                     if (msg == DM_PRINTOBJECT)
  304.                         dev.printer = (PPRINTDEST) mp2;
  305.                     ((XDragHandler *) w->regHandlers[i])->HandleEvent(&dev);
  306.                     return MRFROM2SHORT(dev.accept, dev.operation);
  307.                 }
  308.                 if (w->regHandlers[i]->GetID() == OOL_CONTAINERHANDLER)
  309.                 {
  310.                     cd = (XContainerControl *) ((XContainerHandler *) w->regHandlers[i])->GetWindow();
  311.                     if (msg == DM_DISCARDOBJECT || msg == DM_PRINTOBJECT)
  312.                     {
  313.                         XContainerDragEvent dev(cd, NULL, NULL);
  314.  
  315.                         dev.dragInfo = (PDRAGINFO) mp1;
  316.                         dev.window = cd;
  317.                         dev.windowID = WinQueryWindowUShort(cd->GetHandle(), QWS_ID);
  318.                         dev.eventID = msg;
  319.                         if (msg == DM_PRINTOBJECT)
  320.                             dev.printer = (PPRINTDEST) mp2;
  321.                         ((XContainerHandler *) w->regHandlers[i])->HandleEvent(&dev);
  322.                     }
  323.                     else
  324.                     {
  325.                         XContainerEvent dev(cd, mp1, mp2);
  326.  
  327.                         dev.eventID = msg;
  328.                         handled = TRUE;
  329.                         return (MRESULT) ((XContainerHandler *) w->regHandlers[i])->HandleEvent(&dev);
  330.                     }
  331.                 }
  332.             }
  333.         }
  334.         return (MRESULT) FALSE;
  335.     case DM_DROP:
  336.     case DM_DRAGOVER:
  337.         {
  338.             for (i = 0; i < w->handlers; i++)
  339.             {
  340.                 if (w->regHandlers[i]->GetID() == OOL_DRAGHANDLER)
  341.                 {
  342.                     XDragEvent dev(msg, mp1);
  343.  
  344.                     ((XDragHandler *) w->regHandlers[i])->HandleEvent(&dev);
  345.                     return MRFROM2SHORT(dev.accept, dev.operation);
  346.                 }
  347.             }
  348.             handled = FALSE;
  349.         }
  350.         return (MRESULT) FALSE;
  351.     case WM_MOVE:
  352.         handled = FALSE;
  353.         w->DoMove();
  354.         break;
  355.     case WM_SIZE:
  356. //          WinDefWindowProc( w->GetHandle(), msg, mp1, mp2);
  357.         {
  358.              XSize s(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
  359.             w->DoSize( &s);
  360.             handled = FALSE;
  361.         }
  362.         return 0;
  363.     case WM_DESTROY:
  364.         return 0;
  365.     case WM_FOCUSCHANGE:
  366.         w->FocusChanged(SHORT1FROMMP(mp2));
  367.         handled = FALSE;
  368.         break;
  369.     case WM_PAINT:
  370.         w->Draw();
  371.         handled = FALSE;
  372.         break;
  373.     case WM_MEASUREITEM:
  374.         {
  375.             handled = FALSE;
  376.             SHORT i;
  377.             XWindow *x;
  378.             HWND hwnd = WinWindowFromID(w->GetHandle(), (ULONG) SHORT1FROMMP(mp1));
  379.  
  380.             if (hwnd)
  381.                 return 0;
  382.  
  383.             POWNERITEM o = (POWNERITEM) mp2;
  384.  
  385.             x = (XWindow *) WinQueryWindowPtr(o->hwnd, 0);
  386.             if (x == 0)
  387.             {
  388.                 hwnd = WinQueryWindow(o->hwnd, QW_OWNER);
  389.                 while (hwnd)
  390.                 {
  391.                     x = (XWindow *) WinQueryWindowPtr(hwnd, 0);
  392.                     if (x)
  393.                         break;
  394.                     hwnd = WinQueryWindow(hwnd, QW_OWNER);
  395.                 }
  396.                 if (x == 0)
  397.                     break;
  398.             }
  399.             for (i = 0; i < x->handlers; i++)
  400.             {
  401.                 if (x->regHandlers[i]->GetID() == OOL_ITMDRAWHANDLER)
  402.                 {
  403.                     XItemDrawHandler *d = (XItemDrawHandler *) x->regHandlers[i];
  404.  
  405.                     handled = TRUE;
  406.                     o->rclItem.yTop = d->height;
  407.                     o->rclItem.xRight = d->width;
  408.                     return MRFROM2SHORT(d->width, d->height);
  409.                 }
  410.             }
  411.         }
  412.         break;
  413.     case MEDIA_NOTIFY:
  414.         {
  415.             XControlEvent evn(SHORT2FROMMP(mp1));
  416.  
  417.             w->DoControl(&evn);
  418.         }
  419.         return 0;
  420.     default:
  421.         {
  422.             handled = FALSE;
  423.             for (i = 0; i < w->handlers; i++)
  424.             {
  425.                 if (w->regHandlers[i]->GetID() == OOL_DEFAULTHANDLER)
  426.                 {
  427.                     ((XDefaultHandler *) w->regHandlers[i])->HandleEvent(msg, mp1, mp2);
  428. //                        return (MRESULT) handled;
  429.                 }
  430.             }
  431.         }
  432.         handled = FALSE;
  433.         break;
  434.     }
  435.     return (MRESULT) FALSE;
  436. }
  437.  
  438.  
  439. MRESULT HandleFrameDefault(XFrameWindow * w, ULONG msg, MPARAM mp1, MPARAM mp2, BOOL & handled)
  440. {
  441.     handled = TRUE;
  442.  
  443.     switch (msg)
  444.     {
  445.     case WM_COMMAND:
  446.         handled = TRUE;
  447.         w->DoCommand(SHORT1FROMMP(mp1));
  448.         return 0;
  449.     case WM_INITMENU:
  450.         {
  451.             XMenu *menu = (XMenu *) WinQueryWindowPtr((HWND) mp2, 0);
  452.  
  453.             w->InitMenu(menu);
  454.             handled = FALSE;
  455.         }
  456.         return 0;
  457.     case WM_CLOSE:
  458.         if (w->QueryForClose() == TRUE)
  459.             delete w;
  460.  
  461.         return 0;
  462.     case WM_SIZE:
  463.         handled = TRUE;
  464. //          WinDefWindowProc( w->GetHandle(), msg, mp1, mp2);
  465.         if (w->dlgHandle)
  466.             WinSetWindowPos(w->dlgHandle, 0, 0, 0, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SWP_SIZE);
  467.         break;
  468.     }
  469.     return HandleDefault(w, msg, mp1, mp2, handled);
  470. }
  471.  
  472.  
  473. MRESULT EXPENTRY WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  474. {
  475.     XFrameWindow *w;
  476.  
  477.     if (msg == WM_CREATE)
  478.     {
  479.         WinSetWindowPtr(hwnd, 0, (void *) mp1);
  480.         mp1 = NULL;
  481.         return WinDefWindowProc(hwnd, msg, mp1, mp2);
  482.     }
  483.     else
  484.         w = (XFrameWindow *) WinQueryWindowPtr(hwnd, 0);
  485.  
  486.     if (w)
  487.     {
  488.         if (w->enabled == FALSE && msg != WM_PAINT && msg != WM_CONTROLPOINTER && msg != WM_DRAWITEM && msg != WM_ERASEBACKGROUND && msg != WM_QUERYBORDERSIZE)
  489.             return 0;
  490.  
  491.         BOOL handeld = FALSE;
  492.         MRESULT mr = HandleFrameDefault(w, msg, mp1, mp2, handeld);
  493.  
  494.         if (handeld)
  495.             return mr;
  496.     }
  497.     return WinDefWindowProc(hwnd, msg, mp1, mp2);
  498. }
  499.  
  500.  
  501. MRESULT EXPENTRY DProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  502. {
  503.     XFrameWindow *w = (XFrameWindow *) WinQueryWindowPtr(hwnd, 0);
  504.  
  505.     if (w)
  506.     {
  507.         if (w->enabled == FALSE && msg != WM_PAINT && msg != WM_CONTROLPOINTER && msg != WM_DRAWITEM && msg != WM_ERASEBACKGROUND && msg != WM_QUERYBORDERSIZE && msg != WM_HELP)    // && msg != WM_CONTROL)
  508.             return 0;
  509.  
  510.         BOOL handeld = FALSE;
  511.         MRESULT mr = HandleFrameDefault(w, msg, mp1, mp2, handeld);
  512.  
  513.         if (handeld)
  514.             return mr;
  515.     }
  516.     return WinDefDlgProc(hwnd, msg, mp1, mp2);
  517. }
  518.  
  519.  
  520. /*@ 
  521. @class XFrameWindow
  522. @parent XWindow
  523. @type overview
  524. @symbol _
  525. @remarks XFrameWindow is a window class which has a child and a frame. It supports menus and toolbars.
  526. */
  527.  
  528.  
  529. /*@ XFrameWindow::Activate(void)
  530. @parent XWindow
  531. @group display a window
  532. @remarks Activate the window
  533. */
  534. void XFrameWindow::Activate(void)
  535. {
  536.     WinSetActiveWindow(HWND_DESKTOP, frame);
  537. }
  538.  
  539.  
  540. /*@ XFrameWindow :: ~XFrameWindow()
  541. @group constructors/destructors
  542. @remarks Destructors of windows are called automaticaly when the window is closed.
  543. The destructor of XFrameWindow calles the destructor of every client window, menus and
  544. toolbars. Also the destructors of handlers (derived classes of XHandler) which are
  545. attached with it are called. If the last XFrameWindow of a process is closed, the process
  546. will terminate.<BR>
  547. If you want to close a window yourself, destruct the window with delete.
  548. */
  549. XFrameWindow :: ~XFrameWindow()
  550. {
  551.     HWND hwnd;
  552.     HENUM enumWindow;
  553.  
  554.     if (lockingWin)
  555.     {
  556.         lockingWin->enabled = TRUE;
  557.         lockingWin->Enable();
  558.         lockingWin = NULL;
  559.     }
  560.  
  561.     WinSetWindowPtr(frameWin->winhandle, 0, NULL);
  562.     WinSetWindowPtr(winhandle, 0, NULL);
  563.  
  564.     hwnd = WinWindowFromID(frame, FID_MENU);
  565.     XMenuBar *m = (XMenuBar *) WinQueryWindowPtr(hwnd, 0);
  566.  
  567.     if (m)
  568.         delete m;
  569.  
  570.     if (dlgHandle)
  571.     {
  572.         enumWindow = WinBeginEnumWindows(dlgHandle);
  573.         while ((hwnd = WinGetNextWindow(enumWindow)) != 0)
  574.         {
  575.             XWindow *w = (XWindow *) WinQueryWindowPtr(hwnd, 0);
  576.  
  577.             if (w)
  578.                 delete w;
  579.         };
  580.         WinEndEnumWindows(enumWindow);
  581.         WinDismissDlg(dlgHandle, 1);
  582.         WinDestroyWindow(dlgHandle);
  583.     }
  584.  
  585.     enumWindow = WinBeginEnumWindows(winhandle);
  586.     char str[5];
  587.  
  588.     while ((hwnd = WinGetNextWindow(enumWindow)) != NULLHANDLE)
  589.     {
  590.         XWindow *w = (XWindow *) WinQueryWindowPtr(hwnd, 0);
  591.  
  592.         if (w && w != this)
  593.         {
  594.             WinQueryClassName(hwnd, 5, (PCH) str);
  595.             if (strcmp(str, "#1") == 0)
  596.             {
  597.                 XFrame *f = (XFrame *) w;
  598.  
  599.                 if (f->frame)
  600.                     delete f->frame;
  601.  
  602.                 else
  603.                     delete f;
  604.             }
  605.             else
  606.                 delete w;
  607.         }
  608.     }
  609.     WinEndEnumWindows(enumWindow);
  610.  
  611.     XProcess *p = (XProcess *) WinQueryWindowULong(winhandle, 4);
  612.  
  613.     p->RemoveWindow(this);        // test
  614.  
  615.     delete frameWin;
  616.  
  617.     if (clientWindow)
  618.         delete clientWindow;
  619.  
  620.     WinDestroyWindow(frame);
  621. }
  622.  
  623.  
  624. /*@ XFrameWindow::ShowModal(XFrameWindow * w)
  625. @group display a window
  626. @remarks ShowModal displays a window modal for another window which is specified in the first parameter,
  627. that means that the user cannot perform any input with the specified window.
  628. WARNING: you should only use this function for windows which are constructed with a resource template!
  629. If you do so the operating system stops with executing the calling code until the window is closed,
  630. otherwise the calling code is executed while the window is displayed.
  631. @parameters XFrameWindow * theOwnerWindow   the window which is disabled until this window is closed
  632. */
  633. void XFrameWindow::ShowModal(XFrameWindow * w)
  634. {
  635.     if (!w)
  636.         return;
  637.  
  638.     lockingWin = w;
  639.     w->enabled = FALSE;
  640.     w->Enable(FALSE);
  641.  
  642.     if (dlgHandle)
  643.         WinProcessDlg(dlgHandle);
  644. }
  645.  
  646.  
  647. /*@ XFrameWindow::InitMenu()
  648. @group display a window
  649. @remarks If a menu must be initialized this function is called. If you
  650. want to setup the menu dynamicaly, override this function.
  651. @parameters   XMenu * theMenu
  652. */
  653.  
  654.  
  655. /*@ XFrameWindow::GetHandle()
  656. @group misc
  657. @remarks GetHandle returns the window-handle defined by the operating system. The handle is different
  658. from the ID of the window and the pointers used by the OOL. In XFrameWindow the function returns:
  659. <OL COMPACT>
  660. <LI>if you have set a client window with function XFrameWindow::SetClient() the handle of the client
  661. <LI>if the XFrameWindow displays a resource-defined window, the resource window handle is returned
  662. <LI>on default, the handle of the client-rect is returned
  663. </OL>
  664. @returns       OOL_WINDOWHANDLE  theSystemHandle
  665. */
  666. OOL_WINDOWHANDLE XFrameWindow::GetHandle() const
  667. {
  668.     if (clientWindow)
  669.         return clientWindow->winhandle;
  670.     return dlgHandle ? dlgHandle : winhandle;
  671. }
  672.  
  673.  
  674. /*@ XFrameWindow::Enable(const BOOL enable)
  675. @group display a window
  676. @remarks Enables/disables a window for user-input
  677. @parameters    BOOL enable     enables/disables the window (default is TRUE)
  678. */
  679. void XFrameWindow::Enable(const BOOL enable)
  680. {
  681.     WinEnableWindow(frame, enable);
  682. }
  683.  
  684.  
  685. /*@ XFrameWindow::EnableWindowUpdate(const BOOL enable) 
  686. @group drawing a window
  687. @remarks This function can stop drawing the window contents until you allow drawing.
  688. For complex windows there can be some performance-advantages.<BR>
  689. <B>WARNING:</B> If you disable drawing of a window and attach a XToolBar to it, the position
  690. and size of the toolbar can not set correctly.
  691. @parameters    BOOL enable    enable/disable window drawing (default is TRUE)
  692. */
  693. void XFrameWindow::EnableWindowUpdate(const BOOL enable) const
  694. {
  695.     WinEnableWindowUpdate(winhandle, enable);
  696. }
  697.  
  698.  
  699. /*@ XFrameWindow::FillBackground(void)
  700. @group drawing a window
  701. @remarks FillBackground fills the background in the color you have set with
  702. SetBackgroundColor (default is black). Usualy you call this function when
  703. you have overridden XFrameWindow::Draw(). You don∩t have to call this function if a resource defined
  704. window is displayed or a window is set as client with XFrameWindow::SetClient().
  705. */
  706. void XFrameWindow::FillBackground(void)
  707. {
  708.     RECTL rec;
  709.     HPS hps = WinBeginPaint(winhandle, NULLHANDLE, &rec);
  710.  
  711.     GpiCreateLogColorTable(hps, LCOL_RESET, LCOLF_RGB, 0, 1, &backCol);
  712.     WinFillRect(hps, &rec, (LONG) backCol);
  713.     WinEndPaint(hps);
  714. }
  715.  
  716.  
  717. /*@ XFrameWindow::SetBackgroundColor(const XColor * col)
  718. @group colors
  719. @remarks With this function you set the color wich is used to fill the
  720. background in XFrameWindow::FillBackground(). Default color is black. If you change
  721. background color, you should do this before you start to insert
  722. client-windows.
  723. @parameters XColor * theNewColor
  724. */
  725. void XFrameWindow::SetBackgroundColor(const XColor * col)
  726. {
  727.     backCol = col->GetColor();
  728.     if (dlgHandle)
  729.         WinSetPresParam(dlgHandle, PP_BACKGROUNDCOLOR, 4, &backCol);
  730. }
  731.  
  732.  
  733. void XFrameWindow::GetBackgroundColor(XColor * rgb)
  734. {
  735.     if (dlgHandle)
  736.     {
  737.         LONG c;
  738.  
  739.         WinQueryPresParam(dlgHandle, PP_BACKGROUNDCOLOR, 0, NULL, 4, &c, QPF_PURERGBCOLOR);
  740.         rgb->SetColor(c);
  741.     }
  742.     else
  743.         rgb->SetColor(backCol);
  744. }
  745.  
  746. /*@ XFrameWindow::GetText(XString * buffer)
  747. @group text functions
  748. @remarks Query the title of the window
  749. @parameters    XString * theBuffer       theBuffer will contain the title of the window
  750. */
  751. void XFrameWindow::GetText(XString * buffer)
  752. {
  753.     SHORT r = WinQueryWindowTextLength(frame);
  754.  
  755.     r = WinQueryWindowText(frame, r + 1, (PCH) buffer->GetBuffer(r + 1));
  756.     buffer->ReleaseBuffer(r);
  757. }
  758.  
  759.  
  760. /*@ XFrameWindow::SetBottom(void)
  761. @group size/position/order
  762. @remarks Set the window to the bottom (in z-order)
  763. */
  764. void XFrameWindow::SetBottom(void) const
  765. {
  766.     WinSetWindowPos(frame, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
  767. }
  768.  
  769.  
  770. /*@ XFrameWindow::SetIcon(const XIcon * icon)
  771. @group misc
  772. @remarks Set the icon which is displayed in the button of the system menu.
  773. @parameters    OOL_ICONHANDLE theNewIcon
  774. */
  775. void XFrameWindow::SetIcon(const XIcon * icon)
  776. {
  777.     WinSendMsg(frame, WM_SETICON, MPFROMP(icon->GetHandle()), 0);
  778. }
  779.  
  780.  
  781. /*@ XFrameWindow::SetText(const char *buffer)
  782. @group text functions
  783. @remarks Set the Text which is displayed in the titlebar
  784. @parameters    char * theNewText
  785. */
  786. void XFrameWindow::SetText(const char *buffer)
  787. {
  788.     WinSetWindowText(frame, (PSZ) buffer);
  789. }
  790.  
  791.  
  792. /*@ XFrameWindow::SetTop(void)
  793. @group size/position/order
  794. @remarks Set the window to the top (in z-order)
  795. */
  796. void XFrameWindow::SetTop(void) const
  797. {
  798.     WinSetWindowPos(frame, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
  799. }
  800.  
  801.  
  802. /*@ XFrameWindow::Show(const BOOL show)
  803. @group size/position/order
  804. @remarks Displayes a window. The window wil be activated an be shown at the topmost position
  805. (in z-order). If the window is minimized the old position and size will be restored.
  806. @parameters BOOL show            TRUE=show, FALSE=hide
  807. */
  808. void XFrameWindow::Show(const BOOL show)
  809. {
  810.     if (show)
  811.         WinSetWindowPos(frame, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE | SWP_RESTORE);
  812.     else
  813.         WinSetWindowPos(frame, 0, 0, 0, 0, 0, SWP_HIDE);
  814. }
  815.  
  816.  
  817. /*@ XFrameWindow::SetClient(const XWindow * c)
  818. @group misc
  819. @remarks SetClient is used to set a window, for example a control like a XMultiLineEdit,
  820. as a clientwindow of the XFrameWindow so sizing, moving and painting is automaticaly done.
  821. Moving/Sizing automaticaly may fail if the client is a frame-window.
  822. @parameters XWindow * theNewClient
  823. */
  824. BOOL XFrameWindow::SetClient(const XWindow * c)
  825. {
  826.     if (c->GetHandle() == 0)
  827.         return FALSE;
  828.     if (frameWin)
  829.         frameWin->adds += 1;
  830.     WinSetOwner(c->winhandle, frame);
  831.     WinSetParent(c->winhandle, frame, FALSE);
  832.     clientWindow = (XWindow *) c;
  833.     SWP swp;
  834.  
  835.     WinQueryWindowPos(winhandle, &swp);
  836.     WinSetWindowPos(c->winhandle, 0, swp.x, swp.y, swp.cx, swp.cy, SWP_SIZE | SWP_MOVE | SWP_SHOW);
  837.     return TRUE;
  838. }
  839.  
  840.  
  841. /*@ XFrameWindow::GetProcess(void)
  842. @group misc
  843. @remarks Returns a pointer to the owning process (XApplication or XThread or derived class) of this window.
  844. @returns XProcess * onwer process
  845. */
  846. XProcess * XFrameWindow::GetProcess(void) const
  847. {
  848.     return (XProcess *) WinQueryWindowULong(winhandle, 4);
  849. }
  850.  
  851.  
  852. void BuildChilds(HWND dlgHandle)
  853. {
  854.     HWND hwnd;
  855.     char className[50];
  856.     SHORT classtype;
  857.     HENUM enumWindow = WinBeginEnumWindows(dlgHandle);
  858.     XWindow *du;
  859.  
  860.     while ((hwnd = WinGetNextWindow(enumWindow)) != 0)
  861.     {
  862.         WinQueryClassName(hwnd, 50, (PCH) className);
  863.         className[0] = ' ';
  864.         classtype = atol(className);
  865.         switch (classtype)
  866.         {
  867.         case 1:                // Frame
  868.             du = new XFrame(hwnd);
  869.             break;
  870.         case 2:                // Combobox
  871.             du = new XComboBox(hwnd);
  872.             break;
  873.         case 3:                // Button
  874.             {
  875.                 ULONG style = WinQueryWindowULong(hwnd, QWL_STYLE);
  876.  
  877.                 if (style & BS_AUTOCHECKBOX)
  878.                     du = new XCheckBox(hwnd);    // CheckBox
  879.                 else
  880.                 {
  881.                     if (style & BS_AUTORADIOBUTTON)    // RadioButton
  882.                         du = new XRadioButton(hwnd);
  883.                     else
  884.                         du = new XPushButton(hwnd);    // PushButton
  885.                 }
  886.             }
  887.             break;
  888.         case 4:                // Menu
  889.             du = new XMenuBar(hwnd);
  890.             break;
  891.         case 5:                // Static
  892.             {
  893.                 ULONG style = WinQueryWindowULong(hwnd, QWL_STYLE);
  894.  
  895.                 if (style & SS_GROUPBOX)
  896.                     du = new XGroupBox(hwnd);
  897.                 if (style & SS_TEXT)
  898.                     du = new XStaticText(hwnd);
  899.                 if (style & SS_ICON)
  900.                     du = new XStaticIcon(hwnd);
  901.                 if (style & SS_BITMAP)
  902.                     du = new XStaticBitmap(hwnd);
  903.             }
  904.             break;
  905.         case 6:                // EntryField
  906.             du = new XEntryField(hwnd);
  907.             break;
  908.         case 7:                // Listbox
  909.             du = new XListBox(hwnd);
  910.             break;
  911.         case 8:                // ScrollBar
  912.             du = new XScrollBar(hwnd);
  913.             break;
  914.         case 10:                // MLE
  915.             du = new XMultiLineEdit(hwnd);
  916.             break;
  917.         case 32:                // SpinButton
  918.             du = new XSpinButton(hwnd);
  919.             break;
  920.         case 37:                // Container
  921.             du = new XContainerControl(hwnd);
  922.             break;
  923.         case 38:                // Slider
  924.             du = new XSlider(hwnd);
  925.             break;
  926.         case 39:                // ValueSet
  927.             du = new XValueSet(hwnd);
  928.             break;
  929.         case 40:                // Notebook
  930.             du = new XNoteBook(hwnd);
  931.             break;
  932. /*
  933.                  case 64:                                                   //GraphicButton
  934.                     du = new XGraphicButton( hwnd ); break;
  935. */
  936.         case 65:                // CircularSlider
  937.             du = new XCircularSlider(hwnd);
  938.             break;
  939.         }
  940.     }
  941.     WinEndEnumWindows(enumWindow);
  942. }
  943.  
  944.  
  945. XMenuBar *XFrameWindow::GetMenu(void) const
  946. {
  947.     return (XMenuBar *) frameWin->GetWindow(FID_MENU);
  948. }
  949.  
  950.  
  951. /*@ XFrameWindow :: XFrameWindow(const XResource * id, const char *title, const ULONG style, const XRect * rec, const XFrameWindow * parent, const BOOL build, const BOOL animate)
  952. @group constructors/destructors
  953. @remarks Construct a frame-window
  954. Note that destructors of windows are called automaticaly when a window is closed! (see ~XFrameWindow)
  955. @parameters <t '°' c=2>
  956.                 °XResource * resource        °a XResource contains two informations, an ID and a pointer
  957.                                         to a XResourceLibrary. If you want to create a window out of
  958.                                         a resourcefile you must specify the ID (otherwise it can be zero)
  959.                                         and the XResourceLibrary which contains the window-resource.
  960.                                         The window which is created always belongs to the process who
  961.                                         owns the resource library, so if you work with multiple processes
  962.                                         every process must have its own resource library.
  963.             °char * theTitle             °The title of the window which is displayed in the titlebar
  964.             °ULONG style                 °You can specify the style of the window with the following defines,
  965.                                         which can be or-ed:
  966.                                                         <t '°' c=2>
  967.                                            °FRM_TITLEBAR     °the window gets a titlebar
  968.                                            °FRM_SYSMENU      °the window gets the system menu
  969.                                            °FRM_MINBUTTON    °the titlebar get a button to minimize the window
  970.                                            °FRM_MAXBUTTON    °the titlebar get a button to maximize the window
  971.                                            °FRM_CENTER       °the window is created in the midle of the workplace
  972.                                            °FRM_SIZEBORDER   °the windowsize can be changed by the user
  973.                                            °FRM_DIALOGBORDER °the window gets a thick border
  974.                                            °FRM_BORDER       °the window gets a thin border
  975.                                            °FRM_TASKLIST     °the window is displayed in the tasklist
  976.                                            °FRM_NOMOVEWITHOWNER  °the window dont∩t move when the parent is moved
  977.                                            °FRM_ICON         °the window get an icon wich is identified by theResourceID,
  978.                                                             if the icon is not found in the resource-library, an error ocurses
  979.                                            °FRM_ACCELTABLE   °an acceltable will be loaded from the resources with the windows id.
  980.                                            °FRM_SYSMODAL     °the window is displayed system-modal
  981.                                            °FRM_SCREENALIGN    °
  982.                                            °FRM_MOUSEALIGN    °
  983.                                            °FRM_HIDEBUTTON    °
  984.                                            °FRM_HIDEMAX    °
  985.                                            °FRM_AUTOICON    °
  986.                                                         </t>                                                
  987.                                         there are three static member-variables for default styles
  988.                                                         <t '°' c=2>
  989.                                            °defaultStyle          °default setting for a framewindow
  990.                                            °defaultClientStyle    °default setting for windows wich are displayed as a clientwindow of a framewindow
  991.                                            °defaultDialogStyle    °default setting for windows wich are displayed as a dialog
  992.                                                         </t>
  993.                                         Default is defaultStyle.
  994.             °XRect * theRectangle        °On default a window is created with length and hight of zero. Windows
  995.                                         which are created with an resource template get the size of the template.
  996.                                         Default is NULL.
  997.                                         If theRectangle is specified, the window gets the size of it.
  998.             °XFrameWindow * parent       °If parent is specified the window is a client of the parent. The
  999.                                         behavior depends on the styles you have set.
  1000.                                         Default is NULL.
  1001.             °BOOL buildFromResource      °If this variable is set OOL try to build the window with a resource
  1002.                                         template which is identified by theResourceID. If the template is
  1003.                                         not found, an error ocurses.
  1004.                                         Default is FALSE.
  1005.             °BOOL animate                °Enable/disable animation on window creation. Default is FALSE
  1006.                 </t>
  1007. @exceptions    If the method fails an exception of the type XException is thrown.
  1008. */
  1009. XFrameWindow :: XFrameWindow(const XResource * id,
  1010.              const char *title,
  1011.              const ULONG style,
  1012.              const XRect * rec,
  1013.              const XFrameWindow * parent,
  1014.              const BOOL build,
  1015.              const BOOL animate)
  1016. {
  1017.     HWND p = parent ? parent->winhandle : HWND_DESKTOP;
  1018.     SWP swp;
  1019.     LONG xRight = 0, yBottom = 0;
  1020.  
  1021.     memset(&swp, 0, sizeof(SWP));
  1022.  
  1023.     frame = 0;
  1024.     clientWindow = NULL;
  1025.     vert = horz = NULL;
  1026.     lockingWin = NULL;
  1027.  
  1028.     if (MAXX == 0)
  1029.     {
  1030.         MAXX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  1031.         MAXY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  1032.         cxDlgFrame = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME);
  1033.         cyDlgFrame = WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME);
  1034.         cxBorder = WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER);
  1035.         cyBorder = WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER);
  1036.         cxSizeBorder = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER);
  1037.         cySizeBorder = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
  1038.     }
  1039.  
  1040.     enabled = TRUE;
  1041.     dummy = 0;
  1042.  
  1043.     if (WinRegisterClass(id->GetResourceLibrary()->GetProcess()->hab, (PSZ) "OOL_FRAMEWND", (PFNWP) WindowProc, CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT, 8) == FALSE)
  1044.         OOLThrow("error creating framewindow - couldn∩t register class", -10);
  1045.  
  1046.     backCol = 0;
  1047.     dlgHandle = 0;
  1048.  
  1049.     FRAMECDATA fcmd;
  1050.  
  1051.     fcmd.cb = sizeof(fcmd);
  1052.     fcmd.flCreateFlags = style | FCF_NOBYTEALIGN;
  1053.     fcmd.hmodResources = id->GetResourceLibrary()->GetModuleHandle();
  1054.     fcmd.idResources = id->GetID();
  1055.  
  1056.     frame = WinCreateWindow(p, WC_FRAME, (PSZ) title, 0, 0, 0, 0, 0, p, HWND_TOP, id->GetID(), &fcmd, NULL);
  1057.     winhandle = WinCreateWindow(frame, (PSZ) "OOL_FRAMEWND", (PSZ) "", (animate ? WIN_ANIMATE : 0), 0, 0, 0, 0, 0, HWND_TOP, FID_CLIENT, this, NULL);
  1058.  
  1059.     if (frame == 0)
  1060.         OOLThrow("error creating framewindow - couldn∩t create frame, perhaps resources missing", -10);
  1061.  
  1062.     WinSetWindowULong(winhandle, 4, (LONG) id->GetResourceLibrary()->GetProcess());
  1063.  
  1064.     frameWin = new XFrame(this);
  1065.  
  1066.     if (style & FRM_MENU)
  1067.     {
  1068.         HWND menu = WinQueryWindow(frame, FID_MENU);
  1069.         XMenuBar *b = new XMenuBar(menu);
  1070.     }
  1071.  
  1072.     if (build)
  1073.     {
  1074.         XColor col(COL_PALEGRAY);
  1075.  
  1076.         SetBackgroundColor(&col);
  1077.         dlgHandle = WinLoadDlg(winhandle, winhandle, (PFNWP) DProc, id->GetResourceLibrary()->GetModuleHandle(), id->GetID(), NULL);
  1078.         if (dlgHandle == 0)
  1079.         {
  1080.             OOLThrow("could not create window from resources!", 0);
  1081.             return;
  1082.         }
  1083.         WinSetWindowPtr(dlgHandle, 0, this);
  1084.  
  1085.         BuildChilds(dlgHandle);
  1086.  
  1087.         SHORT x = 0, y = 0;
  1088.  
  1089.         if (style & FCF_TITLEBAR)
  1090.             y = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
  1091.         if (style & FCF_DLGBORDER)
  1092.         {
  1093.             x = cxDlgFrame;
  1094.             y += cyDlgFrame;
  1095.         }
  1096.         if (style & FCF_SIZEBORDER)
  1097.         {
  1098.             x = cxBorder;
  1099.             y += cyBorder;
  1100.         }
  1101.         if (style & FCF_BORDER)
  1102.         {
  1103.             x = cxSizeBorder;
  1104.             y += cySizeBorder;
  1105.         }
  1106.  
  1107.         x += x;
  1108.  
  1109.         WinQueryWindowPos(dlgHandle, &swp);
  1110.  
  1111.         WinSetWindowPos(dlgHandle, 0, 0, 0, 0, 0, SWP_MOVE | SWP_SHOW);
  1112.         swp.cx += x;
  1113.         swp.cy += y;
  1114.     }
  1115.     else
  1116.     {
  1117.         if (rec)
  1118.         {
  1119.             swp.cx = rec->GetWidth();
  1120.             swp.cy = rec->GetHeight();
  1121.         }
  1122.     }
  1123.  
  1124.     if (style & FRM_CENTER)
  1125.     {
  1126.         if (dlgHandle)
  1127.         {
  1128.             xRight = MAXX / 2 - swp.cx / 2;
  1129.             yBottom = MAXY / 2 - swp.cy / 2;
  1130.         }
  1131.         else
  1132.         {
  1133.             if (rec)
  1134.             {
  1135.                 xRight = MAXX / 2 - rec->GetWidth() / 2;
  1136.                 yBottom = MAXY / 2 - rec->GetHeight() / 2;
  1137.             }
  1138.         }
  1139.     }
  1140.     else
  1141.     {
  1142.         if (rec)
  1143.         {
  1144.             xRight = rec->GetX();
  1145.             yBottom = rec->GetY();
  1146.         }
  1147.     }
  1148.  
  1149.     ULONG m = SWP_MOVE | SWP_SIZE | SWP_ZORDER;
  1150.  
  1151.     if (style & WIN_VISIBLE)
  1152.         m |= SWP_SHOW;
  1153.     WinSetWindowPos(frame, HWND_TOP, xRight, yBottom, swp.cx, swp.cy, m);
  1154.  
  1155.     id->GetResourceLibrary()->GetProcess()->AddWindow(this);
  1156. }
  1157.  
  1158.  
  1159. /*@ XFrameWindow::SetSize(const XRect * rect) 
  1160. @group size/position/order
  1161. @remarks Set the size and/or position of a window
  1162. @parameters    XRect * theNewSize
  1163. */
  1164. void XFrameWindow::SetSize(const XRect * rect) const
  1165. {
  1166.     WinSetWindowPos(frame, 0, rect->x, rect->y, rect->cx, rect->cy, SWP_SHOW | SWP_MOVE | SWP_SIZE);
  1167. }
  1168.  
  1169.  
  1170. /*@ XFrameWindow::GetSize(XRect * rect)
  1171. @group size/position/order
  1172. @remarks Get the size and position of a window
  1173. @parameters    XRect * buffer to hold data
  1174. */
  1175. void XFrameWindow::GetSize(XRect * rect) const
  1176. {
  1177.     SWP swp;
  1178.  
  1179.     WinQueryWindowPos(frame, &swp);
  1180.     rect->x = swp.x;
  1181.     rect->y = swp.y;
  1182.     rect->cx = swp.cx;
  1183.     rect->cy = swp.cy;
  1184. }
  1185.  
  1186.  
  1187. /*@ XFrameWindow::GetClientSize(XRect * rect)
  1188. @group size/position/order
  1189. @remarks Query the size of the client area
  1190. @parameters XRect * rect   buffer to hold the data
  1191. */
  1192. void XFrameWindow::GetClientSize(XRect * rect) const
  1193. {
  1194.     XWindow::GetSize(rect);
  1195.     rect->SetX(0);
  1196.     rect->SetY(0);
  1197. }
  1198.  
  1199.  
  1200. /*@ XFrameWindow::GetWindow(const ULONG id)
  1201. @group misc
  1202. @remarks With GetWindow you can get a pointer of a child-window of XFrameWindow.
  1203. Usualy it is used if the XFrameWindow is created with a resource template.<BR>
  1204. Also you can get a pointer to windows which are created dynamicaly if you have specified an
  1205. ID in the constructors of these windows. In this case you don∩t need to store the pointers
  1206. in your program.
  1207. @parameters    ULONG theWindowID      the ID of the client window
  1208. @returns       XWindow * thePointer   the pointer to the window you have asked for. If you
  1209.                                       know the type of the window, you can make a typcast to
  1210.                                       the needed class.
  1211. */
  1212. XWindow * XFrameWindow::GetWindow(const ULONG id)
  1213. {
  1214.     XWindow *win = XWindow::GetWindow(id);
  1215.  
  1216.     if (win)
  1217.         return win;
  1218.     if (clientWindow)
  1219.     {
  1220.         if (WinQueryWindowUShort(clientWindow->winhandle, QWS_ID) == id)
  1221.             return clientWindow;
  1222.     }
  1223.     return NULL;
  1224. }
  1225.  
  1226.  
  1227. /*@ XFrameWindow::QueryForClose()
  1228. @group misc
  1229. @remarks If the user trys to close a XFrameWindow this function is called. If you want
  1230. to check if the window can be closed or not or to perform a security-check (for example
  1231. with XMessageBox), override this function. This function is not called if you destroy
  1232. the window with delete.
  1233. @returns       BOOL canBeClosed    return TRUE if the window can be closed, otherwise return FALSE
  1234. */
  1235.  
  1236.  
  1237. /*@ XFrameWindow::DoCommand()
  1238. @group user input
  1239. @remarks If the user selected a menuitem (from XMenuBar or XPopupMenu) if the
  1240. user pressed a button of a toolbar which is attached to it the framewindow, this function
  1241. is called. To get the ID of the action the user requested, override this function.
  1242. Return TRUE if you have handled the command, otherwise return FALSE.
  1243. @parameters   LONG theCommandID    the ID of the menuitem/toolbar-button
  1244. @returns      BOOL handled
  1245. */
  1246.  
  1247.  
  1248. /*@ XFrameWindow::Draw()
  1249. @group drawing a window
  1250. @remarks This function is called if a window or a part of it must be redrawn.
  1251. If you use a window which is not created from a resource template or you dont∩t
  1252. have set a client with SetClient(), you must override this function and call
  1253. FillBackground().
  1254. */
  1255.