negative dispids
Dicky Singh -- Dicky@landmark.com
Thursday, February 29, 1996
I was aware of negative dispids in the range -1 through -n where (n < 10). Oh,
before I forget,
ENV: MSDEV 4.0, 95; MSDEV 4.0 NT 351 w/ sp3 etc.
Recently I came across DISPIDS in range DISPID_AUTOSIZE (-500)
to DISPID_AMBIENT_APPEARANCE (-716).
Now the controls I am using Chart FX and MS grid don't support these,
causing:
Warning: constructing COleException, scode = DISP_E_MEMBERNOTFOUND ($80020003).
First-chance exception in RunningReport.exe (MFCO40D.DLL): 0xE06D7363: Microsoft C++ Exception.
The first line was output just before the throw statement and the second in the catch block.
Question: Do I need to worry about these?
You'll only see these if you use the create methods for the OLE controls.
(i.e. you will NOT see these, if you drag a OLE control to the dialog box and let
the dialogbox startup code create controls for you. The exceptions will occur
in either case but are not output when the code resides in the dialogbox startup
code). Use something like:
m_Grid.Create("Grid", WS_CHILD,
CRect(0,0, 0, 0), this, IDC_GRID); // sized on OnSize
m_Chart.Create("Chart", WS_CHILD,
CRect(0,0, 0, 0), this, IDC_CHART); // sized on OnSize
My assumption is controls implemented using MFC Control Wizard
will get automatic support for them and the MS grid and chart FX
where not implemented using MFC Control Wiz. Correct me.
------------------------------
// Dicky
// Dicky@Landmark.com
John & Annette Elsbree -- elsbree@msn.com
Saturday, March 02, 1996
[Mini-digest: 2 responses]
Dicky -
Don't worry about the messages. They simply indicate that a control is trying
to access an ambient property that the container doesn't happen to support.
When an attempt is made to access a property that doesn't exist, MFC
internally throws an exception, which is later caught and handled by the
calling code.
Why does it happen with some controls and not others? It all depends on which
ambient properties the controls are requesting from their containers.
Evidently, the Chart FX and MS grid controls are requesting some ambient
properties that other controls aren't. No harm done, as long as the controls
know how to recover gracefully in the absence of a particular ambient
property.
John
-----From: "Mike Blaszczak"
Boy, I really screwed that one up. Well-known _properties_ have positive
DISPIDs. Well-known _events_ have the negative DISPIDs. Ambient properties
have negative DISPIDs, too.
.B ekiM
----------
From: Mike Blaszczak[SMTP:mikeblas@nwlink.com]
Sent: Saturday, March 02, 1996 21:35
To: mfc-l@netcom.com
Subject: RE: negative dispids
---------
From: owner-mfc-l@netcom.com on behalf of Dicky Singh
Sent: Thursday, February 29, 1996 08:00
> Oh, before I forget, ENV: MSDEV 4.0, 95; MSDEV 4.0 NT 351 w/ sp3 etc.
Thanks.
> Recently I came across DISPIDS in range DISPID_AUTOSIZE (-500)
> to DISPID_AMBIENT_APPEARANCE (-716).
This range includes OLE control properties, and ambient properties made
available to OLE controls by their containers.
> Now the controls I am using Chart FX and MS grid don't support these,
Not all controls support all properties. Not all containers support all
ambients.
> The first line was output just before the throw statement and the second in
the catch block.
> Question: Do I need to worry about these?
Do you care about the property inovled in that situation? IF so, then you
need to worry about the error message. If not, then you don't need to worry
about the message--but you might want to consider not setting that property of
the control... or consider fixing your container so that it provides the
ambient that the control can't find.
> You'll only see these if you use the create methods for the OLE controls.
> (i.e. you will NOT see these, if you drag a OLE control to the dialog box
and let
> the dialogbox startup code create controls for you. The exceptions will
occur
> in either case but are not output when the code resides in the dialogbox
startup
> code). Use something like:
> m_Grid.Create("Grid", WS_CHILD,
> CRect(0,0, 0, 0), this, IDC_GRID); // sized on OnSize
> m_Chart.Create("Chart", WS_CHILD,
> CRect(0,0, 0, 0), this, IDC_CHART); // sized on OnSize
Why are you using Create() and not CreateControl()? How does m_Grid know what
OLE control you want to create? That is, how do you connect the m_Grid
COleControl object to the CLSID or ProgID for the control you want to create?
> My assumption is controls implemented using MFC Control Wizard
> will get automatic support for them and the MS grid and chart FX
> where not implemented using MFC Control Wiz. Correct me.
Support for what? There are _lots_ of properties in the DISPID range you
name, and some of them are actually implemented by the container, not the
control. As such, the ControlWizard certainly doesn't implement them. For the
control properties, again, most properties are optional and don't need to be
implemented.
.B ekiM
TCHAR szTomPetty[] = _T("I'm a boy in short pants.");
Dicky Singh -- Dicky@landmark.com
Monday, March 04, 1996
Thanks John.
On a call to a CreateControl( ), COleControlSite::SetWindowText is
called, which calls SetProperty with a dispid of -518 where,
DSPID_CAPTION = -518. It is easier to just look at the stack
(see below.)
(It is evident that I am not using an implicit property call that can
be avoided.)
John, clear this:
>>They simply indicate that a control is trying
>>to access an ambient property that the container
>>doesn't happen to support.
Is it wrong to say that the container is trying to set an unsupported
property on the control.
Anyway, It is good to know I don't have to worry about the
messages.
-------------------------------
AfxThrowOleException(long -2147352573) line 417
COleDispatchDriver::InvokeHelperV(long -518, unsigned short 4,
unsigned short 0, void * 0x00000000,
unsigned char * 0x0065eea8,
char * 0x0065ef04) line 387
COleControlSite::InvokeHelperV(long -518, unsigned short 4,
unsigned short 0,
void * 0x00000000,
unsigned char * 0x0065eea8,
char * 0x0065ef00) line 794
COleControlSite::SetPropertyV(long -518, unsigned short 14,
char * 0x0065ef00) line 816
COleControlSite::SafeSetProperty(COleControlSite * const 0x00673604
{COleControlSite}, long -518) line 858
COleControlSite::SetWindowTextA(char * 0x004198fc) line 962 + 23 bytes
COleControlSite::CreateControl(CWnd * 0x00672c40
{CChartfx hWnd=0x00000560},
const _GUID & {...},
char * 0x004198fc, unsigned long 1073741824,
const tagRECT & {top=0 bottom=0
left=0 right=0},
unsigned int 3000, CFile * ...) line 210
COleControlContainer::CreateControl(CWnd * 0x00672c40 {
CChartfx hWnd=0x00000560},
const _GUID & {...},
char * 0x004198fc,
unsigned long 1073741824,
const tagRECT & {top=0 bottom=0 left=0 right=0},
unsigned int 3000, CFile * ...)
line 141 + 44 bytes
CWnd::CreateControl(const _GUID & {...}, char * 0x004198fc,
unsigned long 1073741824,
const tagRECT & {top=0 bottom=0 left=0 right=0},
CWnd * 0x006729f4 {CClientWnd hWnd=0x00000548},
unsigned int 3000, CFile * 0x00000000 {
hFile=7341157 name=""}, ...) line
CChartfx::Create(char * 0x004198fc, unsigned long 1073741824,
const tagRECT & {top=0 bottom=0 left=0 right=0},
CWnd * 0x006729f4 {CClientWnd hWnd=0x00000548},
unsigned int 3000, CFile * 0x00000000 {hFile=7341157
name=""}, int 0, unsigned short * ...) line
CClientWnd::CreateQBAsAndMarginControl() line 195
CClientWnd::OnCreate(tagCREATESTRUCTA * 0x0065f39c) line 171 + 8 bytes
CWnd::OnWndMsg(unsigned int 1, unsigned int 0, long 6681500,
long * 0x0065f22c) line 1821 + 13 bytes
--------------------
Mike B. in his message 1/2 wrote:
Why are you using Create() and not CreateControl()? How does m_Grid know what
OLE control you want to create? That is, how do you connect the m_Grid
COleControl object to the CLSID or ProgID for the control you want to create?
--------------------
For every Ole control that you insert in the project using the Component Gallery,
VC 40, creates a wrapper effectively hiding from the user whether the control is
a Ole control or a windows control.
class CChartfx : public CWnd { .... };
The overloaded Methods Create() call CreateControl with respective CLSIDs....
CLSID const& GetClsid()
{
static CLSID const clsid
= { 0x8996b0a1, 0xd7be, 0x101b, { 0x86, 0x50, 0x0, 0xaa, 0x0, 0x3a, 0x55, 0x93 } };
return clsid;
}
virtual BOOL Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); }
BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey); }
| Вернуться в корень Архива
|