|
Why I want to do this:
I have gota class A with an array of class B items.
Class B owns two items of class C. Class C runs in a thread.
When the thread of class C ends, I want A to remove B from its array. So I must call a function in A from within C (just before the thread terminates). But the function call can never return to C, because it will be killed during this call. So I think this will not work properly. That's why I want this call to be made asynchronous. So the function will return.
Chris
|
|
|
|
|
Does sound like a good approach. One possible solution would be to get C to call A and tell it that C is no longer valid. Then let C delete itself. Next time A tries to access B/C it will test this flag and no it can't. Something along those lines. Or maybe use smart pointers.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hello !
How do i create a Modeless Dialog Box which is to be shown in task bar
|
|
|
|
|
Set the WS_EX_APPWINDOW bit in the extended style. This needs to be done prior to window creation (i.e. specified as part of the CreateWindowEx call).
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
how can you convert a CString to a WCHAR?
Thanks
|
|
|
|
|
First of all there is no real comparison between CString and WCHAR.
If you are compiling under _UNICODE then CString already contains string in WCHAR format.
so...
(LPCTSTR)strTest; // will return you string in WCHAR under _UNICODE.
If you have not declared _UNICODE then you may need to use WideByteToMultibyte api... lookup in the MSDN for further information.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
Mr.Prakash wrote:
If you have not declared _UNICODE then you may need to use WideByteToMultibyte api... lookup in the MSDN for further information
should be MultiByteToWideChar..
|
|
|
|
|
thank you.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
Hi everyone,
I bussy working on my c++ skills at the mooment and I came across a little hitch that I cannot find the answer to any where on the net. How do you retrieve the file name of your own application at runtime. The reason is that I don't want people to change it and if it is changed then I would prompt to change it back before running the app.
Any Ideas I would be most greatfull.
Kind Regards
Nyhl G Rawlings (in spain)
|
|
|
|
|
|
Thank you, you have been a great help.
I hope to be helping out on here soon, although at the momment I fear I would confuse people if anything.
Kind Regards
Nyhl G Rawlings
|
|
|
|
|
artful wrote:
I hope to be helping out on here soon, although at the momment I fear I would confuse people if anything.
no problem, help in any form is always welcome.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
:-DMany newbie questions are more about C rather than C++, so dive on in!
INTP
|
|
|
|
|
AfxGetAppName
LPCTSTR AfxGetAppName( );
Return Value
A null-terminated string containing the application’s name.
Remarks
The string returned by this function can be used for diagnostic messages or as a root for temporary string names.
GFLPOWER
|
|
|
|
|
Hey, if you are using Windows API to program, you can use the GetCommandLine function to obtain the command line string, and then use CommandLineToArgvW to convert the command line to an argv style array of strings.
Remember, the first argument of the commandline is always the "filename"
Check msdn online resource for details about these functions
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Ahoy there,
I've made this custom list control which supports edit controls, check boxes and combo boxes in its items.
However, I have a minor problem. Say I have restricted the user to only input numbers into the edit control of a specific item. Now, I would also like to verify that the inputted data is between a specific range whenever the user has finished typing (that is, when the edit control loses focus and is destroyed). I do not want to put this verify code specifically in my custom list control class as I want it (the class) to be as abstract as possible. Instead, it should be up to the specific application which uses the control to verify this inputted data. The problem is, however, how I can notify the dialog containing the custom list control about the need to verify some data.
I've tried sending e.g. the LVN_ENDLABELEDIT message but it doesn't seem to be intercepted by the dialog. Also, I've been thinking that one could perhaps pass a function pointer to the custom list control class which the class can then just call whenever it needs data verification.
I'm not sure, though, which one is the best and if my ideas even are preferable.
Suggestions are very welcome!
Thanks in advance,
|
|
|
|
|
"Window Subclassing" will help you solve your particular problem. You can study it in detail in "Programming windows" book by Petzold (chapter 9).
But i have a request, can you please give me a short tutorial(hints/tips) about how to make custom list controls.
It will be of great help
Thanx
|
|
|
|
|
avenger_sb25 wrote:
"Window Subclassing" will help you solve your particular problem. You can study it in detail in "Programming windows" book by Petzold (chapter 9).
Thanks, I'll have a look!
avenger_sb25 wrote:
But i have a request, can you please give me a short tutorial(hints/tips) about how to make custom list controls.
It will be of great help
Check out the other custom list controls at this site, like XListCtrl. They are some great references
Good luck
|
|
|
|
|
This innocent looking little bit o' code:
double CROT_Optimizer::DoStrongWolfeSearch(const CSpringNode& TempNode, const CMatrix& rGradient, const CMatrix& rMatrix_p)
{
#ifndef WORK_IN_SILENCE
TRACE ("Starting Wolfe line search...\n");
#endif
#ifdef _DEBUG
UINT nfe = 0;
UINT nge = 0;
#endif
CMatrix Position(2,1);
Position.SetElement(0,0, TempNode.m_M3DNodePosition.x);
Position.SetElement(1,0, TempNode.m_M3DNodePosition.y);
double alpha = 0.0;
double FunctionVal = PESurfaceValueAtNode(TempNode);
CMatrix Gradient(2,1);
Gradient = rGradient;
causes me the following headaches:
Compiling...
ROT_Optimizer.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1521) : error C2664: 'PESurfaceValueAtNode' : cannot convert parameter 1 from 'const class CSpringNode' to 'class CSpringNode &'
Conversion loses qualifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1569) : error C2166: l-value specifies const object
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1570) : error C2166: l-value specifies const object
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1573) : error C2664: 'PESurfaceValueAtNode' : cannot convert parameter 1 from 'const class CSpringNode' to 'class CSpringNode &'
Conversion loses qualifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1591) : error C2664: 'FirstXDerivative' : cannot convert parameter 1 from 'const class CSpringNode' to 'class CSpringNode &'
Conversion loses qualifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1592) : error C2664: 'FirstYDerivative' : cannot convert parameter 1 from 'const class CSpringNode' to 'class CSpringNode &'
Conversion loses qualifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1670) : error C2166: l-value specifies const object
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1671) : error C2166: l-value specifies const object
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1674) : error C2664: 'PESurfaceValueAtNode' : cannot convert parameter 1 from 'const class CSpringNode' to 'class CSpringNode &'
Conversion loses qualifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1690) : error C2664: 'FirstXDerivative' : cannot convert parameter 1 from 'const class CSpringNode' to 'class CSpringNode &'
Conversion loses qualifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\PATI May 5\ROT_Optimizer.cpp(1691) : error C2664: 'FirstYDerivative' : cannot convert parameter 1 from 'const class CSpringNode' to 'class CSpringNode &'
Conversion loses qualifiers
Generating Code...
Compiling...
AbstractSpringSolver.cpp
Generating Code...
Skipping... (no relevant changes detected)
PatiKernalTester.cpp
PatiStretch.cpp
Error executing cl.exe.
Creating browse info file...
Presenter.exe - 11 error(s), 0 warning(s)
The sad tale is that I am not sure why this is...
There is obviously a problem with the const keyword going on here, but
the function prototype is fine...
Help appreciated.
thx.
<EDIT>
I think I am seeing the problem now...the complaining functions want to
modify the reference and since it has been declared const I am getting
the compile errors, yes?
</EDIT>
John Theal
Physicist at Large
Got CAD?
http://www.presenter3d.com[^]
|
|
|
|
|
If PESurfaceValueAtNode( const CSpringNode& TempNode ) you should be fine, but if it isn't 'const ..' you'll get this error. If const PESurfaceValueAtNode() is a function you've written and the param can be a const reference then you can of course simply change it.
One of the hassles with const is that you need to start using const at all the appropriate lower level functions from the get go. These days I pretty much make everything that can be const, const including functions.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hi Neville -
Yes, I've since figured out this is exactly what is going on. Unfortunately, there are several layers of function calls (that I
can't post) that need to be amended. A seeminly small
tweak & adjustment has now turned into an all-day re-write...
Thanks.
John Theal
Physicist at Large
Got CAD?
http://www.presenter3d.com[^]
|
|
|
|
|
John Theal wrote:
A seeminly small
tweak & adjustment has now turned into an all-day re-write...
const has a habit of doing this to you. An editor with good global search and replace can help a lot at these times. Hint - see my sig.;)
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
If you can come up with an editor with refactoring tools such as those found in Jet Brain's IntelliJ editor[^] I will be your customer until the day comes when I will no longer program for a living.
I know that's no easy task for a C++ IDE/editor (at least not as easy as in Java, where they have introspection/reflection API's), but I'd gladly pay for it, cause it would 1) save me a lot of time, and 2) dare to bite the bullet and go ahead with redesigns, since the code will be refactored in a jiffy.
If I'll be a good boy 'til Christmas, will you have such an IDE for me to buy? Please?
--
Din mamma.
|
|
|
|
|
Can someone please explain 1) how the predicate 'op' differs in each map example below, 2)why op needs to be a class or struct with the predicate specified in an overloaded () operator , 3) why when I use #2 or #3 I loose the ability to change an element using map[key] (such as ++map[key]), and 4) if it is possible to order the elements based on the elements(elem) themselves (i.e. not the key). Thanks!
1) map<key, elem, op> m;
2) map<key, elem> m(op);
3) map<key, elem, op1> m(op2);
Matthew
|
|
|
|