Hi,
I have qome questions about templated class and pointer.
Let's says I have some graphical classes defined like this(WTL framework) :
// represent a view
class CFooView : public CStdDialogImpl< CFooView>
{
public:
enum { IDD = IDD_FOO_FORM };
....
};
// represent a welcome view
class CWelcomeView : public CStdDialogImpl< CWelcomeView>
{
public:
....
};
class CMainFrame :
public CFrameWindowImp l<CMainFrame>,
public CUpdateUI<CMain Frame>,
public CAppWindow<CMai nFrame>,
public CFullScreenFram e<CMainFrame>,
public CMessageFilter,
public CIdleHandler,
public CMDIBase<CMainF rame>
{
public:
virtual BOOL PreTranslateMes sage(MSG* pMsg)
{
if(CFrameWindow Impl<CMainFrame >::PreTranslate Message(pMsg))
return TRUE;
return m_mainView.IsWi ndow() ? m_mainView.PreT ranslateMessage (pMsg) :
FALSE;
}
// our views
CVoxsyncBackupV iew m_mainView;
CWelcomeView m_welcomeView;
???????????? m_curView;
....
};
As you can see in CMainFrame class I have some views defined in it and I
am supposed to be able to switch between them.
The problem comes from the PreTranslateMes sage method, because it is
supposed to point to the current view.
So how could I declare a kind of pointer on the current templated class ?
Until now I was using only one view so PreTranslateMes sage is using
m_mainView but what if I want to use another view ? 2 1690
On May 2, 7:46 am, mosfet <john....@anony mous.orgwrote:
Hi,
I have qome questions about templated class and pointer.
Let's says I have some graphical classes defined like this(WTL framework) :
// represent a view
class CFooView : public CStdDialogImpl< CFooView>
{
public:
enum { IDD = IDD_FOO_FORM };
...
};
// represent a welcome view
class CWelcomeView : public CStdDialogImpl< CWelcomeView>
{
public:
...
};
class CMainFrame :
public CFrameWindowImp l<CMainFrame>,
public CUpdateUI<CMain Frame>,
public CAppWindow<CMai nFrame>,
public CFullScreenFram e<CMainFrame>,
public CMessageFilter,
public CIdleHandler,
public CMDIBase<CMainF rame>
{
public:
virtual BOOL PreTranslateMes sage(MSG* pMsg)
{
if(CFrameWindow Impl<CMainFrame >::PreTranslate Message(pMsg))
return TRUE;
return m_mainView.IsWi ndow() ? m_mainView.PreT ranslateMessage (pMsg) :
FALSE;
}
// our views
CVoxsyncBackupV iew m_mainView;
CWelcomeView m_welcomeView;
???????????? m_curView;
...
};
As you can see in CMainFrame class I have some views defined in it and I
am supposed to be able to switch between them.
The problem comes from the PreTranslateMes sage method, because it is
supposed to point to the current view.
So how could I declare a kind of pointer on the current templated class ?
Until now I was using only one view so PreTranslateMes sage is using
m_mainView but what if I want to use another view ?
probably:
CWnd * pView;
However, this has nothing to do with C++. Why not try in a relevant
newsgroup?
mosfet wrote:
As you can see in CMainFrame class I have some views defined in it and I
am supposed to be able to switch between them.
You can't.
The problem comes from the PreTranslateMes sage method, because it is
supposed to point to the current view.
So how could I declare a kind of pointer on the current templated class ?
Until now I was using only one view so PreTranslateMes sage is using
m_mainView but what if I want to use another view ?
Two ways.
I ran into this issue myself and switched to runtime based dialog
detection. Instead of IDD being an enum it becomes a variable and the
base class a non-template. So there is way number one.
Number two involves studying boost::any and realizing that kind of idiom
can be used to virtualify any interface.
There are probably others but that's my ideas. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: tirath |
last post by:
Hi all,
I have a templated class that derives from a non-templated abstract class.
How do I then cast a base class pointer to a <templated> derived class
pointer in a generalised fashion?
Here's what I'm generally trying to achieve:
I'm building (trying to anyway) a serialization library. Here's my design:
|
by: Chris Schadl |
last post by:
Hi,
I'm working on writing a templated Binary Search Tree class in C++. In
regular C, I would have functions which traverse the tree take a pointer
to a user-defined function as an argument, which would then execute the
user-defined function for each node that is "visited". For example:
/* in the BST header file */
/* I actually don't...
|
by: FP |
last post by:
I have a function that returns a base class pointer as in:
baseClass<T>* FunctionA( );
As you can see the baseClass is templated. FunctionA is found in a
third templated class.
What I'm trying to do is on the other side of things "catch" the
returned value as the derived class. My call looks liked this:
|
by: Albert |
last post by:
Hi,
I need to pass a pointer-to-member-function as a parameter to a function
which takes pointer-to-function as an argument. Is there any way to do it
besides overloading the function?
Here is a small program I wrote to check if I could get the address of the
function from the member-function-pointer, so that I could pass it to the...
|
by: shaun |
last post by:
Dear all,
I realized an error in a previous post, I reproduce it here because I'm
still not sure how to solve it:
I want to make a templated function which points to one-past-the-end of
a simple array, to pass to a range constructor for a const vector.
Here is some demonstration code:
#include <iostream>
using namespace std;
| |
by: Anonymous |
last post by:
template<class T>
class A
{
public:
A() {
T * object = new T(this); //passing instance as parent of nested class
m_obj.push_back(object);
}
~A() {
|
by: domehead100 |
last post by:
I have a templated class, CDerived:
template <typename TValue, typename TDraw, typename TEdit ...>
class CDerived : public CBase
{
TValue m_Value
public:
TValue& GetValue() const
{
|
by: Tim Frink |
last post by:
Hi,
I'm experimenting with function pointers and found
two questions. Let's assume this code:
1 #include <iostream>
2 class A;
3
4 ////////////////////////////////////////////
5 class B
|
by: Juha Nieminen |
last post by:
I asked a long time ago in this group how to make a smart pointer
which works with incomplete types. I got this answer (only relevant
parts included):
//------------------------------------------------------------------
template<typename Data_t>
class SmartPointer
{
Data_t* data;
void(*deleterFunc)(Data_t*);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |