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

  1. /*
  2.  * pframeproc.cpp: window procedure for WPS folder which
  3.  *                 handles our private frame controls
  4.  *
  5.  *             (C) Chris Wohlgenuth 1999
  6.  */
  7. /*
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2, or (at your option)
  11.  * any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; see the file COPYING.  If not, write to
  20.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22. #include "progfolder.h"
  23. #include "progfolder.hh"
  24. #include <stdio.h>
  25.         
  26. /**************************************************************/
  27. /*                                                            */
  28. /* New frame window procedure which handles all the stuff     */
  29. /* related to our private frame controls.                     */
  30. /* It calls member functions of CWProgFolder to size and      */
  31. /* position our frame controls.                               */
  32. /*                                                            */
  33. /**************************************************************/
  34. MRESULT EXPENTRY folderFrameProcedure(HWND hwnd,ULONG msg, MPARAM mp1,MPARAM mp2)
  35. {
  36.   MRESULT mr;
  37.   PSWP  pswp, pswpClient=0, pswpFrame=0;
  38.   PFNWP orgFrameProc;
  39.   
  40.   switch(msg) 
  41.     {
  42.     case WM_CALCFRAMERECT:
  43.       /* Get the original frame procedure from the window words of the invisible child window */ 
  44.       orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
  45.       if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured! The original frame proc is lost */
  46.       
  47.       mr=(*orgFrameProc)(hwnd,msg,mp1,mp2);
  48.       
  49.       if(mr && mp2) {
  50.         /* Calculate new client size .
  51.            This is done in a member function of our folder class.
  52.            We get the pointer to our folder object by querying the
  53.            window ptr. of the hidden child window. */ 
  54.         ((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),0))
  55.           ->cwCalculateClient(hwnd, (PRECTL)mp1);
  56.       }
  57.       
  58.       return mr;
  59.  
  60.     case WM_FORMATFRAME:
  61.       SHORT countSwp;
  62.       SWP  *sav;
  63.       
  64.       orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
  65.       if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
  66.       /* Query the count of standard frame controls */
  67.       countSwp = (int) (*orgFrameProc)(hwnd, msg, mp1, mp2);
  68.       
  69.       /*
  70.        * Reformat the frame to move the client
  71.        * over and make room for the framecontrols.
  72.        * Add the new controls to the array of
  73.        * frame controls.
  74.        * After doing so add our own framecontrols
  75.        * to the total number of framecontrols.
  76.        * This is done in the member function of the class.
  77.        */
  78.       return MRFROMSHORT(countSwp+((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),
  79.                                                                     0))
  80.                          ->cwFormatFrame(hwnd, countSwp,(PSWP)mp1));//Our Frame(s) added
  81.     case WM_QUERYFRAMECTLCOUNT:
  82.       /* The system asks for the total count of framecontrols.
  83.          First we ask the old frame procedure for the number of standard
  84.          controls. After that we add our controls to the count. */
  85.       orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
  86.       if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
  87.       
  88.       return MRFROMSHORT((ULONG)((*orgFrameProc)(hwnd,msg,mp1,mp2))
  89.                          +((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),0))
  90.                          ->cwNumAdditionalFrameControls(hwnd));//Our Frame(s) added
  91.  
  92.     case WM_CLOSE:
  93.  
  94.       orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
  95.       if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
  96.       /* Call the cwClose() method */
  97.       ((CWProgFolder*)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),0))
  98.         ->cwClose();      
  99.        return (MRESULT)(*orgFrameProc)(hwnd,msg,mp1,mp2);
  100.     default:
  101.       orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
  102.       if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
  103.       
  104.       return (*orgFrameProc)(hwnd,msg,mp1,mp2);
  105.     }
  106.   orgFrameProc=(PFNWP)WinQueryWindowPtr(WinWindowFromID(hwnd, ID_FOLDERSTOREWINDOW),QWP_ORGFRAMEPROC);
  107.   if(!orgFrameProc)return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
  108.   
  109.   return (*orgFrameProc)(hwnd,msg,mp1,mp2);
  110.   return WinDefWindowProc(hwnd,msg,mp1,mp2);/* Error occured */
  111. }
  112.  
  113.  
  114.  
  115.  
  116.