home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / system / wpsnewf / wpnewf.c < prev    next >
Text File  |  1993-11-17  |  3KB  |  74 lines

  1.  
  2. /*
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: wpnewf.c.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitc: 1.26
  8.  */
  9.  
  10. /*
  11.  * 
  12.  *      New Program object: It closes the parent folder upon launching it
  13.  *      Written by : Ghassan Salem
  14.  *
  15.  *      The part that fetches the WPS hwnd relies on what the Author of PC/2
  16.  *      did in his program. Many thanks.
  17.  */
  18.  
  19.  
  20. #define WPNewF_Class_Source
  21. #define INCL_WIN
  22. #define INCL_DOS
  23. #define INCL_GPIBITMAPS
  24. #define INCL_DOSERRORS
  25. #include "WPNewF.ih"
  26. #include <wpdesk.h>
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <malloc.h>
  31. #define         DESKTOP_CLASS   "#37"   /* Class name of the "Desktop" window handle (which */
  32.  
  33.  
  34. SOM_Scope HWND   SOMLINK WPNewFX_wpOpen(WPNewF *somSelf,
  35.         HWND hwndCnr,
  36.         ULONG ulView,
  37.         ULONG param)
  38. {   
  39.     HWND hwndFold1,hwndFold2;
  40.     ULONG ulDepth,ulSFs;
  41.     HWND hwndFold;
  42.     UCHAR       ucClass[8];
  43.     HWND        hwndWPS;              
  44.     HWND        hwndDesktop;          
  45.     HENUM       henumWindows;         
  46.     WPNewFData *somThis = WPNewFGetData(somSelf);
  47.     WPNewFMethodDebug("WPNewF","WPNewFX_wpOpen");
  48.     ulSFs=WinGetKeyState(HWND_DESKTOP,VK_F2);
  49.     hwndFold=WinQueryActiveWindow(HWND_DESKTOP);
  50.     hwndFold1=parent_wpOpen(somSelf,hwndCnr,ulView,param);
  51.     if(ulSFs&0x8000){ /* If F2 is Pressed, close the parent if it is
  52.                             not the desktop, so let's search for the WPS desktop
  53.                             Handle */
  54.                   /* Get to bottommost window handle of the "Desktop" */
  55.          hwndDesktop=WinQueryWindow(HWND_DESKTOP, QW_BOTTOM);
  56.                  /* Enumerate all windows at "Desktop" z-order */
  57.          henumWindows=WinBeginEnumWindows(hwndDesktop);
  58.          while(hwndWPS=WinGetNextWindow(henumWindows)){
  59.                       /* Now get the class name of that window handle */
  60.                WinQueryClassName(hwndWPS, sizeof(ucClass), (PCH)ucClass);
  61.                      /* DeskTop is class "#37" */
  62.               if(!strcmp(ucClass, DESKTOP_CLASS)) break;
  63.          }
  64.          WinEndEnumWindows(henumWindows);    /* End enumeration */
  65.          if (!WinIsChild(hwndWPS,hwndFold)) { /*If current window is the parent of
  66.                               the WPS desktop, then it is the WPS desktop */
  67.             WinSetFocus(HWND_DESKTOP,hwndFold);
  68.             WinPostMsg(hwndFold,WM_CLOSE,NULL,NULL);
  69.          } 
  70.     }
  71.     WinSetFocus(HWND_DESKTOP,hwndFold1);
  72.     return(hwndFold1);
  73. }
  74.