Currently viewing: GipsySoft » Front Page» QHTM

QHTM_RenderHTMLRect

BOOL WINAPI QHTM_RenderHTMLRect( HDC hdc, LPCTSTR pcsz, HINSTANCE hInst, UINT uSource, LPRECT prc );

Given a RECT draw some HTML. The HTML content can be text, a file or resources

This function is useful if you wish to render the HTML somewhere other than 0,0

Parameters

hdc
Device context use for drawing.
pcsz
Name of resource, name of file or HTML content. Meaning depends on uSource.
hInst
Instance handle to be used when loading from resources.
uSource
  • QHTM_SOURCE_TEXT - pcsz is the HTML text to use. hInst is ignored.
  • QHTM_SOURCE_RESOURCE - pcsz is the name of a resource and hInst is the instance handle to use.
  • QHTM_SOURCE_FILENAME - pcsz is the name of a file to load. hInst is ignored.
prc
Rectangle where you want the HTML rendered.

Return value

non-zero if it succeeds.

It could fail because the filename passed was incorrect or because the resources passed were incorrect

Example

//
//	We set a maximum width just to be sure...
const UINT uMaxWidth = 600;
HDC hdcWindow = ::GetDC( hwndParent );
HDC hdcDraw = ::CreateCompatibleDC( hdcWindow );

UINT uHeight = 0;
if( QHTM_GetHTMLHeight( hdcDraw, pcszHTMLFilename, NULL, QHTM_SOURCE_FILENAME, uMaxWidth, &uHeight ) )
{
	//
	//	Now we have a width and a height...
	HGDIOBJ hbmp = ::CreateCompatibleBitmap( hdcWindow, uMaxWidth, uHeight );
	if( hbmp )
	{
		//
		//	Select the bitmap and render the HTML onto it.
		hbmp = ::SelectObject( hdcDraw, hbmp );
		const RECT rc = { 0, 0, uMaxWidth, uMacHeight };
		if( QHTM_RenderHTMLRect( hdcDraw, pcszHTMLFilename, NULL, QHTM_SOURCE_FILENAME, &rc ) )
		{
			//
			//	Deselect the bitmap
			hbmp = ::SelectObject( hdcDraw, hbmp );
			SaveBitmapAsFile( hbmp, pcszBMPFilename );
		}
	}
	(void)::DeleteObject( hbmp );
}

(void)::ReleaseDC( hwndParent, hdcWindow );

(void)::DeleteDC( hdcDraw );
(void)::SetCursor( hOld );

See also QHTM_GetHTMLHeight

See also QHTM_RenderHTML