|
No,no,no, my meaning is how to write like the following code:
A<T>* ptA;
B b;
C c;
ptA=&b; //upcast here
ptA->xxx();
ptA=&c; //upcast here
ptA->xxx();
But the "A<T>* ptA" is invalid, because it need instantiation here, I must fill the T with B or C, but if I write A<B>* ptA, then ptA=&c is invalid, the same as writing A<C>* ptA.
Now I want to know, how to define a pointer can pointer b or c?
I'm amumu, and you?
|
|
|
|
|
By definition, a pointer to A can be set to be a new B or C, if B and C derive from A. I don't know that passing an address should work any different. Why can't the B and C instances be stored as pointers ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Because I need dynamic load B or C or D, from the viewpoint of main program, it only know A, (B C D)is developed later and loaded later.
I'm amumu, and you?
|
|
|
|
|
Hi guys,
I have implemented the code that dinamically change my toolbar's tooltips in CMainFrame. I found the code in WinFrm.cpp.
The problem is that I cannot access CMainFrame thru the Wizard anymore. Meaning that I cannot add anymore handlers.
Any advice is appreciated.
The code is :
CMainFrame.Cpp
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, ...., ..., ...)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, ...., ..., ...)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, ...., ..., ...)
CMainFrame.h
afxmsg BOOL OnToolTipText (..., ..., ..., ...)
Thanks.
Louis
|
|
|
|
|
Try to delete the .clw file - ClassWizard will rebuild it from sources.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Thanks.
Sorry for my late reply. Easter and family holidays here in S.A.
But I found my mistake.
Firstly, ClassWizard does not handle ON_NOTIFY_EX_RANGE. If one wants to use it, one must edit the message map oneself.
Also, I moved ON_NOTIFY_EX_RANGE outside the //{{AFX_MSG_MAP.
All is OK.
Cheers.
Louis
|
|
|
|
|
Hi,
I have an ActiveX component showing two buttons.
When you press the buttons a pop up message appears.
When I add the following in an HTML doc:
<OBJECT classid="clsid:56C19B8A-3BD8-11D6-8F9C-0006294E85D7"></OBJECT>
<OBJECT classid="clsid:56C19B8A-3BD8-11D6-8F9C-0006294E85D7"></OBJECT>
In IE see the object twice. When I click on a button the pop up message appears.
I want to program this behaviour myself.
I took the 'oclient' sample project from MSDN, compiled it and made a new document
in which I inserted my OCX twice. Saved it.
Now, I changed the function CMainView::OnLButtonDown() to this:
[I know I can't move any objects, but it's for ease]
void CMainView::OnLButtonDown(UINT /*nFlags*/, CPoint point)
{
CRectItem* pItemHit = GetHitItem(point);
if (!pItemHit) return;
pItemHit->DoVerb(OLEIVERB_UIACTIVATE, this);
}
Now, when I click the item it is first activated.
It's only when I click for a second time on the button, that the pop up message appears.
I want the pop up message appearing from the first mouse click (like in IE).
How do I implement this behaviour?
Thanks in advance.
|
|
|
|
|
Hello every body
I am using a CRecordset object but I want to make my own connection string, not defult,so how can i make this? is it don by using CDatabase Object and how?
Best Regards
|
|
|
|
|
If you are using access you can just give file path or if you use ODBC driver this is another example:
CDatabase aDB;
try
{
aDB.OpenEx("DSN=MyDSN");
CRecordset aRS(&aDB);
aRS.Open(CRecordset::forwardOnly,
"SELECT DISTINCT state FROM authors");
.
.
.
.
or another example for SQLServer(without ODBC) this is a connection string:
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=NorthWind;Data Source=MAZY;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=MAZY;Use Encryption for Data=False;Tag with column collation when possible=False
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I am currently playing with the concept of designing a custom toolbar from CControlBar, this is actually a lot more difficult than I thought.
I'm thinking i'll probably go with just deriving from CWnd and include some controlbar repositioning code (I don't need docking).
Shog9 pointed out that doing this is pointless because the short life expectancy of MFC(VS.NET and all) and the time required to design a toolbar isn't worth it. However I don't want to derive from CToolBar I wanna start from scartch. I'm an anus...no really my face looks like a colon(spelling).
Anyways...if i do derive from CWnd(although the fact MFC is dying slowly has no effect on me) what is the C# (probably the direction i'd go in, it's closer related to C++???) equivelant...? Or is there one...?
I'm dead set on starting from either CControlBar, but will probably end up deriving from CWnd, cuz I can't get nothing from CControlBar. Stupid thing is like my last girlfriend, so much work...so little profit...
Basically if I do this (even though it doesn't concern me really, yet anayway!) what is the probability of getting the same thing to work in later versions of VC++ 7.0+..?
Ciao!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
Shog9 pointed out that doing this is pointless because the short life expectancy of MFC(VS.NET and all)
VS.NET has new version of MFC. What's the problem?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
I was not aware of this.
For backwards compatibility...? I thought managed C++ was to do this...?
So there is a CWnd in VS.NET...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
VS.NET ships with new, updated version of MFC. CWnd is still there.
Managed C++ is something entirely else.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Thanx Tomasz!
All I needed to hear.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
My program about ADO run correctly on my machine,but it can't correctly run on the machine whithout VisualC++ IDE. I find it runs the following statment:
_CommandPtr cmd;
_ConnectionPtr conn;
.......................................
cmd->ActiveConnection = conn;/Error occurs
I don't why.Can somebody help me!
Thanks very much!!
VCBeginer
|
|
|
|
|
Do you have the same version of MDAC installed on both machines? You can download it from the microsoft web site. www.microsoft.com/data
Michael
|
|
|
|
|
Oh! I get it. Thank you again!!
VCBeginer
|
|
|
|
|
namespace afilter {
:
:
template <typename cr,="" int="" i,="" o="">
ReplItr<cr,i,o>::ReplItr(const typename CR::Base & cr)
: repl(static_cast<const cr="" &="">(cr)), buffer(repl.max_out()) {}
template <typename cr,="" int="" i,="" o=""> // <--error C2954: template definitions cannot nest
ReplItr<cr,i,o> * ReplItr<cr,i,o>::clone() const {
return new ReplItr(*this);
}
:
:
}
why this error comes ?
error C2954: template
Is there any way to get rid of this ?
Regards,
_Nandika
|
|
|
|
|
Can Visual Studio .NET still use my old custom appwizards from 6.0? I can't find any way to incorporate my *.awx files into the new IDE.
|
|
|
|
|
Hi,
I have started a project(DLL) which was not using MFC. But I need to add some of my classes which are derieved from MFC to this project. So, I added stdafx.h with all MFC includes to this dll and included where ever necessary. But still I am getting compilation errors that the MFC classes are undefined.
Can some one help me?
Thanks in advance
Maithili
Maithili
|
|
|
|
|
Maithili
In addition to adding the MFC header files, you will also need to link with the MFC DLLs either statically or dynamically.
Nish
I am the Keyboard Smasher
|
|
|
|
|
Hi Nish,
Thanks for your reply.
But if you are referring to the project settings/general/MFC classes
then, I have already chosen 'Use MFC in a static Library' option.
Should'nt that be enough? I still get the compilation errors.
Thanks
Maithili
|
|
|
|
|
Mythili wrote:
I have already chosen 'Use MFC in a static Library' option.
Should'nt that be enough?
Yes, that should do.
You are getting compile errors eh?
Can you show your stdafx.h please?
And I presume you have included it in all your cpp files.
Nish
I am the Keyboard Smasher
|
|
|
|
|
Perhaps post the actual error you are receiving.
Compilation error...? I don't think that has anything to do with including the right libs/dll's. The compiler goes blitz when your code is funny...like your using a structure that doesn't exist.
You have all the right includes...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hi,
I am using visual studio installer 1.1 and I would like to create a sreen that would allow the user to select the features that he wishes to install, a bit like in office 2k/xp. Please help me as this is of urgent matter.
JS Paquet.
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|