|
Yu Zhiquan wrote: for (MyIterator = MyMap.begin(); MyIterator!=MyMap.end(); MyIterator++)
{
MyMap.erase(MyIterator);
}
the moment u call MyMap.erase(MyIterator), the size is reduced and begin() has changed. so in your for loop, MyIterator++ is directing u to the "3rd" element.
u should use while loop to delete by check the size, not begin till end.
from,
-= aLbert =-
|
|
|
|
|
I developed an activeX and I managed to add it to a richeditctrl but the problem is that the activeX doesn't handel its messages that I alread add a handel for them so my question first any suggested solutions and is this a general problem arises with activeX or not
thanks in advance
|
|
|
|
|
Using both together, I cant overcome some problems with locales.
I am getting a C2668 in \vc98\include\xlocnum : 'sprintf' ambiguous call to overloaded function
When I dont include the regex, all compiles just fine. I just dont get it. HEEEEEEEEEEEEEEEEELP. please.
Finally moved to Brazil
|
|
|
|
|
I use VC6 and check "Add common controls manifest" in the WTL wizard.
But then I compile my apps they have classic windows style.
Manifest doesn't work!
Then I recompile samples from this site it doesn't work. Why? Bug in the wizard? In VC? I
don't understand. Please help me!
|
|
|
|
|
What OS are you running?
Steve S
|
|
|
|
|
|
this was happening to me long time ago when I had an old SDK that didn't define RT_MANIFEST in any header file. So that's your primal suspect; try getting the latest platform SDK
|
|
|
|
|
Hi All,
I am writing an ATL/COM extension for a mapping application. All is fine except I am struggling to get field validation on Edit boxes to work.
I open up a Modal ATL dialog and the user does there thing, but when it comes to the OnOk button event my code bombs when I try to get the text from the edit boxes
<br />
BSTR field1;<br />
BSTR field2;<br />
<br />
this->GetDlgItemText(IDC_WIZEDIT1, field1); <br />
<br />
this->GetDlgItemText(IDC_WIZEDIT2, field2);<br />
EndDialog(wID);<br />
<br />
The error when I try the above is:
Application Error-
The instruction at "0x0f074b68" referenced memory at "0x0f074b68". The memory could not be "read"
Which is not a very helpful message.
In short, is there a an easy way to validate resources on an ATL dialog?
thanks for your time in advance
cheers
Bryce
|
|
|
|
|
At the risk of stating the obvious, have you tried setting the BSTR variables to NULL first?
It's eminently possible that it contains a garbage value. This causes the code to attempt to SysFreeString it first, and it's likely that is tripping the error. The eip looks about right for being somewhere in the system, rather than in "your" code.
Steve S
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|