Does window width equal (xmax - xmin) or (xmax - xmin + 1)?

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?

Thanks,
Mark

Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
If the window is 3 pixels wide, and you place it at top left corner, it would span from 0 to 3

Try this code:

HWND hWnd = CreateWindow("EDIT", "", WS_CHILD|WS_VISIBLE, 0, 0, 3, 3, m_hWnd, NULL, AfxGetInstanceHandle(), NULL) ;

RECT rc ;
::GetClientRect(hWnd, &rc) ;//see rect = {0, 0, 3, 3}

So, the answer would be width = right - left. not right - left +1
0

Experts Exchange Solution brought to you by