home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / ONTOP.CMD < prev    next >
OS/2 REXX Batch file  |  1994-10-04  |  2KB  |  76 lines

  1. EXTPROC CEnvi2
  2. // ********************************************************
  3. // *** OnTop.cmd - Keep a window always on top of other ***
  4. // *** ver.1       windows. Specify window name and     ***
  5. // ***             frequency.                           ***
  6. // ********************************************************
  7.  
  8. #include <WinTools.lib>
  9.  
  10. main(argc,argv)
  11. {
  12.    if ( argc != 3 )
  13.       Instructions();
  14.    else {
  15.       Frequency = atoi(argv[2]);
  16.       if ( Frequency < 1 ) {
  17.          printf("\aFrequncy must be an integer greater than 0\n");
  18.          Instructions();
  19.       } else {
  20.          WindowTitle = argv[1];
  21.          WindowHandle = GetWindowHandle(WindowTitle);
  22.          if ( !WindowHandle ) {
  23.             printf("\aCould not locate window title \"%s\"\n",WindowTitle);
  24.             Instructions();
  25.          } else {
  26.             // install the resident version of this program
  27.             system("detach CEnvi2 #include 'OnTop.cmd,,,/*RESIDENT*/' Forever(%d,%d)",
  28.                    WindowHandle,Frequency);
  29.          }
  30.       }
  31.    }
  32. }
  33.  
  34. Instructions()
  35. {
  36.    printf("\n")
  37.    printf("OnTop - Keep any window always on top of other windows\n")
  38.    printf("\n")
  39.    printf("SYNTAX: OnTop <WindowTitle> <Frequency>\n")
  40.    printf("\n")
  41.    printf("Where: WindowTitle - Current title of window to keep on top (partial name)\n")
  42.    printf("       Frequncy - How often to push window to top (in milliseconds)\n")
  43.    printf("\n")
  44.    printf("Example: The following command would put the Clock window up every 5 seconds\n")
  45.    printf("            OnTop \"Clock\" 5000\n")
  46.    printf("\n")
  47. }
  48.  
  49. /*RESIDENT*/
  50. // All code below this is part of the resident program
  51.  
  52. Forever(WindowHandle,Frequency)
  53. {
  54.    while ( IsWindow(WindowHandle) ) {
  55.       PutWindowOnTop(WindowHandle);
  56.       suspend(Frequency);
  57.    }
  58. }
  59.  
  60. PutWindowOnTop(pHwnd)
  61. {
  62.    #define HWND_TOP     3
  63.    #define SWP_ZORDER   4
  64.    #define ORD_WIN32SETWINDOWPOS 875
  65.    DynamicLink("PMWIN",ORD_WIN32SETWINDOWPOS,BIT32,CDECL,
  66.                pHwnd,HWND_TOP,0,0,0,0,SWP_ZORDER);
  67. }
  68.  
  69. IsWindow(pHwnd)
  70. {
  71.    #define ORD_WIN32ISWINDOW  772
  72.    return DynamicLink("PMWIN",ORD_WIN32ISWINDOW,BIT32,CDECL,
  73.                       Info().hab,pHwnd);
  74. }
  75.  
  76.