Loadin bitmap image from file not resources
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Loadin bitmap image from file not resources

Hybrid View

  1. #1
    Join Date
    Jul 2011
    Posts
    1

    Loadin bitmap image from file not resources

    Hi guys,
    I need to load a bitmap image from the file and show it in the screen in MFC. The following code load the image from a resource but I want to load it from a file.
    void CScViewView::OnDraw(CDC* pDC)
    {
    CScViewDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
    return;

    CBitmap bmpCar;
    CDC mdcCar;
    CSize szeBitmap;
    bmpCar.LoadBitmapW(IDB_BITMAP1);
    szeBitmap.cx = 1276;
    szeBitmap.cy = 1024;
    mdcCar.CreateCompatibleDC(pDC);
    CBitmap *bmpOld = mdcCar.SelectObject(&bmpCar);
    pDC->BitBlt(0, 0, 1276, 1024, &mdcCar, 0, 0, SRCCOPY);
    pDC->SelectObject(bmpOld);
    SetScrollSizes(MM_TEXT, szeBitmap);
    }

    I replaced the LoadBitmapW with this bmpCar.LoadBitmap((LPCTSTR) "mybitmap.bmp"), but it does not work.
    Thanks for you help in advance.
    Hossein

  2. #2
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,553

    Re: Loadin bitmap image from file not resources

    LoadBitmap Function
    The LoadBitmap function loads the specified bitmap resource from a module's executable file. This function has been superseded by the LoadImage function.
    And LoadImage() can load from file.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center