Changing the Title of Unit Windows in QuickWin Programs

Last reviewed: July 20, 1995
Article ID: Q83327
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.1

SUMMARY

Microsoft FORTRAN version 5.1 QuickWin programs can change the title of any window using the Windows API functions GetFocus() and SetWindowText(), which are documented in the Windows SDK manuals. The GetFocus() function is used to obtain a handle to the window with the focus, then this handle is used as the window handle parameter in the SetWindowText() function.

MORE INFORMATION

GetFocus() returns the handle of the window with the user focus. This handle is an internal Windows integer value that represents a token to manipulate on a specific window. If the function is successful, it returns a valid handle. If no window has focus, the function returns 0. The syntax of GetFocus() is as follows:

   INTERFACE TO INTEGER*2 FUNCTION GetFocus [PASCAL]
   END

SetWindowText() has no return value. The first argument is the handle of the window to change the title. The second argument is the string containing the new title. The syntax of SetWindowText() is as follows:

    INTERFACE TO SUBROUTINE SetWindowText [PASCAL]
   +(HWND, LPSTRING)
    INTEGER*2 HWND [VALUE]
    CHARACTER*1 LPSTRING [REFERENCE]
    END

The LPSTRING parameter is a pointer to a NULL terminated string containing the new title for the window.

Sample Code

c The following code demonstrates how to change the title in the c UNIT * window. This code should be compiled and linked as a QuickWin c Windows-based application (fl /MW sample.for).

      INTERFACE TO SUBROUTINE SetWindowText [PASCAL]
     + (HWND, LPSTRING)
      INTEGER*2 HWND [VALUE]
      CHARACTER*1 LPSTRING [REFERENCE]
      END

      INTERFACE TO INTEGER*2 FUNCTION GetFocus [PASCAL]
      END

      PROGRAM Sample_Test
      INTEGER*2 hWnd, GetFocus
      PRINT *, 'Changing the Title of this Window'
      hWnd = GetFocus ()          !gets focus of current window
      CALL SetWindowText (hWnd, 'My Title'C)     !changes title
      END


Additional reference words: kbinf 5.10
KBCategory: kbprg kbcode
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 20, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.