Re: Problem with vista and form appearance

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"peter smith" <qqpixe@xxxxxxxxxxxxxx> wrote in message news:608dba46-ed27-4371-a61d-82b764da5c41@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

picture1.line (0,195)-(195,0)

.. . . another thing I also forgot to mention Peter is about the line lengths (although it is just a side note really in terms of your specific probem). When drawing single pixel thickness lines (the default thickness) then the final pixel of the line is not actually plotted. This applies both when drawing using the native VB Line method and when drawing using the alternative API (GDI) LineTo method. It is the standard behaviour in Windows. So, in the case of a 200 x 200 pixel PictureBox with a standard border the actual drawing area is 196 x 196 pixels (for the reasons described in my previous responses) and those pixels are numbered 0 to 195, with the top right coordinate of course being coordinate (195, 0). Therefore when you draw your (0, 195) - (195, 0) line the very last pixel of that line, pixel (195, 0) will not actually be plotted, with the result that the diagonal line does not quite extend fully to the top right corner of the drawing area. The first pixel of the line is always plotted, but the last pixel is not, although the "current pixel position" /does/ actually move to the final unplotted pixel position (as you will see if you use Picture1.CurrentX and Picture1.CurrentY to examine the current coordinate after drawing the line). This is not easy to see normally, but if you press the PrintScreen key on your keyboard to copy the screen to the clipboard and then open MS Paint and use use Edit / Paste and then use the MS Paint View / Zoom / Custom to set the view to 400 or 800 per cent you will clearly see the missing pixel.

Again this behaviour is by design, and one of the reasons for it is so that continuous lines which are drawn by repeatedly using the Line method to draw from the end of the previous line to some new position, etc, etc all get drawn properly. (The same reasoning applies to lines drawn using the API (GDI) PolyLine method which draws connected line segments). The rationale behind it is to prevent the last pixel of each line segment being plotted twice, once as the last pixel of the first line segment and once again as the first pixel of the following line segment. This "double plotting" of a specific pixel at the join of each line segment (if it were allowed to happen) would not be a problem when drawing with the standard DrawMode (vbCopyPen) but it would definitely be a problem for some other DrawModes, such as vbInvert or vbXorPen (drawing modes which are common for many tasks) because in such cases the "double plotting" of a pixel would return it back to the condition it was in before the drawing took place, causing little "holes" to appear in the otherwise continuous full line that was drawn with multiple Line methods or with the API PolyLine method or whatever.

Anyway, I just though I would mention this in case you examine the output of your new code in detail (after you have taken account of the stuff I said in my previous responses) and if you begin to wonder why the final pixel of your diagonal line has not been plotted. In order to draw the line fully you need to take the "last pixel of a line is not plotted" business into account, and draw your line accordingly.

Mike




.



Relevant Pages

  • Re: Inverse Selection Box
    ... When I draw a selection box, I need the selection line color to be ... Thus far, the only solution I have come up with is to draw each pixel, ... inverting the pixel color that I am drawing over. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: How to store relative position
    ... drawing area out 50%, and I paint a dot, then zoom the drawing ... For example, if your drawing area is meant to represent a full US Letter Size page then it treats the displayed drawing area as being 8.5 units wide and 11 units high at all times, regardless of the current physically displayed pixel width and height. ... That is exactly how the VB will treat your PictureBox drawing area if you ignore its current physically displayed size and set its ScaleWidth to 8.5 and its ScaleHeight to 11, as has already been suggsted to you by a number of people who have posted reponses to your question. ...
    (microsoft.public.vb.general.discussion)
  • Inverse Selection Box
    ... I am needing to draw a 'selection' rectangle in a drawing application. ... Thus far, the only solution I have come up with is to draw each pixel, ...
    (microsoft.public.win32.programmer.gdi)
  • Freehand Drawing
    ... I am trying to add freehand drawing to my application. ... rectangles, ellipses, etc but having trouble with single pixel drawing. ... start the draw but if I hold down the mouse and move (wanting to draw while ... Draw Function It makes it to the switch but doesn't ...
    (microsoft.public.win32.programmer.gdi)
  • Re: CDC problem
    ... GDI+ although it would support float has to round it of to the nearest pixel ... There is no concept of float pixel or partial whatever library we choose. ... >> I am using CDC member functionsfor drawing ...
    (microsoft.public.win32.programmer.gdi)