Click here to Skip to main content
15,915,328 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralODBC and CListCtrl Pin
Anonymous20-Mar-03 10:14
Anonymous20-Mar-03 10:14 
QuestionCreate Report in Access? Pin
Aaron Schaefer20-Mar-03 9:59
Aaron Schaefer20-Mar-03 9:59 
GeneralEndDialog() for modal Pin
ns20-Mar-03 9:09
ns20-Mar-03 9:09 
GeneralRe: EndDialog() for modal Pin
Alvaro Mendez20-Mar-03 9:31
Alvaro Mendez20-Mar-03 9:31 
GeneralRe: EndDialog() for modal Pin
ns20-Mar-03 9:34
ns20-Mar-03 9:34 
GeneralRe: EndDialog() for modal Pin
Neville Franks20-Mar-03 9:37
Neville Franks20-Mar-03 9:37 
Generalsorry for the confusion Pin
ns20-Mar-03 9:42
ns20-Mar-03 9:42 
QuestionHow to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 7:43
professionalJoan M20-Mar-03 7:43 
Hello,

INTRODUCTION
I'm using HTMLView in order to show the user a better and intuitive GUI.

I'm modifying the contents of the HTML page dinamically, and in order to avoid to write to disk each time that I want to make a modification, I modify the contents directly from memory.

I don't know how to create a new HTML document, so I must make the first navigation in a standard way before to modify the contents. (I've not been able to do it Blush | :O ). In order to create the document I use one of those methods:
<code>1.</code> this->Navigate2(_T("about:blank"), navNoHistory);
<code>2.</code> this->LoadFromResource(_T("IDR_HTML1"));
The code that I use in order to modify the HTML content dynamically (after the creation via the previous 1 or 2 method) is the next one:
<code>3.</code>
lpDispatch = this->GetHtmlDocument();

	if (lpDispatch)
	{
		hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDoc2);
		lpDispatch->Release();

		if (!SUCCEEDED(hr))
		{
			bRetorn = false;
		}
		else
		{
			pSafeArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
			
			if (pSafeArray)
			{ 
				hr = ::SafeArrayAccessData(pSafeArray,(LPVOID*) &pElement);
			
				if (!SUCCEEDED(hr))
				{
					bRetorn = false;
				}
				else
				{
					pElement->vt				= VT_BSTR;
					pElement->bstrVal		= csHTML.AllocSysString();

					hr = SafeArrayUnaccessData(pSafeArray);

					if (!SUCCEEDED(hr))
					{
						bRetorn = false;
					}
					else
					{
						pHTMLDoc2->clear();
						pHTMLDoc2->close();

						hr = pHTMLDoc2->write(pSafeArray);
						
						if (!SUCCEEDED(hr))
						{
							bRetorn = false;
						}
					}

					SysFreeString(pElement->bstrVal);
				}

				if (pSafeArray) SafeArrayDestroy(pSafeArray);
			}

			if (pHTMLDoc2) pHTMLDoc2->close();
		}
	}
QUESTION
I have used the perfmon Win2k utility [(Control Panel >> Administrative tools >> ...) or (executing directly "perfmon")] in order to find out if my code has memory leaks or handle leaks.

Calling the previous portions of code (1., 2., and 3.) leak some handles.

I would like to know why this is happening and how to avoid this.

NOTES
NOTE 1:
In order to see this I've used perfmon and I've added a new graph:
1. I've selected type "process".
2. I've selected "my process".
3. I've selected "Handles amount".

NOTE 2:
If I comment the code (1., 2. and 3.), there are no handle leaks (the handle leaks disappear).

As always thank you in advance.
AnswerRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 8:19
Stephane Rodriguez.20-Mar-03 8:19 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 8:44
professionalJoan M20-Mar-03 8:44 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 9:19
Stephane Rodriguez.20-Mar-03 9:19 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 20:35
professionalJoan M20-Mar-03 20:35 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 21:17
Stephane Rodriguez.20-Mar-03 21:17 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 22:09
professionalJoan M20-Mar-03 22:09 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 22:31
Stephane Rodriguez.20-Mar-03 22:31 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 22:53
professionalJoan M20-Mar-03 22:53 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 22:59
professionalJoan M20-Mar-03 22:59 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M21-Mar-03 4:05
professionalJoan M21-Mar-03 4:05 
AnswerRe: How to avoid this? (HTMLView and Handle leaks) Pin
Neville Franks20-Mar-03 9:34
Neville Franks20-Mar-03 9:34 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 19:45
professionalJoan M20-Mar-03 19:45 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Neville Franks21-Mar-03 0:29
Neville Franks21-Mar-03 0:29 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M21-Mar-03 1:15
professionalJoan M21-Mar-03 1:15 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M21-Mar-03 3:56
professionalJoan M21-Mar-03 3:56 
GeneralWenn printing the fill function doesn't work Pin
willempipi20-Mar-03 7:40
willempipi20-Mar-03 7:40 
GeneralRe: Wenn printing the fill function doesn't work Pin
Chris Losinger20-Mar-03 8:03
professionalChris Losinger20-Mar-03 8:03 

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

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