Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Klasse CBitmap.

Empfohlene Antworten

Veröffentlicht

Servus,

wie kann ich eine Bilddatei in ein CBitmap Objekt laden?

CBitmap Bild1;

Bild1.LoadBitmap ("bild1.bmp");

... wollte dann das Bild in eine CImageList zuweisen und es funktionierte nicht.

"LoadBitmap( LPCTSTR lpszResourceName );" --> Wie muss der Bildpfad bei der Methode LoadBitmap angegeben werden?

Hoffe auf schnelle Antworten!

Danke schonmal,

Phil:confused:

Hallo!

Eine Möglichkeit wäre vielleicht so:

BOOL Klassenname::Load(LPCTSTR szFileName)

{

	_ASSERTE(szFileName);


	CFile file;

	HGLOBAL hGlobal;

	DWORD dwSize;


	if (!file.Open(szFileName,

				CFile::modeRead | 

				CFile::shareDenyWrite) )

	{

		TRACE(_T("Load (file): Error opening file %s\n"),szFileName);

		return FALSE;

	}


	dwSize = file.GetLength();

	hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD,dwSize);

	if (!hGlobal)

	{

		TRACE(_T("Load (file): Error allocating memory\n"));

		return FALSE;

	}


	char *pData = reinterpret_cast<char*>(GlobalLock(hGlobal));

	if (!pData)

	{

		TRACE(_T("Load (file): Error locking memory\n"));

		GlobalFree(hGlobal);

		return FALSE;

	}


	TRY

	{

		file.Read(pData,dwSize);

	}

	CATCH(CFileException, e);                                          

	{

		TRACE(_T("Load (file): An exception occured while reading the file %s\n"),

			szFileName);

		GlobalFree(hGlobal);

		e->Delete();

		file.Close();

		return FALSE;

	}

	END_CATCH

	GlobalUnlock(hGlobal);

	file.Close();


	BOOL bRetValue = Load(hGlobal,dwSize);

	GlobalFree(hGlobal);

	return bRetValue;

}


BOOL Klassenname::Load(HGLOBAL hGlobal, DWORD dwSize)

{

	IStream *pStream = NULL;

	UnLoad();


	if (!(m_pRawData = reinterpret_cast<unsigned char*> (GlobalLock(hGlobal))) )

	{

		TRACE(_T("Load: Error locking memory\n"));

		return FALSE;

	}


	m_nDataSize = dwSize;

	GlobalUnlock(hGlobal);


		// don't delete memory on object's release

		if (CreateStreamOnHGlobal(hGlobal,FALSE,&pStream) != S_OK)

			return FALSE;


		if (OleLoadPicture(pStream,dwSize,FALSE,IID_IPicture,

			reinterpret_cast<LPVOID *>(&m_pPicture)) != S_OK)

		{

			pStream->Release();

			return FALSE;

		}

		pStream->Release();

}


So, ich hoffe ich hab nix vergessen!

Hoffentlich hilft es Dir!

Die moral von der Geschichte ist, dass Du einen Stream vom Datenträger in den Speicher bauen musst.

Ist das erledigt, musst Du das Abbild im Speicher auf einen DC bringen, dies könnte mittels Render() geschehen!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.