Solved

1 pixel wide Brush ?

Posted on 1998-08-10
1
449 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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