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
Solved

to give path in LoadBitmap function

Posted on 2003-11-19
7
419 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
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Socket Programming (Unix) 8 142
Path to  STL Map header file 1 69
How can i compile this github project?? 2 90
VS2015 Redefinition errors 4 69
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

838 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