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!

displaying a splash screen

Status
Not open for further replies.

CDuddley

Programmer
Feb 4, 2002
26
US
i'm using a dialog box with no frame or borders, and i'm trying to display an image in the background like for an installer splash screen. and then, i'll just use the buttons to install stuff with. i tried making the whole dialog transparent so that only the buttons show up, and then do GetClientRect and display the image like that, but i'm having trouble with getting the HDC to work it's not getting set properly when i do:

CImage myimg;
HDC hDC = myimg.GetDC();
myimg.Load("mybmp.bmp");
...

any help would be appreciated.

-will
 
load a bitmap into a CBitmap object..
m_mybmp.DeleteObject();
HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, "mybmp.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);

if (!hBitmap || !m_mybmp.Attach(hBitmap))
return FALSE;

then in OnEraseBkgnd blit the pic to the background

BOOL CMyDlg::OnEraseBkgnd (CDC *pDC)
{
CRect rc;
GetClientRect (rc);

// Get a DC for the bitmap
CDC dcImage;
dcImage.CreateCompatibleDC (pDC);
CBitmap *pOldBitmap = dcImage.SelectObject (&m_mybmp);

// Draw the bitmap as the window background
pDC->BitBlt (0, 0, rc.Width(), rc.Height(), &dcImage, 0, 0, SRCCOPY);

// Release
dcImage.SelectObject (pOldBitmap);
dcImage.DeleteDC ();

// Return value: Nonzero if it erases the background.
return TRUE;
}

hope this is what you need O.B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top