Solved

to give path in LoadBitmap function

Posted on 2003-11-19
7
407 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

757 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

22 Experts available now in Live!

Get 1:1 Help Now