Set your wallpaper as background of a dialog box

One day I was messing around with a dialog based application and I found that I can set my wallpaper as dialog's background. I don't know how it did  though :).

Create a dialog based application and replace your OnPaint code with this code.

void CDlgFontDlg::OnPaint() 

{

CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

if (IsIconic())

{

// Center icon in client rectangle

int cxIcon = GetSystemMetrics(SM_CXICON);

int cyIcon = GetSystemMetrics(SM_CYICON);

CRect rect;

GetClientRect(&rect);

int x = (rect.Width() - cxIcon + 1) / 2;

int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon

dc.DrawIcon(x, y, m_hIcon);

}

else

{

hdc = dc.GetSafeHdc() ;

::SetBkColor( hdc , RGB(255, 0, 100));

CDialog::OnPaint();

}