home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / ACDCR032.ZIP / source / MiscFolder / progfolder.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-11  |  23.8 KB  |  645 lines

  1. /*
  2.  *
  3.  * Main Source file for class CWProgFolder
  4.  *
  5.  *             (C) Chris Wohlgenuth 1999
  6.  *
  7.  * This class is intended for programmers and provides functions for some
  8.  * common tasks like:
  9.  *                     - Adding dialogs as frame controls to WPS folders
  10.  *                     - Showing 'About'-dialogs
  11.  *                     - Checking of object pointers
  12.  *                     - ...
  13.  *
  14.  * Use IBM VAC++ V3.00 and Gnu-make 3.74.1 to compile
  15.  *
  16.  */
  17.  
  18. /*
  19.  * This program is free software; you can redistribute it and/or modify
  20.  * it under the terms of the GNU General Public License as published by
  21.  * the Free Software Foundation; either version 2, or (at your option)
  22.  * any later version.
  23.  *
  24.  * This program is distributed in the hope that it will be useful,
  25.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27.  * GNU General Public License for more details.
  28.  *
  29.  * You should have received a copy of the GNU General Public License
  30.  * along with this program; see the file COPYING.  If not, write to
  31.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  32.  */
  33. #define INCL_DOSQUEUES
  34. #include "progfolder.h"
  35. #include "progfolder.hh"
  36. #include <stdlib.h>
  37. #include <stdio.h>
  38.  
  39. MRESULT EXPENTRY folderFrameProcedure(HWND hwnd,ULONG msg, MPARAM mp1,MPARAM mp2);
  40. HWND createStoreWindow(HWND hwndCLF);
  41. HWND createLeechFrame(HWND hwndCLF);
  42.  
  43. /**************************************************************/
  44. /*                                                            */
  45. /* This function returns the module handle of our class-dll   */
  46. /*                                                            */
  47. /**************************************************************/
  48. HMODULE queryModuleHandle(void)
  49. {
  50.   static HMODULE hmod=0;
  51.   
  52.   if(!hmod) {
  53.     PSZ pathname=SOMClassMgrObject  //Query Pathname of class file
  54.       ->somLocateClassFile(somIdFromString("CWProgFolder"),1,2);
  55.     DosQueryModuleHandle(pathname,&hmod);  //Query module handle
  56.   }
  57.   return hmod;
  58. }
  59.  
  60. /**************************************************************/
  61. /*                                                            */
  62. /* Overriden function: wpclsQueryStyle()                      */
  63. /*                                                            */
  64. /* This class doesn't need a template.                        */
  65. /*                                                            */
  66. /**************************************************************/
  67. ULONG M_CWProgFolder::wpclsQueryStyle()
  68. {
  69.   ULONG rc;
  70.   rc=M_WPFolder::wpclsQueryStyle();
  71.   rc|=CLSSTYLE_NEVERTEMPLATE;
  72.   return rc; 
  73. }
  74.  
  75. /**************************************************************/
  76. /*                                                            */
  77. /* Overriden function: wpclsQueryTitle()                      */
  78. /*                                                            */
  79. /* Returns our class name                                     */
  80. /*                                                            */
  81. /**************************************************************/
  82. PSZ M_CWProgFolder::wpclsQueryTitle()
  83. {
  84.   return "Support-Folder";
  85. }
  86.  
  87. /*
  88.    MRESULT EXPENTRY dialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
  89.    {
  90.    
  91.    return WinDefDlgProc(hwnd, msg, mp1, mp2);
  92.    }
  93.    */
  94.  
  95. /* This Funktion is called when the close button of the */
  96. /* frame is pressed or if the user chooses 'close' from */
  97. /* the menu. Apparently the wpClose() method isn't      */
  98. /* called when choosing close. Seems that it is only    */
  99. /* used if the WPS want's to close a folder.            */ 
  100. BOOL CWProgFolder::cwClose()
  101. {
  102.   return TRUE;
  103. }
  104.  
  105. /**************************************************************/
  106. /*                                                            */
  107. /* Overriden function: wpOpen()                               */
  108. /*                                                            */
  109. /* This function subclasses the folder frame window and       */
  110. /* prepares it for the addition of frame controls.            */
  111. /*                                                            */
  112. /**************************************************************/
  113. HWND CWProgFolder::wpOpen(HWND hwndCnr,ULONG ulView,ULONG ulParam)
  114. {
  115.   HWND hwnd;
  116.   HWND hwndStore;
  117.   PFNWP orgFrameProc;
  118.  
  119.   //  hwnd=WPFolder::wpOpen(hwndCnr, ulView, ulParam);/* Call parent to build folder window */
  120.   hwnd=((somTD_WPObject_wpOpen)
  121.         somParentNumResolve(__ClassObject->somGetPClsMtabs(),
  122.                             1,
  123.                             __ClassObject->
  124.                             somGetMethodToken(somIdFromString
  125.                                               ("wpOpen")))                    
  126.         )(this,hwndCnr, ulView, ulParam);
  127.   
  128.   if(ulView==OPEN_SETTINGS)
  129.     /* We only build frame controls for folder frame windows */
  130.     return hwnd;
  131.   if(WinWindowFromID(hwnd,ID_FOLDERSTOREWINDOW))
  132.     return hwnd;/* Already subclassed */
  133.   
  134.   hwndStore=createStoreWindow(hwnd);/* This holds our object pointer */
  135.   if(hwndStore){
  136.     /* Save 'this' ptr. */
  137.     WinSetWindowPtr(hwndStore,0,this);
  138.     /* Subclass the folder frame window */
  139.     orgFrameProc=WinSubclassWindow(hwnd,&folderFrameProcedure);
  140.     /* Save the old window procedure in our store window */
  141.     WinSetWindowPtr(hwndStore,QWP_ORGFRAMEPROC,orgFrameProc);
  142.     /* Save a ptr. to private control data */
  143.     WinSetWindowPtr(hwndStore,QWP_FCTRLDATA,malloc(sizeof(FRAMECTRLDATA)));
  144.   }
  145.   return hwnd;
  146. }
  147.  
  148. /**************************************************************/
  149. /*                                                            */
  150. /* This member function returns the count of additional frame */
  151. /* controls we have added to the frame. This fuction is       */
  152. /* called from the frame window procedure                     */
  153. /*                                                            */
  154. /**************************************************************/
  155. ULONG CWProgFolder::cwNumAdditionalFrameControls(HWND hwndFolder)
  156. {
  157.   ULONG rc;
  158.   FRAMECTRLDATA * fctrlData;
  159.   
  160.   fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
  161.   if(!fctrlData) return 0;
  162.   
  163.   rc=0;
  164.   
  165.   if(fctrlData->bLeft)rc++;
  166.   if(fctrlData->bRight)rc++;
  167.   if(fctrlData->bTop)rc++;
  168.   if(fctrlData->bBottom)rc++;
  169.  
  170.   return rc;
  171. }
  172.  
  173. /**************************************************************/
  174. /*                                                            */
  175. /* This function adjusts the size and position of the client. */
  176. /* It is called from the frame window procedure               */
  177. /*                                                            */
  178. /**************************************************************/
  179. BOOL CWProgFolder::cwCalculateClient(HWND hwndFolder, PRECTL pRectl)
  180. {
  181.   FRAMECTRLDATA * fctrlData;
  182.   
  183.   fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
  184.   if(!fctrlData) return FALSE;
  185.   
  186.   if(fctrlData->bLeft) 
  187.     pRectl->xLeft+=fctrlData->sizelLeftFrame.cx;
  188.   if(fctrlData->bRight)
  189.     pRectl->xRight-=fctrlData->sizelRightFrame.cx;
  190.   if(fctrlData->bTop)
  191.     pRectl->yTop-=fctrlData->sizelTopFrame.cy;
  192.   if(fctrlData->bBottom)
  193.     pRectl->yBottom+=fctrlData->sizelBottomFrame.cy;
  194.  
  195.   return TRUE;/* Everything's ok */
  196. }
  197.  
  198. /**************************************************************/
  199. /*                                                            */
  200.  
  201. /*                                                            */
  202. /**************************************************************/
  203. ULONG CWProgFolder::cwFormatFrame(HWND hwndFolder, USHORT countSWP,PSWP pswp)
  204. {
  205.   /* countSWP:  number of standard framecontrols
  206.      pswp:      Array of SWP describing the framecontrols.
  207.                 Since we added the number of our controls to the
  208.                 standard controls in the framecontrol there is
  209.                 space for the new controls.
  210.                 */
  211.   ULONG rc;
  212.   PSWP pswpClient=0, pswpFrameCtl=0;
  213.   int iCount;
  214.   FRAMECTRLDATA * fctrlData;
  215.   int a;
  216.     
  217.   /* The data of our framecontrols is stored in a structure.
  218.      Get a pointer from the window words of the invisible child. */
  219.   fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
  220.   if(!fctrlData) return 0;
  221.  
  222.   iCount=0;
  223.   rc=0;
  224.     
  225.   for (a = 0; a < countSWP; a++)
  226.     {
  227.       /* Find the client window */
  228.       if ( WinQueryWindowUShort( pswp[a].hwnd, QWS_ID ) == 0x8008 ) // FID_CLIENT )
  229.         {
  230.           pswpClient=&pswp[a];
  231.           
  232.           /* Framecontrol at the top */                      
  233.           if(fctrlData->bTop){
  234.             pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
  235.  
  236.             /* Adjust client and insert the new control into the array of SWPs */ 
  237.              
  238.             /* Decrease the height of the client to have place for the new control */
  239.             pswp[a].cy -= fctrlData->sizelTopFrame.cy;
  240.  
  241.             /* Insert the HWND of the new control into the structure */
  242.             pswpFrameCtl->hwnd=fctrlData->hwndCtlTop;
  243.  
  244.             /* The x-position is the same as that of the client */
  245.             pswpFrameCtl->x  = pswpClient->x;
  246.  
  247.             /* The control is placed above the client */
  248.             pswpFrameCtl->y  = pswpClient->y + pswpClient->cy;
  249.             
  250.             /* The control is as wide as the client */
  251.             pswpFrameCtl->cx = pswpClient->cx;
  252.             
  253.             /* Insert the height of the control */ 
  254.             pswpFrameCtl->cy = fctrlData->sizelTopFrame.cy;
  255.  
  256.             /* Place the control on top of all windows */
  257.             pswpFrameCtl->hwndInsertBehind = HWND_TOP;
  258.  
  259.             /* Insert necessary flags */
  260.             pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER |SWP_SHOW;
  261.  
  262.             /* Adjust position if flags are set. It's possible to place
  263.                the control above the controls on the left and right or let these controls
  264.                cover the full height of the folder. */
  265.             if(fctrlData->bLeft){
  266.               /* There is a frame control on the left side */
  267.               if(!(fctrlData->ulFlagsLeft & FCTL_POSBELOW)) {
  268.                 pswpFrameCtl->x  += fctrlData->sizelLeftFrame.cx;
  269.                 pswpFrameCtl->cx -= fctrlData->sizelLeftFrame.cx; 
  270.               }
  271.             }
  272.             /* framecontrol on the right side */
  273.             if(!(fctrlData->ulFlagsRight & FCTL_POSBELOW) && fctrlData->bRight)
  274.               pswpFrameCtl->cx -= fctrlData->sizelRightFrame.cx;
  275.             /* One new control added */
  276.             rc++;
  277.           }/* end of if(fctrlData->bTop) */
  278.  
  279.           /* Left frame control */
  280.           if(fctrlData->bLeft){
  281.             pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
  282.             
  283.             pswpClient->cx -= fctrlData->sizelLeftFrame.cx;/* Size client */
  284.             pswpFrameCtl->hwnd=fctrlData->hwndCtlLeft;
  285.  
  286.             pswpFrameCtl->x  =pswpClient->x;
  287.             pswpClient->x  += fctrlData->sizelLeftFrame.cx;/* Size client */
  288.             pswpFrameCtl->y  =pswpClient->y;
  289.  
  290.             pswpFrameCtl->cx = fctrlData->sizelLeftFrame.cx;
  291.             pswpFrameCtl->cy =pswpClient->cy;
  292.                         
  293.             pswpFrameCtl->hwndInsertBehind = HWND_TOP;
  294.             pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER |SWP_SHOW;
  295.                         
  296.             /* Position this frame control above bottom ctrl if requested */
  297.             if((fctrlData->ulFlagsLeft & FCTL_POSABOVE) && fctrlData->bBottom){
  298.               pswpFrameCtl->y  +=fctrlData->sizelBottomFrame.cy;
  299.               pswpFrameCtl->cy  -=fctrlData->sizelBottomFrame.cy;
  300.             }
  301.             /* Position this frame control below top ctrl if requested */
  302.             if(!(fctrlData->ulFlagsLeft & FCTL_POSBELOW) && fctrlData->bTop){
  303.               pswpFrameCtl->cy  +=fctrlData->sizelTopFrame.cy;
  304.             }
  305.             rc++;
  306.           }/* end of if(fctrlData->bLeft) */
  307.                     
  308.           /* Bottom frame control */
  309.           if(fctrlData->bBottom){
  310.             pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
  311.                         
  312.             pswpClient->cy -= fctrlData->sizelBottomFrame.cy;    
  313.             pswpFrameCtl->hwnd=fctrlData->hwndCtlBottom;
  314.                         
  315.             pswpFrameCtl->x  = pswpClient->x;
  316.             pswpFrameCtl->y  = pswpClient->y;
  317.             pswpClient->y += fctrlData->sizelBottomFrame.cy;
  318.                         
  319.             pswpFrameCtl->cx = pswpClient->cx;
  320.             pswpFrameCtl->cy = fctrlData->sizelBottomFrame.cy;
  321.                         
  322.             pswpFrameCtl->hwndInsertBehind = HWND_TOP;
  323.             pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER |SWP_SHOW;
  324.                                                 
  325.             /* Adjust position if flags are set */
  326.             if(fctrlData->bLeft){
  327.               if((fctrlData->ulFlagsLeft & FCTL_POSABOVE)) {
  328.                 pswpFrameCtl->cx +=fctrlData->sizelLeftFrame.cx;
  329.                 pswpFrameCtl->x  -= fctrlData->sizelLeftFrame.cx;
  330.               }
  331.             }
  332.             if(!(fctrlData->ulFlagsRight & FCTL_POSABOVE)&& fctrlData->bRight) {
  333.               pswpFrameCtl->cx -= fctrlData->sizelRightFrame.cx; 
  334.             }
  335.             rc++;    
  336.           }/* end of if(fctrlData->bBottom) */
  337.                     
  338.           /* Right frame control */
  339.           if(fctrlData->bRight){
  340.             pswpFrameCtl=&pswp[countSWP+iCount++];/* First free position */
  341.             
  342.             pswpClient->cx -= fctrlData->sizelRightFrame.cx;/* Size client */
  343.             pswpFrameCtl->hwnd=fctrlData->hwndCtlRight;
  344.  
  345.             pswpFrameCtl->x  =pswpClient->x+pswpClient->cx;
  346.             pswpFrameCtl->y  =pswpClient->y;
  347.  
  348.             pswpFrameCtl->cx = fctrlData->sizelRightFrame.cx;
  349.             pswpFrameCtl->cy =pswpClient->cy;
  350.                         
  351.             pswpFrameCtl->hwndInsertBehind = HWND_TOP;
  352.             pswpFrameCtl->fl = SWP_MOVE | SWP_SIZE | SWP_NOADJUST | SWP_ZORDER |SWP_SHOW;
  353.  
  354.             /* Position this frame control above bottom ctrl only if requested */
  355.             if(!(fctrlData->ulFlagsRight & FCTL_POSABOVE) && fctrlData->bBottom){
  356.               pswpFrameCtl->y  -=fctrlData->sizelBottomFrame.cy;
  357.               pswpFrameCtl->cy  +=fctrlData->sizelBottomFrame.cy;
  358.             }
  359.             /* Position this frame control below top ctrl only if requested */
  360.             if(!(fctrlData->ulFlagsRight & FCTL_POSBELOW) && fctrlData->bTop){
  361.               pswpFrameCtl->cy  +=fctrlData->sizelTopFrame.cy;
  362.             }
  363.             rc++;
  364.           }/* end of if(fctrlData->bRight) */
  365.         }
  366.     }
  367.   return rc;/* Return additional controls */
  368. }
  369.  
  370.  
  371. /**************************************************************/
  372. /*                                                            */
  373. /* This function adds a frame control at the specified        */
  374. /* position.                                                  */
  375. /*                                                            */
  376. /**************************************************************/
  377. BOOL CWProgFolder::cwAddFrameCtl(HWND hwndFolder, HWND hwndNewCtl,SIZEL sizel, ULONG ulPos, ULONG ulFlags)
  378. {
  379.   FRAMECTRLDATA * fctrlData;
  380.   
  381.   /* Get the framecontrol datastructure from the invisible control window */
  382.   fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
  383.   if(!fctrlData) return FALSE;
  384.   
  385.   /* Fill in the values into the structure */
  386.   /* This is the dialog at the left */
  387.   if(ulPos & FCTL_LEFT) {
  388.     /* The HWND of the dialog used as a framcontrol */
  389.     fctrlData->hwndCtlLeft=hwndNewCtl;
  390.     /* The size of the dialog. Actually only sizel.cx is used
  391.        since this is a dialog at the left which always has
  392.        got the height of the client. */ 
  393.     fctrlData->sizelLeftFrame=sizel;
  394.     /* A flag which determines the positioning of the dialog. 
  395.        If there is a dialog at the top you may tell the folder
  396.        to move it sizel.cx pixel to the right to allow the
  397.        control at the left to cover the full height of the folder.
  398.        The same is with the control at the bottom. This gives
  399.        you the ability to finetune the appearance of the
  400.        folder. Just try the flags FCTL_POSBELOW, FCTL_POSABOVE as
  401.        defined in progfolder.h in conjunction with framecontrols
  402.        at different positions of the folder.
  403.        */
  404.     fctrlData->ulFlagsLeft=ulFlags;
  405.     /* Tell the frame procedure that there's a framecontrol
  406.        at the left. */
  407.     fctrlData->bLeft=TRUE;
  408.     if(!fctrlData->hwndCtlLeft)
  409.       /* If this method is called with hwndNewCtl=NULL the framecontrol
  410.          is disabled. */
  411.       fctrlData->bLeft=FALSE;
  412.   }
  413.   /* This is the dialog at the right */
  414.   if(ulPos & FCTL_RIGHT){
  415.     fctrlData->hwndCtlRight=hwndNewCtl;
  416.     fctrlData->sizelRightFrame=sizel;
  417.     fctrlData->ulFlagsRight=ulFlags;
  418.     fctrlData->bRight=TRUE;
  419.     if(!fctrlData->hwndCtlRight) 
  420.       fctrlData->bRight=FALSE;
  421.   }
  422.   if(ulPos & FCTL_TOP){
  423.     fctrlData->hwndCtlTop=hwndNewCtl;
  424.     fctrlData->sizelTopFrame=sizel;
  425.     fctrlData->bTop=TRUE;
  426.     if(!fctrlData->hwndCtlTop) 
  427.       fctrlData->bTop=FALSE;
  428.   }
  429.   if(ulPos & FCTL_BOTTOM){
  430.     fctrlData->hwndCtlBottom=hwndNewCtl;
  431.     fctrlData->sizelBottomFrame=sizel;
  432.     fctrlData->bBottom=TRUE;
  433.     if(!fctrlData->hwndCtlBottom) 
  434.       fctrlData->bBottom=FALSE;
  435.   }
  436.   return TRUE;
  437. }
  438.  
  439.  
  440. /**************************************************************/
  441. /*                                                            */
  442. /* This function returns information about the specified      */
  443. /* private frame control.                                     */
  444. /*                                                            */
  445. /**************************************************************/
  446. HWND CWProgFolder::cwQueryFrameCtl(HWND hwndFolder, SIZEL* sizel, ULONG ulPos, ULONG * ulFlags)
  447. {
  448.   FRAMECTRLDATA * fctrlData;
  449.   
  450.   fctrlData=(FRAMECTRLDATA*)WinQueryWindowPtr(WinWindowFromID(hwndFolder, ID_FOLDERSTOREWINDOW),QWP_FCTRLDATA);
  451.   if(!fctrlData) return FALSE;
  452.   
  453.   
  454.   if(ulPos & FCTL_LEFT){
  455.     *sizel=fctrlData->sizelLeftFrame;
  456.     *ulFlags= fctrlData->ulFlagsLeft;
  457.     return fctrlData->hwndCtlLeft;
  458.   }
  459.   if(ulPos & FCTL_RIGHT){
  460.     *sizel=fctrlData->sizelRightFrame;
  461.     *ulFlags=fctrlData->ulFlagsRight;
  462.     return fctrlData->hwndCtlRight;
  463.   }
  464.   if(ulPos & FCTL_TOP){
  465.     *sizel=fctrlData->sizelTopFrame;
  466.     *ulFlags=0;
  467.     return  fctrlData->hwndCtlTop;
  468.   }
  469.   if(ulPos & FCTL_BOTTOM){
  470.     *sizel=fctrlData->sizelBottomFrame;
  471.     *ulFlags=0;
  472.     return fctrlData->hwndCtlBottom;
  473.   }
  474.   return NULL;
  475. }
  476.  
  477. /**************************************************************/
  478. /*                                                            */
  479. /* This function requests an update of frame controls so      */
  480. /* added frame controls will become visible.                  */
  481. /* You must call this function after calling cwAddFrameCtl(). */
  482. /*                                                            */
  483. /**************************************************************/
  484. void CWProgFolder::cwUpdateFrame(HWND hwndFolder)
  485. {
  486.   WinSendMsg(hwndFolder,WM_UPDATEFRAME,0,0);
  487. }
  488.  
  489. /**************************************************************/
  490. /*                                                            */
  491. /* This function returns the pointer to a file system object  */
  492. /* or NULL.                                                   */
  493. /* It follows shadow objects and returns the object handle    */
  494. /* of the linked object if it's a file system object          */
  495. /*                                                            */
  496. /**************************************************************/
  497. WPObject* CWProgFolder::cwGetFileSystemObject(WPObject* wpObject)
  498. {
  499.   if(!wpObject) return NULL;//No object given
  500.   
  501.   /* Check if it's a shadow */
  502.   if(somResolveByName(wpObject,"wpQueryShadowedObject")){ 
  503.     /* Yes, it's a shadow. Query the linked object. */
  504.     wpObject=((WPShadow*)wpObject)->wpQueryShadowedObject(FALSE);
  505.   }
  506.   
  507.   if(!wpObject) return NULL;//The link is broken
  508.   
  509.   /* Check if it's a file system object */
  510.   if(somResolveByName(wpObject, "wpQueryRealName")){
  511.     return wpObject;/* Yes */
  512.   }
  513.   else
  514.     return NULL;
  515. }
  516.  
  517.  
  518. /**************************************************************/
  519. /*                                                            */
  520.  
  521. /*                                                            */
  522. /**************************************************************/
  523. MRESULT EXPENTRY aboutDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  524. {
  525.   switch( msg )
  526.     {
  527.     case WM_INITDLG:
  528.       return (MRESULT) TRUE;
  529.     case WM_DESTROY:
  530.       break;
  531.     case WM_CLOSE:
  532.       break;
  533.     case WM_COMMAND:
  534.       {
  535.     switch( SHORT1FROMMP( mp1 ) )
  536.       {
  537.       default:
  538.         break;
  539.       }
  540.       }
  541.       break;
  542.       return (MRESULT) TRUE;
  543.     }   
  544.   return( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );   
  545. }
  546.  
  547. /**************************************************************/
  548. /*                                                            */
  549.  
  550. /*                                                            */
  551. /**************************************************************/
  552. ULONG CWProgFolder::cwShowAboutDlg(HMODULE hModule, ULONG idDialog)
  553. {
  554.   return (WinDlgBox( HWND_DESKTOP, HWND_DESKTOP, aboutDlgProc, hModule,idDialog, 0));
  555. }
  556.  
  557. /**************************************************************/
  558. /*                                                            */
  559. /* This funktion returns the CD-Drives in the system          */
  560. /*                                                            */
  561. /* iNumCD (output): # of CD-Drives                            */
  562. /* cFirstDrive (output): first cd-Drive letter                */
  563. /* returns TRUE: We have cd-drives                            */
  564. /*                                                            */
  565. /**************************************************************/
  566. BOOL CWProgFolder::cwQueryCDDrives(int *iNumCD, char * cFirstDrive)
  567. {
  568.   HFILE hfDevice;
  569.   ULONG ulAction;
  570.   ULONG ulLen;
  571.   static char cFirst=0;
  572.   static int iNumCDLocal=0;
  573.   static BOOL haveCD=FALSE;
  574.   static BOOL done=FALSE;         
  575.   struct
  576.   {
  577.     USHORT usCountCD;
  578.     USHORT usFirstCD;
  579.   } CDInfo;
  580.  
  581.   if(!done){
  582.     ulLen = sizeof(CDInfo);
  583.     if(!DosOpen("\\DEV\\CD-ROM2$", &hfDevice, &ulAction, 0,
  584.                 FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
  585.                 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL))
  586.       {
  587.         if(!DosDevIOCtl(hfDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, ulLen, &ulLen))
  588.           {
  589.             if(CDInfo.usCountCD) {
  590.               haveCD=TRUE;
  591.               iNumCDLocal=CDInfo.usCountCD;
  592.               cFirst='A'+ CDInfo.usFirstCD;
  593.             }                                        
  594.           }
  595.         DosClose(hfDevice);
  596.       }
  597.     done=TRUE;
  598.   }
  599.   *iNumCD=iNumCDLocal;
  600.   *cFirstDrive=cFirst;
  601.   return haveCD;              
  602. }
  603.  
  604. /*ULONG CWProgFolder::cwQueryAudioCDInfo(char * drive)
  605. {
  606.     HFILE hfCD = 0;
  607.     ULONG ulAction;
  608.     ULONG ulParamLen=4;
  609.     ULONG ulDataLen;
  610.     ULONG rc;
  611.  
  612.     rc = DosOpen(drive, &hfCD, &ulAction, 0,
  613.                      FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
  614.                      OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY |
  615.                      OPEN_FLAGS_DASD, NULL);    
  616.  
  617.     if(rc)
  618.         return 0;//Error
  619.     ulDataLen=0;
  620.     
  621.     rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK,
  622.                           "CD01", 4, &ulParamLen, cdInfo,
  623.                           sizeof(*cdInfo), &ulDataLen);
  624.  
  625.     if(rc) {
  626.         DosClose(hfCD);
  627.         return 0;//Error
  628.     }
  629.     
  630.     DosClose(hfCD);
  631.     return 0;
  632.     
  633. }
  634. */
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.