N
Neil Stevens
Hi,
Not too sure if this is the write place to post this, im sure someone will
correct me if im in the wrong place.
I have been developing a C# DLL component based on the WBCustomizer object
from microsoft.
The problem i have reached is that i want to be able to fire KeyUp, KeyPress
and KeyDown events from the TranslateAccelerator method. The reason for this
is as follows, i am disabling certain accelerator keys (Ctrl+5, Ctrl+F5,
etc...), these accelerator key presses are eaten up by translate accelerator
because they are disabled, but i still need to access these key presses as
my application uses them in a number of ways.
I can modify the translate accelerator to check the KeyDown, KeyPress and
KeyUp messages but i need to raise these events back to the caller (i guess
in this case that means the web browser or document).
I have seen some code in C++ but as i am not a C++ developer i do not
understand what is going on, could anyone possibly help me with translating
the C++, and what equivelants there are in C#.
VOID Fire_KeyPress(SHORT KeyCode)
{
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections;
nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
pvars[0] = KeyCode;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&disp, NULL, NULL, NULL);
}
}
delete[] pvars;
}
Thanks in advance for your help
Regards
Neil
Not too sure if this is the write place to post this, im sure someone will
correct me if im in the wrong place.
I have been developing a C# DLL component based on the WBCustomizer object
from microsoft.
The problem i have reached is that i want to be able to fire KeyUp, KeyPress
and KeyDown events from the TranslateAccelerator method. The reason for this
is as follows, i am disabling certain accelerator keys (Ctrl+5, Ctrl+F5,
etc...), these accelerator key presses are eaten up by translate accelerator
because they are disabled, but i still need to access these key presses as
my application uses them in a number of ways.
I can modify the translate accelerator to check the KeyDown, KeyPress and
KeyUp messages but i need to raise these events back to the caller (i guess
in this case that means the web browser or document).
I have seen some code in C++ but as i am not a C++ developer i do not
understand what is going on, could anyone possibly help me with translating
the C++, and what equivelants there are in C#.
VOID Fire_KeyPress(SHORT KeyCode)
{
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections;
nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
pvars[0] = KeyCode;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&disp, NULL, NULL, NULL);
}
}
delete[] pvars;
}
Thanks in advance for your help
Regards
Neil