?
Solved

to give path in LoadBitmap function

Posted on 2003-11-19
7
Medium Priority
?
430 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

770 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