|
The signatures differ by return type - which isn't the same, nor is it different enough.
Why are they virtual, what behaviour are you expecting ?
How are you planning on using the CreateClone() method(s).
What Ryan and PJ suggest is similar to what is described in the ARM 10.1.1.
If you read ARM 10.1, 10.2, 10.3 i'm sure you'll be able to figure out a soultion.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi, thanks for the reply.
The reason they're virtual is pretty much standard interface inheritance. Instead of clients using a C3DCamera instance directly, they will use it's ICamera interface. I need the clients to not expect a C3DCamera, as I'm extending my application with another class (C2DCamera) that can provide ICamera functionality, but NOT IOrientation. Clients that only use the ICamera interface should be able to use either C2DCamera or C3DCamera interchangably. Does that make sense?
I need both interfaces to expose a CreateClone() method because clients of both interfaces need to be able to make local copies of the instance that's implementing, without knowing the concrete type of the instance.
Unforunately I don't have a copy of ARM at my current workplace. It's not available online, AFAIK. I'll have to bug my boss for a copy, I know it's kinda the bible for C++.
Thanks again for the response,
Pete
|
|
|
|
|
Then you may want to make the return type an argument instead.
e.g.
class ICamera {
public:
virtual bool CreateClone( ICamera* &C ) const = 0;
virtual bool f() = 0;
};
class IOrientation {
public:
virtual bool CreateClone( IOrientation* &O ) const = 0;
virtual bool f() = 0;
};
class C2DCamera : public ICamera, public IOrientation {
public:
virtual bool CreateClone( ICamera* &C ) const { C = new C2DCamera; return(true); }
virtual bool CreateClone( IOrientation* &O ) const { O = new C2DCamera; return(true); }
virtual bool f() { return(true); }
};
class C3DCamera : public ICamera, public IOrientation {
public:
virtual bool CreateClone( ICamera* &C ) const { C = new C3DCamera; return(true); }
virtual bool CreateClone( IOrientation* &O ) const { O = new C3DCamera; return(true); }
virtual bool f() { return(true); }
};
int main(int argc, char* argv[])
{
C2DCamera d2;
C3DCamera d3;
ICamera *i2 = &d2,
*i3 = &d3;
ICamera *c2 = NULL,
*c3 = NULL;
i2->CreateClone(c2);
c2->f();
i3->CreateClone(c3);
c3->f();
return 0;
}<pre>
...cmk
<small>Save the whales - collect the whole set</small>
|
|
|
|
|
Hi,
That'll work! I think I'll implement the CreateClone(...) methods as you suggest.
A shame that standard C++ won't let you explicitly override a specific base class's pure virtual, but that's life I guess. I'm sure there's a good (and suitably obscure) reason for it.
Cheers,
Pete
|
|
|
|
|
Please tell me how can i use USB port in VC++6.Any api aur functions. I Don't want to use ActiveComport.
Humayun AJmal
|
|
|
|
|
yes u can.....u can use the windows driverz for that.....
hope thiz site helpz u.....
http://www.lvr.com/usb.htm[^]
hmmm...i have one project in it...by sending midid data to the windows driver which getz routed to the usb driver..
anywayz .....
just look up the above link...
itz informative.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Hello,
I'm making a dialog-based application and I want to assign a CEdit class to an Edit Box and when I right-click on the control and choose "Add Variable...", I can't assign a control variable because the "Control Variable" checkbox is disabled as well as all the control-related parameters. I can add an "int" or "char" or another standard type but I connot add a control variable. Does anyone would know why I can't assign a control variable to my Edit Box??
Thanks in advance,
Veronique
|
|
|
|
|
Is this with Visual Studio v6? If so, I'm not seeing the same thing you are (e.g., where do you right-click on the control).
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
It is with Visual Studio .NET (v7).
|
|
|
|
|
Are you positive you don't already have a CEdit member variable for that control?
|
|
|
|
|
Hi!
Yes, I'm positive I don't have a CEdit member variable for that control... but now I found the problem. The problem is (was) in the .vcproj project file. In the <Globals> section, the RESOURCE_FILE Value was set to the wrong .rc file. I was trying to assign a member variable to a control that wasn't defined in the specified .rc file. I set the correct .rc file in the .vcproj file and now I can do what I wanted to do.
Here is the <Globals> section of the .vcproj file.
<Globals>
<Global
Name="RESOURCE_FILE"
Value="WX.rc"/>
</Globals>
Thank you all for trying to help me!!
Bye!
Véronique
|
|
|
|
|
Hello Veronique,
It is not hard to do it by hand as well.
- Add the control variable to your dialog header file(
CEdit m_myEdit; ) - On your implementation file, add a line to the DoDataExchange method (
DDX_Control(pDX, IDC_MY_EDIT, m_myEdit); , where IDC_MY_EDIT is the ID of the Edit Box) - On your code now you can use the m_myEdit for controlling the edit box. (
m_myEdit.SetWindowText("bla bla bla"); )
Hope this helps.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
Ok, I'm trying to take this code apart and understand it
http://www.codeproject.com/threads/killprocess.asp
The code is at the bottom.
Now with the TerminateProcess function
bResult = TerminateProcess(hProcess,0);
What are the parameters that it takes, is 0 the PID?
Thanks
|
|
|
|
|
0 is the exit code.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
What other exit codes are there,
and with the first argument for the terminate process function.
I tired the code and for this segment
HANDLE hProcess = FindProcess(pstrProcessName,
dwId);
I get a compiling error saying it can't find the function FindProcess.
This is going to show how little I know about windows coding but what is a HANDLE?
Thankss
|
|
|
|
|
superstar4410 wrote:
What other exit codes are there,
Exit codes are application specific, with 0 usually indicating success.
superstar4410 wrote:
I get a compiling error saying it can't find the function FindProcess.
I cannot find it in MSDN. Do you know it to exist?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
FindProcess() is a private method of the CKillProcess class. It can only be used within a CKillProcess object.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
where do I find the code to the CKillprocess class?
|
|
|
|
|
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i'm confused, the link just takes me to the discussion board
|
|
|
|
|
You referenced an article by Eugene Polonsky. The source code is in that article.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello,
I have a CFormView in which i have a tabcontrol with two tabs and there are two dialog boxes which act as the pages for the tabs. Inside these dialog boxes i have added a CListCtrl which i would like to populate with data. These two dialog boxes have their own classes and I have added a variable to each of these dialog boxes pointing to the CListCtrl. However when i want to use this variable inside the Dialog class to populate the CListCtrl I notice that the CListCtrl hWnd = 0x00000000. I think this is the problem and does anyone know how to fix it?
thanks,
Lino
|
|
|
|
|
Do you have an entry for the list control in the dialog's DoDataExchange() method? At what point are you trying to populate the list control?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
here it is:
the base code for this is from something published by Ben Hill on CTabCtrl applications.
//*View.h
CMyTabCtrl m_tabMyTabCtrl;
In OnInitialUpdate in my *View.cpp
void CTestTabCtrlThreeView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_tabMyTabCtrl.InsertItem(0, _T("Tab One"));
m_tabMyTabCtrl.InsertItem(1, _T("Tab Two"));
m_tabMyTabCtrl.Init();
}
//Init is a member function of the CMyTabCtrl Class
void CMyTabCtrl::Init(void)
{
m_tabCurrent=0;
m_tabPages[0]->Create(IDD_TAB_ONE, this);
m_tabPages[1]->Create(IDD_TAB_TWO, this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
SetRectangle();
}
void CMyTabCtrl::SetRectangle(void)
{
CRect tabRect, itemRect;
int nX, nY, nXc, nYc;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
nX=itemRect.left;
nY=itemRect.bottom+1;
nXc=tabRect.right-itemRect.left-1;
nYc=tabRect.bottom-nY-1;
m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
for(int nCount=1; nCount < m_nNumberOfPages; nCount++)
{
m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
//below this point is where my code begins
//here i create a tmp object of type CTabOne which is derived from CDialog
CTabOne tmp;
tmp.Populate();
}
//CTabOne is the dialog box created to work with TabOne of the CTabCtrl
//and it has a data member of type CListCtrl m_TabOneList
void CTabOne::Populate(void)
{
CPersonInfo Person;
m_TabOneList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
//ListView_SetExtendedListViewStyle(rDest.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
//get client rect of list view control
RECT rect;
m_TabOneList.GetClientRect(&rect);
//delete all of the items in teh CListCtrl
//deletes all rows in the CListCtrl before populating
m_TabOneList.DeleteAllItems();
//open CRecordSet
if(Person.IsOpen())
Person.MoveFirst();
else
Person.Open();
//test to see if there are zero columns
if(m_TabOneList.GetHeaderCtrl()->GetItemCount() == 0)
{
//insert column headings
//rDest.InsertColumn(
m_TabOneList.InsertColumn(0, "First", LVCFMT_LEFT, rect.right/2);
m_TabOneList.InsertColumn(1, "Last", LVCFMT_LEFT, rect.right/2);
}
//loop to add rows to listview control
while(Person.IsEOF() == false)
{
//add each row
int row = m_TabOneList.InsertItem(m_TabOneList.GetItemCount(),Person.m_FirstName);
//set next column item
m_TabOneList.SetItemText(row, 1, Person.m_LastName);
//assign the row to an invisible column
m_TabOneList.SetItemData(row, Person.m_ID);
//move to next row
Person.MoveNext();
}
}
void CTabOne::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_TabOneList);
}
hope this helps.
Thanks for your Help.
Lino
|
|
|
|