Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Use the Win32 SetWindowPos function to set a window’s position and size. Pass the window handle, an insertion-after value for Z order, pixel coordinates and dimensions, and flags for any properties you want to leave unchanged.
What SetWindowPos changes
SetWindowPos can change the size, position, and Z order of a child, pop-up, or top-level window. Its coordinates and dimensions are pixel values. The function takes an HWND, an insertion-after handle or special Z-order value, the new X and Y coordinates, the new width and height, and a flags bitmask. See Microsoft’s SetWindowPos function reference for the declaration and full flag list.
Use the flags to specify what should stay as it is. When SWP_NOMOVE is set, X and Y are ignored; SWP_NOSIZE makes width and height ignored; and SWP_NOZORDER preserves the current Z order and ignores the insertion-after value.
How to choose coordinates and flags
Choose the coordinate origin
For a top-level window, X and Y are measured from the upper-left corner of the screen. For a child window, they are measured from the upper-left corner of its parent. Microsoft’s window features documentation describes these coordinate systems.
#1 Best Overall
- Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
- Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
- Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
- Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
- Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites
GetWindowRect returns a window rectangle in screen coordinates, including for child windows. To use a child window’s bounds in its parent’s client area, map the points with ScreenToClient or MapWindowPoints.
Preserve activation and repaint behavior when needed
- Use
SWP_NOACTIVATEwhen the window should not be activated as a result of the operation. - Avoid
SWP_NOREDRAWunless your application manages repainting. With this flag, the affected window areas are not repainted automatically; arrange the necessary invalidation or redraw yourself.
Check whether the call succeeded
The documented return value is nonzero on success and zero on failure. If it returns zero, call GetLastError for extended error information.
Rank #2
- Dependable wireless connection: Enjoy the reliability and convenience of 2.4 GHz connectivity with your logitech wireless keyboard and mouse combo, wireless range up to 10 meters away at home, or work.
- Full-Size Wireless Keyboard: Comfortable, quiet typing on a familiar keyboard layout with palm rest, spill-resistant design, and media keys. This wireless keyboard and mouse logitech has easy-access to media keys
- Plug and Play: MK345 works seamlessly with Windows, macOS, and ChromeOS. Experience hassle-free setup with the logitech mk345 wireless combo and wireless keyboard mouse combo for various operating systems.
- Long-lasting Battery: The MK345 combo offers a full size keyboard battery life of up to 3 years and a mouse battery life of 18 months (1); batteries included
- Comfortable Right-handed Mouse: This wireless USB mouse with dongle works well for this wireless mouse and keyboard combo, featuring a contoured shape for all-day comfort and smooth, precise tracking and scrolling for easier navigation.
When another positioning API fits better
Choose based on whether you are positioning one window or several and whether show state or saved placement matters. Microsoft’s window functions overview lists the relevant alternatives.
| API | Use it when | What it handles |
|---|---|---|
SetWindowPos |
You need to position or resize one window and may need control over flags such as activation, visibility, or Z order. | Position, size, Z order, and behavior controlled by flags. |
MoveWindow |
You need to set the position or size of one window without the broader flag options of SetWindowPos. |
Position and size of a single window. |
SetWindowPlacement |
You need to manage a window’s minimized, maximized, or restored placement and show state. | Minimized and maximized positions, restored size and position, and show state. |
BeginDeferWindowPos, DeferWindowPos, and EndDeferWindowPos |
You need to set the positions or sizes of several windows together. | Deferred positioning of multiple windows. |
Position several windows together
For a group of windows, Microsoft documents the BeginDeferWindowPos, DeferWindowPos, and EndDeferWindowPos sequence. See the DeferWindowPos function reference for its role in deferred positioning.
Rank #3
- Type and Click Across Your Personal and Work Computers: Move seamlessly between your home desktop and your work laptop with this wireless and quiet keyboard and mouse combo (2)(3)
- Save Time Like Magic: Customizable keys, buttons and shortcuts for extended possibilities with the Logi Options+ App; available for Windows and macOS (3) (4) (5)
- Enhance Your Space: A sleek and solidly built full-size bluetooth keyboard with familiar laptop-style typing and a comfortable, contoured, bluetooth mouse made of recycled plastic (8)
- Quiet Experience: Conjure some focus time with quiet typing and clicking; the M750 L Signature Plus is a quiet click mouse with SilentTouch technology for 90% less click noise (7)
- Easy Scrolling: With the M750 L Signature Plus wireless mouse for larger hands, you can scroll through documents line by line, or fly effortlessly through long web pages with the SmartWheel
What you need to build a Win32 application
The API reference identifies winuser.h and desktop-app requirements. Microsoft’s Windows SDK overview describes the SDK as providing platform headers, libraries, metadata, and build tools for Windows development, including Win32. The SDK version and Windows targeting details on that page can change, so check the current overview when selecting a release.
For a Visual Studio setup, Microsoft’s Win32 getting-started guide points to the Desktop development with C++ workload. Its setup guidance also identifies the Windows SDK or Visual Studio as options for writing Windows programs in C or C++.
Quick Recap
Best Value
- Durable and Reliable: This USB keyboard features a curved space bar, spill-resistant design (2), durable keys that can withstand 10 million keystrokes, and sturdy, adjustable tilt legs
- Comfortable, Familiar Typing: You’ll enjoy a comfortable and familiar typing experience thanks to the deep-profile keys and standard layout with full-size F-keys and number pad
- Full-size Sculpted Mouse: The high-definition optical USB mouse puts comfort and control in your hands with smooth, accurate tracking and an ambidextrous shape that feels good hour after hour
- Simple Set-Up: Simply plug the keyboard and mouse into the USB ports on your desktop, laptop, or netbook and you're ready to work; compatible with Windows 7, 8, 10 or later
- Clear and Convenient: The bold, bright white and long-lasting characters make the keys on this PC or laptop keyboard easy to read and extra durable
Rank #4
- Logitech MK470 cordless combo features a compact modern designed keyboard with low-profile scissor keys, a number pad and a layout optimized for Windows
- This wireless keyboard and mouse set also features a comfortable, ambidextrous 3 button mouse with high precision optical tracking and mechanical scroll wheel, Sensor resolution: 1000 DPI
- Whisper quiet keyboard and lab-tested, noise-reduced mouse means an ultra quiet work experience for you and those around you both in the office and at home
- Simple plug-and-play USB nano receiver offers a strong reliable 2.4 GHz wireless connection with 10 m (33ft) of range(1) (1) Wireless range may vary based on environmental and computing conditions
- Auto-sleep feature saves battery life, allowing for 36 months of keyboard use and 18 months of mouse use(2) (2) Battery life may vary based on user and computing conditions
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools

