Changing the Title of Unit Windows in QuickWin Programs

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

  1. 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 query words: kbinf 5.10

Keywords :
Version : :5.1
Platform :
Issue type :


Last Reviewed: November 1, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.