OA. free
Free
IBM Quantitative Aptitude Core Computer Science Medium

Which of the following Windows APIs is used to hide a window?

IBM aptitude question, verified with a worked answer. Free to practise - no sign-up.

Which of the following Windows APIs is used to hide a window?

Choose one option.
Show answer & explanation
Answer: A. ShowWindow

ShowWindow is the standard Windows API function used to show, hide, or minimize a window by specifying visibility flags (e.g., SW_HIDE, SW_SHOW). EnableWindow controls whether a window accepts user input but does not change visibility. MoveWindow repositions and resizes windows. SetWindowPlacement restores or minimizes windows but is less commonly used for simple hide operations.

Step-by-step Derivation:
The ShowWindow function in Windows API accepts two parameters: HWND (window handle) and nCmdShow (display command). Common flags include:

  • SW_HIDE (0): Hides the window
  • SW_SHOW (5): Shows the window
  • SW_MINIMIZE (6): Minimizes the window

This is the primary and most direct API for controlling window visibility. The other options serve different purposes: EnableWindow disables/enables input handling, MoveWindow changes position/size, and SetWindowPlacement is used with WINDOWPLACEMENT structure for restoration. Therefore, ShowWindow is the correct answer.