Jump to content

WinSetWindowText

From EDM2
Revision as of 21:15, 6 August 2023 by Martini (talk | contribs) (Created page with " This function sets the window text for a specified window. ==Syntax== WinSetWindowText(hwnd, pszString); ==Parameters== ;hwnd (HWND) - input :Window handle. ;pszString ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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);

Definition

#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);

Related Functions

Related Messages

  • WM_SETWINDOWPARAMS