|
It is ok, CPallini!
Looks like a bug in Visual Studio debugger that the whole vtable can not be displayed.
regards,
George
|
|
|
|
|
Well I don't know and probably needs further investigation. Probably it is a debugger issue but I don't think its is a bug.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hi CPallini,
Why do you think it is not a bug? Do you have any result yet?
regards,
George
|
|
|
|
|
|
How did you add the button?
You can always type or copy/paste the code for the
command enabler yourself
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark
Yes, that is true i.e. I could add the code manually. However, I still can't see what I'm doing wrong. The omission of the Class Wizard is what is causing me problems. There is obviously a step I'm missing. Previously, what I would do would be to:
(1) Add a toolbar button using the Toolbar Editor
(2) Give the button an ID e.g. ID_BUTTON1
(3) Use the Class Wizard to add the OnUpdate or OnCommand and there you go!
However, using VS2005 to create an MFC application is to perform steps 1 and 2. Looking at the Properties window of the View there is nowhere I can see a way to access the UPDATE_COMMAND and COMMAND messages for ID_BUTTON1.
Surely there must be a way to do it without resorting to cut and paste?
Can you point me in the right direction?
David
|
|
|
|
|
Add the button
Open the class view (view menu or Ctrl-Shift-C)
Find the window class you want to add the handler to - right click it
Choose properties
In the properties window, select the "Events" tab - (the lightning bolt tab button on top).
Find the button ID in the list - expand by clicking the little + box if necessary
Click in right column to add the handler(s)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark
Yes, that's what I was expecting to do but the ID is not in the list. All that I can see are "Accelerator Commands" e.g. ID_HELP and "Menu Commands" e.g. ID_APP_ABOUT.
Again I list the steps I have done in the hope it can be reproduced:
(1) Create a new SDI MFC application using VS2005.
(2) Add a new toolbar button using the toolbar editor.
(3) Give it an ID like ID_BUTTON_NEW.
(4) Open the Class View.
(5) Right click the View Class and choose Properties.
(6) Select the "Events" tab (the lightening button).
(7) The ID_BUTTON_NEW is not there! (well, not here anyway).
Can you help?
Thanks
David
|
|
|
|
|
Hi all
I've resolved it! Basically, a toolbar button ID won't appear in the Events list. All you need to do is have, for example, an ID accelerator and then give the button the same ID.
David
|
|
|
|
|
Hello friends,
I have created my own NT Service, it works fine in Win 2000 and WinXP.
In Vista,Its register in ServiceManager and showing in the services list but unable to run after PC boots.
The reason might be UAC in Vista.
Please tell me the way that I can run my service in Vista successfully.
If possible please provide some source achieve it.
abhi
|
|
|
|
|
You should run your service in a Service User Account[^]
that has the permissions it needs to run the service.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
In the following multiple inheritance sample code, I have tested in class Derived, there are two __vfptr, pointing to the virtual function table for Foo and Goo repectively -- i.e. 8 bytes, 2 pointer on 32-bit machine.
My questions,
1. Why two __vfptr is needed? Why not just one?
2. class Derived has its own virtual method func2, why it does not have its own virtual function table pointer?
class Foo {
public:
virtual int func() {return 1;};
};
class Goo {
public:
virtual int func() {return 2;};
};
class Derived: Foo, Goo {
public:
virtual int func2() {return 3;};
int increase() {return -1;};
int decrease() {return -2;};
};
int main()
{
Derived d;
int size;
size = sizeof (d);
return 0;
}
thanks in advance,
George
|
|
|
|
|
Well this is realy a question on how the compiler designers decided how the compiler should lay out the code, and why. The answer takes a Lazy chair, a glass of wine and a cigar, but there we go.
When the Ancestors of both Foo and Goo were written, No one was aware (at least conceptually) that at a later date someone might want to combine both in a single multiple inherrited decendant. So, the compiler has to lay out the code inrespect of both Foo and Goo in the conventional way, i.e. with the __vtable pointer at the head of the class. with multiple inheritance, we include a copy of each base class in the decendant. The Casting operator is implemented at compile time, so (Foo*)(&Derived) effectively returns a Pointer to the 'Foo' part of the Derrived class. As as stated before the Ancestors of Foo are unaware of the Derived Class, they would expect the __vtable to be at the head of what the cast points at. And of course, the same would apply to Goo. To combine the two __vtable's into one sounds like a good idea, BUT:
The ancestral code for Foo and Goo may well reside in a library to which there is no access when 'Derived' is compiled. The solution with the two __vtable pointers leaves the problem of calling the correct virtual function at the place where it belongs, namely there where the Derived Multiple Inheritance is compiled into code. In a nutshell I cannot see a way of combining the two vtables, without also having to recompile ancestrial code.
Hope this explains it clearly (sort of)
Regards,
Bram van Kampen
|
|
|
|
|
Thanks Bram van Kampen,
I agree with your theory, but it does not cover one of my confusions, which is, where is class Derived's own __vfptr (points to its own virtual methods)? From debugging, I can not find it out by adding a new method in Derived which is not in Foo and Goo. Like, we add a new virtual method called func_derived.
virtual int func_derived() {return 4;}
regards,
George
|
|
|
|
|
I need to write my version of code similar to CString::Empty() function for char*. Is it enough if i just free the memory of the string to implement the function. How do i empty the string otherwise?
Thanks in advance
|
|
|
|
|
If you are talking C or working directly with C style string in C++, then you do not need a function.
char* pData = (char*)malloc(size of data required);
if( pData )
free(pData);
pData = NULL;
if( pData )
else
You do not really need a function, unless you are designing your own sting class.
Good Luck!
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
gReaen wrote: Is it enough if i just free the memory of the string to implement the function. How do i empty the string otherwise?
Yes and No!
After you free it you must NEVER again refer to that section of memory. The way I usually do it is:
char* p=(char*)malloc(size);...... free(p); p=NULL;
At least you get a definite runtime error if you try to do something with p after freeing, instead of an obscure runtime bug.
Bram van Kampen
|
|
|
|
|
Actually if you designed your string as a class then you don't even need to free memory, you can just mark the string as empty: this way avoiding memory deallocation/rellaocation if there is chance the string will be used again.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i want to hide / show menubar on an command click.
my application is an mfc mdi app.
i tried using setmenu(null) to hide and then loadmenu again to show.
but his has a problem that the maximize/ minimize/close buttons of the child disappears once u show back the menu. also when the document is closed and opened again, i get two sets of maximize/minimize/close buttons one set of which is unusable.
can anyone guide me on this how to show / hide ?
thanks
|
|
|
|
|
I am drawing some thing on picture box . Now I need to save the
Bitmap image of picture box how can I do it. can I use another control
for it .
Trioum
|
|
|
|
|
Do you want to save to a file?
|
|
|
|
|
yes want to save in file , and also use some another module
Trioum
|
|
|
|
|
You can use of CImage class like this
CImage m;
m.Attach(hbitmap);
m.save("c:\\1.jpg");
|
|
|
|
|
I have 3 different applications that generate similar data. This data is grouped into different categories. I would like to have an option so that the user can export this data HTML or XML format. Also, for each format (HTML or XML) the user should be allowed to choose which data categories to export. For example, in HTML, the user may select certain optios. In XML, the user may choose other options. I decided to create 2 property pages each with the same options (check boxes): one for xml and one for html. When displayed on a propertysheet, both look identical (as expected).
I implemented this on one of the 3 applications and it works fine. But as I started to implement this on the second application, I noticed that i had to recreate the property page dialogs and classes (each property page dialog includes about 40 controls). If I continue this way, I will be duplicating a lot of code.
Can the property page dialogs (resources) and classes be placed in a central location where they can be used (referenced) by any number of applications without having to duplicate the code in each app?
LA
|
|
|
|
|
You can always create a resource DLL, you can find articles on the internat about that.
Also you can use two projects in the same workspace and one of the projects can have the fnctionality you want to share, the most interesting way to proceed would be the DLL as in that case you can change the DLL without having to rebuild everything and you can get an upgrade...
Hope this helps.
|
|
|
|