Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 8 GDI Orientation and Transformations


Practical Learning: Loading a Bitmap



  1. Start a new project and name it Bitmap1

  2. Create it as a Single Document application based on CView

  3. In the Class View, expand everything and access the
    CMainFrame::PreCreateWindow() method

  4. Change its code as follows:


BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;

// The new width of the window's frame
cs.cx = 480;
// The new height of the window's frame
cs.cy = 490;
// Remove the Untitled thing
cs.style &= ~FWS_ADDTOTITLE;

return TRUE;
}


  1. In the Resource View, display the string table and change the IDR_MAINFRAME
    Caption to
    Lady on Phone\n\nBitmap\n\n\nBitmap1.Document\nBitmap Document

  2. Right-click any folder and click Import...

  3. In the Import Resource dialog box, change the Files of Type to All Files and, in the
    Look In combo box, change the folder to the one that holds the accompanying
    exercises for this book.

  4. Select lady.bmp

  5. Click Import. After the bitmap has been imported, you may receive a message box,
    click OK

  6. Right-click the new IDB_BITMAP1 resource and click Properties

Free download pdf