| |

VerySource

 Forgot password?
 Register
Search
View: 816|Reply: 5

Set background image in dialog

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-24 10:00:01
| Show all posts |Read mode
How do I set the background image in the dialog box? After searching the Internet, I found this method:
Overload WM_ERASEBKGND message mapping function OnEraseBkgnd (CDC * pDC)
BOOL CMPlayerDlg :: OnEraseBkgnd (CDC * pDC)
{
CDC memDC;
CBitmap MPlayer;
if (! MPlayer.LoadBitmap (IDB_MPLAYER))
return FALSE;
memDC.CreateCompatibleDC (pDC);
CBitmap * pOldBmp = memDC.SelectObject (&MPlayer);
pDC-> BitBlt (0,0, MPLAYERWIDTH, MPLAYEREXT,&memDC, 0,0, SRCCOPY);
memDC.SelectObject (pOldBmp);
return TRUE;
}
However, I can only implement it in a single document.I cannot implement it in the dialog box because the WM_ERASEBKGND message cannot be found.
Is there a better way to set the background image in the dialog box?
Reply

Use magic Report

0

Threads

36

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-2-9 21:30:01
| Show all posts
You can also use this message, add this function to your dialog class, and then add a macro to the message map
ON_WM_ERASEBKGND
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-13 10:30:01
| Show all posts
1: add message mapping manually
2: In the Add Message Wizard, select (Window) (VC6) when filtering messages in the lower right corner
Reply

Use magic Report

0

Threads

14

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-2-19 01:30:01
| Show all posts
Right click on the dialog-> Events-> select the "Window" or "ChildWindow" in the lower right corner to find ON_WM_ERASEBKGND, and then "Add and Edit", OK Then right click on the dialog and add your code with ClassWizard.
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-2-21 16:15:01
| Show all posts
As long as it is a window
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-3-10 16:00:01
| Show all posts
Already done according tozzw781225, thank you!
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