Re: Pen created using ExtCreatePen fails to get selected into a metafi

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 11/21/04


Date: Sun, 21 Nov 2004 01:05:17 -0500

Are you sure it is a 1-pixel solid black pen you are seeing, and not a pen of width 5
pixels (which might translate to, say, 5/600ths of an inch), with very tiny dots? I've
found there are a lot of problems like this when moving to printers. Try a number like 30
when printing, just as a test. 5 is also a poor choice, because that looks good only for
one screen resolution. Generally, you want to pick values that are based on some factor of
the screen resolution or printer resolution. For example, on a 600x800 display, 5 pixels
is 5/600 of the width of the screen, but on a printer it is 5/600 of an inch, which is
pretty small. So for an 8 1/2 inch page, at 600dpi, that's a width of 5100dots, so a value
like 42 pixels would make a bit more sense, unless you are doing all the proper scaling to
get the image to appear correctly. Then it should scale the pen width accordingly.

You might find, in graphics-intensive drawing, that it makes more sense to do
SaveDC/RestoreDC (which can nest) rather than generating lots of temporary variables to
hold intermediate state.
                                joe

On Thu, 18 Nov 2004 01:24:03 -0800, George <George@discussions.microsoft.com> wrote:

>Hello,
> In the OnDraw() function of my ActiveX control(just drawing , I select
>a Pen as
>shown below. The constructor of CPen passes the parameters to create
>EMR_EXTCREATEPEN structure. ( ExtCreatePen also creates a similar
>structure)
>
> LOGBRUSH tmpLB;
> tmpLB.lbColor = COLORREF(RGB(0,0,0));
> tmpLB.lbStyle = BS_SOLID;
> CPen tempPen(PS_GEOMETRIC|PS_DOT, 5, &tmpLB,0,NULL);
> pOldPen = (CPen*)pdc->SelectObject(&tempPen);
> VERIFY(pOldPen);
> pdc->Ellipse(rc);
>
>On Screen, the ellipse draws correctly with dots of width 5.
>But, On printing or drawing to a metafile DC , the ellipse is drawn
>with the stockPen (BLACK,width=1,PS_SOLID). The pen appears not to get
>selected at all into a metafile DC.
>I am using winXP.
>
>I found a related article in the KB
>http://support.microsoft.com/kb/q196299/
>But, it claims that the problem is only on win95/98.
>
>Any comments?
>Thanks,
>Bipin

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Draw pixel
    ... whether Autoredraw is True or not. ... As far as drawing individual pixels ... difference the API is up ...
    (comp.lang.basic.visual.misc)
  • Re: Apple II VGA Video Generator Card Project
    ... of the frame buffer, so all line drawing will take longer. ... 1.- It takes n times longer to draw n*x pixels as it takes to draw x ... that provide either more resolution or more color depth or both. ...
    (comp.sys.apple2)
  • Re: newbie questions on OpenGL and C#. I am using NeHe example code
    ... > and 2) you can have the window covered by another window ... This implies that read pixels is not ... to put a red square down on the drawing surface. ... >> graphics card then you're rendering in software. ...
    (comp.graphics.api.opengl)
  • Re: Positioning datalabels
    ... resolution (Pixels per inch??????) ... Dim lngXdpi As Long ... 'Get Screen resolution ... drop a line on a chart at a particular X value. ...
    (microsoft.public.excel.programming)
  • Re: screen resolution
    ... That is the double-edged sword of changing the screen resolution - you get more stuff on the screen, but much of the stuff that there get's smaller. ... Screen res determines how many pixels of information are displayed on the screen; many items displayed on a PC are "pictures" composed of a fixed number of pixels. ... For example, if a screen icon is 100x100 pixels and the resolution of your monitor is set to 640x480, that icon would be filling up about a fifth of the screen vertically. ... using Photoshop the more pixels per inch the sharper an image will be. ...
    (microsoft.public.windows.mediacenter)