oops, well heres the thing..i need to display a .jpg in fullscreen
but the image will be the entire screens size. I have finished the
screenshot function. Now i need to just display it and thats it.
I did some research and found this but i do get a few errors. Maybe
someone can debug it? or perhaps theres an easier way to do this. I
have commented exactly where the errors are.
C:\Documents and Settings\Administrator\Desktop\Copy of Lower EICAS
(240709)\LowerEicasDlg.cpp(27050) : error C2660: 'GetDC' : function
does not take 1 parameters
C:\Documents and Settings\Administrator\Desktop\Copy of Lower EICAS
(240709)\LowerEicasDlg.cpp(27057) : error C2065: 'HIMETRIC_INCH' :
undeclared identifier
C:\Documents and Settings\Administrator\Desktop\Copy of Lower EICAS
(240709)\LowerEicasDlg.cpp(27060) : error C2660: 'GetClientRect' :
function does not take 2 parameters
C:\Documents and Settings\Administrator\Desktop\Copy of Lower EICAS
(240709)\LowerEicasDlg.cpp(27064) : error C2660: 'ReleaseDC' :
function does not take 2 parameters
void CLowerEicasDlg::LoadPictureFile(LPCTSTR szFile, HWND hWnd)
{
LPPICTURE gpPicture = 0;
// open file
HANDLE hFile = CreateFile(szFile, GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, NULL);
_ASSERTE(INVALID_HANDLE_VALUE != hFile);
// get file size
DWORD dwFileSize = GetFileSize(hFile, NULL);
_ASSERTE(-1 != dwFileSize);
LPVOID pvData = NULL;
// alloc memory based on file size
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
_ASSERTE(NULL != hGlobal);
pvData = GlobalLock(hGlobal);
_ASSERTE(NULL != pvData);
DWORD dwBytesRead = 0;
// read file and store in global memory
BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead,
NULL);
_ASSERTE(FALSE != bRead);
GlobalUnlock(hGlobal);
CloseHandle(hFile);
LPSTREAM pstm = NULL;
// create IStream* from global memory
HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
_ASSERTE(SUCCEEDED(hr) && pstm);
// Create IPicture from image file
if (gpPicture)
gpPicture->Release();
hr = ::OleLoadPicture(pstm, dwFileSize, FALSE, IID_IPicture, (LPVOID
*)&gpPicture);
_ASSERTE(SUCCEEDED(hr) && gpPicture);
pstm->Release();
/** Painting part added to make it into one function **/
// Retrieve dc
HDC hdc = GetDC( hWnd ); //error1
long hmWidth = 0;
long hmHeight = 0;
gpPicture->get_Width(&hmWidth);
gpPicture->get_Height(&hmHeight);
// convert himetric to pixels
int nWidth = MulDiv(hmWidth, GetDeviceCaps(hdc, LOGPIXELSX),
HIMETRIC_INCH); //error2
int nHeight = MulDiv(hmHeight, GetDeviceCaps(hdc, LOGPIXELSY),
HIMETRIC_INCH);
RECT rc;
GetClientRect(hWnd, &rc); //error3
// display picture using IPicture::Render
gpPicture->Render(hdc, 0, 0, nWidth, nHeight, 0, hmHeight, hmWidth, -
hmHeight, &rc);
ReleaseDC( hWnd, hdc ); //error4
gpPicture->Release();
/** End Painting Part **/
}