Jump to content

WinSetDlgItemText

From EDM2
Revision as of 16:36, 15 May 2025 by Martini (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function sets a text string in a dialog item.

Syntax

WinSetDlgItemText(hwndDlg, idItem, pszText);

Parameters

hwndDlg (HWND) - input
Parent-window handle.
idItem (ULONG) - input
Identity of the child window whose text is to be set.
It must be greater or equal to 0 and less or equal to 0xFFFF.
pszText (PSZ) - input
Source string.
This is the text string that is to be set into the dialog item.

Returns

rc (BOOL) - returns
Success indicator.
TRUE: Successful completion.
FALSE: Error occurred.

Remarks

This function is valid for any window with children. However, it is typically used for dialog items in a dialog window.

This function is equivalent to:

WinSetWindowText (WinWindowFromID (hwndDlg, idItem), pszText);

Errors

Possible returns from WinGetLastError

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

Example Code

Declaration.

#define INCL_WINDIALOGS /* Or use INCL_WIN, INCL_PM, Also in COMMON section */
#include <os2.h>

HWND     hwndDlg;  /*  Parent-window handle. */
ULONG    idItem;   /*  Identity of the child window whose text is to be set. */
PSZ      pszText;  /*  Source string. */
BOOL     rc;       /*  Success indicator. */

rc = WinSetDlgItemText(hwndDlg, idItem, pszText);

This example sets the text "CALENDAR" in a dialog box.

#define INCL_WINDIALOGS
#include <OS2.H>
#define ID_DLG_CALENDAR 900
HWND    hwndDlg;

    WinSetDlgItemText(hwndDlg,
                      ID_DLG_CALENDAR,
                      "CALENDAR");

Related Functions