Solved

1 pixel wide Brush ?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now