View Single Post
  #4  
Old June 23rd 09, 11:10 AM posted to microsoft.public.outlook.program_addins
Reinwald
external usenet poster
 
Posts: 5
Default Outlook eating up delete keypress Options

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)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Reinwald" wrote in message
...
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?





Ads