RE: Win32Lib: drawRectangle question
- Posted by Derek Parnell <ddparnell at bigpond.com> May 09, 2001
- 482 views
Hi Brendon, > -----Original Message----- > From: Brendon Sly [mailto:bwsly at infoscience.otago.ac.nz] > Sent: Wednesday, 9 May 2001 7:52 AM > To: EUforum > Subject: Win32Lib: drawRectangle question > If I drew a rectangle (filled or not) then plotted the > corner points, it wouldn't match up. Here are the Microsoft docs. Take note of the "Remarks" section. --------------- Rectangle The Rectangle function draws a rectangle. The rectangle is outlined by using the current pen and filled by using the current brush. BOOL Rectangle( HDC hdc, // handle to DC int nLeftRect, // x-coord of upper-left corner of rectangle int nTopRect, // y-coord of upper-left corner of rectangle int nRightRect, // x-coord of lower-right corner of rectangle int nBottomRect // y-coord of lower-right corner of rectangle ); ------------- Parameters ------------- hdc [in] Handle to the device context. nLeftRect [in] Specifies the logical x-coordinate of the upper-left corner of the rectangle. nTopRect [in] Specifies the logical y-coordinate of the upper-left corner of the rectangle. nRightRect [in] Specifies the logical x-coordinate of the lower-right corner of the rectangle. nBottomRect [in] Specifies the logical y-coordinate of the lower-right corner of the rectangle. ------------- Return Values ------------- If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Windows NT/ 2000: To get extended error information, call GetLastError. ------------- Remarks ------------- The current position is neither used nor updated by Rectangle. The rectangle that is drawn excludes the bottom and right edges. If a PS_NULL pen is used, the dimensions of the rectangle are 1 pixel less in height and 1 pixel less in width. --------------------- As Win32lib uses this GDI function to draw rectangles, it means that the right and bottom edges are not drawn. This is not intuitive but I'm sure uncle Bill has a VERY GOOD reason for confusing us all My guess is that it was a bug, but to fix it would break so much code they decided to document it instead. ----------- cheers, Derek Parnell