WinSetParent: Difference between revisions
Appearance
Created page with "This function sets the parent for ''hwnd'' to ''hwndNewParent''. ==Syntax== WinSetParent(hwnd, hwndNewParent, fRedraw) ==Parameters== ;hwnd (HWND) - Input: Window handle. ;hwndNewParent (HWND) - Input: New parent window handle. :This cannot be a descendant of ''hwnd''. :If this parameter is a desktop window handle or HWND_DESKTOP, ''hwnd'' becomes a main window. :If this parameter is not equal to HWND_OBJECT, it must be a descendant of the same desktop window..." |
No edit summary |
||
Line 61: | Line 61: | ||
* [[WinMultWindowFromIDs]] | * [[WinMultWindowFromIDs]] | ||
* [[WinQueryWindow]] | * [[WinQueryWindow]] | ||
* | * WinSetClipRegion | ||
* [[WinSetOwner]] | * [[WinSetOwner]] | ||
[[Category:Win]] | [[Category:Win]] |
Latest revision as of 16:47, 15 April 2025
This function sets the parent for hwnd to hwndNewParent.
Syntax
WinSetParent(hwnd, hwndNewParent, fRedraw)
Parameters
- hwnd (HWND) - Input
- Window handle.
- hwndNewParent (HWND) - Input
- New parent window handle.
- This cannot be a descendant of hwnd.
- If this parameter is a desktop window handle or HWND_DESKTOP, hwnd becomes a main window.
- If this parameter is not equal to HWND_OBJECT, it must be a descendant of the same desktop window as hwnd.
- If this parameter is HWND_OBJECT or a window handle returned by WinQueryObjectWindow, hwnd becomes an object window.
- fRedraw (BOOL) - Input
- Redraw indicator.
- TRUE: If hwnd is visible, any necessary redrawing of both the old parent and the new parent windows is performed.
- FALSE: No redrawing of the old and new parent windows is performed. This avoids an extra device update when subsequent calls cause the windows to be redrawn.
Returns
- rc (BOOL) - Returns
- Parent-changed indicator.
- TRUE
- Parent successfully changed.
- FALSE
- Parent not successfully changed.
Remarks
This function returns an error (PMERR_INVALID_HWND) if the user specifies the desktop window as the new parent of a window to which a clip region is currently set.
Errors
Possible returns from WinGetLastError:
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
- PMERR_INVALID_FLAG (0x1019)
- An invalid bit was set for a parameter. Use constants defined by PM for options, and do not set any reserved bits.
Example Code
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwnd; /* Window handle. */ HWND hwndNewParent; /* New parent window handle. */ BOOL fRedraw; /* Redraw indicator. */ BOOL rc; /* Parent-changed indicator. */ rc = WinSetParent(hwnd, hwndNewParent, fRedraw);
This example uses the WinSetParent call to change a window to a main window.
#define INCL_WINWINDOWMGR #include <OS2.H> HWND hwnd; /* Window handles */ WinSetParent(hwnd, HWND_DESKTOP, TRUE); /* Do any necessary redrawing */