|
sohailkadiwala wrote:
Hi all,
Someone please explain me why COM doesnot support Multiple Inheritance incase of Interfaces
I mean why I shouldn't have
IDerived:IBase1,IBase2
I did read about it in Don Box book, but I would appreciate if someone explains it in detail (A link to some online resource would work fine too )
Com interfaces are required to have a certain binary structure. Specificly, an interface referes to a table (simple array) of function pointers. The first three members of this table are always QueryInterface, AddRef, and Release. Additional interface functions come right after these. Therefore, both IBase1 and IBase2 would have members in the fourth slot (unless one is IUnknown). Multiple inheritence of interfaces would require the fourth slot to contain both the IBase1 member and the *Base2 member, which is not possible.
When you use C++ multiple inheritance with classes that have virtual functions, it creates multiple tables of function pointers. This makes it easy to create an object with multiple interfaces, but isn't useful for creating interfaces with multiple base classes.
It seems to me that what I've explained so far would all be in your book, so please feel free to ask for clarification.
Nathan Holt
|
|
|
|
|
Hi Nathan,
Thanks for the detailed explanation. I agree about the Binary Structure that must be standard for all interfaces and thats why COM avoids multiple inheritance among interfaces
Nathan Holt at CCEI wrote:
Multiple inheritence of interfaces would require the fourth slot to contain both the IBase1 member and the *Base2 member, which is not possible
Can you please explain me more on this. I am confused abt the above quote. What I know is there can be multiple inheritance possible among structures. COM interface is nothing but a Structure. So why would it be not possible to have multiple inhertance amongst interface ?
Thanks again
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
modified 21-Apr-21 21:01pm.
|
|
|
|
|
sohailkadiwala wrote:
Can you please explain me more on this. I am confused abt the above quote. What I know is there can be multiple inheritance possible among structures. COM interface is nothing but a Structure. So why would it be not possible to have multiple inhertance amongst interface ?
Sure. Multiple inheritance in C++ can rely on detailed information about the object. If both base classes have virtual functions, then the derived class will have two pointers to two different virtual function tables. (The virtual function tables are the tables I described in the previous message.) I don't know if C++ specifies the order the pointers occur in, and I'm pretty sure it doesn't specify how far apart the pointers are. This would make it difficult to specify a binary standard for multiple inheritance in interfaces.
In practice, I suspect that Microsoft could have defined their own standards for windows C++ compilers that would have made multiple inheritance of interfaces possible, but they didn't. In fact, there are a disturbing number of people who seem to think multiple inheritance was a mistake.
Nathan Holt
|
|
|
|
|
Thanks Nathan.
Very informative. Helped me understand the concept in a much better way.
Thanks Again
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I've created a get / put property inside an activeX control. I know the functionality is working ok because i've tested it with script <param =="" />
What i now need to do is copy the BSTR into a char* or c style array.
I've tried:
char str[MAX_PATH];
CComBSTR m_bstrString;
put:
ATLTRACE(_T("String assigned to: %ls\n"),newVal);
m_bstrFileString = newVal; //assign btr to CComBSTR
//do conversion
BSTR var = m_bstrString.Copy();
strcat(str,(LPCTSTR)var);
It only seems to be copying the first char?
Please help
|
|
|
|
|
|
The following line has undefined variable m_bstrFileString (could be typo)
m_bstrFileString = newVal; //assign btr to CComBSTR
Note : W2A macros has limitation, can not be used in loop. It can convert max 500KB of chars
One more soln would be using _bstr_t class..
For Ex:
char str[MAX_PATH];
_bstr_t str1(newVal);
strcpy(str,(char *)str1);
Sandeep Naik
|
|
|
|
|
thanks i will try that.
Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.
|
|
|
|
|
thanks i will try that.
Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.
|
|
|
|
|
|
thanks i will try that.
Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.
|
|
|
|
|
Hi, i've just created an ATL dll which houses a full control for activeX support.
Basically it's working ok.
However i need to run some code once the control has been installed successfully. (after Register server)
This control is windowless.
In an MFC based control i could use something like OnCreate() but i don't have a clue where to start here.
I basically need an event that gets called once the control is installed.
Please Help
Thanks in advance!!!
Carl
|
|
|
|
|
|
Hello
Every time I try to create a RichEdit (using CRichEditCtrl), Create fails and GetLastError returns either ERROR_CANNOT_FIND_WND_CLASS or ERROR_CLASS_DOES_NOT_EXIST. I looked in the CRichEditCtrl class and the window class seems to be "RICHEDIT". Has anyone else had this problem or am I just doing something wrong? (When I use MFC, it works fine.)
|
|
|
|
|
|
|
Hi,All,I am developing an ACTIVEX control embedded in IE, which is used to display continuous jpegs captured from a server.Firstly I wrote my ACTIVEX control in MFC,and call InvalidateControl() to realize control window redraw.It is ok.Then I rewrote my ACTIVEX in ATL,most of the code regards to grapic are same,but this time since InvalidateControl() can not be called in ATL based control, I call FireViewChange() to realize control window redraw time by time.However,I found that the control window got flicker when it is redraw.What happened and how to deal with?
please contact:
max_xiayi@hotmail.com
|
|
|
|
|
FireViewChange() calls InvalidateRect with bErase=TRUE. You'll need to write your own FireViewChange() and pass FALSE for bErase.
<br />
inline HRESULT CComControlBase::FireViewChange()<br />
{<br />
if (m_bInPlaceActive)<br />
{<br />
if (m_hWndCD != NULL)<br />
::InvalidateRect(m_hWndCD, NULL, TRUE);
else if (m_spInPlaceSite != NULL)<br />
m_spInPlaceSite->InvalidateRect(NULL, TRUE);
}<br />
else
SendOnViewChange(DVASPECT_CONTENT);<br />
return S_OK;<br />
}<br />
Todd Smith
|
|
|
|
|
Having the same problem here. I have tried the above suggestion but it has not worked. I still get flickering. I have also user temporary DC buffer to do all the drawing onto before copying the buffer to the final output in one step.
Anybody come up with another way arround this?
Thanks,
Aristotel
|
|
|
|
|
Anyone?
|
|
|
|
|
Ok...quite embarrasing but basically I had forgotten to add
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
So onEraseBkgnd was not being called at all. Silly me...
|
|
|
|
|
Hi
I create in VC.7 an control and when one of property change it affected other,
and container should change this second property also.But when i test
my control in VB.NET affected property not changed(in property window),althoughi invoke FireOnChange for one.
<br />
class ATL_NO_VTABLE CMyControl : <br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CStockPropImpl<CMyControl, IDigDisplay><br />
public IPersistStreamInitImpl<CMyControl>,<br />
public IOleControlImpl<CMyControl>,<br />
public IOleObjectImpl<CMyControl>,<br />
public IOleInPlaceActiveObjectImpl<CMyControl>,<br />
public IViewObjectExImpl<CMyControl>,<br />
public IOleInPlaceObjectWindowlessImpl<CMyControl>,<br />
public IConnectionPointContainerImpl<CMyControl>,<br />
public IPropertyNotifySinkCP<CMyControl>,<br />
public CProxy_IDigDisplayEvents<CMyControl>, <br />
public IPersistStorageImpl<CMyControl>,<br />
public ISpecifyPropertyPagesImpl<CMyControl>,<br />
public IQuickActivateImpl<CMyControl>,<br />
public IDataObjectImpl<CMyControl>,<br />
public IProvideClassInfo2Impl<&CLSID_CMyControl, &__uuidof(_IMyControlEvents), &LIBID_MyControlLib>,<br />
public CComCoClass<CDigDisplay, &CLSID_CMyControl>,<br />
public CComControl<CMyControl><br />
{<br />
..<br />
}<br />
<br />
<br />
CMyControl()::put_FirstProperty(short newVal)<br />
{<br />
m_firstValue = newVal;<br />
m_secondValue = newVal + 1;<br />
<br />
FireOnChanged(1);<br />
FireOnChanged(2);<br />
}<br />
<br />
...<br />
<br />
CMyControl()::put_SecondProperty(short newVal)<br />
{<br />
m_secondValue = newVal;<br />
FireOnChanged(2);<br />
}<br />
<br />
CMyControl()::get_SecondProperty(short* pVal)<br />
{<br />
*pVal = m_secondValue;<br />
}<br />
<br />
Thats i miss here???
Thank
|
|
|
|
|
I am trying to develop the gird control in which Comboboxes are displayed over each subitem.
In DrawItem event i am displaying the combobox for each subitem, which is i think cause the flickering problem. Anyone knows the solution to remove the flickering in this scenario.
<br />
for(int nRow = 0; nRow < rows; ++ nRow)<br />
{<br />
<br />
for(int nCol = 0; cols; nCol++ )<br />
{<br />
}<br />
}<br />
|
|
|
|
|
While I've never had to do what you're doing, two things come to mind
1. Queue up the display of multiple windows with DeferWindowPos()
2. In the parent, change the erase background code to create a region that exclude the area of the child windows - I neat trick for dealing with excessive flickering when resizing a dialog.
I hope this helps
[ Jason De Arte | Toy Maker | 1001010.com ]
|
|
|
|
|
Jason De Arte wrote:
2. In the parent, change the erase background code to create a region that exclude the area of the child windows - I neat trick for dealing with excessive flickering when resizing a dialog.
Isn't WS_CLIPCHILDREN supposed to do this... I've a couple of dialogs which I want flicker free. WS_CLIPCHILDREN doesn't always help me. Say, you don't have a small dialog sample anywhere you'd like to show me, or better yet, write an article about it?
--
Arigato gozaimashita!
|
|
|
|