cannot trap the enter key using atl control that is hosted in a container 
Author Message
 cannot trap the enter key using atl control that is hosted in a container

Hi,
    I have created a atl dll that has edit box and some button. Later, I
created a atl exe that has a container dlg box that host the atl dll. I
would like the trap the enter key when user press it if the focus is in the
edit box. I have implemented a superclass of the edit control and I can trap
most of the keys using WM_CHAR. But somehow, I can't trap the enter key.

    Did anyone of you know how to solve the problems.

Thanks



Sun, 12 Oct 2003 15:07:13 GMT  
 cannot trap the enter key using atl control that is hosted in a container

Quote:
>I have implemented a superclass of the edit control and I can trap
>most of the keys using WM_CHAR. But somehow, I can't trap the enter
>key.

Implement IOleControl::GetControlInfo. In CONTROLINFO.dwFlags, set
CTRLINFO_EATS_RETURN.

Christian.



Sun, 12 Oct 2003 16:24:52 GMT  
 cannot trap the enter key using atl control that is hosted in a container

Quote:
>    I have created a atl dll that has edit box and some button. Later, I
>created a atl exe that has a container dlg box that host the atl dll. I
>would like the trap the enter key when user press it if the focus is in the
>edit box. I have implemented a superclass of the edit control and I can trap
>most of the keys using WM_CHAR. But somehow, I can't trap the enter key.

create the editbox with following styles:

ES_WANTRETURN
ES_MULTILINE

and in your OnChar() trap the VK_RETURN

kr,

Peter
--
==========================================
 Peter D'Hoye (speaking only for himself)
 Barco Commercial Printing - R&D - Belgium



Sun, 12 Oct 2003 19:15:07 GMT  
 cannot trap the enter key using atl control that is hosted in a container
Hi,
    I tried to add the following code into my dll, the  main control but it
don't help. Did I miss out anything?
ALternatively, I can create the editbox with following styles:
ES_WANTRETURN
ES_MULTILINE
, but I will encounter problems if I am using a combo box.

   STDMETHOD(GetControlInfo)(CONTROLINFO *pCI)
   {
      if(!pCI)
      {
         return E_POINTER;
      }
      //pCI->hAccel   = NULL;
      //pCI->cAccel   = 0;
      //pCI->dwFlags  = 0;
   pCI->dwFlags  = CTRLINFO_EATS_RETURN;

      return S_OK;
   }

   STDMETHOD(TranslateAccelerator)(MSG *pMsg)
   {
      /*
   if (
         ((pMsg->message >= WM_KEYFIRST) && (pMsg->message <= WM_KEYLAST))
         &&
         ((VK_TAB == pMsg->wParam) || (VK_RETURN == pMsg->wParam))
      )
   */
      {
         CComQIPtr<IOleControlSite,&IID_IOleControlSite>
         spCtrlSite(m_spClientSite);
         if(spCtrlSite)
         {
            return spCtrlSite->TranslateAccelerator (pMsg,0);
         }
      }
      return S_FALSE;
   }

Quote:
----- Original Message -----

Newsgroups: microsoft.public.vc.atl
Sent: Wednesday, April 25, 2001 4:24 PM
Subject: Re: cannot trap the enter key using atl control that is hosted in a
container

> >I have implemented a superclass of the edit control and I can trap
> >most of the keys using WM_CHAR. But somehow, I can't trap the enter
> >key.

> Implement IOleControl::GetControlInfo. In CONTROLINFO.dwFlags, set
> CTRLINFO_EATS_RETURN.

> Christian.



Mon, 13 Oct 2003 15:02:43 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Trapping ENTER key to move to next control

2. Problem Hosting ActiveX Controls Using ATL AXHost (CAxWindow2) using VC7

3. Cannot find ATL control in Test Container

4. Hosting the WebBrowser Control using Visual C++/ATL does not work

5. Trapping the enter key in a Datagrid cell

6. Trapping ENter KEY

7. trapping ENTER KEY

8. Trapping Enter Key

9. trapping the enter key in a dialog app

10. Trapping ESC, ENTER key for dialogs

11. Trapping ENTER KEY

12. CListCtrl - trapping ENTER key

 

 
Powered by phpBB® Forum Software