home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12324.ZIP / SAMPLE.C < prev    next >
C/C++ Source or Header  |  1989-05-30  |  2KB  |  62 lines

  1. /*
  2.  * sample: attempt to make child windows of HWND_DESKTOP invisible.
  3.  *       a dialogue box to exit sample is invoked, and refers to
  4.  *       a readme file attached which reports the strange behaviors
  5.  *       we have encountered.
  6.  */
  7. #define INCL_WIN
  8. #include <os2.h>
  9. #include <string.h>
  10.  
  11. char szBuf[80];
  12. RECTL rOldSize;
  13.  
  14. SHORT cdecl main(  )
  15. {
  16.     HAB   hAB;
  17.     HMQ   hMsgQ;
  18.     HENUM henum;
  19.     HWND  next;
  20.     HWND  hwndClient;
  21.  
  22.     hAB   = WinInitialize(NULL);
  23.     hMsgQ = WinCreateMsgQueue( hAB, 0 );
  24.  
  25.     /*
  26.      * To disable the Task Manager window, our solution is to
  27.      * obtain its hwnd via enumerating the child windows of
  28.      * HWND_DESKTOP and make it invisible via WinSetWindowPos().
  29.      */
  30.  
  31.  
  32.      henum = WinBeginEnumWindows( HWND_DESKTOP );
  33.  
  34.      while( (next = WinGetNextWindow(henum)) != NULL ) {
  35.        WinLockWindow( next, FALSE );  /* Unlock the windows locked above */
  36.        /* next is the window handle of direct children of HWND_DESKTOP */
  37.        /* Now we'll see if there is client window and what it's class is */
  38.        hwndClient = WinWindowFromID( next, FID_CLIENT );
  39.        if (hwndClient) {
  40.            WinQueryClassName( hwndClient, sizeof( szBuf ), szBuf );
  41.            /* Hide the program starter */
  42.            if (!strcmp( "StarterWindow", szBuf)) {
  43.           WinQueryWindowRect(next,&rOldSize);
  44.           WinSetWindowPos(next,HWND_BOTTOM,
  45.                   rOldSize.xLeft,rOldSize.yBottom,
  46.                   rOldSize.xRight,rOldSize.yTop,
  47.                   SWP_MINIMIZE | SWP_MOVE | SWP_SIZE);
  48.            }
  49.        }
  50.      }
  51.  
  52.      WinEndEnumWindows( henum );
  53.  
  54.      WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  55.             "OK to Exit... please read README ", "WHA?",
  56.             NULL, MB_OK );
  57.  
  58.      WinDestroyMsgQueue( hMsgQ );
  59.      WinTerminate( hAB );
  60.      return 0;
  61. } /* main */
  62.