| |

VerySource

 Forgot password?
 Register
Search
Author: zgw716

Master: Multi-line strings, how to achieve in DC like Word can let different characters display with different colors /

[Copy link]

2

Threads

16

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-13 17:30:01
| Show all posts
Various formats are defined in the file:
Such as: <br> means line break, <color> means color

In PAINT, corresponding to different format characters, different brushes and fonts are used.

Macros can be used to customize some commonly used
Reply

Use magic Report

2

Threads

18

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

 Author| Post time: 2020-6-20 06:45:01
| Show all posts
But upstairs, so defined, how can you control word wrap?
I want to display the color of different words in a cell of MFCgridCtrl. For example, the word I searched should be displayed in red.
I don't want to do manual line wrapping, DrawText can automatically wrap based on the size of Rect.
Reply

Use magic Report

1

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-6-21 12:15:01
| Show all posts
It is recommended that the landlord use other controls directly, if you want to do it yourself, you are exhausted.
Reply

Use magic Report

2

Threads

18

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

 Author| Post time: 2020-6-26 23:45:01
| Show all posts
Upstairs, what good controls are recommended?
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-7-12 00:00:01
| Show all posts
Use SetTextColor to determine the color
Draw with DrawTextA
A color is drawn once, the coordinates of the character are specified in the parameter lpRect,
Draw as much as you want,
Isn't it OK?
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-7-12 07:00:02
| Show all posts
A line can be divided into small segments according to color. DrawText
Reply

Use magic Report

2

Threads

18

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

 Author| Post time: 2020-7-12 22:00:01
| Show all posts
The upstairs is too simple, such as how to consider whether it is time to wrap? If it's a Chinese character, how do you treat it?
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-7-20 17:00:02
| Show all posts
The total character width of each line displayed should not be greater than the width of the parameter lpRect coordinate interval, otherwise it will be displayed in a new line. Chinese and English are only different in pixel height and width for DrawTextA, ok
Reply

Use magic Report

2

Threads

18

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

 Author| Post time: 2020-7-21 10:15:01
| Show all posts
For example, if I want to make the searched phrase appear red, but it happens that half of the phrase is on one line and the other half is on the next line, use
Isn't drawtext troublesome?
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-7-21 13:45:01
| Show all posts
Don't be afraid of trouble, formatting itself is more cumbersome, you can see that DrawText has a lot of logo parameters.
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