Currently viewing: GipsySoft » Front Page» QHTM

QHTM_GetHTMLHeight

BOOL WINAPI QHTM_GetHTMLHeight( HDC hdc, LPCTSTR pcsz, HINSTANCE hInst, UINT uSource, UINT uWidth, UINT *lpuHeight );

Given a width determine the height of some HTML. The HTML content can be text, a file or resources

Parameters

hdc
Device context use for measuring.
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.
  • uWidth
    Constraining width.
    lpuHeight
    pointer to a UINT that will recieve the measured height of the HTML.

    Return value

    non-zero if it succeeds.

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

    Example

    This code has been taken from the example program, source file SaveAsBitmap.cpp.
    //
    //	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 );
    		if( QHTM_RenderHTML( hdcDraw, pcszHTMLFilename, NULL, QHTM_SOURCE_FILENAME, uMaxWidth ) )
    		{
    			//
    			//	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_RenderHTML