|
In my sample,
Abc < Foo >
will be expanded to
Abc:Foo
And
Abc < Goo >
will be expanded to
Abc:Goo
So, class Abc will be defined twice. So I think there is conflicting. Any ideas or comments?
regards,
George
|
|
|
|
|
I think template class names will be name mangled
Regards,
Sandip.
|
|
|
|
|
What do you think will be the classes' after template instantiation/expansion, Sandip?
regards,
George
|
|
|
|
|
Hi George,
I am not sure exactly what will be the class names. I even dont know any way through which you can see the class names after expansion.
I tried
class Foo: public CObject
{
public:
int add(int a , int b)
{
return a+b;
}
};
class Goo : public CObject
{
public:
int add(int a , int b)
{
return a+b;
}
};
template <class t="">
class Abc : public T
{
};
</class>
I used CObject because this enables my class to have RTTI.
now when i step in the respective add functions i see following contents in the watch window
this VFoo::?$abc
this VGoo::?$abc
Regards,
Sandip.
|
|
|
|
|
Thanks Sandip,
So in your sample, actually there will be two classes Abc < Foo > and Abc < Goo > , other than a single Abc class?
regards,
George
|
|
|
|
|
George_George wrote: So in your sample, actually there will be two classes Abc < Foo > and Abc < Goo >
Yes there will be two classes
George_George wrote: other than a single Abc class?
I doubt that this will be there
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
You mentioned in your experiment, you watched window likes this,
this VFoo::?$abc
this VGoo::?$abc
My question is what variable/object are you watching on to get such results?
regards,
George
|
|
|
|
|
i called function add and when i step in to add function
in watch window i see the above values against this pointer.
Regards,
Sandip.
|
|
|
|
|
Thanks Sandip,
You mean you step into the member function like foo and watch for "this" pointer?
regards,
George
|
|
|
|
|
George_George wrote: You mean you step into the member function like foo and watch for "this" pointer?
Yes..
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
I have tried but can not see the same thing.
Here is my situation. Do you know what is the problem?
when I watch this in function Foo::func, the Name/Value/Type in Watch window is
this 0x0012ff63 Foo * const
Here is the code I am using,
class Foo
{
public:
int func();
};
int Foo::func()
{
int a = 3;
return a;
}
class Goo
{
public:
int func();
};
int Goo::func()
{
int a = 3;
return a;
}
template < class T >
class Abc : public T
{
};
int main()
{
Abc < Foo > f;
Abc < Goo > g;
f.func();
g.func();
return 0;
}
regards,
George
|
|
|
|
|
Hi George,
That is because your class does not have RTTI.
That is the reason i derived my classes from CObject.
I hope it helps..
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
I think RTTI is the capability of runtime to discover the actual underlying type of variable pointed by some pointer. So, in short RTTI is some specific capability of runtime. What do you mean class does not have RTTI? Looks like you think RTTI is some capability of a class? Could you clarify please?
regards,
George
|
|
|
|
|
George_George wrote: So, in short RTTI is some specific capability of runtime.
and in MFC this is supported by CObject.
If you do not derive class using CObject it will not support RTTI.
In my application if i remove CObject it just gives me address just like you.
Does it help..
Regards,
Sandip.
modified on Monday, September 22, 2008 8:07 AM
|
|
|
|
|
Thanks Sandip!
I am not using MFC, any ways to display things like you showed below in a standard C++ project in VC?
this VFoo::?$abc
this VGoo::?$abc
regards,
George
|
|
|
|
|
Now I'm also pretty much sure (after having tested) that templates are name mangled. If you try to use extern 'c' for templates (class/functions), the compilier will flash an error saying 'error C2894: templates cannot be declared to have 'C' linkage'.
- Malli...!
|
|
|
|
|
Are there any ways to see the classes' after template instantiation/expansion, Malli_S?
regards,
George
|
|
|
|
|
I get this message when I run my application which is built on another computer:
This application failed to start because the application initializtion is incorrect.
?????
What?
|
|
|
|
|
Did you use VC2005 ? If yes, you have to download and install vcredist_x86.exe[^] on the target machine. This will install the MFC and C-runtime libraries. If you have installed the SP1 for VC, check at the bottom of the page for the SP1 version of VCredist_x86.
|
|
|
|
|
When right click my tray icon, show the menu, And there is a menu item "Restore window".
When click this menu item, it should restore window.
My code implement "Restore window" below:
void CWinSearchDlg::OnTrayRestoreWnd()
{
DestroyTray();
ShowWindow(SW_SHOW);
<font color="red">
::BringWindowToTop(this->GetSafeHwnd());
::SetForegroundWindow(this->GetSafeHwnd());
::SetActiveWindow(this->GetSafeHwnd());</font>
}
I've tried the code in red font, but when restore the window, It doesn't bring to the top.
Please give me a sign!
|
|
|
|
|
Try using CWnd::SetWindowPos
|
|
|
|
|
Thank for your reply first.
SetWindowPos Not Working too.
I even try to put them in different order.
Please do me a favor.
|
|
|
|
|
Did you check the return values for the above (Red colored) function calls ? The other possibility is that (if the functions return success), the window might have brought up to top, but your some other code might be changing the order again.
Or, calling SetForegroundWindow() before displaying your context menu might help you.
- Malli...!
|
|
|
|
|
I have a problem setting bg-text color of static control on one of my dialog
I try to set the bg-text color of every static control on my dialog by
overriding OnCtrlColor (ON_WM_CTLCOLOR) of that dilaog
HBRUSH CCAESDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_DLG){
COLORREF color = RGB(255,225,255);
pDC->SetBkColor(color);
return (HBRUSH)GetStockObject(WHITE_BRUSH);
}
else{
return hbr;
}
}
this work fine for all of my dialog (10 of them).
But it doesn't work on one dialog,all the bg-text of every static control turn into pink.
even if i remove the if-else block from my code any force setting bg-text color of evey control on dialog to white color ,it still doesn't work.
declare & initialized the variable color as a class's member doesn't help either.
Does anyone know what the cause of this problem?
Thank in advance.
|
|
|
|
|
Did you make a Bursh and did you return it instead return hbr?
|
|
|
|