|
what exactly do you mean Zero??
are you creating a thread and trying to pass function parameters to the function your using to create the thread??
or are you calling another function from inside the function used for the thread start??
Steve
|
|
|
|
|
Hi,
In our app here @ work I can call a function from inside the main thread or from another thread started by the main thread.
If you're inside your own thread there are no worries. If you want to call your function from another thread it crashes (or at least here it did ) You should pass the instance of your class to the thread and when you want to call your function from that thread post a message to your class saying you want to execute that function.
I'm not sure this is the way to go, but it works. The program doesn't crash anymore (jeej )
You can look things up at CP or MSDN or google.
The reason for this I THINK, is that the threads work on a different part of memory or something like that.
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I am studing C++ and the textbook says every class should have a public destructor. OK, I accept that, but the wizard generated code always has a private: destructor and the other examples in the text have a virtual private: destructor.
So what is the value of a public destructor? Is it just the freedom to 'delete' where and when as desired?
|
|
|
|
|
The textbook is wrong. The destructor is called by the class, not by the client, and so does not need to be public. You also don't need a destructor unless your class has objects it needs to clean up in there. An empty constructor and destructor are provided for you without you having to specify them.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thank you. That make perfect sense.
|
|
|
|
|
Christian Graus wrote:
The destructor is called by the class, not by the client, and so does not need to be public.
No sir, I'm sorry, but you are wrong. In order to delete an object, the destructor must be visible in the scope in which it's being deleted. If it's a private destructor, then only code belonging polymorphically* to the class (including friend s) can delete the object. And the client does call the destructor, although implicitly by using ::operator delete , class::operator delete or simply letting the stack object go out of scope. You can call the destructor explicitly, which is a must, if you deal with exotic memory allocations such as in embedded systems where objects are supposed to be in fixed memory locations. Actually, it's not all that exotic. STL does it everywhere under the hood. I.e.: X* x = (X*)malloc(sizeof(X)); new (x) X; x->~x(); free(x); is equivalent to X* x = new X; delete x; (Just make sure you have included <memory> and is using std::new as the "compiler new" may not support the placement new syntax. G++ doesn't for some reason )
Moreover, you cannot instantiate an object on the stack, whose destructor is not visible in the current scope. This is one way to force the programmer to use the heap.
*If you have a public virtual destructor in a base class, and the subclass has hidden it, you can delete the object through the base class' interface. However, making a previously public destructor private doesn't make much sense IMO, so it's a moot point dragging the polymorphic case into the picture.
--
Arigato gozaimashita!
|
|
|
|
|
Dagnamit. I googled for that answer, and spent a fair amount of time reading, too. I'm not saying you are wrong, just that I've been cheated by the web, again.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Is there any way to tell if the user has clicked on the button or the item in a ctreectrl.
I want to limit expansion of the tree to only the button and use overwrite the single click of an item to do something else besides expand the tree.
I have been watching the on_notify but it doesn't seem to make a distinction.
Thanks
|
|
|
|
|
"Is there any way to tell if the user has clicked on the button or the item in a ctreectrl."
Yes, there is. Use HitTest() to determine which item was hit.
"I want to limit expansion of the tree to only the button and use overwrite the single click of an item to do something else besides expand the tree."
Couldn't get what you are saying. Can u explain it a little bit.
Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth!
-Fyodor Dostoevsky, The Brothers Karamazov
|
|
|
|
|
I am writing a script that allows for nodes on tree to be transferred to another tree. They are side by side in a dialog box.
What I want is the tree to expand and collapse when the +/- button is pressed and when the node receives a single-click to simply highlight and when the node is double-cliked to then move the node to the other tree.
Right now the +/- button, single-click and double click all expand the tree plus carryout the above mentioned functionality. It is too confusing for end-users. Even I hate it.
So I am looking for a way to caught the above mention three clicks and then parse them as needed. Basically pass the +/- click on to expand/collapse the tree and do nothing with the single and double click.
Do you have any examples of code were I can caught the expand/collapse action. I have tried a TVN_ITEMEXPANDING on_notify and on_notify_reflect in both the parent dialog box and the cmytreeview class to no avail. It doesn't seem to catch the event. I have doubled checked to make sure that I have all of the includes and base classes.
Any help and examples would be appreciated
|
|
|
|
|
Cedar Sith wrote:
I want to limit expansion of the tree to only the button and use overwrite the single click of an item to do something else besides expand the tree.
For this you can handle the TVN_ITEMEXPANDING message.
[EDIT]Sorry, I didn't properly read your request. I guess the most first thing that comes to mind is to set an explicit mouse click flag (when you do your button HitTest()). This would probably let your program know whether the expansion was due to a mouse action, or a keyboard action.[/EDIT]
I Dream of Absolute Zero
|
|
|
|
|
I'm experienced with MFC/C++, but new to the VBA world, and I've been charged with writing a MFC app that can be controlled by (possibly user-written) VBA scripts, just as the bigtime MS apps are.
I've gotten the VBA SDK, and I followed the documentation to the point where I can make a MFC app that can call up the VBA IDE and a macro dialog using APC. But there, the documentation appears to end, there is apparently nothing that tells me how to hook up the functionality inside my app to run outside VB files.
That is, if I have a class in my C++ app: CMyDoc::Foo(int x), what do I need to do so that I can write a VB file that says something like:
for x = 1 to 5
mydoc.Foo(x)
next
and get it to run?
|
|
|
|
|
Lookup "Automation: Overview" in MSDN.
|
|
|
|
|
I will also be venturing into exactly this in a little while with my app.
Have a look at the Automation[^] section here at CP. The articles should give you a good intro on whats involved.
[EDIT]must remember to reply to original sender!! Sorry Josh![/EDIT]
I Dream of Absolute Zero
|
|
|
|
|
see prev ^ post.
I Dream of Absolute Zero
|
|
|
|
|
Hi all,
I am working on converting some images into BMP format and the given images are in *.LL1 and *.LT1 formats. After converting them into BMP I have to display them in an interface that I am goin to build. (i.e when I select an Image file of any of those two formats fromt he 'open' menu item then it should display the image on a seperate window after doing all the process of changing the format into BMP.
Anybody having ideas or suggestions of how to convert an image format in VC++, plz lemme know and I appreciate ur help.
I hope I am clear in problem description.
thanks in advance,
Pavan.
Pavan
|
|
|
|
|
There are image libraries such as devIL (a.k.a openIL), FreeImage and this one:
[^]
Some of these are hard to set up, I haven't been having much luck anyway but it's a place to start. Also will parse and load many files and allow saving, but I haven't seen if they support *.LL1. I used openIL to convert formats.
As far as displaying images there are many ways to do that. From the Doc\View architecture you can override the OnDraw() method and draw the image if you have access to the raw pixels (which you have loaded with some image library). If you have a bitmap you can also use the Picture Control and I believe you can call .SetBitmap() but I don't remember the details.
That's my attempt.
|
|
|
|
|
Hi,
thanks a lot on providing that info and I will try to use it.
In the meanwhile can you tell me how we can read an image in vc++, not just reading it, but wht i am talking abt is after reading how can we access the data in the image (like in Matlab, where we can read the image and can access the intensity value for any pixel directly) in an array format. Becos i want to do some image processing techniques on the image I am reading where i need each pixel's info.
thanks,
Pavan.
Pavan
|
|
|
|
|
Read my GDI+ articles here on Code Project. They tell you all you need to know. If you can't use GDI+, use a DIBSection wrapper, there are several on the site as well.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
Thanks for ur valuable info ... actually I am not able to find the file 'psdk-common.11.cab ' at the microsoft ftp site. can u tell me from where i can get it.
thanks,
Pavan.
Pavan
|
|
|
|
|
The cab is inside the SDK. What compiler do you have ? Any .NET compiler has the GDI+ headers and libs in it's default SDK. otherwise, you need to download and install a platform SDK to get them for VC6.
I strongly advise against trying to install just the GDI+ part of the SDK, you should install the whole thing.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
I have downloaded whole SDK and installed it on my PC and i am working on it.... in the meanwhile can you tell me anything abt my previous message
"how we can read an image in vc++, not just reading it, but wht i am talking abt is after reading how can we access the data in the image (like in Matlab, where we can read the image and can access the intensity value for any pixel directly) in an array format. Becos i want to do some image processing techniques on the image I am reading where i need each pixel's info."
thanks,
Pavan.
Pavan
|
|
|
|
|
Like I said, read my articles on GDI+. The image processing ones are probably all in C#, but the syntax for C++ will be similar, and the methods you call will be the same.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi all,
thank you very much Mr.Graus, the information u have provided really helped me a lot.
Here is another problem that I am having, I am working on converting some images into BMP format and the given images are in *.LL1 and *.LT1 formats. After converting them into BMP I have to display them in an interface that I am goin to build. (i.e when I select an Image file of any of those two formats fromt the 'open' or 'Load' menu item then it should display the image on a seperate window after doing all the process of changing the format into BMP.
Anybody having ideas or suggestions of how to convert an image format in VC++, plz lemme know and I appreciate ur help.
I hope I am clear in problem description.
thanks in advance,
Pavan.
|
|
|
|
|
I have no idea what an LL1 or an LT1 format looks like, you need to get ahold of a specification of those formats, then you can work out how to decode them.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|