Solved

1 pixel wide Brush ?

Posted on 1998-08-10
1
450 Views
Last Modified: 2013-11-20
Hi,
My program's view is based on the CZoomView by Brad Pirtle(codeguru.com Doc-View catagory), which is derieved from CSrollView.

I used the SelectStockObject(BLACK_PEN) to do most of my drawing, so when I zoom in and out the lines stay a the same thickness(1 pixel), this works great.

The problem is when certain items are selected they are redrawn using a brush similar to the PS_ALTERNATE pen in NT (Drawing dotted lines - Jean-Edouard Lachand-Robert/GDI catagory). This works great when you stay in the default zoom mode, but when you zoom in/out the lines really look bad. Sometimes some lines are thicker than others.

What I would like to do is keep them(the dotted lines) at the same 1 pixel width regaurdless of how far in/out you zoom.

I also implement the DrawDragRect, which as you might guessed works great in the default mode. When I zoom in/out things get crazy, it does not redraw it's self correctly. I've testet the CRectTracker which uses the DrawDragRect and it works fine at any zoom. When I call the DrawDragRect I pass it a CSize(1,1) like CRectTracker.

Can anybody help? I'm really stuck :(

Mark

0
Comment
Question by:studebaker
1 Comment
 

Accepted Solution

by:
scs1 earned 200 total points
ID: 1320533
Mark,
       I have been writing an MFC Application that uses several different pen colors.  I am only using continous lines with 1 pixel thickness.  I use the following commands to create the pen object, define it, and use it.  I think it should work for you.  I also have a zoom-in and zoom-out command in my application and it still works fine.

// creating the pens
CPen *oldpen, redPen, blackPen, yellowPen;

// defining the pens.  The 1 is the pixel width.
redPen.CreatePen(PS_SOLID, 1, RGB(255,0,0));
blackPen.CreatePen(PS_SOLID, 1, RGB(0,0,0));
yellowPen.CreatePen(PS_SOLID, 1, RGB(255,255,0));

//selecting the pen to be used
oldpen=pDC->SelectObject(&redPen);

I hope this is clear and helpful
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro to save highlighted rows as a separate file 5 46
centeredAverage challenge 8 185
abstract class with all non abstract mentods 6 84
wordmultiple challenge 12 156
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question