| |

VerySource

 Forgot password?
 Register
Search
View: 935|Reply: 8

Masters, some questions about VC drawing dotted lines?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 United States

Post time: 2020-2-24 06:30:03
| Show all posts |Read mode
The points and points I draw with CPen's PS_DOT type are too small and the distance is narrow. How do I make the point larger and how to adjust the distance between points.
   The method of drawing a small circle at the starting point and the ending point can solve my problem, but isn't this clumsy and the speed is particularly slow? (I have to draw a lot, almost full screen)
   Wang experts enlighten simple methods, as far as possible through the function provided by gdi
Reply

Use magic Report

0

Threads

3

Posts

53.00

Credits

Member

Rank: 2

Credits
53.00

 China

Post time: 2020-2-28 22:05:12
| Show all posts
The second parameter of the CPen constructor specifies the line width. You can increase its value to increase the line width. You can use LineTo to draw continuous lines.
The following is called in the onPaint function:
CPen pen (PS_DOT, 20, RGB (0, 0, 255));
CClient dc (this);
CPen * oldPen = dc.SelectObject (&pen);
dc.MoveTo (m_ptOrigin);
dc.LineTo (point);
dc.SelectObject (&pOldPen);
Reply

Use magic Report

1

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-11 15:30:01
| Show all posts
// CDialog :: OnPaint ();
        CPaintDC dc (this);
        LOGBRUSH lb;
        lb.lbColor = RGB (255,0,0);
        lb.lbHatch = HS_CROSS;
        lb.lbStyle = BS_SOLID;

        CPen NewPen (PS_GEOMETRIC | PS_DOT | PS_ENDCAP_SQUARE, 20,&lb, 0, NULL);
        CPen * pOldPen = dc.SelectObject (&NewPen);
        dc.MoveTo (20,20);
        dc.LineTo (200,200);
        dc.SelectObject (pOldPen);
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-12 19:30:01
| Show all posts
The method upstairs is to use the second constructor of cpen. Use clientdc to draw?
===============
CClientDC dc (this);
        LOGBRUSH lb;
        lb.lbColor = RGB (255,0,0);
        lb.lbHatch = HS_CROSS;
        lb.lbStyle = BS_SOLID;

        CPen NewPen (PS_GEOMETRIC | PS_DOT | PS_ENDCAP_SQUARE, 20,&lb, 0, NULL);
        CPen * pOldPen = dc.SelectObject (&NewPen);
        dc.MoveTo (20,20);
        dc.LineTo (200,200);
        dc.SelectObject (pOldPen);
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-5-23 19:15:01
| Show all posts
Thank you two upstairs. The point size problem is solved, but what about distance?
Reply

Use magic Report

0

Threads

21

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 United States

Post time: 2020-7-6 19:15:01
| Show all posts
That one seems to change the brush, but I’m not sure
Reply

Use magic Report

0

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-7 16:45:01
| Show all posts
The distance is large, then you can just draw some
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-16 21:45:01
| Show all posts
Are you going to draw a dotted line?
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-7-16 22:15:02
| Show all posts
firehawk85


   
Thank you two upstairs. The point size problem is solved, but what about distance?

  

=============================
Distance is related to width. You see on MSDN, when you change from 20 to 10, isn't the spacing smaller?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list