| |

VerySource

 Forgot password?
 Register
Search
View: 545|Reply: 4

When writing on a bitmap, when the background of the text is set to be transparent, when I write multiple times in the s

[Copy link]

1

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 United States

Post time: 2020-3-8 17:30:02
| Show all posts |Read mode
As the title ~~~
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-6-4 09:15:01
| Show all posts
You can do this, when writing the text for the second time, use the first question at the original position, XOR texture can restore the background color, and then write new text.
Reply

Use magic Report

2

Threads

16

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-12 17:45:01
| Show all posts
Try:
If the text is drawn outside the PAINT message processing function, Invalidate() causes it to erase the background;
If you draw text in the PAINT message, use the space character padding to overwrite the previous text;
Reply

Use magic Report

1

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-7-3 20:30:01
| Show all posts
The specific approach is:
   I made a window background with a bitmap on a form, and then used a function to write text somewhere on the window background,
My function is:
wf_writetext(char *szstr, hbitmap hbit)
ulong dc, memdc, holdbitmap, htextcolor, htemp
RECT rt

dc=GetDC(handle(this))
memdc=CreateCompatibleDC(dc)
holdbitmap=SelectObject(memdc,hbit)
rt.top=40
rt.left=100
rt.right=200
rt.bottom=70
SetBkMode(memdc, TRANSPARENT)
DrawText(memdc, as_str, len(as_str), rt, DT_LEFT +DT_VCENTER)
BitBlt(dc, rt.left, rt.top, rt.right -rt.left, rt.bottom -rt.top, memdc, rt.left, rt.top, SRCCOPY)

SelectObject(memdc, holdbitmap)
DeleteDC(memdc)
ReleaseDC(handle(this),dc)
When I repeatedly call this function to write numbers at rt, the text will overlap,
Is my approach correct?
Does anyone have an example to solve this problem? Thank you
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-14 11:45:01
| Show all posts
Use a blank brush before each write: dc.SelectStockObject(NULL_BRUSH);
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