|
I am using VC++ 6.0 and have included atlmisc.h
|| ART OF LIVING ||
|
|
|
|
|
This problem is yet not solved ?
|| ART OF LIVING ||
|
|
|
|
|
Patience is a virtue; do you think we have nothing better to do than answer questions all day?
Before you include any WTL headers, try
#define _WTL_USE_CSTRING
This tells WTL to define and use it's own CString implementation, instead of relying on the MFC one. If you have VC7 or later (which you apparently don't), CString doesn't really need the rest of MFC.
Steve S
Developer for hire
|
|
|
|
|
Dear Friend
Did you noticed problem is not with only CString. It is giving problem with
d:\mrutyunjaya\xmlload\xmldom.h(82) : error C2065: 'IXMLDOMDocument' : undeclared identifier
d:\mrutyunjaya\xmlload\xmldom.h(82) : error C2955: 'CComPtr' : use of class template requires template argument list
c:\program files\microsoft visual studio\vc98\atl\include\atlbase.h(563) : see declaration of 'CComPtr'.
Thanks for CString suggestion I will try that.
We have came in world only for doing human service , that is only joy on this earth which dont have tail of sorrow.
|
|
|
|
|
Well, the file producing the errors isn't a standard one, but my guess is that you're not including an MS supplied file, like msxml.h or something, since that would define IXMLDOMDocument. In any case, this latter issue is nothing to do with WTL.
Steve S
Developer for hire
|
|
|
|
|
#include <msxml2.h> ?
--
Made From Meat By-Products
|
|
|
|
|
I have a recurive loop where each element has to get its parent and retrieve the property
CComPTR<ihtmlelement> spElem=....
.........
........
.......
IHTMLElement* spParentElem=NULL;
while (1)
{
CComBSTR bsTagName;
spElem->get_tagName(&bsTagName);
std::string thisods=ODSTag;
ODSTag=OLE2A(bsTagName);
if(thisods.size() > 0)
{
ODSTag+= ".";
ODSTag+=thisods.c_str();
}
hr = spElem->get_parentElement(&spParentElem);===>memory leaks here
if (FAILED(hr) || !spParentElem)
break;
spElem.Detach()->Release();
spElem=NULL;
spElem = spParentElem;
}
I am getting massive memory leaks in the line above.What am i doing wrong here?Any help or advise would be appreciated.Thanks in advance.
|
|
|
|
|
Firstly if you use the "sp" prefix, which generally stands for "Smart Pointer", the variable in question should actually be a smart pointer. i.e.
CComPtr<IHTMLElement> spParentElem;
Don't write misleading code.
Make your code like this:
CComPtr<IHTMLElement> spParentElem;
while (1)
{
CComBSTR bsTagName;
spElem->get_tagName(&bsTagName);
std::string thisods=ODSTag;
ODSTag=OLE2A(bsTagName);
if(thisods.size() > 0)
{
ODSTag+= ".";
ODSTag+=thisods.c_str();
}
spParentElem.Release();
hr = spElem->get_parentElement(&spParentElem);===>memory leaks here
if (FAILED(hr) || !spParentElem)
{
break;
}
spElem.Detach()->Release();
spElem=NULL;
spElem = spParentElem;
}
The addition is shown in bold.
I'm going to finish with a bitch. We can't see any "<"s or ">"s or what's between them: this is important in C++ code. Also there is no formatting. Please make an effort to make things easier for the people who are taking time to help you. At the very least you could tick the "Ignore HTML tags in this message (good for code snippets)" check box.
Steve
PS: I can see iteration here but no recursion.
|
|
|
|
|
Very well written answer indeed i like your style
You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!"
Only kings, presidents, editors, and people with tapeworms have the right to use the editorial "we."
|
|
|
|
|
|
I have an SDI application. This SDI application has a Splitter control, which has Pane controls and the pane controls themselves have other child controls. So, there is a hierarchy of controls. Now, If I have the handle of any child control, I want to get the Handle of the SDI application window. Is there any way to achieve this?
GetParent() may work, but I would certainly not know how many GetParent()s I am supposed to call. For Example, if I have the HWND of the PaneControl, I would have to call GetParent() twice. One for the Splitter control and the other for the application Window. Similarly, if I have the handle of the Splitter control, I would have to call GetParent() only once. This is the why I think GetParent() is not such a good idea. Any other options?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
I think AfxGetMainWnd will do.
--
======
Arman
|
|
|
|
|
Is there an AfxGetMainWnd in ATL/WTL?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
Is there an AfxGetMainWnd in ATL/WTL?
Ah sorry, not sure. I though of MFC forum, sorry again.
--
======
Arman
|
|
|
|
|
Imagine.. in the ATL implementation, we have a collection or an array, ie :
<br />
int num[5];<br />
num[0]=100;..... [5]=500;<br />
Now in my client, (i.e VB) , I need to access them like,
(Imagine collection is the property which points to the array I've mentioned above}
<br />
msgbox (MyComp.Collection[0])<br />
(and like this too..)<br />
MyComp.Collection(0).length --> this should pop "3"<br />
It should popup 100.
-- modified at 11:24 Monday 10th July, 2006
|
|
|
|
|
Try using a SafeArray on the ATL side.
|
|
|
|
|
Hi, you have variuos options in this case, you can try and use some kind of collection enumeration based on the variant safearrays to try to please com clients like VB, or you can use the raw and simply way of having a property that inputs an index and returns the value in the array.
Something like:
idl:
HRESULT get_CollectionItemName([in]long Index,[out,retval]BSTR* pVal);
ClassName.cpp
STDMETHODIMP ClassName::get_CollectionItemName(long Index,BSTR* pVal)
{
lookup vector or container using index
copy item or item member on return value *pVal
return S_OK;
}
This method is fairly simple of implement, you don't need to get very involved in com specific code, and you can use simple datatypes and the kind of array of your choice.
|
|
|
|
|
I was very well able to create toolbar and buttons on it .
but how to use TBSTYLE_DROPDOWN and create the DropDown Button.
SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, (2 * sizeof(TBBUTTON)), 0);
SendMessage(m_hWnd, TB_SETMAXTEXTROWS, 1, 0L);// Decides size of button (length)
HICON mh1 = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON1));
HICON mh2 = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_ICON2));
m_hImageList = ImageList_Create(16,16, ILC_COLOR16, 1, 0);
int iI1 = ImageList_AddIcon(m_hImageList, mh1); //NO USE OF iI1
int iI2 = ImageList_AddIcon(m_hImageList, mh2);
// Set the toolbar's image
::SendMessage(m_hWnd, TB_SETIMAGELIST,0, (LPARAM)m_hImageList);
TBBUTTON Button1;
ZeroMemory((void*)&Button1, sizeof(TBBUTTON));
Button1.idCommand = IDM_GETQUOTE1;
Button1.fsState = TBSTATE_ENABLED;
Button1.dwData = 0;
Button1.iBitmap = MAKELONG(0, 0);
::SendMessage(m_hWnd, TB_INSERTBUTTON,0, (LPARAM)&Button1);
TBBUTTON Button2;
ZeroMemory((void*)&Button2, sizeof(TBBUTTON));
Button2.idCommand = IDM_GETQUOTE2;
Button2.fsState = TBSTATE_ENABLED;
Button2.dwData = 0;
Button2.iBitmap = MAKELONG(1, 0);
::SendMessage(m_hWnd, TB_INSERTBUTTON, 0, (LPARAM)&Button2);
We can write Buttonxyz.fsStyle |= TBSTYLE_DROPDOWN;
but how to add extra buttons.
|| ART OF LIVING ||
|
|
|
|
|
I want to know, What Design Pattern does ATL/COM is based upon, I dont want what ATL/COM support, What I need is ON WHAT DESIGN ATL/COM is build upon???
regards
Balkrishna Talele
|
|
|
|
|
If you using VC++ then you hardly worry about com interiors
ATL will internally take care and you will feel like using additional MFC.
But If you are a VC++ programmer do not even dare to develop com component
using c++ without training. It is very much far from normal programming flow
of inheritance using languages.
ATL hides all details of COM inside and you feel like using additional MFC
though it is not.
|| ART OF LIVING ||
|
|
|
|
|
Balkrishna Talele wrote: What Design Pattern does ATL/COM is based upon,
ATL/Com is nothing just the Runtime Polymorphism! all the concept based on that only!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I am getting a memory leak in the following lines.whats wrong?
bool CreatorObject::doesSinkSupportElement(IHTMLElement* pelem)
{
//If type is m_iidtype the nwe support element.
USES_CONVERSION;
CComBSTR bsttag;
CComVariant vartype(VT_NULL);
std::string sttype="";
std::string sttag="";
HRESULT hr;
hr=pelem->get_tagName(&bsttag);
if(FAILED(hr))
return false;
sttag=OLE2A(bsttag);
CComBSTR type(_T("type"));
hr=pelem->getAttribute(type,FALSE,&vartype);//GET TEH TYPE ATTRIBUTE OF THE ELEMENT
if(FAILED(hr))
return false;
hr=vartype.ChangeType(VT_BSTR );
if((SUCCEEDED(hr)) && (vartype.vt==VT_BSTR))
{
CComBSTR bsttype(vartype.bstrVal);
vartype.Clear();
sttype=OLE2A(bsttype);
}
....
....
}
I am gettign the memory leak in the ChangeType line.How is that to be avoided?
|
|
|
|
|
I have a executable which creates a thread to perform a particular routine.
HANDLE hThread = CreateThread(NULL, 0, ThreadAdvise, pStream, 0, &dwThreadID);
WaitForSingleObject(hThread,1000);
CloseHandle(hThread);
The thread is created with a specified timeout duration.
If the routine takes more than that duration,then the thread exits irrespective of the state of the routine.
Now,in the case of such a forced abort,how do i ensure that all memory allocated for the routine is cleaned up prior to exit?
Is there a hook/API which can be used to do clean-ups for forced thread abortions?
|
|
|
|
|
What you are doing is just closing the thread's handle without notifying the thread about its exitance. Generally, a thread is considered to exit in a normal manner if it returns from its subroutine. In other words, the client side should somehow notify the thread to return (you may use events).
--
======
Arman
|
|
|
|
|
I'm in the process of developing a demonstration application that will allow password auto-fill for both forms and HTTP-AUTH... however I cannot find any reference on how to handle the HTTP-AUTH requests.
I'm developing a BHO so that I can hook into IE's system and perform lookups on username/password... potentially asking to save new passwords.
Since I cannot seem to find a way to intercept the password manager/autocomplete so that HTTP-AUTH and forms would work.. I am trying to shoehorn form parsing and the as-yet-unknown method of intercepting HTTP-AUTH box to do what I need.
I'll also be developing a similar thing for Firefox, and having both methods present a similar interface to a scripting language so I can do the 'dirty work' with easy-updates/fixing... (However the browser interface seems to be the real dirty work...).
|
|
|
|