| |

VerySource

 Forgot password?
 Register
Search
Author: 守望爱情

The bitmap created by CreateCompatibleBitmap is black by default. Before drawing up, you must paint the background color

[Copy link]

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-11-25 12:45:02
| Show all posts
sorry:
>>>temBmp.CreateCompatibleBitmap(&pDC,rect.Width(),rect.Height());
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-11-25 13:00:02
| Show all posts
>>>temBmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());

---old!
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-11-25 13:15:01
| Show all posts
The result of running the following code is red.
         CDC dc;
CDC* pDrawDC = pDC;
CBitmap bitmap;
CBitmap* pOldBitmap;
To
CRect rect;
GetClientRect(&rect);
//============================================== ========
if (dc.CreateCompatibleDC(pDC))
{
if (bitmap.CreateCompatibleBitmap(pDC,
rect.Width(),
rect.Height()))
{
OnPrepareDC(&dc,NULL);
pDrawDC =&dc;
pOldBitmap = dc.SelectObject(&bitmap);
}
}
//============================================== ========
//pDoc->Draw(pDrawDC,ViewID);
>>>>>>>>>pDrawDC->FillSolidRect(0,0, 100,100, RGB(255,0,0));
pDrawDC->TextOut(1,1,_T("ABC"));
dc.DPtoLP(&rect);
//=============================================== ========
if (1)//pDrawDC != pDC)
{
pDC->BitBlt( 0, 0,rect.Width(), rect.Height(),
&dc, 0, 0, SRCCOPY);
dc.SelectObject(pOldBitmap);
bitmap.DeleteObject();
}
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-11-25 13:30:01
| Show all posts
I seem to be careless, oops
Reply

Use magic Report

2

Threads

8

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-11-25 13:45:01
| Show all posts
I have the SetMapMode(MM_TWIPS) statement in OnPrepareDC(); when I comment out this statement, the normal result can be obtained. Why?
Reply

Use magic Report

2

Threads

8

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-11-25 14:00:01
| Show all posts
--->>>meteora12

I tried your example and it is correct. If I add SetMapMode(MM_TWIPS) in OnPrepareDC() of this example;

A black screen will also appear, because my program needs to support printing, so SetMapMode(MM_TWIPS) is added.

Do you know the reason?
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