|
Hi Steve,
Thanks for your help! You hit the nail on the head with your reply... exactly the problem.
Will remember that one from now on.
Another quick question if you can be bothered answering:
Is it the programmers responsability to do the SysFreeString if they have called SysAllocString, or will be taken care of by the compiler? (Am relatively new to the ATL/COM system, and have had the luxury of the automatic garbage collection in java)
Is there a general rule for COM objects for when they should be ->Release() or ->Detach(). It seems that if I call CoCreateInstance, then I need to call ->Release() otherwise if I have a smartpointer where I define it in a local scope, then I can only call ->Detach() or it is destroyed when scope is lost.
Thanks once again
cheers
Bryce
|
|
|
|
|
Depends. If you're writing a COM client (ie you're using objects and passing BSTR values in), the general rule is that if you allocate, you must free. There's a _bstr_t (and a CComBSTR) type that is like a smart-pointer for BSTRs but it's not perfect.
If you have a smart-pointer to an interface, then it will call Release on destruct.
Non-smart pointers don't, so you should. You wouldn't call Detach unless you needed a raw interface for some reason.
Steve S
|
|
|
|
|
I have CheckBox in TreeControl (from WTL). Please let me know how can i receive Event notification from checkbox when it is selected/unselected. I tried LButtonDOwm and OnClick but it does not work.
For LButtonDOwn i used
NOTIFY_HANDLER(IID_TC, WM_LBUTTONDOWN, OnLButtonDown) but control does not come to this.
For click i am unable to detect on which item was clicked.
NOTIFY_HANDLER(IID_TC, NM_CLICK, OnClick)
Thanks
Shiv
|
|
|
|
|
Place the following code into OnClick:
#define MSG_CHECKSTATECHANGE (WM_USER + 1001)
DWORD dwpos = GetMessagePos();
TVHITTESTINFO ht;
ht.pt.x = GET_X_LPARAM(dwpos);
ht.pt.y = GET_Y_LPARAM(dwpos);
::MapWindowPoints(HWND_DESKTOP, pnmh->hwndFrom, &ht.pt, 1);
::TreeView_HitTest(lpnm->hwndFrom, &ht);
// If click on checkbox then post user defined message
if(TVHT_ONITEMSTATEICON & ht.flags)
{
PostMessage(MSG_CHECKSTATECHANGE, 0, (LPARAM)ht.hItem);
}
You can also send the MSG_CHECKSTATECHANGE message from TVN_KEYDOWN notify handler when SPACE key is pressed.
|
|
|
|
|
I made an activeX control with ATL.
The control has one property.
In the .html file, the source code looks like below:
<object
classid="clsid:c3043399-79bd-4bca-ab35-7dc1a206af4a"
codebase="http: www.chinagrovetech.com="" i3d="" i3dformproj.cab#version="1,0,0,0"
width=800" height="600
">
<param name="movie" value="test.i3d" />
The control is a little like the flash player which can play .swf files.
Now I want the control to player .i3d files, and the file format is customed.
If the value of "movie" is an absolute path, everything is OK, but when it is a relative path, my control is not able to know the file's location.
Please help me !
stanley
|
|
|
|
|
If I know I'll be dealing with millions of objects, and assigning them to vectors, is there an algorithm I can use to determine what size I should initially set the vector to, in order to avoid (as much as possible) the vector from constantly growing (which it is constantly doing as more and more objects are "pushed" into it)?
For example, if the vector is going to grow from 200K to 400K, and then from 400K to 800K, and from 800K to 1.6 Million (and so forth), I'd like to set the vector to 2 million right from the very start, just to avoid the system from having to use up time constantly allocating more space, then copying from the old over to the new (etc.), and simply cut to the chase.
It's an algorithm I looking for that would let me enter the variables and have it give me a good estimate of what size I sould make the vector at the beginning.
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
The solution depends on the type of object. What object is it?
Kuphryn
|
|
|
|
|
There's not much here to work with... exactly what are the input variables?
- Mike
|
|
|
|
|
std::vector<double> v_dbl; // create an empty vector
v.reserve(100); // reserve memory for 100 elements
or
std::vector<t> v(100); // creates a vector and initializes it with 100 values
// but calls the default contructor of type T 100 times.
|
|
|
|
|
Thanks for your reply.
I just found out about the "reserve()" member function of vector about a week ago, and it seemed to be the answer nearest to the concern I presented.
I'm constantly challenged by the STL, and likewise finding solutions (within itself) to the various problems for which I'm using it in the first place.
Thanks.
William
Fortes in fide et opere!
|
|
|
|
|
I get this error when trying to incorporate some code that uses ATL's CStringT into my straight Win32 program:
<br />
IGCutter error LNK2019: unresolved external symbol "class ATL::CAtlStringMgr ATL::g_strmgr" (?g_strmgr@ATL@@3VCAtlStringMgr@1@A) referenced in function "public: static struct ATL::IAtlStringMgr * __cdecl ATL::StrTraitATL<char,class ATL::ChTraitsCRT<char> >::GetDefaultManager(void)" (?GetDefaultManager@?$StrTraitATL@DV?$ChTraitsCRT@D@ATL@@@ATL@@SAPAUIAtlStringMgr@2@XZ)<br />
My header has these files defined (many are probably unnecessary):
<br />
#include <atlbase.h><br />
#include <objbase.h><br />
extern CComModule _Module;<br />
#include <atlcom.h><br />
#include <atlapp.h><br />
#include <atlwin.h><br />
#include <atlframe.h><br />
#include <atlstr.h><br />
and I have "Static link to ATL" specified. What in the world am I doing wrong?
Thanks!
|
|
|
|
|
This is an update of the early semi-official announcement that WTL will go "open source". MS has set up licensing (legal stuff) to make this happen... read more...
Microsoft toys with open source[^]
Unlike Microsoft's previous shared-source efforts, the WTL plan would allow non-Microsoft staff to be involved in managing and developing WTL.
While reluctant to reveal details, Mr Kumar said a key concern was to provide more support for developers so they did not have to keep using the Yahoo! forum.
Mike M
WinInsider.com
|
|
|
|
|
I'm having difficulty using ATL Server's CBlobCache class. I'm trying to add an entry to the blob cache. The key is "v1" and the value is an int. The add method takes a *void for the actual data, so I figured I could push an int into it. Unfortunately, the mout int reads 6,500,000 . Is it a problem with my implementation of m_spBlobCache->Add or m_spBlobCache->GetData ?
HCACHEITEM hEntry;
// Get the IMemoryCache service from the ISAPI extension
if (FAILED(m_spServiceProvider->QueryService(__uuidof(IMemoryCache),
&m_spBlobCache)))
return HTTP_FAIL;
HRESULT hr = m_spBlobCache->LookupEntry("v1", &hEntry);
if (FAILED(hr) || !hEntry)
{
static const int s7 = 1;
int *pData = (int *)malloc(sizeof(int));
if (!pData)
return HTTP_FAIL;
*pData = s7;
CFileTime ft = CFileTime::GetCurrentTime() + CFileTime::Minute;
if(FAILED(m_spBlobCache->Add("v1", pData, (DWORD)sizeof(int), &ft,
m_hInstHandler, &hEntry, &g_MemoryCacheClient)))
{
m_spBlobCache->ReleaseEntry(hEntry);
return HTTP_FAIL;
}
}
if(FAILED(m_spBlobCache->GetData(hEntry, (void**)&mout, &dwSize)))
{
m_spBlobCache->ReleaseEntry(hEntry);
return HTTP_FAIL;
}
TIA
Ryan
|
|
|
|
|
Stupid Me...
This code is correct, I just messed up the request handling part. Well, now if anyone wants to know how to write an int to CBlobCache, they can use this snippet...
Ryan
|
|
|
|
|
HI,
I am looking for atlstr.h header file.
Can anyone point to download from?
Thanks
|
|
|
|
|
|
Hi,
In MSDN, there is a desccription of the interface ISimpleFrameSite:
Containers can also support container controls without supporting ISimpleFrameSite, although the behavior cannot be guaranteed. For this reason, a component category exists for SimpleFrameSite controls where the full functionality of this interface is required.
To support container controls without implementing ISimpleFrameSite, an ActiveX control container must:
Activate all controls at all times.
Reparent the contained controls to the hWnd of the containing control.
Remain the parent of the container control.
Now I create a composite ActiveX control, Can I implement interface ISimpleFrameSite:, and how?
Thank you!
|
|
|
|
|
When right clicking on taskbar there is a sub menu :"toolbars"
Clicking here, shows a list of existing toolbars and "add new bar..."
Selecting this option shows a dialog where it is possiple to specify an URL pointing to a web page ie: http:www.nanana.com/button.htm
All this is manual ! and works fine and easy (only one parameter)
Is there a way (using VB or VBS) to create a deskband with a HTML content pointed by an URL.
This should look like : ...deskband.create url:="http:/...."
Obviously, there is a build in applet in the explorer that do the job a lot more simpler than creating 100% from scratch using ATL.
mailto:riberollesb@fsb.fr
|
|
|
|
|
hiya
I have a coclass that implements a dual interface (for use in C#), and I want to add a low level custom interface with the same methods for use by clients written in c++. But I have a couple of problems: firstly, C# picks the wrong method and refuses to compile unless I explicitly cast to the dual interface. Secondly, how do I implement methods from different interfaces with the same signature?
here's the code...
[<br />
object,<br />
uuid("32273BE2-CB15-47c2-BE09-DAA824A44916"),<br />
helpstring("IFuzzyLogic Interface"),<br />
pointer_default(unique),<br />
hidden<br />
]<br />
__interface IFuzzyLogic : IUnknown<br />
{<br />
[id(1), helpstring("method CreateModel")] HRESULT CreateModel([in] const char* szFileName, [out,retval] IFuzzyModel** ppModel);<br />
};<br />
<br />
[<br />
object,<br />
uuid("529A2190-6BB0-47A9-B1B4-001CD5981597"),<br />
dual, <br />
helpstring("IFuzzyLogicDual Interface"),<br />
pointer_default(unique)<br />
]<br />
__interface IFuzzyLogicDual : IDispatch<br />
{<br />
[id(1), helpstring("method CreateModel")] HRESULT CreateModel([in] BSTR sFileName, [out,retval] IFuzzyModelDual** ppModel);<br />
};
cheers,
Rob
|
|
|
|
|
Hi all,
Is WTL even available on MSDN/PlatformSDK anymore or is it really dead now ? I was planning on using it for a new app I'll be developing in VS.NET 2003, but I can't even find the SDK.
Thanks
|
|
|
|
|
|
I have an ATL project where I define several ATL COM objects. I would like to be able to create instances of these objects inside my module without having to use CoCreateInstance(). Everytime I try to do so it claims the classes are abstract because they do not define QueryInterface,AddRef...
Is there a way to create these objects internally without having to call CoCreateInstance?
Here's the logic to why I want to do this. I'm using a local class to catch some COM events. The local class implements a COM interface but itself is not a COM object. If I create this class with CoCreateInstance I will only be able to get the Event Sink interface back. The only way that I know of to call methods on this object would be to create a new interface for the object for the local methods I need. I would really like to avoid this. Here is a sample bit of code to show better what I'm trying to do
<br />
CEventSink : public _IEvents<br />
{<br />
public:<br />
void Setup(IEventSource *source);<br />
}<br />
<br />
...<br />
CEventSink sink;<br />
IEventSource *source;<br />
... CoCreatInstance for source...<br />
sink.Setup(source);<br />
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
|
|
I'm getting this error in ATL 7.0 trying to capture COM events from another library. I've researched this error on the web and it says to make sure you've included several header files. I've included all of hte header files
(atlbase,atlcom) and I've defined ATL_ATTRIBUTES above them. So far I've had no success in removing the error. Any ideas?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|