Overridden functions for IAccessible interface do not work in cwnd-drived class

I have a button called CWnd -derived class named and want to use the CWnd accessibility CWnd , I redefine this function in my class:

 virtual HRESULT get_accName(VARIANT varChild, BSTR *pszName); virtual HRESULT get_accChildCount(long *pcountChildren); virtual HRESULT get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction); virtual HRESULT get_accDescription(VARIANT varChild, BSTR *pszDescription); virtual HRESULT get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut); virtual HRESULT get_accParent(IDispatch **ppdispParent); virtual HRESULT get_accRole(VARIANT varChild, VARIANT *pvarRole); virtual HRESULT get_accState(VARIANT varChild, VARIANT *pvarState); virtual HRESULT get_accValue(VARIANT varChild, BSTR *pszValue); 

When I run the program and set a break in the implementation of any of these functions, the program does not introduce these functions and instead uses the parent function, can someone help me?

get_accName implementation:

 HRESULT Button::get_accName(VARIANT varChild, BSTR *pszName) { //*pszName = SysAllocString(lpstrTitle); return S_OK; } 

I call EnableActiveAccessibility() in the constructor of this class, but it still does not work.

+6
source share
2 answers

Have you tried something like:

 class CWnd { virtual HRESULT get_accChildCount(long *pcountChildren); }; class Button : public CWnd { virtual HRESULT get_accChildCount(long *pcountChildren) { HRESULT childCount = CWnd:get_accChildCount(long *pcountChildren); //you can use the value from the ancestor class if it is of any use //to you or add your own code childCount = 1234; return childCount; } }; 
0
source

You may be misusing these redundant methods. Try renaming override. This can make everything clearer and indicate that something is wrong. The following is an example implementation.

 ref class Base { public: virtual void Boo() { Show("Base::Boo"); } }; ref class Derived : Base { public: //Overrides Base::Boo virtual void Woo() = Base::Boo { Show("Derived::Woo"); } }; 

Call it like:

 void _tmain() { Base* r = new Derived(); Derived* d = dynamic_cast<Derived*>(r); d->Woo(); } 

From CodeProjects

0
source

Source: https://habr.com/ru/post/915358/


All Articles