Solved

How to insert bmp or jpeg as bakground in SDI which has the ability of stretching

Posted on 2003-12-06
7
198 Views
Last Modified: 2013-11-20
Can somebody upload an example source code with the ability of above using visual C++?
can explain how to do so? Hope u can help me as i need it urgently. thank u

huey
 
0
Comment
Question by:hueychian83
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 38 total points
Comment Utility
0
 

Expert Comment

by:andyinlondon
Comment Utility
I hope this will work for you.

1. In your doc.h file:
   #include "atlimage.h"
   CImage m_bmp;
2. In your doc constructor:
    m_bmp.Load("C:\\My Pictures\\Somewhere\\Nice Picture.JPG");
3. In your view.cpp:

void CMyView::OnDraw(CDC* pDC)
{ // get a pointer to the document
  CMyDoc* pDoc = GetDocument();
  ASSERT_VALID(pDoc);

  CRect rClientRect;
  GetClientRect(&rClientRect);
  CRect rBmpRect(0, 0, pDoc->m_bmp.GetWidth() - 1, pDoc->m_bmp.GetHeight() - 1);

  pDoc->m_bmp.StretchBlt(*pDC, rClientRect, rBmpRect, SRCCOPY);
}
0
 

Expert Comment

by:andyinlondon
Comment Utility
Further to my earlier solution, add the following line to your OnDraw method, before the call to StretchBlt to get the colours looking nice.
    pDC->SetStretchBltMode(HALFTONE);
0
 

Assisted Solution

by:MAYURNATH
MAYURNATH earned 37 total points
Comment Utility

Override WM_ERASEBKGROUND message
CView::OnEraseBKGround(CDC* pDC )
{
GetClientRect()
              // here draw the bitmap or jpeg strecthing it to the rect. This is standard what i suppose
Loading Bitmap
select to memory dc
strecth blt to the original pDC dc,
release memory dc
return true;
}


// i think code was also given in above

thanx
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Doc'in system (example?) BA 7 78
FizzBuzz challenge 9 71
Unix Command -- Challenging  question 7 79
Not needed 13 53
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now