Solved

to give path in LoadBitmap function

Posted on 2003-11-19
7
420 Views
Last Modified: 2008-03-04
How can i give the path in the LoadBitmap function?I have to load a bitmap directly on screen(not using picture box) through LoadBitmap function..it just taking the ResourceID but  i have to load the external bitmap on screen...How can this be possible?
borntough
0
Comment
Question by:cancermcs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9785296
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, _T("C:\\SomeDir\\Sample.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
0
 

Expert Comment

by:borntough
ID: 9793859
i have used this function,but how a bitmap is shown on the formView screen.?
born
0
 
LVL 3

Expert Comment

by:RJSoft
ID: 9808226
Get the dc (screen or window of form)

Create a compatible dc. Memdc.

Get the HBITMAP hbmp (above code LoadImage)

Select the hbmp into the Memdc.

Get the size of the bitmap (GetObject)

BitBlt from Memdc to the screen.

Clean up memory

RJ



0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:cancermcs
ID: 9848098
I had tried this one according to u..Here is what i did...
void CMyView::OnLoadBitmap(CString objvalue,POINT pt)
{
CString m_strBmpFileOb=objvalue;//containing name of    bitmap

CPaintDC dc(this);
   CDC *MemDC;

 MemDC->CreateCompatibleDC (NULL);
  HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, _T(m_strBmpFileOb), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

      MemDC->SelectObject (&hBmp);
GetObject(hBmp,sizeof(m_strBmpFileOb),NULL);
      
MemDC->BitBlt (ptB.x,ptB.y,20,20,&dc,700,600,SRCCOPY);
}
But on CreateCompatibleDC,a debug error comes out...Similarly if i // that line then error goes to next line.
what i had missed.?

cancermcs
0
 

Author Comment

by:cancermcs
ID: 9856310
Is any body there to help me in this regard?
cancermcs
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10249320
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10308151
PAQed, with points refunded (150)

modulo
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

733 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