Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing appearance of DIalog BOx

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is there a way to change the appearance (image, background color) of the grayed Dialog box (and Message box) that you get in a "Dialog-based" VC++ app.
 
Hi

Suppose you add a small bitmap to your app resources
You need to override OnEraseBkgnd
Here is the code to tile a bmp in a dialog box:

BOOL CAboutDlg::OnEraseBkgnd(CDC* pDC)
{

CDC dc;
CBitmap bmbkg;

// Get Client Size
CRect rc;

GetClientRect( &rc);

if ( !bmbkg.LoadBitmap( IDB_BACKGROUND))
return FALSE;

BITMAP bmbkgData;
bmbkg.GetBitmap( &bmbkgData);

// Create Compatible DC
if ( !dc.CreateCompatibleDC( pDC))
return FALSE;

// Select Bitmap
CBitmap* pOldBkgBmp = dc.SelectObject( &bmbkg);

// Fill DialogBox

int nXNbr = 1 + ( rc.Width() / bmbkgData.bmWidth);
int nYNbr = 1 + ( rc.Height() / bmbkgData.bmHeight);

int nXPos = 0;

for ( int nX = 0; nX < nXNbr; nX++)
{
int nYPos = 0;

for ( int nY = 0; nY < nYNbr; nY++)
{
// Draw Background Bitmap

pDC->StretchBlt( nXPos, nYPos,
bmbkgData.bmWidth, bmbkgData.bmHeight, &dc,
0, 0, bmbkgData.bmWidth, bmbkgData.bmHeight,
SRCCOPY);

nYPos += bmbkgData.bmWidth;
}

nXPos += bmbkgData.bmHeight;
}

// Clean Up

dc.SelectObject( pOldBkgBmp);

bmbkg.DeleteObject();

return TRUE; // CDialog::OnEraseBkgnd(pDC);
}

HTH

Thierry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top