SetWindowPos function user32

Win32Result<bool> SetWindowPos(
  1. HWND hWnd,
  2. HWND? hWndInsertAfter,
  3. int x,
  4. int y,
  5. int cx,
  6. int cy,
  7. SET_WINDOW_POS_FLAGS uFlags,
)

Changes the size, position, and Z order of a child, pop-up, or top-level window.

These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

To learn more, see learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setwindowpos.

Implementation

Win32Result<bool> SetWindowPos(
  HWND hWnd,
  HWND? hWndInsertAfter,
  int x,
  int y,
  int cx,
  int cy,
  SET_WINDOW_POS_FLAGS uFlags,
) {
  resolveGetLastError();
  final result_ = _SetWindowPos(
    hWnd,
    hWndInsertAfter ?? nullptr,
    x,
    y,
    cx,
    cy,
    uFlags,
  );
  return .new(value: result_ != FALSE, error: GetLastError());
}