Jump to content

WinSetWindowText: Difference between revisions

From EDM2
Created page with " This function sets the window text for a specified window. ==Syntax== WinSetWindowText(hwnd, pszString); ==Parameters== ;hwnd (HWND) - input :Window handle. ;pszString ..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
 
This function sets the window text for a specified window.
This function sets the window text for a specified window.  


==Syntax==
==Syntax==
  WinSetWindowText(hwnd, pszString);
  WinSetWindowText(hwnd, pszString)


==Parameters==
==Parameters==
;hwnd (HWND) - input
;hwnd (HWND) - input:Window handle.
:Window handle.  
;pszString (PSZ) - input:Window text.
 
;pszString (PSZ) - input
:Window text.  
 


==Returns==
==Returns==
;rc (BOOL) - returns
;rc (BOOL) - returns:Success indicator.
:Success indicator.
::TRUE: Text updated
 
::FALSE: Error occurred.
:;TRUE
::Text updated  
:;FALSE
::Error occurred.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
;PMERR_INVALID_HWND (0x1001)
;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified.
:An invalid window handle was specified.


==Remarks==
==Remarks==
Line 34: Line 24:
If hwnd has a style of WS_FRAME, the title-bar window text is set.
If hwnd has a style of WS_FRAME, the title-bar window text is set.


Some window classes interpret the pszString in a special way. The tilde character ( ~ ) indicates that the following character is a mnemonic; for details, see  
Some window classes interpret the pszString in a special way. The tilde character (~) indicates that the following character is a mnemonic; for details, see ?


==Example Code==
==Example Code==
Line 41: Line 31:
#define INCL_WINMESSAGEMGR
#define INCL_WINMESSAGEMGR
#define INCL_WINWINDOWMGR
#define INCL_WINWINDOWMGR
#include <OS2.H>
#include <os2.h>
 
HAB hab;
HAB hab;
HWND hwndFrame, hwndClient;
HWND hwndFrame, hwndClient;
Line 54: Line 45:
                                       /* which is frame window. */
                                       /* which is frame window. */
WinSetWindowText(hwndFrame, szTitle);
WinSetWindowText(hwndFrame, szTitle);
</pre>
Definition
<pre>
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>
HWND    hwnd;      /*  Window handle. */
PSZ    pszString;  /*  Window text. */
BOOL    rc;        /*  Success indicator. */
rc = WinSetWindowText(hwnd, pszString);
</pre>
</pre>



Latest revision as of 07:22, 7 August 2023

This function sets the window text for a specified window.

Syntax

WinSetWindowText(hwnd, pszString)

Parameters

hwnd (HWND) - input
Window handle.
pszString (PSZ) - input
Window text.

Returns

rc (BOOL) - returns
Success indicator.
TRUE: Text updated
FALSE: Error occurred.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.

Remarks

This function sends a WM_SETWINDOWPARAMS message to the window identified by hwnd.

If this function references the window of another process, pszString must be in memory that is shared by both processes; otherwise, a memory error may occur.

If hwnd has a style of WS_FRAME, the title-bar window text is set.

Some window classes interpret the pszString in a special way. The tilde character (~) indicates that the following character is a mnemonic; for details, see ?

Example Code

This example calls WinQuerySessionTitle to retrieve the application's title, and then sets the title bar of the frame window to that title with WinSetWindowText.

#define INCL_WINMESSAGEMGR
#define INCL_WINWINDOWMGR
#include <os2.h>

HAB hab;
HWND hwndFrame, hwndClient;
CHAR szTitle[MAXNAMEL + 1];

WinQuerySessionTitle(hab,
                     0, szTitle,
                     sizeof(szTitle));

hwndFrame = WinQueryWindow(hwndClient,
                           QW_PARENT); /* get handle of parent, */
                                       /* which is frame window. */
WinSetWindowText(hwndFrame, szTitle);

Related Functions

Related Messages

  • WM_SETWINDOWPARAMS