Hi,
As per my previous post I am having trouble with loading resources from a dll. This time it is a Bitmap that I want to grab and place in a picture box
Here's the code - guidance much appreciated.
As you can see I am simply taking the name of a resource only dll, saving the dll name as a CString, calling a handle to the file then using LoadBitmap as per MSDN guidance
This code compiles and runs but doesn't show the image.
As per my previous post I am having trouble with loading resources from a dll. This time it is a Bitmap that I want to grab and place in a picture box
Here's the code - guidance much appreciated.
As you can see I am simply taking the name of a resource only dll, saving the dll name as a CString, calling a handle to the file then using LoadBitmap as per MSDN guidance
This code compiles and runs but doesn't show the image.
Code:
void CDllImageDlg::OnOpenFile()
{
CFileDialog dlg(
true, //create an open file dialog
NULL, //default file extension
NULL, //filename
NULL, //flags
_T("Wreck Data Files (.dll)| *.dll|") //filter string
_T("All files (.txt)| *.*|")
_T("|")
);
if (IDOK != dlg.DoModal()) // display open file dialog
return; // do nothing if open file dialog cancel button pressed
// take selected file and insert file name into a public CString variable for later use
m_NewDatFile = dlg.GetFileName();
//********************** call the string from the dll
// create a handle for the dll
HINSTANCE hDLL; // Handle to DLL
// create char buffer
char m_CharNewDatFile;
// create pointer for loadbitmap
char *lpImageBuffer = &m_CharNewDatFile;
// call and load the dll
hDLL = LoadLibrary(m_NewDatFile);
// create a HBITMAP variable for the chart picture control
HBITMAP h_ChartBmp;
// call Loadbitmap function and load bmp for image
h_ChartBmp = (HBITMAP) LoadBitmap(hDLL,
lpImageBuffer
);
// load the picture control with the setbitmap function and load
// the bitmap into it
m_ImageBox.SetBitmap(h_ChartBmp);
MessageBox("past image load");
}