home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool_main.zip / ool / source / xwindow.cpp < prev    next >
C/C++ Source or Header  |  1998-04-06  |  19KB  |  727 lines

  1. #include "XWindow.h"
  2.  
  3. #include "XString.h"
  4. #include "XRect.h"
  5. #include "XColor.h"
  6. #include "XHandler.h"
  7. #include "XPoint.h"
  8. #include "xreswin.h"
  9. #include "xapp.h"
  10. #include "xexcept.h"
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14.  
  15. void BuildChilds(HWND dlgHandle);
  16.  
  17. /*@ XWindow :: GetSysValue( LONG valueID )
  18. @group misc
  19. @remarks Query a system-value
  20. @parameters LONG id of the value (SV_* see OS/2 documentation)
  21. @returns LONG value
  22. */
  23. LONG XWindow :: GetSysValue( LONG valueID )
  24. {
  25.    return WinQuerySysValue( HWND_DESKTOP, valueID);
  26. }
  27.  
  28.  
  29. /*@
  30. @class XObject
  31. @type overview
  32. @symbol _
  33. @remarks The base of the Open Object Library
  34. */
  35.  
  36. /*@
  37. @class XWindow
  38. @type overview
  39. @parent XObject
  40. @symbol _
  41. @remarks XWindow is the base class for several window classes.
  42. */
  43.  
  44.  
  45. /*@ XWindow :: Close()
  46. @group misc
  47. @remarks Close the window
  48. */
  49. void XWindow :: Close() const
  50. {
  51.    WinSendMsg( winhandle, WM_CLOSE, 0, 0);
  52. }
  53.  
  54.  
  55. /*@ XWindow::SetParent(const XWindow * w, const BOOL redraw)
  56. @group misc
  57. @remarks Set a new parent for  this window
  58. @parameters
  59. <t '°' c=2>
  60. °XWindow * °the new parent
  61. °BOOL °redraw the window
  62. </t>
  63. */
  64. void XWindow::SetParent(const XWindow * w, const BOOL redraw) const
  65. {
  66.    WinSetParent(winhandle, w->GetHandle(), redraw);
  67. }
  68.  
  69.  
  70. /*@ XWindow::SetOwner(const XWindow * w)
  71. @group misc
  72. @remarks Set a new owner for  this window
  73. @parameters
  74. <t '°' c=2>
  75. °XWindow * °the new parent
  76. </t>
  77. */
  78. void XWindow::SetOwner(const XWindow * w) const
  79. {
  80.    WinSetOwner(winhandle, w->GetHandle());
  81. }
  82.  
  83.  
  84. /*@ XWindow::SetStyle(const ULONG style)
  85. @group style
  86. @remarks Set the style of a window
  87. @parameters ULONG style    the new syle (depending on the type of window)
  88. */
  89. void XWindow::SetStyle(const ULONG style)
  90. {
  91.    WinSetWindowULong(winhandle, QWL_STYLE, style);
  92. }
  93.  
  94.  
  95. /*@ XWindow::GetStyle(void)
  96. @group style
  97. @remarks Query the current style of the window.
  98. @returns ULONG style
  99. */
  100. ULONG XWindow::GetStyle(void) const
  101. {
  102.    return WinQueryWindowULong(winhandle, QWL_STYLE);
  103. }
  104.  
  105.  
  106. /*@ XWindow::DoControl(XControlEvent * e)
  107. @group user input
  108. @remarks If the user has done some interaction with a window this function is called.
  109. To get information about the event, override this function, the parameter holds
  110. information of your interest.
  111. @parameters   XControlEvent * pointerOfEvent   a pointer to an instance of XControlEvent
  112. */
  113. void XWindow::DoControl(XControlEvent * e)
  114. {
  115.    XWindow *w = QueryWindow(QW_PARENT);
  116.  
  117.    if (w)
  118.       w->DoControl(e);
  119. }
  120.  
  121.  
  122. /*@ XWindow::SetPointer(const OOL_POINTERHANDLE thePointer)
  123. @group pointer
  124. @remarks Set the actual pointer. You can receive a pointer-handle by calling GetSystemPointer()
  125. or load a pointer from a resource with XResourceLibrary::LoadIcon.
  126. @parameters OOL_POINTERHANDLE handle   the pointer
  127. */
  128. BOOL XWindow::SetPointer(const OOL_POINTERHANDLE thePointer)
  129. {
  130.    return WinSetPointer(HWND_DESKTOP, thePointer);
  131. }
  132.  
  133.  
  134. /*@ XWindow::GetPointerHandle(void)
  135. @group pointer
  136. @remarks Returns the handle of the actual pointer.
  137. @returns OOL_POINTERHANDLE handle
  138. */
  139. OOL_POINTERHANDLE XWindow::GetPointerHandle(void)
  140. {
  141.    return WinQueryPointer(HWND_DESKTOP);
  142. }
  143.  
  144.  
  145. /*@ XWindow::GetSystemPointerHandle(LONG theID, BOOL copy)
  146. @group pointer
  147. @remarks Returns the handle of the pointer identified by theID.
  148. @parameters   <t '°' c=2>
  149.                °LONG theID             °ID of the needed pointer. Valid values are:
  150. <BR>
  151. PTR_ARROW
  152. <BR>
  153. PTR_TEXT
  154. <BR>
  155. PTR_WAIT
  156. <BR>
  157. PTR_SIZE
  158. <BR>
  159. PTR_SIZENWSE
  160. <BR>
  161. PTR_SIZENESW
  162. <BR>
  163. PTR_SIZEWE
  164. <BR>
  165. PTR_SIZENS
  166. <BR>
  167. PTR_MOVE
  168. <BR>
  169. PTR_ILLEGAL
  170.                   °BOOL copy              °If you need a copy of the pointer (to modify
  171.                                          it) set copy TRUE, otherwise FALSE.<BR>
  172.                                       Default is FALSE.
  173.                </t>
  174. @returns OOL_POINTERHANDLE handle
  175. */
  176. OOL_POINTERHANDLE XWindow :: GetSystemPointerHandle( const LONG theID, const BOOL copy)
  177. {
  178.    return WinQuerySysPointer(HWND_DESKTOP, theID, copy);
  179. }
  180.  
  181.  
  182. /*@ XWindow::GetPointerPos(XPoint * p)
  183. @group pointer
  184. @remarks Returns the position of the pointer
  185. @parameters XPoint * point    buffer to hold the datas
  186. */
  187. void XWindow::GetPointerPos(XPoint * p)
  188. {
  189.    POINTL pointl;
  190.  
  191.    WinQueryPointerPos(HWND_DESKTOP, &pointl);
  192.    p->Set(pointl.x, pointl.y);
  193. }
  194.  
  195.  
  196. /*@ XWindow::Activate(void)
  197. @group misc
  198. @remarks Activate the window
  199. */
  200. void XWindow::Activate(void) const
  201. {
  202.    WinSetActiveWindow(HWND_DESKTOP, winhandle);
  203. }
  204.  
  205.  
  206. /*@ XWindow::IsVisible(void)
  207. @group misc
  208. @remarks Query if the window is visible or not
  209. @returns BOOL result
  210. */
  211. BOOL XWindow::IsVisible(void) const
  212. {
  213.    return WinIsWindowVisible(winhandle);
  214. }
  215.  
  216.  
  217. /*@ XWindow::GetSize(XRect * rect)
  218. @group size/position/order
  219. @remarks Query the size and position of the window
  220. @parameters XRect * rect   buffer to hold the datas
  221. */
  222. void XWindow::GetSize(XRect * rect) const
  223. {
  224.    SWP swp;
  225.  
  226.    WinQueryWindowPos(winhandle, &swp);
  227.    rect->x = swp.x;
  228.    rect->y = swp.y;
  229.    rect->cx = swp.cx;
  230.    rect->cy = swp.cy;
  231. }
  232.  
  233.  
  234. /*@ XWindow::GetWindowID(void)
  235. @group misc
  236. @remarks Query the ID of the window
  237. @returns SHORT theID
  238. */
  239. SHORT XWindow::GetWindowID(void) const
  240. {
  241.    return WinQueryWindowUShort(winhandle, QWS_ID);
  242. }
  243.  
  244.  
  245. /*@ XWindow::QueryWindow(const ULONG id)
  246. @group misc
  247. @remarks Find a window with the given relationship
  248.             ULONG relationship:
  249.                                  <t '°' c=1>
  250.                                  °WIN_NEXT
  251.                                  °WIN_PREV
  252.                                  °WIN_TOP
  253.                                  °WIN_BOTTOM
  254.                                  °WIN_OWNER
  255.                                  °WIN_PARENT
  256.                                  °WIN_NEXTTOP
  257.                                  °WIN_PREVTOP
  258.                                  °WIN_FRAMEOWNER
  259.                                  </t>
  260. @returns XWindow * pointer
  261. */
  262. XWindow * XWindow::QueryWindow(const ULONG id) const
  263. {
  264.    HWND hwnd = WinQueryWindow(winhandle, id);
  265.    return (XWindow *) WinQueryWindowPtr(hwnd, 0);
  266. }
  267.  
  268.  
  269. /*@ XWindow::GetWindow(const ULONG id)
  270. @group misc
  271. @remarks Find a child-window with the given ID
  272. @parameters ULONG theID    ID of the window to find
  273. @returns XWindow * pointer
  274. */
  275. XWindow * XWindow::GetWindow(const ULONG id)
  276. {
  277.    HWND hwnd = WinWindowFromID(GetHandle(), id);
  278.  
  279.    return (XWindow *) WinQueryWindowPtr(hwnd, 0);
  280. }
  281.  
  282.  
  283. /*@ XWindow::SetTop(void)
  284. @group size/position/order
  285. @remarks The window is set to the top in z-order
  286. */
  287. void XWindow::SetTop(void) const
  288. {
  289.    WinSetWindowPos(winhandle, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
  290. }
  291.  
  292.  
  293. /*@ XWindow::Enable(const BOOL enable)
  294. @group misc
  295. @remarks Enable/disable the window
  296. @parameters BOOL enabe     TRUE=enable, FALSE=disable
  297. */
  298. void XWindow::Enable(const BOOL enable)
  299. {
  300.    WinEnableWindow(winhandle, enable);
  301. }
  302.  
  303.  
  304. /*@ XWindow::EnableWindowUpdate(const BOOL enable)
  305. @group misc
  306. @remarks Enable/disable window-update
  307. @parameters BOOL enabe     TRUE=enable, FALSE=disable window-update
  308. */
  309. void XWindow::EnableWindowUpdate(const BOOL enable) const
  310. {
  311.    WinEnableWindowUpdate(winhandle, enable);
  312. }
  313.  
  314.  
  315. /*@ XWindow::GetText(XString * buffer)
  316. @group text functions
  317. @remarks Query the text of the window
  318. @parameters XString * buffer     buffer to hold the text
  319. */
  320. void XWindow::GetText(XString * buffer) const
  321. {
  322.    SHORT r = WinQueryWindowTextLength(winhandle);
  323.  
  324.    r = WinQueryWindowText(winhandle, r + 1, (PCH) buffer->GetBuffer(r));
  325.    buffer->ReleaseBuffer(r);
  326. }
  327.  
  328.  
  329. /*@ XWindow::GetUpdateRect(XRect * r)
  330. @group size
  331. @remarks Get the rectangle which should be redrawn
  332. @parameters XRect * rect      buffer
  333. */
  334. void XWindow::GetUpdateRect(XRect * r) const
  335. {
  336.    RECTL rect;
  337.  
  338.    WinQueryUpdateRect(winhandle, &rect);
  339.    r->SetX(rect.xLeft);
  340.    r->SetY(rect.yBottom);
  341.    r->SetWidth(rect.xRight - rect.xLeft);
  342.    r->SetHeight(rect.yTop - rect.yBottom);
  343. }
  344.  
  345.  
  346. /*@ XWindow::SetSize(const XRect * rect)
  347. @group size
  348. @remarks Set the size and position of the window
  349. @parameters XRect * rect   new size and position
  350. */
  351. void XWindow::SetSize(const XRect * rect) const
  352. {
  353.    WinSetWindowPos(winhandle, 0, rect->x, rect->y, rect->cx, rect->cy, SWP_SHOW | SWP_MOVE | SWP_SIZE);
  354. }
  355.  
  356.  
  357. /*@ XWindow::SetSize(SetSize( const ULONG xPos, const ULONG yPos, const ULONG width, const ULONG height)
  358. @group size/position/order
  359. @remarks Set the size and/or position of a window
  360. @parameters
  361. <t '°' c=2>
  362. °ULONG °xPosition
  363. °ULONG °yPosition
  364. °ULONG °width
  365. °ULONG °height
  366. </t>
  367. */
  368. void XWindow::SetSize(const ULONG xPos, const ULONG yPos, const ULONG width, const ULONG height) const
  369. {
  370.    WinSetWindowPos(winhandle, 0, xPos, yPos, width, height, SWP_SHOW | SWP_MOVE | SWP_SIZE);
  371. }
  372.  
  373.  
  374. /*@ XWindow::SetText(const char *text)
  375. @group text functions
  376. @remarks Set the text of the window
  377. @parameters char * text    text to display
  378. */
  379. void XWindow::SetText(const char *text)
  380. {
  381.    WinSetWindowText(winhandle, (PSZ) text);
  382. }
  383.  
  384.  
  385. /*@ XWindow::Show(const BOOL show)
  386. @group size/position/order
  387. @remarks Show/hide the window
  388. @parameters BOOL show            TRUE=show, FALSE=hide
  389. */
  390. void XWindow::Show(const BOOL show)
  391. {
  392.    if (show)
  393.       WinSetWindowPos(winhandle, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE | SWP_RESTORE);
  394.    else
  395.       WinSetWindowPos(winhandle, 0, 0, 0, 0, 0, SWP_HIDE);
  396. }
  397.  
  398.  
  399. /*@ XWindow::SetFocus(void)
  400. @group focus
  401. @remarks Set the focus to this window
  402. @returns BOOL result
  403. */
  404. BOOL XWindow::SetFocus(void) const
  405. {
  406.    return WinSetFocus(HWND_DESKTOP, winhandle);
  407. }
  408.  
  409.  
  410. /*@ XWindow::GetTextLength(void)
  411. @group text functions
  412. @remarks Query the length of the windows text
  413. @returns LONG length
  414. */
  415. LONG XWindow::GetTextLength(void) const
  416. {
  417.    return WinQueryWindowTextLength(winhandle);
  418. }
  419.  
  420.  
  421. /*@ XWindow::Invalidate(BOOL invalidateChilds)
  422. @group misc
  423. @remarks Invalidates the window content, it will be redrawn
  424. @parameters BOOL childs    TRUE=childs of the window are invalidated too
  425.                            FALSE=childs are not invalidated
  426. */
  427. void XWindow::Invalidate(BOOL invalidateChilds, XRect * rect )
  428. {
  429.    if( rect == NULL)
  430.       WinInvalidateRegion(winhandle, NULLHANDLE, invalidateChilds);
  431.    else
  432.    {
  433.       RECTL r;
  434.       r.xLeft = rect->GetX();
  435.       r.yBottom = rect->GetY();
  436.       r.yTop = r.yBottom + rect->GetHeight();
  437.       r.xRight = r.xLeft + rect->GetWidth();
  438.       WinInvalidateRect(winhandle, &r, invalidateChilds);
  439.    }
  440. }
  441.  
  442.  
  443. /*@ XWindow::SetBottom(void)
  444. @group size/position/order
  445. @remarks The window is set to the bottom in z-order
  446. */
  447. void XWindow::SetBottom(void) const
  448. {
  449.    WinSetWindowPos(winhandle, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
  450. }
  451.  
  452.  
  453. /*@ XWindow::GetForegroundColor(XColor * rgb)
  454. @group colors
  455. @remarks Query the foreground-color of the window
  456. @parameters XColor * color buffer to hold data
  457. */
  458. void XWindow::GetForegroundColor(XColor * rgb) const
  459. {
  460.    LONG c;
  461.  
  462.    WinQueryPresParam(winhandle, PP_FOREGROUNDCOLOR, 0, NULL, 4, &c, QPF_PURERGBCOLOR);
  463.    rgb->SetColor(c);
  464. }
  465.  
  466.  
  467. /*@ XWindow::GetBackgroundColor(XColor * rgb)
  468. @group colors
  469. @remarks Query the background-color of the window
  470. @parameters XColor * color buffer to hold data
  471. */
  472. void XWindow::GetBackgroundColor(XColor * rgb) const
  473. {
  474.    LONG c;
  475.  
  476.    WinQueryPresParam(winhandle, PP_BACKGROUNDCOLOR, 0, NULL, 4, &c, QPF_PURERGBCOLOR);
  477.    rgb->SetColor(c);
  478. }
  479.  
  480.  
  481. /*@ XWindow::SetForegroundColor(const XColor * rgb)
  482. @group colors
  483. @remarks Set the foregrund-color of the window
  484. @parameters XColor * color   the new color
  485. @returns BOOL success
  486. */
  487. BOOL XWindow::SetForegroundColor(const XColor * rgb) const
  488. {
  489.    LONG c = rgb->GetColor();
  490.  
  491.    return WinSetPresParam(winhandle, PP_FOREGROUNDCOLOR, 4, (PVOID) (ULONG) & c);
  492. }
  493.  
  494.  
  495. /*@ XWindow::SetBackgroundColor(const XColor * rgb)
  496. @group colors
  497. @remarks Set the foregrund-color of the window
  498. @parameters XColor * color   the new color
  499. @returns BOOL success
  500. */
  501. BOOL XWindow::SetBackgroundColor(const XColor * rgb)
  502. {
  503.    LONG c = rgb->GetColor();
  504.  
  505.    return WinSetPresParam(winhandle, PP_BACKGROUNDCOLOR, 4, (PVOID) (ULONG) & c);
  506. }
  507.  
  508.  
  509. /*@ XWindow::SetFont(const char *fontName, const unsigned short fontSize)
  510. @group fonts
  511. @remarks Set the font of the window
  512. @parameters char * fontName   the name of the font<BR>
  513.             USHORT fontSize   the size of the font
  514. @returns BOOL success
  515. */
  516. BOOL XWindow::SetFont(const char *fontName, const unsigned short fontSize) const
  517. {
  518.    short l;
  519.    char st[FACESIZE + 3];
  520.  
  521.    sprintf(st, "%i.%s", fontSize, fontName);
  522.    l = strlen(st);
  523.  
  524.    return WinSetPresParam(winhandle, PP_FONTNAMESIZE, l, (PVOID) st);
  525. }
  526.  
  527.  
  528. /*@ XWindow::SetFont(const char *fontNameSize)
  529. @group fonts
  530. @remarks Set the font of the window
  531. @parameters char * fontName   the name of the font in format "10.Helvetica"
  532. @returns BOOL success
  533. */
  534. BOOL XWindow::SetFont(const char *fontNameSize) const
  535. {
  536.    return WinSetPresParam(winhandle, PP_FONTNAMESIZE, strlen(fontNameSize), (PVOID) fontNameSize);
  537. }
  538.  
  539.  
  540. /*@ XWindow :: ~XWindow()
  541. @group constructors/destructors
  542. @remarks Destructors of windows are called automaticaly when they are closed. All destructors
  543. of child-windows are called too. All handlers registered at the window aredestructed.
  544. You can destroy a window by calling the destructor.
  545. */
  546. XWindow :: ~XWindow()
  547. {
  548.    SHORT i;
  549.    WinSetWindowPtr(winhandle, 0, NULL);
  550.    WinDestroyWindow(winhandle);
  551.    for (i = 0; i < handlers; i++)
  552.    {
  553.       regHandlers[i]->handleFor = NULL;
  554.       delete regHandlers[i];
  555.    }
  556.    handlers = 0;
  557.    free(regHandlers);
  558. }
  559.  
  560.  
  561. BOOL XWindow::IsEnabled(void) const
  562. {
  563.    return WinIsWindowEnabled(winhandle);
  564. }
  565.  
  566.  
  567. /*@ XWindow::GetFontName(XString * font)
  568. @group fonts
  569. @remarks Query the font of the window
  570. @parameters XString * buffer   the name of the font in format "10.Helvetica"
  571. */
  572. void XWindow::GetFontName(XString * font) const
  573. {
  574.    WinQueryPresParam(winhandle, PP_FONTNAMESIZE, 0, NULL, 100, font->GetBuffer(100), QPF_NOINHERIT);
  575.    font->ReleaseBuffer();
  576. }
  577.  
  578.  
  579. /*@ XWindow::DoCommand()
  580. @group user input
  581. @remarks If the user selected a XPopupMenu or if the
  582. user pressed a button which is attached to a window, this function
  583. is called. To get the ID of the command the user requested, override this function.
  584. Return TRUE if you have handled the command, otherwise return FALSE. If you return FALSE
  585. the command is posted to the owner of this window.
  586. @parameters   LONG theCommandID    the ID of the menuitem/toolbar-button
  587. @returns      BOOL handled
  588. */
  589.  
  590.  
  591. /*@ XWindow::DoSize()
  592. @group size/position/order
  593. @remarks DoSize informs the application if the window is resized. Override
  594. this function if you need this information.
  595. @parameters XSize * size
  596. */
  597.  
  598.  
  599. /*@ XWindow::DoMove()
  600. @group size/position/order
  601. @remarks DoMove informs the application if the window is moved. Override
  602. this function if you need this information.
  603. */
  604.  
  605.  
  606. /*@ XWindow::FocusChanged()
  607. @group focus
  608. @remarks Informs the window if the focus a moved
  609. Override
  610. this function if you need this information.
  611. @parameters BOOL focus is received
  612. */
  613.  
  614. /*@ XWindow::IsVisible()
  615. @group size/position/order
  616. @remarks Query if the window is visible
  617. @returns BOOL
  618. */
  619.  
  620. /*@ XWindow::DoSysCommand()
  621. @group user input
  622. @remarks If the user selected a command from the sytem-menu or chosed a button
  623. of the titlebar a syscommand is send to the window. Return TRUE if the action can be performed
  624. by the OS, otherwise return FALSE.
  625. @parameters   USHORT theCommandID    SC_CLOSE, SC_RESTORE etc, see OS/2 API documentation
  626. @returns      BOOL handled
  627. */
  628.  
  629.  
  630. MRESULT EXPENTRY RProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  631. {
  632.    XWindow *w = (XWindow *) WinQueryWindowPtr(hwnd, 0);
  633.  
  634.    if (w)
  635.    {
  636.       if(msg == WM_COMMAND )
  637.       {
  638.          if( w->DoCommand( SHORT1FROMMP(mp1) ) == TRUE)
  639.          {
  640.             WinSetWindowULong(hwnd, 0, 0);
  641.             return WinDefDlgProc(hwnd, msg, mp1, mp2);
  642.          }
  643.          else
  644.             return (MRESULT) FALSE;
  645.       }
  646.       else if(msg == WM_MOVE)
  647.       {
  648.          MRESULT mr = WinDefDlgProc(hwnd, msg, mp1, mp2);
  649.          w->DoMove();
  650.          return mr;
  651.       }
  652.       else if(msg == WM_ADJUSTWINDOWPOS )
  653.       {
  654.          MRESULT mr = WinDefDlgProc(hwnd, msg, mp1, mp2);
  655.          PSWP pswp = (PSWP) mp1;
  656.          XSize size( pswp->cx, pswp->cy);
  657.          w->DoSize(&size);
  658.          return mr;
  659.       } /* end if */
  660.  
  661.       BOOL handeld = FALSE;
  662.       MRESULT mr = HandleDefault(w, msg, mp1, mp2, handeld);
  663.  
  664.       if (handeld)
  665.          return mr;
  666.    }
  667.    return WinDefDlgProc(hwnd, msg, mp1, mp2);
  668. }
  669.  
  670.  
  671. /*@
  672. @class XResourceWindow
  673. @parent XWindow
  674. @type overview
  675. @symbol _
  676. @remarks XResourceWindow is a window class which is loaded from the resources. Usualy you
  677. create a dialog-template with your dialog editor, disable the styles for titlebar and frame.
  678. Then create one or more XResourceWindows with a dialog or framewindow as owner.
  679. */
  680.  
  681.  
  682. /*@ XResourceWindow :: XResourceWindow(XWindow * w, ULONG id)
  683. @group constructor/destructor
  684. @remarks Create a resource-window
  685. @parameters
  686. <t '°' c=2>
  687. °XWindow *  °owner
  688. °ULONG °ID of the window-resource (the resource must be linked to the exe-file)
  689. </t>
  690. */
  691. XResourceWindow :: XResourceWindow(XWindow * w, ULONG id)
  692. {
  693.    CreateWindow( w, id, NULL);
  694. }
  695.  
  696.  
  697. /*@ XResourceWindow :: XResourceWindow(XWindow * w, XResource * r)
  698. @group constructor/destructor
  699. @remarks Create a resource-window
  700. @parameters
  701. <t '°' c=2>
  702. °XWindow *  °owner
  703. °XResource * °resource where to load the window from
  704. </t>
  705. */
  706. XResourceWindow :: XResourceWindow(XWindow * w, XResource * r)
  707. {
  708.    CreateWindow( w, r->GetID(), r->GetResourceLibrary());
  709. }
  710.  
  711.  
  712. void XResourceWindow :: CreateWindow(XWindow * w, ULONG id, XResourceLibrary* lib)
  713. {
  714.    if(lib)
  715.       winhandle = WinLoadDlg(w->GetHandle(), w->GetHandle(), (PFNWP) RProc, lib->GetModuleHandle(), id, NULL);
  716.    else
  717.       winhandle = WinLoadDlg(w->GetHandle(), w->GetHandle(), (PFNWP) RProc, XApplication::GetApplication()->GetResourceLibrary()->GetModuleHandle(), id, NULL);
  718.    if (winhandle == 0)
  719.    {
  720.       OOLThrow("could not create window from resources!", 0);
  721.       return;
  722.    }
  723.    WinSetWindowPtr(winhandle, 0, this);
  724.    BuildChilds(winhandle);
  725. }
  726.  
  727.