Outlook eating up delete keypress Options

Status
Not open for further replies.
R

Reinwald

Our VB6.0 Outlook addin loads a panel (written in VC++) containing an

internet explorer control in both the inspector and explorer views.

The internet explorer control displays an HTML file with a simple text

input. We faced similar issues with the backspace and delete key

events being eaten up by Outlook and not forwarded to the text input.

So we tried out a solution similar to the one posted by you, where we

used SetWindowsHookEx to catch the delete and backspace keypress

events and send appropriate messages to the panel window. While this

does seem to work for backspace in both the explorer and inspector

views, the delete keypress event *still* seems to be eaten up by

Outlook. This is what our callback for the SetWindowsHookEx looks

like :

LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM

lParam){

LRESULT lRes;

KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;

if ( pkbhs->vkCode == VK_DELETE || pkbhs->vkCode == VK_BACK)

{

if(outlook_mainwindow_Handle)

{

HWND panel = FindWindowEx(outlook_mainwindow_Handle,

NULL, NULL, _T

("PanelDialog"));

if (panel)

{

HWND hWndCtl = ::GetFocus();

if:):IsChild(panel, hWndCtl))

{

if (wParam == WM_KEYDOWN)

{

::SendMessage(hWndCtl,

WM_KEYDOWN, pkbhs->vkCode, 0);

}

return 1;

}

}

}

}

lRes = CallNextHookEx (0, nCode, wParam, lParam);

return lRes;

}

Any idea how we can get the delete key working?
 
D

Dmitry Streblechenko

I have no problem with the following hook in Outlook (Delphi):

initialization

g_hook := SetWindowsHookEx(WH_GETMESSAGE, RAHLEditorHookProc, 0,

GetCurrentThreadId());

finalization

UnhookWindowsHookEx(g_hook);

end.

var g_hook : HHOOK;

function RAHLEditorHookProc(Code : integer; wParam : WPARAM; lParam :

LPARAM):LResult;stdcall;

var pMsg : ^TMsg;

//ClassName:string;

Ctrl{, NextCtrl} : TWinControl;

ParentFrm : TCustomForm;

begin

pMsg:=pointer(lParam);

if ((wParam and PM_REMOVE) = PM_REMOVE) then begin

if (pMsg.message >= WM_KEYFIRST) and (pMsg.message <= WM_KEYLAST)

then begin

if ((pMsg.message = WM_KEYDOWN) or (pMsg.message = WM_KEYUP)) and

(pMsg.wParam <> VK_RETURN) and //ignore "Return" keys

((pMsg.wParam = VK_BACK) or (pMsg.wParam = VK_DELETE) or

(pMsg.wParam = VK_TAB) or (pMsg.wParam = VK_SPACE) or

//(pMsg.wParam = VK_LEFT) or (pMsg.wParam = VK_RIGHT) or

(GetKeyState(VK_CONTROL) < 0) or //Control key

(GetKeyState(VK_MENU) < 0) or //Alt key

((pMsg.lParam and (1 shl 24)) <> 0) or //extended key

{(pMsg.wParam = VK_RETURN) or} (pMsg.wParam = VK_UP) or

(pMsg.wParam = VK_DOWN))

then begin

//SetLength(ClassName, 1024);

//SetLength(ClassName, GetClassName(pMsg.hwnd, PChar(ClassName),

Length(ClassName)));

//if (ClassName = 'TRAHLEditor') then begin

Ctrl:=FindDelphiControl(pMsg.hwnd);

if Ctrl <> nil then begin //is it a Delphi control?

if (pMsg.wParam = VK_TAB) then begin

if (pMsg.message = WM_KEYDOWN) then begin

ParentFrm:=GetParentForm(Ctrl);

if ParentFrm <> nil then begin

TCheatControl(ParentFrm).SelectNext(Ctrl, true, true);

//PostMessage(ParentFrm.Handle, WM_NEXTDLGCTL, 0, 0);

end;

end;

end

else begin

TranslateMessage(pMsg^);

SendMessage(pMsg.hwnd, pMsg.message, pMsg.wParam, pMsg.lParam);

end;

pMsg.message :=WM_NULL;

end;

end

end

end;

Result:=CallNextHookEx(g_hook, Code, wParam, lParam);

end;

Dmitry Streblechenko (MVP)

-

"Reinwald" <Reinwald> wrote in message

news:A193AE22-EBAD-4544-92B3-90A570FFC496@microsoft.com...
> Our VB6.0 Outlook addin loads a panel (written in VC++) containing an
> internet explorer control in both the inspector and explorer views.
> The internet explorer control displays an HTML file with a simple text
> input. We faced similar issues with the backspace and delete key
> events being eaten up by Outlook and not forwarded to the text input.
> So we tried out a solution similar to the one posted by you, where we
> used SetWindowsHookEx to catch the delete and backspace keypress
> events and send appropriate messages to the panel window. While this
> does seem to work for backspace in both the explorer and inspector
> views, the delete keypress event *still* seems to be eaten up by
> Outlook. This is what our callback for the SetWindowsHookEx looks
> like :

> LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM
> lParam){
> LRESULT lRes;
> KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;

> if ( pkbhs->vkCode == VK_DELETE || pkbhs->vkCode == VK_BACK)
> {
> if(outlook_mainwindow_Handle)
> {
> HWND panel =
> FindWindowEx(outlook_mainwindow_Handle,
> NULL, NULL, _T
> ("PanelDialog"));

> if (panel)
> {
> HWND hWndCtl = ::GetFocus();
> if:):IsChild(panel, hWndCtl))
> {

> if (wParam == WM_KEYDOWN)
> {
> ::SendMessage(hWndCtl,
> WM_KEYDOWN, pkbhs->vkCode, 0);
> }
> return 1;
> }
> }
> }
> }

> lRes = CallNextHookEx (0, nCode, wParam, lParam);
> return lRes;

> }

> Any idea how we can get the delete key working?

>
 
R

Reinwald

Hey,

We tried using TranslateMessage(message) and then calling sendmessage ,but

it stills doesnt work.

Using spy ++ i monitored the keystrokes and i clearly see the after

installing our hook the delete message goes to the appropriate window but

somehow i feel outlook is eating up the delete key.

To confirm my doubt i even mapped the delete key to another key say "?" and

when i press the delete key the "?" symbol gets printed .

As i mentioned before this hook works for the backspace key which prior to

this wasnt working.Any other suggestion to get the delete key working?

Thanks

"Dmitry Streblechenko" wrote:


> I have no problem with the following hook in Outlook (Delphi):

> initialization
> g_hook := SetWindowsHookEx(WH_GETMESSAGE, RAHLEditorHookProc, 0,
> GetCurrentThreadId());
> finalization
> UnhookWindowsHookEx(g_hook);
> end.

> var g_hook : HHOOK;
> function RAHLEditorHookProc(Code : integer; wParam : WPARAM; lParam :
> LPARAM):LResult;stdcall;
> var pMsg : ^TMsg;
> //ClassName:string;
> Ctrl{, NextCtrl} : TWinControl;
> ParentFrm : TCustomForm;
> begin
> pMsg:=pointer(lParam);
> if ((wParam and PM_REMOVE) = PM_REMOVE) then begin
> if (pMsg.message >= WM_KEYFIRST) and (pMsg.message <= WM_KEYLAST)
> then begin
> if ((pMsg.message = WM_KEYDOWN) or (pMsg.message = WM_KEYUP)) and
> (pMsg.wParam <> VK_RETURN) and //ignore "Return" keys
> ((pMsg.wParam = VK_BACK) or (pMsg.wParam = VK_DELETE) or
> (pMsg.wParam = VK_TAB) or (pMsg.wParam = VK_SPACE) or
> //(pMsg.wParam = VK_LEFT) or (pMsg.wParam = VK_RIGHT) or
> (GetKeyState(VK_CONTROL) < 0) or //Control key
> (GetKeyState(VK_MENU) < 0) or //Alt key
> ((pMsg.lParam and (1 shl 24)) <> 0) or //extended key
> {(pMsg.wParam = VK_RETURN) or} (pMsg.wParam = VK_UP) or
> (pMsg.wParam = VK_DOWN))
> then begin
> //SetLength(ClassName, 1024);
> //SetLength(ClassName, GetClassName(pMsg.hwnd, PChar(ClassName),
> Length(ClassName)));
> //if (ClassName = 'TRAHLEditor') then begin
> Ctrl:=FindDelphiControl(pMsg.hwnd);
> if Ctrl <> nil then begin //is it a Delphi control?
> if (pMsg.wParam = VK_TAB) then begin
> if (pMsg.message = WM_KEYDOWN) then begin
> ParentFrm:=GetParentForm(Ctrl);
> if ParentFrm <> nil then begin
> TCheatControl(ParentFrm).SelectNext(Ctrl, true, true);
> //PostMessage(ParentFrm.Handle, WM_NEXTDLGCTL, 0, 0);
> end;
> end;
> end
> else begin
> TranslateMessage(pMsg^);
> SendMessage(pMsg.hwnd, pMsg.message, pMsg.wParam, pMsg.lParam);
> end;
> pMsg.message :=WM_NULL;
> end;
> end
> end
> end;
> Result:=CallNextHookEx(g_hook, Code, wParam, lParam);
> end;

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "Reinwald" <Reinwald> wrote in message
> news:A193AE22-EBAD-4544-92B3-90A570FFC496@microsoft.com...
> > Our VB6.0 Outlook addin loads a panel (written in VC++) containing an
> > internet explorer control in both the inspector and explorer views.
> > The internet explorer control displays an HTML file with a simple text
> > input. We faced similar issues with the backspace and delete key
> > events being eaten up by Outlook and not forwarded to the text input.
> > So we tried out a solution similar to the one posted by you, where we
> > used SetWindowsHookEx to catch the delete and backspace keypress
> > events and send appropriate messages to the panel window. While this
> > does seem to work for backspace in both the explorer and inspector
> > views, the delete keypress event *still* seems to be eaten up by
> > Outlook. This is what our callback for the SetWindowsHookEx looks
> > like :
> > LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM
> > lParam){
> > LRESULT lRes;
> > KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
> > if ( pkbhs->vkCode == VK_DELETE || pkbhs->vkCode == VK_BACK)
> > {
> > if(outlook_mainwindow_Handle)
> > {
> > HWND panel =
> > FindWindowEx(outlook_mainwindow_Handle,
> > NULL, NULL, _T
> > ("PanelDialog"));
> > if (panel)
> > {
> > HWND hWndCtl = ::GetFocus();
> > if:):IsChild(panel, hWndCtl))
> > {
> > if (wParam == WM_KEYDOWN)
> > {
> > ::SendMessage(hWndCtl,
> > WM_KEYDOWN, pkbhs->vkCode, 0);
> > }
> > return 1;
> > }
> > }
> > }
> > }
> > lRes = CallNextHookEx (0, nCode, wParam, lParam);
> > return lRes;
> > }
> > Any idea how we can get the delete key working?
> >


>
 
R

Reinwald

Hey,

The code we tried out after reading your suggestion

llKeyHook = SetWindowsHookEx(WH_GETMESSAGE, GetMessageProc, 0,

GetCurrentThreadId());

LRESULT CALLBACK GetMessageProc(int code, WPARAM wParam, LPARAM lParam)

{

const MSG *pMsg = (MSG *) lParam;

HWND panel = FindWindowEx(application_Handle, NULL, NULL, _T("PanelDialog"));

if (panel)

{

HWND hWndCtl = ::GetFocus();

if:):IsChild(panel, hWndCtl))

{

if (wParam & PM_REMOVE)

{

if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)

{

if (pMsg->message == WM_KEYDOWN &&

(pMsg->wParam == VK_BACK || pMsg->wParam == VK_DELETE))

{

::TranslateMessage(pMsg);

return ::SendMessage(hWndCtl, pMsg->message, pMsg->wParam,

pMsg->lParam);

}

}

}

}

}

return ::CallNextHookEx(0, code, wParam, lParam);

}

As i mentioned before this hook works for the backspace key.Any other

suggestion to get the delete key working?

"Dmitry Streblechenko" wrote:


> I have no problem with the following hook in Outlook (Delphi):

> initialization
> g_hook := SetWindowsHookEx(WH_GETMESSAGE, RAHLEditorHookProc, 0,
> GetCurrentThreadId());
> finalization
> UnhookWindowsHookEx(g_hook);
> end.

> var g_hook : HHOOK;
> function RAHLEditorHookProc(Code : integer; wParam : WPARAM; lParam :
> LPARAM):LResult;stdcall;
> var pMsg : ^TMsg;
> //ClassName:string;
> Ctrl{, NextCtrl} : TWinControl;
> ParentFrm : TCustomForm;
> begin
> pMsg:=pointer(lParam);
> if ((wParam and PM_REMOVE) = PM_REMOVE) then begin
> if (pMsg.message >= WM_KEYFIRST) and (pMsg.message <= WM_KEYLAST)
> then begin
> if ((pMsg.message = WM_KEYDOWN) or (pMsg.message = WM_KEYUP)) and
> (pMsg.wParam <> VK_RETURN) and //ignore "Return" keys
> ((pMsg.wParam = VK_BACK) or (pMsg.wParam = VK_DELETE) or
> (pMsg.wParam = VK_TAB) or (pMsg.wParam = VK_SPACE) or
> //(pMsg.wParam = VK_LEFT) or (pMsg.wParam = VK_RIGHT) or
> (GetKeyState(VK_CONTROL) < 0) or //Control key
> (GetKeyState(VK_MENU) < 0) or //Alt key
> ((pMsg.lParam and (1 shl 24)) <> 0) or //extended key
> {(pMsg.wParam = VK_RETURN) or} (pMsg.wParam = VK_UP) or
> (pMsg.wParam = VK_DOWN))
> then begin
> //SetLength(ClassName, 1024);
> //SetLength(ClassName, GetClassName(pMsg.hwnd, PChar(ClassName),
> Length(ClassName)));
> //if (ClassName = 'TRAHLEditor') then begin
> Ctrl:=FindDelphiControl(pMsg.hwnd);
> if Ctrl <> nil then begin //is it a Delphi control?
> if (pMsg.wParam = VK_TAB) then begin
> if (pMsg.message = WM_KEYDOWN) then begin
> ParentFrm:=GetParentForm(Ctrl);
> if ParentFrm <> nil then begin
> TCheatControl(ParentFrm).SelectNext(Ctrl, true, true);
> //PostMessage(ParentFrm.Handle, WM_NEXTDLGCTL, 0, 0);
> end;
> end;
> end
> else begin
> TranslateMessage(pMsg^);
> SendMessage(pMsg.hwnd, pMsg.message, pMsg.wParam, pMsg.lParam);
> end;
> pMsg.message :=WM_NULL;
> end;
> end
> end
> end;
> Result:=CallNextHookEx(g_hook, Code, wParam, lParam);
> end;

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "Reinwald" <Reinwald> wrote in message
> news:A193AE22-EBAD-4544-92B3-90A570FFC496@microsoft.com...
> > Our VB6.0 Outlook addin loads a panel (written in VC++) containing an
> > internet explorer control in both the inspector and explorer views.
> > The internet explorer control displays an HTML file with a simple text
> > input. We faced similar issues with the backspace and delete key
> > events being eaten up by Outlook and not forwarded to the text input.
> > So we tried out a solution similar to the one posted by you, where we
> > used SetWindowsHookEx to catch the delete and backspace keypress
> > events and send appropriate messages to the panel window. While this
> > does seem to work for backspace in both the explorer and inspector
> > views, the delete keypress event *still* seems to be eaten up by
> > Outlook. This is what our callback for the SetWindowsHookEx looks
> > like :
> > LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM
> > lParam){
> > LRESULT lRes;
> > KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
> > if ( pkbhs->vkCode == VK_DELETE || pkbhs->vkCode == VK_BACK)
> > {
> > if(outlook_mainwindow_Handle)
> > {
> > HWND panel =
> > FindWindowEx(outlook_mainwindow_Handle,
> > NULL, NULL, _T
> > ("PanelDialog"));
> > if (panel)
> > {
> > HWND hWndCtl = ::GetFocus();
> > if:):IsChild(panel, hWndCtl))
> > {
> > if (wParam == WM_KEYDOWN)
> > {
> > ::SendMessage(hWndCtl,
> > WM_KEYDOWN, pkbhs->vkCode, 0);
> > }
> > return 1;
> > }
> > }
> > }
> > }
> > lRes = CallNextHookEx (0, nCode, wParam, lParam);
> > return lRes;
> > }
> > Any idea how we can get the delete key working?
> >


>
 
D

Dmitry Streblechenko

So you do see the message and it gets forwarded, right?

Dmitry Streblechenko (MVP)

-

"Reinwald" <Reinwald> wrote in message

news:4751F871-B7CC-4115-93F1-272B3A8AAE3F@microsoft.com...
> Hey,
> The code we tried out after reading your suggestion

> llKeyHook = SetWindowsHookEx(WH_GETMESSAGE, GetMessageProc, 0,
> GetCurrentThreadId());

> LRESULT CALLBACK GetMessageProc(int code, WPARAM wParam, LPARAM lParam)
> {
> const MSG *pMsg = (MSG *) lParam;

> HWND panel = FindWindowEx(application_Handle, NULL, NULL,
> _T("PanelDialog"));

> if (panel)
> {
> HWND hWndCtl = ::GetFocus();

> if:):IsChild(panel, hWndCtl))
> {
> if (wParam & PM_REMOVE)
> {
> if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
> {
> if (pMsg->message == WM_KEYDOWN &&
> (pMsg->wParam == VK_BACK || pMsg->wParam == VK_DELETE))
> {
> ::TranslateMessage(pMsg);
> return ::SendMessage(hWndCtl, pMsg->message, pMsg->wParam,
> pMsg->lParam);
> }
> }
> }
> }
> }

> return ::CallNextHookEx(0, code, wParam, lParam);
> }

> As i mentioned before this hook works for the backspace key.Any other
> suggestion to get the delete key working?

> "Dmitry Streblechenko" wrote:
>
> > I have no problem with the following hook in Outlook (Delphi):
>

>> initialization
> > g_hook := SetWindowsHookEx(WH_GETMESSAGE, RAHLEditorHookProc, 0,
> > GetCurrentThreadId());
> > finalization
> > UnhookWindowsHookEx(g_hook);
> > end.
>

>
>> var g_hook : HHOOK;
> > function RAHLEditorHookProc(Code : integer; wParam : WPARAM; lParam :
> > LPARAM):LResult;stdcall;
> > var pMsg : ^TMsg;
> > //ClassName:string;
> > Ctrl{, NextCtrl} : TWinControl;
> > ParentFrm : TCustomForm;
> > begin
> > pMsg:=pointer(lParam);
> > if ((wParam and PM_REMOVE) = PM_REMOVE) then begin
> > if (pMsg.message >= WM_KEYFIRST) and (pMsg.message <= WM_KEYLAST)
> > then begin
> > if ((pMsg.message = WM_KEYDOWN) or (pMsg.message = WM_KEYUP)) and
> > (pMsg.wParam <> VK_RETURN) and //ignore "Return" keys
> > ((pMsg.wParam = VK_BACK) or (pMsg.wParam = VK_DELETE) or
> > (pMsg.wParam = VK_TAB) or (pMsg.wParam = VK_SPACE) or
> > //(pMsg.wParam = VK_LEFT) or (pMsg.wParam = VK_RIGHT) or
> > (GetKeyState(VK_CONTROL) < 0) or //Control key
> > (GetKeyState(VK_MENU) < 0) or //Alt key
> > ((pMsg.lParam and (1 shl 24)) <> 0) or //extended key
> > {(pMsg.wParam = VK_RETURN) or} (pMsg.wParam = VK_UP) or
> > (pMsg.wParam = VK_DOWN))
> > then begin
> > //SetLength(ClassName, 1024);
> > //SetLength(ClassName, GetClassName(pMsg.hwnd, PChar(ClassName),
> > Length(ClassName)));
> > //if (ClassName = 'TRAHLEditor') then begin
> > Ctrl:=FindDelphiControl(pMsg.hwnd);
> > if Ctrl <> nil then begin //is it a Delphi control?
> > if (pMsg.wParam = VK_TAB) then begin
> > if (pMsg.message = WM_KEYDOWN) then begin
> > ParentFrm:=GetParentForm(Ctrl);
> > if ParentFrm <> nil then begin
> > TCheatControl(ParentFrm).SelectNext(Ctrl, true, true);
> > //PostMessage(ParentFrm.Handle, WM_NEXTDLGCTL, 0, 0);
> > end;
> > end;
> > end
> > else begin
> > TranslateMessage(pMsg^);
> > SendMessage(pMsg.hwnd, pMsg.message, pMsg.wParam,
> > pMsg.lParam);
> > end;
> > pMsg.message :=WM_NULL;
> > end;
> > end
> > end
> > end;
> > Result:=CallNextHookEx(g_hook, Code, wParam, lParam);
> > end;
>

>
>
>
>
>> > > Dmitry Streblechenko (MVP)
> >

> >

> >

> > -
> > "Reinwald" <Reinwald> wrote in message
> > news:A193AE22-EBAD-4544-92B3-90A570FFC496@microsoft.com...
> > > Our VB6.0 Outlook addin loads a panel (written in VC++) containing an
> > > internet explorer control in both the inspector and explorer views.
> > > The internet explorer control displays an HTML file with a simple text
> > > input. We faced similar issues with the backspace and delete key
> > > events being eaten up by Outlook and not forwarded to the text input.
> > > So we tried out a solution similar to the one posted by you, where we
> > > used SetWindowsHookEx to catch the delete and backspace keypress
> > > events and send appropriate messages to the panel window. While this
> > > does seem to work for backspace in both the explorer and inspector
> > > views, the delete keypress event *still* seems to be eaten up by
> > > Outlook. This is what our callback for the SetWindowsHookEx looks
> > > like :
> >> > LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM
> > > lParam){
> > > LRESULT lRes;
> > > KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
> >>> > if ( pkbhs->vkCode == VK_DELETE || pkbhs->vkCode == VK_BACK)
> > > {
> > > if(outlook_mainwindow_Handle)
> > > {
> > > HWND panel =
> > > FindWindowEx(outlook_mainwindow_Handle,
> > > NULL, NULL, _T
> > > ("PanelDialog"));
> >>> > if (panel)
> > > {
> > > HWND hWndCtl = ::GetFocus();
> > > if:):IsChild(panel, hWndCtl))
> > > {
> >>> > if (wParam == WM_KEYDOWN)
> > > {
> > > ::SendMessage(hWndCtl,
> > > WM_KEYDOWN, pkbhs->vkCode, 0);
> > > }
> > > return 1;
> > > }
> > > }
> > > }
> > > }
> >>> > lRes = CallNextHookEx (0, nCode, wParam, lParam);
> > > return lRes;
> >>>> > }
> >>> > Any idea how we can get the delete key working?
> >> >

>

>
>>
 
R

Reinwald

Hey,

In spy ++ when I spied on the internet browser inside our panel I observed

that the keypresses were getting logged

On checking these articles

http://209.85.153.132/translate_c?h...le.com&usg=ALkJrhg1MN57JlpJOKuATZqLfQwGM4i3zQ

http://209.85.153.132/translate_c?h...le.com&usg=ALkJrhg1MN57JlpJOKuATZqLfQwGM4i3zQ

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/3144d41a-c6aa-4069-acff-5f22b66bcd5a

Any idea how to go about this ???

"Dmitry Streblechenko" wrote:


> So you do see the message and it gets forwarded, right?

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "Reinwald" <Reinwald> wrote in message
> news:4751F871-B7CC-4115-93F1-272B3A8AAE3F@microsoft.com...
> > Hey,
> > The code we tried out after reading your suggestion
> > llKeyHook = SetWindowsHookEx(WH_GETMESSAGE, GetMessageProc, 0,
> > GetCurrentThreadId());
> > LRESULT CALLBACK GetMessageProc(int code, WPARAM wParam, LPARAM lParam)
> > {
> > const MSG *pMsg = (MSG *) lParam;
> > HWND panel = FindWindowEx(application_Handle, NULL, NULL,
> > _T("PanelDialog"));
> > if (panel)
> > {
> > HWND hWndCtl = ::GetFocus();
> > if:):IsChild(panel, hWndCtl))
> > {
> > if (wParam & PM_REMOVE)
> > {
> > if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
> > {
> > if (pMsg->message == WM_KEYDOWN &&
> > (pMsg->wParam == VK_BACK || pMsg->wParam == VK_DELETE))
> > {
> > ::TranslateMessage(pMsg);
> > return ::SendMessage(hWndCtl, pMsg->message, pMsg->wParam,
> > pMsg->lParam);
> > }
> > }
> > }
> > }
> > }
> > return ::CallNextHookEx(0, code, wParam, lParam);
> > }
> > As i mentioned before this hook works for the backspace key.Any other
> > suggestion to get the delete key working?
> > "Dmitry Streblechenko" wrote:
> >
> >> I have no problem with the following hook in Outlook (Delphi):
> >
> >> initialization
> >> g_hook := SetWindowsHookEx(WH_GETMESSAGE, RAHLEditorHookProc, 0,
> >> GetCurrentThreadId());
> >> finalization
> >> UnhookWindowsHookEx(g_hook);
> >> end.
> >
> >
> >> var g_hook : HHOOK;
> >> function RAHLEditorHookProc(Code : integer; wParam : WPARAM; lParam :
> >> LPARAM):LResult;stdcall;
> >> var pMsg : ^TMsg;
> >> //ClassName:string;
> >> Ctrl{, NextCtrl} : TWinControl;
> >> ParentFrm : TCustomForm;
> >> begin
> >> pMsg:=pointer(lParam);
> >> if ((wParam and PM_REMOVE) = PM_REMOVE) then begin
> >> if (pMsg.message >= WM_KEYFIRST) and (pMsg.message <= WM_KEYLAST)
> >> then begin
> >> if ((pMsg.message = WM_KEYDOWN) or (pMsg.message = WM_KEYUP)) and
> >> (pMsg.wParam <> VK_RETURN) and //ignore "Return" keys
> >> ((pMsg.wParam = VK_BACK) or (pMsg.wParam = VK_DELETE) or
> >> (pMsg.wParam = VK_TAB) or (pMsg.wParam = VK_SPACE) or
> >> //(pMsg.wParam = VK_LEFT) or (pMsg.wParam = VK_RIGHT) or
> >> (GetKeyState(VK_CONTROL) < 0) or //Control key
> >> (GetKeyState(VK_MENU) < 0) or //Alt key
> >> ((pMsg.lParam and (1 shl 24)) <> 0) or //extended key
> >> {(pMsg.wParam = VK_RETURN) or} (pMsg.wParam = VK_UP) or
> >> (pMsg.wParam = VK_DOWN))
> >> then begin
> >> //SetLength(ClassName, 1024);
> >> //SetLength(ClassName, GetClassName(pMsg.hwnd, PChar(ClassName),
> >> Length(ClassName)));
> >> //if (ClassName = 'TRAHLEditor') then begin
> >> Ctrl:=FindDelphiControl(pMsg.hwnd);
> >> if Ctrl <> nil then begin //is it a Delphi control?
> >> if (pMsg.wParam = VK_TAB) then begin
> >> if (pMsg.message = WM_KEYDOWN) then begin
> >> ParentFrm:=GetParentForm(Ctrl);
> >> if ParentFrm <> nil then begin
> >> TCheatControl(ParentFrm).SelectNext(Ctrl, true, true);
> >> //PostMessage(ParentFrm.Handle, WM_NEXTDLGCTL, 0, 0);
> >> end;
> >> end;
> >> end
> >> else begin
> >> TranslateMessage(pMsg^);
> >> SendMessage(pMsg.hwnd, pMsg.message, pMsg.wParam,
> >> pMsg.lParam);
> >> end;
> >> pMsg.message :=WM_NULL;
> >> end;
> >> end
> >> end
> >> end;
> >> Result:=CallNextHookEx(g_hook, Code, wParam, lParam);
> >> end;
> >
> >
> >
> >
> >
> >> > >> Dmitry Streblechenko (MVP)
> >>

> >>

> >>

> >> -
> >> "Reinwald" <Reinwald> wrote in message
> >> news:A193AE22-EBAD-4544-92B3-90A570FFC496@microsoft.com...
> >> > Our VB6.0 Outlook addin loads a panel (written in VC++) containing an
> >> > internet explorer control in both the inspector and explorer views.
> >> > The internet explorer control displays an HTML file with a simple text
> >> > input. We faced similar issues with the backspace and delete key
> >> > events being eaten up by Outlook and not forwarded to the text input.
> >> > So we tried out a solution similar to the one posted by you, where we
> >> > used SetWindowsHookEx to catch the delete and backspace keypress
> >> > events and send appropriate messages to the panel window. While this
> >> > does seem to work for backspace in both the explorer and inspector
> >> > views, the delete keypress event *still* seems to be eaten up by
> >> > Outlook. This is what our callback for the SetWindowsHookEx looks
> >> > like :
> >> >> > LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM
> >> > lParam){
> >> > LRESULT lRes;
> >> > KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
> >> >> >> > if ( pkbhs->vkCode == VK_DELETE || pkbhs->vkCode == VK_BACK)
> >> > {
> >> > if(outlook_mainwindow_Handle)
> >> > {
> >> > HWND panel =
> >> > FindWindowEx(outlook_mainwindow_Handle,
> >> > NULL, NULL, _T
> >> > ("PanelDialog"));
> >> >> >> > if (panel)
> >> > {
> >> > HWND hWndCtl = ::GetFocus();
> >> > if:):IsChild(panel, hWndCtl))
> >> > {
> >> >> >> > if (wParam == WM_KEYDOWN)
> >> > {
> >> > ::SendMessage(hWndCtl,
> >> > WM_KEYDOWN, pkbhs->vkCode, 0);
> >> > }
> >> > return 1;
> >> > }
> >> > }
> >> > }
> >> > }
> >> >> >> > lRes = CallNextHookEx (0, nCode, wParam, lParam);
> >> > return lRes;
> >> >> >> >> > }
> >> >> >> > Any idea how we can get the delete key working?
> >> >> >
> >
> >>


>
 
R

Reinwald

Hey,

Well this article helped me also and now the keystrokes work on the internet

explorer control.

Also thanks Dmitry for the help.

------------i have pasted the article below ATL and Standard C++

When hosting the WebBrowser control in either an ATL application or one

written in standard C++, the solution is sometimes rather simple. All you

have to do is query the WebBrowser control for the IOleInPlaceActiveObject

interface and call its TranslateAccelerator method. Typically, you call this

method in your handler function for the WM_KEYDOWN message. Figure 2 contains

ATL and standard C++ code that shows how to call the TranslateAccelerator

method to fix the keystroke problem.

Sometimes your application will not automatically be sent WM_KEYDOWN

messages for accelerator keys. In this case, you must manually send this

message to your window. Here is a sample message pump that sends all keyboard

messages to the window of your application:

while (GetMessage(&msg, NULL, 0, 0))

{

TranslateMessage(&msg);

// Send all keyboard messages to the window of your

// application. hwndApp is the window handle of

// your application.

//

if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST)

::SendMessage(hwndApp, msg.message, msg.wParam, msg.lParam);

DispatchMessage(&msg);

}

Win32 SDK Modal Dialogs

The Win32? dialog box functions (DialogBox, DialogBoxIndirect,

DialogBoxIndirectParam, and DialogBoxParam) are very helpful when creating

modal dialog boxes. They take care of handling the message pump for your

application. However, this creates a problem when you are trying to fix these

keystroke problems. Where do you put the call to TranslateAccelerator?

Unfortunately, if you need to host the WebBrowser control in a dialog,

it is not a good idea to use these functions to create the modal dialog. The

reason for this is simple. When focus is set to a control on a dialog, the

control is sent the WB_GETDLGCODE message. Controls typically respond to this

message by returning DLGC_WANTALLKEYS. Then the control is given a chance to

handle all keys entered by the user.

The WebBrowser control returns DLGC_WANTARROWS| DLGC_WANTCHARS in

response to the WM_GETDLGCODE message. This means that it will not handle

certain keys such as Tab and Delete. Therefore, to work around these

keystroke problems, you need to have control of the message pump so that you

can call TranslateAccelerator.

For these reasons, I recommend that you do not use the Win32 dialog box

functions to create your modal dialog box. Create the dialog window yourself

so you have control of the message pump. You can use MFC or ATL to create

this dialog. In addition, if you just need a modal dialog that displays a Web

page, you can use the DHTML showModalDialog function provided by Microsoft

Internet Explorer.

There is one other option you can use to fix these problems, instead of

creating the dialog window manually. You can use a Windows hook. This will

enable you to retrieve all keyboard messages for the current thread and then

call TranslateAccelerator so that accelerator keys will be processed. There

is one problem with this approach, however. When the focus is on the

WebBrowser control and you attempt to change focus between controls on the

Web page by pressing tab, the focus will never leave the WebBrowser window.

This means that you can Tab between controls on the Web page or between

controls in your application, but not both.

There are four steps required to set up a Windows hook to work around the

keystroke problems in a Win32 SDK dialog. First, declare your hook procedure

in your header file.

static LRESULT CALLBACK GetMsgHookProc(int nCode, WPARAM wParam, LPARAM

lParam);

Next, set your hook procedure during initialization by calling

SetWindowsHookEx. Also, make sure to save the returned hook handle so that

you can unhook the procedure when you are shutting down or when it is no

longer needed.

// Declare this global handle in one of your project files.

HHOOK g_hook;

// Place this code inside an initialization

// method in your implementation file (.cpp)

g_hook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgHookProc,

NULL, GetCurrentThreadId());

After that, implement your hook procedure and call TranslateAccelerator.

LRESULT CALLBACK CYourClass::GetMsgHookProc(int nCode, WPARAM wParam,

LPARAM lParam)

{

LPCKFSEARCH pThis = (LPCKFSEARCH)GetWindowLong(hwndMain, DWL_USER);

if (pThis && nCode >= 0)

{

MSG* pMsg = (MSG*)lParam;

// m_pOleInPlaceActObj is an IOleInPlaceActiveObject

// data member of the view class that is initialized

// after the WebBrowser control is loaded.

if (pThis->m_pOleInPlaceActObj)

pThis->m_pOleInPlaceActObj->TranslateAccelerator(pMsg);

// This causes the tab to work in the WebBrowser window. If you do

not do

// this, tabbing will happen in the dialog only. You have the choice

of

// tabbing in the dialog or the WebBrowser window, not both.

if (pMsg->wParam == VK_TAB)

ZeroMemory(pMsg, sizeof(MSG));

}

return CallNextHookEx(g_hook, nCode, wParam, lParam);

}

Finally, when your application is shutting down or when you no longer need

the hook, unhook the procedure.

UnhookWindowsHookEx(g_hook);

"Dmitry Streblechenko" wrote:


> So you do see the message and it gets forwarded, right?

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "Reinwald" <Reinwald> wrote in message
> news:4751F871-B7CC-4115-93F1-272B3A8AAE3F@microsoft.com...
> > Hey,
> > The code we tried out after reading your suggestion
> > llKeyHook = SetWindowsHookEx(WH_GETMESSAGE, GetMessageProc, 0,
> > GetCurrentThreadId());
> > LRESULT CALLBACK GetMessageProc(int code, WPARAM wParam, LPARAM lParam)
> > {
> > const MSG *pMsg = (MSG *) lParam;
> > HWND panel = FindWindowEx(application_Handle, NULL, NULL,
> > _T("PanelDialog"));
> > if (panel)
> > {
> > HWND hWndCtl = ::GetFocus();
> > if:):IsChild(panel, hWndCtl))
> > {
> > if (wParam & PM_REMOVE)
> > {
> > if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
> > {
> > if (pMsg->message == WM_KEYDOWN &&
> > (pMsg->wParam == VK_BACK || pMsg->wParam == VK_DELETE))
> > {
> > ::TranslateMessage(pMsg);
> > return ::SendMessage(hWndCtl, pMsg->message, pMsg->wParam,
> > pMsg->lParam);
> > }
> > }
> > }
> > }
> > }
> > return ::CallNextHookEx(0, code, wParam, lParam);
> > }
> > As i mentioned before this hook works for the backspace key.Any other
> > suggestion to get the delete key working?
> > "Dmitry Streblechenko" wrote:
> >
> >> I have no problem with the following hook in Outlook (Delphi):
> >
> >> initialization
> >> g_hook := SetWindowsHookEx(WH_GETMESSAGE, RAHLEditorHookProc, 0,
> >> GetCurrentThreadId());
> >> finalization
> >> UnhookWindowsHookEx(g_hook);
> >> end.
> >
> >
> >> var g_hook : HHOOK;
> >> function RAHLEditorHookProc(Code : integer; wParam : WPARAM; lParam :
> >> LPARAM):LResult;stdcall;
> >> var pMsg : ^TMsg;
> >> //ClassName:string;
> >> Ctrl{, NextCtrl} : TWinControl;
> >> ParentFrm : TCustomForm;
> >> begin
> >> pMsg:=pointer(lParam);
> >> if ((wParam and PM_REMOVE) = PM_REMOVE) then begin
> >> if (pMsg.message >= WM_KEYFIRST) and (pMsg.message <= WM_KEYLAST)
> >> then begin
> >> if ((pMsg.message = WM_KEYDOWN) or (pMsg.message = WM_KEYUP)) and
> >> (pMsg.wParam <> VK_RETURN) and //ignore "Return" keys
> >> ((pMsg.wParam = VK_BACK) or (pMsg.wParam = VK_DELETE) or
> >> (pMsg.wParam = VK_TAB) or (pMsg.wParam = VK_SPACE) or
> >> //(pMsg.wParam = VK_LEFT) or (pMsg.wParam = VK_RIGHT) or
> >> (GetKeyState(VK_CONTROL) < 0) or //Control key
> >> (GetKeyState(VK_MENU) < 0) or //Alt key
> >> ((pMsg.lParam and (1 shl 24)) <> 0) or //extended key
> >> {(pMsg.wParam = VK_RETURN) or} (pMsg.wParam = VK_UP) or
> >> (pMsg.wParam = VK_DOWN))
> >> then begin
> >> //SetLength(ClassName, 1024);
> >> //SetLength(ClassName, GetClassName(pMsg.hwnd, PChar(ClassName),
> >> Length(ClassName)));
> >> //if (ClassName = 'TRAHLEditor') then begin
> >> Ctrl:=FindDelphiControl(pMsg.hwnd);
> >> if Ctrl <> nil then begin //is it a Delphi control?
> >> if (pMsg.wParam = VK_TAB) then begin
> >> if (pMsg.message = WM_KEYDOWN) then begin
> >> ParentFrm:=GetParentForm(Ctrl);
> >> if ParentFrm <> nil then begin
> >> TCheatControl(ParentFrm).SelectNext(Ctrl, true, true);
> >> //PostMessage(ParentFrm.Handle, WM_NEXTDLGCTL, 0, 0);
> >> end;
> >> end;
> >> end
> >> else begin
> >> TranslateMessage(pMsg^);
> >> SendMessage(pMsg.hwnd, pMsg.message, pMsg.wParam,
> >> pMsg.lParam);
> >> end;
> >> pMsg.message :=WM_NULL;
> >> end;
> >> end
> >> end
> >> end;
> >> Result:=CallNextHookEx(g_hook, Code, wParam, lParam);
> >> end;
> >
> >
> >
> >
> >
> >> > >> Dmitry Streblechenko (MVP)
> >>

> >>

> >>

> >> -
> >> "Reinwald" <Reinwald> wrote in message
> >> news:A193AE22-EBAD-4544-92B3-90A570FFC496@microsoft.com...
> >> > Our VB6.0 Outlook addin loads a panel (written in VC++) containing an
> >> > internet explorer control in both the inspector and explorer views.
> >> > The internet explorer control displays an HTML file with a simple text
> >> > input. We faced similar issues with the backspace and delete key
> >> > events being eaten up by Outlook and not forwarded to the text input.
> >> > So we tried out a solution similar to the one posted by you, where we
> >> > used SetWindowsHookEx to catch the delete and backspace keypress
> >> > events and send appropriate messages to the panel window. While this
> >> > does seem to work for backspace in both the explorer and inspector
> >> > views, the delete keypress event *still* seems to be eaten up by
> >> > Outlook. This is what our callback for the SetWindowsHookEx looks
> >> > like :
> >> >> > LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM
> >> > lParam){
> >> > LRESULT lRes;
> >> > KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
> >> >> >> > if ( pkbhs->vkCode == VK_DELETE || pkbhs->vkCode == VK_BACK)
> >> > {
> >> > if(outlook_mainwindow_Handle)
> >> > {
> >> > HWND panel =
> >> > FindWindowEx(outlook_mainwindow_Handle,
> >> > NULL, NULL, _T
> >> > ("PanelDialog"));
> >> >> >> > if (panel)
> >> > {
> >> > HWND hWndCtl = ::GetFocus();
> >> > if:):IsChild(panel, hWndCtl))
> >> > {
> >> >> >> > if (wParam == WM_KEYDOWN)
> >> > {
> >> > ::SendMessage(hWndCtl,
> >> > WM_KEYDOWN, pkbhs->vkCode, 0);
> >> > }
> >> > return 1;
> >> > }
> >> > }
> >> > }
> >> > }
> >> >> >> > lRes = CallNextHookEx (0, nCode, wParam, lParam);
> >> > return lRes;
> >> >> >> >> > }
> >> >> >> > Any idea how we can get the delete key working?
> >> >> >
> >
> >>


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Rupert Dragwater Background colors not saving in Outlook 365 Using Outlook 11
petunia Outlook tasks module sunsetting? Exchange Server Administration 3
G Save emails as msg file from Outlook Web AddIn (Office JS) Outlook VBA and Custom Forms 1
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 3
U Outlook 2021 not showing contact cards in Searches Using Outlook 2
C Outlook - Macro to block senders domain - Macro Fix Outlook VBA and Custom Forms 2
H Outlook 365 O365 outlook calendar item editing Using Outlook 1
J Outlook 365 html inline images Using Outlook 1
Rupert Dragwater How to get Outlook 365 to open from websites Using Outlook 5
S Why do I have to close and reopen Outlook for macros to work? Outlook VBA and Custom Forms 2
J Outlook 2021 ScanPST errors (yet again ... sorry): repair button missing Outlook 2021 Using Outlook 0
HarvMan Outlook 365 - Rule to Move an Incoming Message to Another Folder Using Outlook 4
K Moved pst to new computer, now Gmail not coming into Outlook Using Outlook 7
S Email Macros to go to a SHARED Outlook mailbox Draft folder...NOT my personal Outlook Draft folder Using Outlook 2
F Running Scripts in Outlook 2021 Using Outlook 0
Nufc1980 Outlook "Please treat this as private label" auto added to some emails - Help. Using Outlook 3
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
V Outlook macros no longer run until VB editor is opened Outlook VBA and Custom Forms 0
R Outlook 365 How to integrate a third-party app with Outlook to track email and sms? Using Outlook 2
e_a_g_l_e_p_i I can't believe what I am seeing when trying to install Outlook 2021 Using Outlook 9
Kika Melo Outlook Calendar deleted appointments not in Deleted Items folder Using Outlook 3
P How to get a QR code for automatic signin with Outlook for iOS Using Outlook 5
J Migrating Outlook Using Outlook 1
Retired Geek Outlook for the MAC with Yahoo accounts now very broken Using Outlook 9
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
L How Stop Outlook Nag Messages Using Outlook 1
TomHuckstep Remove Send/Receive All Folders (IMAP/POP) button from Outlook 365 Ribbon Using Outlook 1
L I Cannot Sign Into My Outlook Account? Outlook VBA and Custom Forms 0
icacream Outlook 2021 - Google calendar in the peek Using Outlook 0
e_a_g_l_e_p_i Question about installing my Gmail account on my iPhone but still getting messages downloaded to my desktop Outlook. Using Outlook 3
F Want to add second email to Outlook for business use Using Outlook 4
kburrows Outlook Email Body Text Disappears/Overlaps, Folders Switch Around when You Hover, Excel Opens Randomly and Runs in the Background - Profile Corrupt? Using Outlook 0
M using excel to sort outlook appointment items Outlook VBA and Custom Forms 4
e_a_g_l_e_p_i MY Outlook 2021 changed the format of the shortcuts for mail, calendar etc. Using Outlook 10
Z Outlook 2021 Outlook new emails notification not working Using Outlook 4
K Changing the Deleted Items location in Outlook 2019 Using Outlook 2
J Outlook 365 Outlook Macro to Sort emails by column "Received" to view the latest email received Outlook VBA and Custom Forms 0
V How to use Comas in a picklist in Outlook forms Outlook VBA and Custom Forms 3
e_a_g_l_e_p_i Question about reinstalling Outlook 2021 Using Outlook 5
A Outlook 365 Outlook (part of 365) now working offline - argh Using Outlook 5
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
G LinkedIn tab missing in Outlook 365 (but working in OWA) Using Outlook 0
Jay Freedman Outlook forgets "not junk" marking Using Outlook 0
KurtLass Opening Graphics Attachments in Outlook 2021 Using Outlook 0
P now on office 365 but getting error messages about missing Outlook 2013 cache folders Using Outlook 2
B Outlook config download Outlook VBA and Custom Forms 1
M Short term workaround for when Outlook searching stopped functioning Using Outlook 0
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
BartH VBA no longer working in Outlook Outlook VBA and Custom Forms 1

Similar threads

Top