|
Hi'
I'm writing an ATL component to manage RAS connections.
I've got all my Async Dial stuff operating coreectly, and I've now introduced threads to enable multiple operations to all occur.
Now when I watch the Open Handle Count, I notice it just Keeps growing. The documentation says I should CloseHandle on any threads I create, but wheree is the safest place to do so.
in the destructor?
In the End of the Thread function itself (i'm passing it a This which contains a member variable of the hThread)
Please help... I'm experiencing weird errors on the machine and I'm pretty sure it's related to this.
Thanks so much.
Paul Farry
|
|
|
|
|
If you dont need the handle then close it immidiatly after CreateThread()
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
|
Can anyone explain why i have to use a namespace specifier in the code below?
#include <set>
using std::set;
class myclass
{
...
set<CString,strcmpfn> myset;
...
myfunc()
{
...
set<CString, strcmpfn>::iterator it = myset.find(szPath);
...
}
};
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
|
Hi,
I tried to make a std::map of classes like this:
<br />
class A<br />
{ ... };<br />
<br />
typedef map<long, A> AMAP;<br />
As soon as I began experimenting I realized that things were not as simple as I hoped. For example, this code:
<br />
AMAP amap;<br />
amap[10];<br />
Will generate 1 call to A's default constructor and two calls to A's copy constructor. Before I continue experimenting to find the best way to make a map of classes I'd like to hear some advice from people who have already tried this sort of thing. Two specific questions I have are:
1) Is it advisable to have a map of classes?
2) Does anyone know the best way to acheive this?
Any other advice/comments/talk about the subject will be appriciated.
P.S. My class will not only consist of built-in types, but will also have pointers.
Thanks,
James
Drinking In The Sun
Forgot Password?
|
|
|
|
|
One solution I found was to use pointers instead:
typedef map<long, a="" *=""> AMAP;
amap[10] = new A;
This negates the cost of default and copy constructors. However, it does mean that you then have to manage the deletion of the pointers yourself, as empyting the map will just remove them from the map, not from memory. Unfortunatley, auto_ptr does not work here!
I would be interested to see if there are any other solutions, as it seems to be very costly to use anything other than basic types in a container
|
|
|
|
|
I agree that using new and storing pointers is the way to go for any of the STL containers if you don't want the default ctor's and dtor's called unneccessarily. I'd prefer to delete them myself, however the Boost shared_pointer should work fine here, not that I've tried such a thing.
Re. your original question. I guess it depends why you need a collection (multiple instances) of the class in the first place.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
I have in fact resorted to pointers for now, which I agree is the best way to go overall.
I would like to find out the best way to have a collection of classes without resorting to pointers, even if it worse than using pointers. I do not have any particular reason why I need a collection of the class - this is purley research.
Thanks,
James
Drinking In The Sun
Forgot Password?
|
|
|
|
|
both the default CTor and the 2 copies come from the insertion of a default value, if the requested key is not found. So if you use:
tmap::iterator it = map.find(key);
if (it != map.end())
else
Frankly, map is my single most used STL class, and I find myself always coding around the operator[].
The two copies come from
1) creating a temp pair<const key,="" value=""> that is passed to insert, and
2) copying the pair<const key,="" value=""> into the map
(frankly, a good library design would not need one of the copies)
You can ignore that if you have classes with "cheap" Copy-CTor's for default-constructed classes, and do complex construction after inserting a default, like this:
value & v = map[10];
v.ReadDataFromHugeFileAndKeepIt();
the same is true for classes that hold System resources (like HANDLE's that are closed in the DTor) and have no acceptable copy contructor.
Peter
One day I might find it quite amusing how touching tongues make life so confusing Anne Clark again [sighist]
|
|
|
|
|
|
Has someone experience with greta?
void example()
{
string sText="er.r.n.i.e";
match_results results;
rpattern pat("(\\w+\\.)+");
match_results::backref_type brip = pat.match(sText, results);
for(int i=0;i
|
|
|
|
|
Idefix wrote:
I think the parser works but how can i get the single items? Is that possible?
Try:
rpattern pat("{\\w+}\\.");
iterate through your string and extract the text matching the {} tag. Note that I don't know Greta, but this is what you would do with a typical Regex.
Idefix wrote:
Where can I find more documention and information?
Have you tried: http://research.microsoft.com/projects/greta/gretauserguide.htm[^]
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Hi,
I want to create ATL control like MS Tab control to use on VB form
How can i create this control in such a way that user can select other controls from VB toolbox and insert it on my control
i tried to register drag and drop target
inside my control but it wouldnt work if user just put the control and not drag it.
i understand that i need to use CComCompositeControl inside my control
but do i need to expose other interfaces for VB?
thanks
tomer
|
|
|
|
|
You need to create an ATL Project from the main wizard, then add the composite control from the 'Add ATL Object' Wizard.
This gives you the basic composition control that you can use in VB.
Professional ATL COM Programming by Richard Grimes has a good chapter on this suject.
|
|
|
|
|
Thanks Rashid, i already tried to create a composite control,but it didnot work on vb,i mean i could not add controls to the composite from VB
i found that MFC use OLEMISC_SIMPLEFRAMESITE and
ISimpleFrameSite
to create a simple frame container
thanks.
tomer dror
|
|
|
|
|
I recently created a composite control using pure ATL and WTL (No MFC) and I had no problems.
You might need to give me more details on what goes wrong ?
|
|
|
|
|
Rashid here is what i did
1.create a composite control
2.put it on a VB form
3.choose a command button control from the VB toolbox and put it on the atl composite control
the result is that the command button control didnot become a child control of the composite control,if i move the composite control the command button control stay in his place
i just want to create a control like SSTab,of FRAME
|
|
|
|
|
Hi,
I want to remove the "Apply" button in my ATL properties ( I only want to show the "Ok" button), is that possible without completly rewriting the code for the ActiveX property pages container ?
Thanks in advance, greetings
Braulio
|
|
|
|
|
I downloaded the WTL 7 from the link provided in a previous thread. When I tried to compile the MTPad example program using VC6 on XP computer I get 59 errors. There is a message at the beginning that reads:
****************************************************
Compiling...
stdatl.cpp
NOTE: WINVER has been defined as 0x0500 or greater which enables
Windows NT 5.0 and Windows 98 features. When these headers were released,
Windows NT 5.0 beta 1 and Windows 98 beta 2.1 were the current versions.
For this release when WINVER is defined as 0x0500 or greater, you can only
build beta or test applications. To build a retail application,
set WINVER to 0x0400 or visit http://www.microsoft.com/msdn/sdk
to see if retail Windows NT 5.0 or Windows 98 headers are available.
See the SDK release notes for more information.
Compiling...
****************************************************
Then it produces lots of errors. I'll only show the first one.
****************************************************
mtpad.cpp
c:\wtl70\include\atlframe.h(274) : error C2146: syntax error : missing ';' before identifier 'lpnm'
c:\wtl70\include\atlframe.h(905) : see reference to class template instantiation 'WTL::CFrameWindowImplBase<tbase,twintraits>' being compiled
c:\wtl70\include\atlframe.h(274) : error C2501: 'LPNMREBARCHEVRON' : missing storage-class or type specifiers
****************************************************
|
|
|
|
|
I believe that you will need to load the latest version of the windows SDK.
First off, the note about WINVER 5.0 means that the program enabled all of the features only available in Windows 2000 and above.
Second, I get the same basic set of errors, I only get about 14 errors though.
LPNMREBARCHEVRON is not defined in any of the header files that I have as well as IPrintDialogCallback and PRINTERDLGEX, but I believe they will be found in the latest header files in the SDK.
Good luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I've just had a look in the SDK on my PC (May 2002) and all those symbols are defined (well, PRINTDLGEX , not PRINTERDGLEX ).
It's a big download, but it's worth it in the long run.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
If you don't have the latest SDK, change the WINVER define in stdafx.h to 0x0400 and that will eliminate the errors. However, you won't be able to use the IE-style chevron and a few other new toys.
|
|
|
|
|
Hi, i want to program an owner-draw popup menu class with WTL. My actual implementation inherits from CMenu, COwnerDraw and CMessageMap, and the user of the class chains to the msg map of the menu class. But it seems to me that is an overkill, i mean, if i´m getting it right ( i don´t really know ), i´m getting all the messages from the parent window of the class just to process DrawItem and MeasureItem. I don´t know much about WTL, so i suppose there is a better design solution...
Any ideas???
Gabriel
Old C programmers never die. They just cast into void
|
|
|
|
|
That's how message maps work in general. Throw everything at them, and the class acts on only the messages it's interested in.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|