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

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

  • Savvy enterprises are discovering that the cloud holds the power to transform IT processes and support business objectives. IT departments can use the cloud to redefine the continuum of development and operations—a process that is becoming known as DevOps. Download the Executive Brief DevOps: Why IT Operations Managers Should Care About the Cloud—prepared by Frost & Sullivan and sponsored by IBM—to learn how IBM SmartCloud Application services provide a robust platform that streamlines …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds