Does window width equal (xmax - xmin) or (xmax - xmin + 1)?
Posted on 2003-11-18
I am confused as to what the meaning of a window is in regards to the Windows SDK.
Some functions like SetWindowPos() require the window width and height as parmeters and other function like GetWindowRect() pass back the left, right, top, and bottom positions. I am trying to understand exactly how they relate.
I keep coming across code that says width = xmax - xmin. For example in Microsoft Knowledge Base #68556 it has a call to GetWindowRect(hDlg, &rect) followed by a call to SetWindowPos() in which the fourth parameter for the width is the following:
rect.right - rect.left, // Based on the values returned by
// GetWindowRect, calculate the new
// width of the main window.
I would think that the width would be rect.right - rect.left + 1. If the window is 3 pixels wide and placed at the upper right corner wouldn't there be pixels at horizontal screen locations 0, 1, and 2? Therefore right - left would be 2 - 0 which is only 2 (not 3)
Could someone please explain to me the logic of whether or not you add 1 to the right - left calculation to figure out window width?