Implementing the "Font" feature like the one in INTERNET EXPLORER

.

A sample code to change the fonts in your web browser using webbrowser control.

void CMyBrowser::SetFont(int nFontSize)
{	m_pDisp = NULL; 			// IDISPATCH pointer
	LPOLECOMMANDTARGET pCmdTarg = NULL;

	m_pDisp = m_WebBrowser2.GetDocument(); 	// get the idispatch pointer from webbrowser control
	ASSERT(m_pDisp); 			//check for validity
	
	m_pDisp->QueryInterface(IID_IOleCommandTarget, (LPVOID*)&pCmdTarg); //query for IID_IOleCommandTarget interface 
	ASSERT(pCmdTarg); 			// check for validity

	VARIANT vaFontSize;   			// input argumentsVariantInit(&vaFontSize);
	V_VT(&vaFontSize) = VT_I4;
	V_I4(&vaFontSize) = nFontSize;  	//size of the font you want
	VARIANT vaFontOutput;

	pCmdTarg->Exec(NULL,			// execute just change the font
		       OLECMDID_ZOOM,
		       OLECMDEXECOPT_PROMPTUSER,
		       &vaFontSize,
		       &vaFontOutput);
	
	VariantClear(&vaFontSize); 		//clear the variant variable before freeing its memory

	if (pCmdTarg)   pCmdTarg->Release(); 	// release document's command target
	if (m_pDisp)   m_pDisp->Release();    	// release document's dispatch interface
}

Updated on May 18 1998



Comments

  • How to set face name ...

    Posted by Legacy on 05/04/2002 12:00am

    Originally posted by: anhthu

    It just set text size. Do you know how to set font face name ???

    Reply
  • How to intercept the contents of Homepage before showing in the IE browser without proxy?

    Posted by Legacy on 02/20/2001 12:00am

    Originally posted by: Yung-Ming Kuo

    Dear friends:

    I want to intercept and get the contents(including text and image) of homepage from Web server ,before it shows the IE browser(version 5.0).But it is not through proxy.

    And i have ability to prevent HTML document from showing the browser.

    Could you offer some suggestion or source code sample to solve my question?

    Thank you ^_^

    email:ymkuo@neural.ee.ncku.edu.tw

    by Kuo

    Reply
  • doubt

    Posted by Legacy on 01/28/2000 12:00am

    Originally posted by: shri

    In which language is the above code put up in??
    shri.

    Reply
  • request

    Posted by Legacy on 07/31/1999 12:00am

    Originally posted by: manoj


    thanking you

    Manoj@mca.vec.ac.in
    Manoj+

    Reply
  • how to make it with vb5 ?

    Posted by Legacy on 06/28/1999 12:00am

    Originally posted by: Luca

    how to make it with vb5 ? :)

    Reply
  • How to do menu ticks!

    Posted by Legacy on 05/06/1999 12:00am

    Originally posted by: uniken

    Here's how I got the ticks on the menu to work (using CHtmlView from VC6):
    
    

    in resource.h:

    #define ID_BROWSE_FONT_SMALLEST 32769
    #define ID_BROWSE_FONT_SMALL 32770
    #define ID_BROWSE_FONT_MEDIUM 32771
    #define ID_BROWSE_FONT_LARGE 32772
    #define ID_BROWSE_FONT_LARGEST 32773

    in message map:

    ON_COMMAND_RANGE(ID_BROWSE_FONT_SMALLEST, ID_BROWSE_FONT_LARGEST, OnChangeFont)
    ON_UPDATE_COMMAND_UI_RANGE(ID_BROWSE_FONT_SMALLEST, ID_BROWSE_FONT_LARGEST, OnUpdateChangeFont)

    in cpp file:

    void CBrowserView::OnUpdateChangeFont( CCmdUI* pCmdUI )
    {
    VARIANT vaZoomFactor; // input arguments
    VariantInit(&vaZoomFactor);
    ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, NULL, &vaZoomFactor);
    pCmdUI->SetCheck((int)pCmdUI->m_nID - ID_BROWSE_FONT_SMALLEST == V_I4(&vaZoomFactor));
    }
    void CBrowserView::OnChangeFont( UINT nID )
    {
    int fontSize = nID - ID_BROWSE_FONT_SMALLEST;
    VARIANT vaZoomFactor; // input arguments
    VariantInit(&vaZoomFactor);
    V_VT(&vaZoomFactor) = VT_I4;
    V_I4(&vaZoomFactor) = fontSize;
    ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &vaZoomFactor, NULL);
    }


    Reply
  • Dots?

    Posted by Legacy on 03/09/1999 12:00am

    Originally posted by: Chris

    How do you get the radio buttons to show on the menu which shows the current selected size like in IE?

    Reply
  • Good

    Posted by Legacy on 09/30/1998 12:00am

    Originally posted by: Sriram

    Its a good article.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: September 16, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you starting an on-premise-to-cloud data migration project? Have you thought about how much space you might need for your online platform or how to handle data that might be related to users who no longer exist? If these questions or any other concerns have been plaguing you about your migration project, check out this eSeminar. Join our speakers Betsy Bilhorn, VP, Product Management at Scribe, Mike Virnig, PowerSucess Manager and Michele …

  • Live Event Date: September 17, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this upcoming eSeminar and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds