|
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...).
|
|
|
|
|
Hi,
The application i'm writing at the moment is multi-lingual so we're working with std::strings.
I'm generating an html on-the-fly in my application. I do it by using
place holders so i need an efficient "replace" function but i coulnd't find an efficient replace methond for std::strings.
Does anybody have an idea?
thanks in advance.
Snir
Singleton Technologies Ltd.
|
|
|
|
|
String class does have a replace method.
|
|
|
|
|
Igor Vigdorchik wrote: String class does have a replace method.
std::string even has 9 replace functions!
|
|
|
|
|
Define efficient - i.e. why std::string::replace isn't suitable.
You may be better off generating a new string using original string and placeholder replacements, i.e. scan through the original string, copying it to the new one, and when you see a placeholder, copy the replacement text to the new string rather than the placeholder (which you (obviously) step over).
|
|
|
|
|
snir_ya wrote: The application i'm writing at the moment is multi-lingual so we're working with std::strings.I'm generating an html on-the-fly in my application. I do it by using place holders so i need an efficient "replace" function but i coulnd't find an efficient replace methond for std::strings.
You need to write a function that copies your string contents to a new string object thereby replacing all 'place holders' in one pass with the actual strings. Try find_first_of to find a place holder.
|
|
|
|
|
I am right now having third party application to modify and they are very well
integrating WTL in VC++ by mere adding " using namespace WTL;"
I am for practice developing applications on same background.
But As soon as VC sees word WTL it gives error.
I added all WTL header files direcly in my project,at times I kept them just
in the folder tried different combinations.
VC/Common also I have WTL ,but It doesnot want to recognise word WTL
Does any one have any solution.
Third party application is keeping direct downloaded WTL folder inside project
including samples!!!
So one thing is sure they have not customised any thing inside WTL
Let me know what need to be done.
|| ART OF LIVING ||
|
|
|
|
|
There is no need to add the WTL headers to the project as they are just a bunch of template classes. Just add the WTL include directory to your VC++ include directories list. You might also want to install the AppWizard that is in the AppWiz directory.
atlapp.h automatically adds using namespace WTL; unless you #define _WTL_NO_AUTOMATIC_NAMESPACE so writing using namespace WTL; isn't even neccessary if it atlapp.h was included in stdafx.h.
|
|
|
|
|
I seen artical in
www.codeproject.com/atl/rbdeskband.asp page.
I seen it requires that i have to download a zip file and extract it in to particular path. But i m working with
VC-2005 . In it i have not found that path...
How can i do that.
|
|
|
|
|
In thatt problem is different
Somewhere in code. I dont remember right now but that code works fine.
Only some / is extra or less somewhere
|| ART OF LIVING ||
|
|
|
|
|
I am experiencing problems with getting Front Page 98’s hover buttons to function. How do I solve this?
Applet codes of your web page is as follow:
<applet code="fphover.class" codebase="./" width="120" height="24">
<param name="color" value="#000080">
<param name="hovercolor" value="#0000FF">
<param name="textcolor" value="#FFFFFF">
<param name="text" value="C Programming">
<param name="effect" value="glow">
<param name="url" valuetype="ref" value="http://metalab.uniten.edu.my/~azhana/indexCProg.html">
</applet>
prem 86
-- modified at 1:30 Thursday 6th July, 2006
|
|
|
|
|
can template specialisation replace callback?
i wish to replace callback by template specialisation.
is anyone come to this b4 and knowing that is multi-thread safe?
my application goes like this, many instance from our working code
is registering function pointer(for callback) to the library.
so that the library will notify us whenever it completed its job.
from,
-= aLbert =-
|
|
|
|
|
Hi all,
I'm developing ATL dll which will be used in C#. But I have done many things so far now I have to use either file operation (say fprintf) or string operations ("sprintf").
I have tried to do it as in the usuall fashion(like in normal exe) but when I'm calling the methods containing "fprintf or sprintf" in C# project it'll start throwing following error.
........................................
Debug Assertion Failed!
"location\system32\inetsrv\w3wp.exe"
File:sprintf.c
Line:55
Expression: (str != NU.LL)
............................................
when I hit retry i'll get the following messege
The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
...................................................
As per me its not the right way to use fprintf/sprintf in ATL dlls I guess.
You can test it by creating simple ATL dll project and placing file operation including fprintf/sprintf, and calling the method in C#.
plzzzzz guide me to come over it.
Thanks,
Arun
|
|
|
|
|
I'd say you're passing garbage to the functions, because there is no difference in calling them from an .exe or a .dll.
--
Coming Soon to an Illegal DVD
|
|
|
|
|
I don't think so because I experimented with the fresh ATL project, by adding only 3 lines of extra code of file operation consists of "fopen, fprintf and fclose". Here also I have found that "fprintf" is posing same problem.
Please you can easily check it by creating simple ATL dll with a method consists of these file operation lines. And we should use that method in C#. It 'll definately throw the same error.
Regards,
Arun
|
|
|
|
|
I am a beginner. I have read some tutorials and newbie books on C++ but am having trouble doing things beyond the basics.
I am trying to display the HWND when i use certain Win32 functions such as GetForegroundWindow() for debugging purposes. When i use Win32 MessageBox or OutputDebugString such as below...
1)
m_foreHwnd1 = GetForegroundWindow();
MessageBox(NULL, (LPCSTR)m_foreHwnd1, "INFO", MB_OK);
2)
OutputDebugString("ForeHwnd1: ");
OutputDebugString((LPCSTR)m_foreHwnd1);
OutputDebugString("\n");
... I get errors like the following:
First-chance exception at 0x77e26673 in SendFocusWin.exe: 0xC0000005: Access violation reading location 0x00090548.
Unhandled exception at 0x77e26673 in SendFocusWin.exe: 0xC0000005: Access violation reading location 0x00090548.
I am not getting anywhere and am starting to get fustrated. What are the code steps i need to take to get the HWND value safely AND put it into a string variable that i can use elswhere in my code? What would be the ANSI solution?
|
|
|
|
|
why not you try CString instead?
<br />
CString csHWND;<br />
csHWND.Format("%l",m_foreHwnd1);<br />
AfxMessageBox(csHWND);<br />
If you dont use MFC, then
<br />
ltoa(m_foreHwnd1,szText,10);<br />
MessageBox(..szText..);<br />
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
I am restricting my learning to ANSI for now. I canot believe how hard it is to convert a number into a string in C++. ltoa will only convert a long into a string, not HWND. I have searched on the internet and did not find a single code snippet to convert HWND into a string. Certainly programmers print out HWNDs in order to debug their code!? How does one convert HWND into string un ANSI C++?
|
|
|
|
|
You're not supposed to be able to convert a HWND to a string.
Of course, if you treat it as a pointer, you'll get away with it.
CString str; str.Format(_T("%p"), hWnd);
But why you'd want that string, is beyond me. Maybe you want the window's caption/title instead? ::GetWindowText()...
--
Not Y3K Compliant
|
|
|
|
|
I found the answer. You folks have really played the tempting devil with your MFC code, but i am going to restrict my learning to ANSI C++/STL. I plan to develop on Linux/Mac too.
The following code works.
char buffer [100];
sprintf(buffer, "%I64d \n", (unsigned __int64) hwnd);
OutputDebugString(buffer);
The reason i want the HWND in a string is so i can dump debug info to troubleshoot a problem.
It seems that the hardest part of C++ is finding the information! By luck i found the answer on the internet. I had no clue that sprintf was to be used for this. I come from VB6/C# background and so these non-orthodox language commands throw me off. Once i learn the C++ quirks things will become straight forward.
|
|
|
|