Thread: Loading a .bmp and displaying into a dialog?

  1. #1
    Unregistered
    Guest

    Loading a .bmp and displaying into a dialog?

    Right, can anyone help me. Im writting this little program, it will display a series of tiles onto a dialog box. Each tile is 32x32 in pixels. However, 1 problem struck me.... How do i display just 1 bmp into a dialog box?. Anyone know how?

    Thankyou

    Marathon2k

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823

  3. #3
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    He said ON A DIALOG. I don't know how, though. I use Visual Studio.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    bmp on a dialog

    somewhere you have to have a memdc

    Code:
    CDC*      pActiveDC;
    CDC        memdc;
    CBitmap  bmp;
    
    void MyClassDlg::LoadBmp()
    {
             CDC* pdc = GetDC();
           
             memdc.CreateCompatibleDC( pdc );
             bmp.LoadBitmap( IDB_BITMAP1  );
             memdc.SelectObject( &bmp );
    }
    
    //** Windos paint message handler
    void MyClassDlg::OnPaint()
    {
    
           .......
    
           CDC* pdc = GetDC();
    
           BITMAP b;
           bmp.GetBitmap( &b );
    
        
    pActiveDC = &memdc; //not needed but allows for selection from multiple memdcs available
           
    
           pdc->BitBlit( x, y, b.bmWidth, b.bmHeight, pActiveDC, 0, 0, SRCCOPY);
    
    //where x, y are the coordinates on the dialog where the bitmap will be positioned
    
    }
    if you are not using the MFC you will need to use

    HDC
    BITMAP
    and the GetDC(....)
    CreateCompatibleDC(...)
    LoadBitmap(....)

    api calls

    the concept is the same though...

    to load from a file you will need the MAKEINTRESOURCE macro....
    zMan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying strings in a dialog window
    By Frandy in forum Windows Programming
    Replies: 11
    Last Post: 09-27-2004, 08:46 AM
  2. Dialog box not displaying
    By Dohojar in forum Windows Programming
    Replies: 8
    Last Post: 05-03-2003, 01:08 AM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. Displaying bitmaps on a dialog
    By minesweeper in forum Windows Programming
    Replies: 2
    Last Post: 05-15-2002, 03:11 PM
  5. Displaying a picture on a dialog
    By CodeMonkey in forum Windows Programming
    Replies: 2
    Last Post: 02-14-2002, 11:14 AM