|
Use the following code
VARIANT vtErr;
vtErr.vt = VT_ERROR;
vtErr.scode = DISP_E_PARAMNOTFOUND;
VARIANT vtPrompt;
vtPrompt.vt = VT_BOOL;
vtPrompt.boolVal = VARIANT_TRUE;
spDoc->Save(vtErr, vtPrompt, &saved);
This would work but life would be much cool if you use CComVariant or _variant_t.
|
|
|
|
|
that worked, thanks.
I tried using _variant_t but it gave an error when compiling. How do you use CComVariant and _variant_t.
thanks
Scott
|
|
|
|
|
#include <comdef.h>
.
.
.
spDoc->Save(vtMissing, _variant_t(true), &status);
|
|
|
|
|
That gave me the linking errors
Commands.obj : error LNK2001: unresolved external symbol "class _variant_t vtMissing" (?vtMissing@@3V_variant_t@@A)
Commands.obj : error LNK2001: unresolved external symbol "void __stdcall _com_issue_error(long)" (?_com_issue_error@@YGXJ@Z)
|
|
|
|
|
You need to have comsupp.lib linked
|
|
|
|
|
|
How can I replace the scrollbars in a CEdit derived edit control with my own, derviced from CScrollBarCtrl? I've tried all sorts of wierd and wonderful methods, but none seem to work. Also, how would I go about doing the same for list boxes, list controls and combo boxes?
____________________
David Wulff
hu·mour Pronunciation Key (hymr)
n. & v. Chiefly British
Dave's Code Project Screensaver and Wallpaper page.
|
|
|
|
|
Have a look at this article. There is a brief discussion of this question.
Please let us know if you can pull it off.
|
|
|
|
|
|
You shoule be able to override the windows CWnd::GetScrollBarCtrl() virtual function for the window that contains the scroll bars. You can then return pointers to your replacement scrollbars for the horizontal and vertical scrollers.
If you take a look at the base class code you will see what you need to do.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Well that is the first thing I thought of after browsing through the documentation, but it, well, doesn't seem to work. It is of course possible that I approached it wrong, so I will have a go with a new test app later just to make one hundred percent sure.
Thanks.
____________________
David Wulff
hu·mour Pronunciation Key (hymr)
n. & v. Chiefly British
Dave's Code Project Screensaver and Wallpaper page.
|
|
|
|
|
Hi does anyone know of any free cda to wav (or mp3!) freeware mfc classes ?
Bryce
|
|
|
|
|
I am trying to see under what practical circumstances a virtual base class is needed. I know there are lot of experienced programmers here. I am curious to know whether anyone used virtual base classes in real life. If yes for what?
|
|
|
|
|
I wrote a paint program in MFC, and the mainframe class carried a pointer to a PaintTool class, which was a virtual base for all the different tools in the program. It had methods like Draw and Preview, and also methods such as OnLeftButtonUp, so that I could code the behaviour of the tool entirely in the tool, and MFC called them via the pointer to the base class instance.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Did you have something like this :-
class MainFrame
{
private:
PaintTool* m_pTool;
}
class PaintTool
{
...
};
class PaintTool1 : PaintTool
{
};
class PaintTool2 : PaintTool
{
};
Where does multiple inheritance figure in this?
|
|
|
|
|
I don't see how you were asking about multiple inheritance, I thought you wanted to know about virtual base classes ? Did you mean to emphasise the plural, i.e. more than one virtual base ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
My understanding of virtual base classes.
(Excuse the C# style synatx)
class A
{
int x;
}
class B : A
{
}
class C : A
{
}
class D : B, C
{
}
In case of D there will be two distinct copied of data for A as it is not virtual base.
D* pd = new D;
C* pc = (C*)pd;
pc->x = 10;
B* pb = (B*)pd;
//pc->x is not same as pb->x
pb->x = 11;
Now decalring like this
class B : virtual A
{
}
class C : virtual A
{
}
class D : B, C
{
}
In this case,
C* pc = (C*)pd;
pc->x = 10;
B* pb = (B*)pd;
//pc->x is same as pb->x
ASSERT(pc->x == pb->x)
This is what I always understood the purpose of virtual base classes. Am I wrong?
|
|
|
|
|
A virtual base class has at least one pure virtual function
virtual void PaintNow(CDC & DC) =0;
Therefore it cannot be instantiated, it exists somewhat like an interface as I understand it in C# ( which is to say barely ). Multiple inheritance is possible, but in no way implied by the fact that a class is a virtual base. It simply means the class itself cannot be instantiated, because it defines functions that derived classes MUST impliment ( which is it's function ).
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
A virtual base class has at least one pure virtual function
I thought that was abstract class.
Don't know what is the emoticon for that feeling.
|
|
|
|
|
You are right, that is an abstract base class.
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!
|
|
|
|
|
That will create an abstract base class.
A virtual base class is used in multiple inheritance where you derive from two classes that derive from a common class like so:
class a;
class b : public a;
class c : public a;
class d: public b, public c;
Obviously this isn't valid C++ but hopefully you get the idea. In this case, you will get two intstances of the class a in class d. One that is a part of class b, the other that is a part of class c.
If you create a virtual base class with a, this will make it so that only one instance of a appears in the final class d, and this will prevent collisions because of the duplicate variables.
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!
|
|
|
|
|
The only real-world example I know of useful virtual base classes is std::iostream which derives from ostream and istream . Each of those derive from (I think) ios virtually, so iostream ends up with only instance of ios in its inheritance tree.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
|
|
|
|
|
You are right, I totally forgot about it. Thanks
|
|
|
|
|
Hi,
I tried to merge two projects together. The second (some OpenGL things) doesn't use precompiled headers at all, in those files I get errors when compiling.
Is the a precompiler pragma to disable use of precompiled headers for a file?
|
|
|
|
|
#pragma no_pch
does NOT work to suppress precompiled header, hmm any idea?
|
|
|
|