Click here to Skip to main content
Licence 
First Posted 15 Aug 2002
Views 38,053
Bookmarked 16 times

Implemented CHtmlView::GetWidth() method in class CHtmlViewEx

By | 2 Oct 2002 | Article
Description of CHtmlView::GetWidth() can be found In MSDN, however, it is NOT implemented in MFC a bit (afxhtml.h, viewhtml.cpp). In order to make the method useable, I simply generated a class named CHtmlViewEx derived from CHtmlView.
Falling in trouble with CHtmlView when you found the GetWidth() member function not implemented by M$?
Here's a simple way to implement the member function yourself. It takes just a few lines of code.
How to use it in your program? Simply derive your view class from CHtmlViewEx instead of CHtmlView.
(...hmmm, this is my first article, and the article wizard always says "Articles must be at least 100 words".
I really don't know what else I should say about my simple code, only a few short lines.
It's just a little patch for MFC.)

Introduction

Simply create a new class derived from CHtmlView with Class Wizard and following the 2 steps below.
1. Modify the constructor

CHtmlViewEx::CHtmlViewEx() : CHtmlView()
{
	//{{AFX_DATA_INIT(CHtmlViewEx)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}
2. Add a member function called GetWidth()
// comment
long CHtmlViewEx::GetWidth()
{
	ASSERT(m_pBrowserApp != NULL);
	long result;
	m_pBrowserApp->get_Width(&result);
	return result;
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Hoyle

Web Developer

China China

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralI haven't voted, but mate please think about it twice before you post PinmemberStephaneRodriguez22:29 16 Aug '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 3 Oct 2002
Article Copyright 2002 by Hoyle
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid