Solved

to give path in LoadBitmap function

Posted on 2003-11-19
7
413 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting to C# also VS2015 5 117
Compile GLUT with Visual Studio 2015 1 108
Unable to start eclipse ? 17 132
Eclipse IDE - Cannot copy/paste from console output 8 127
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

920 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

17 Experts available now in Live!

Get 1:1 Help Now