|
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
|
|
|
|
|
Hi Mr.Graus,
Hmm, actually I don't know what information we need inorder to convert the format. But, I am having some information of those header files and it is as under
IFFCL_GRAY {
bits: 12
byte: @0=0x00
byte: @1=0x00
byte: @2=0x00
byte: @3=0x00
width:[@6=ishort]/2
height:@4=ishort
start_offset:128
line_offset:width*2
datatype: lsb_msb
}
this is wht I am having about them. If u need a sample file of those formats I can send u to ur mail if u can provide me with it (their size is around 8MB to 10MB each). If u know, if anymore details would help us in converting the formats.
One more doubt is, in your application of CSharpFilters, in Form1.cs I am not understanding how u r defining the Zoom menu items as
private void OnZoomXY(object sender, System.EventArgs e)
while for other menu items u r defining as
private void menuitem_menusubitem(object sender, System.EventArgs e)
thanks a lot,
Pavan.
Pavan
|
|
|
|
|
The names of the menu items is irrelevant. I just didn't prettify them all when I was putting the code together
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Graus,
Sorry to disturb u again... I am having a problem while writing a program on image processing and I did refer your articles on them and they r very helpful. But, wht i am having is I ahve to read an image (which I did) and then I ahve to scan the image from 2nd row, second pixel (imagine the image as an 3D array of values [RGB]) and I have to consider all its neighbouring pixels (means we get a total of 9 pixels considering the center pixel) and then I have to some image processing techniques on it.
Especially can u tell where u r reading the 3X3 matrix ( i hope it is ConvMatrix class and u r creating an instance of that in each technique, but i didn't get how u r using one instance of that clas and performing the operation on whole image) in your program and how u r applying any image processing method on the matrix for the whole image (passing over the image from right to left and then top to bottom), I mean how u r updating ur convolution matrix for each pixel.
I hope I am bothering u very much and i am vey sorry for that.
thanks a lot,
Pavan.
Pavan
|
|
|
|
|
The matrix is applied to each pixel in the image in the nested loop that steps through the x and y values. Each iteration of the loop is stepping through the matrix, working out pixel locations relative to the core pixel being modified, which is decided by the two x and y loops.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|