Problem with TAB control and a MODELESS dialog in a ATL COM DLL 
Author Message
 Problem with TAB control and a MODELESS dialog in a ATL COM DLL

I have a ATL COM DLL in which one of the interface methods invokes a
MODELESS dialog. If from a Front End application if I call the interface
method, the MODELESS dialog pops up. Here I had a problem initially. The
problem was: After invoking the MODELESS dialog from the Front End, on
TAB key press, Focus was not shifting from one control to the other. I
solved the problem by writing the following code in the
PreTranslateMessage of the Front End:

    HWND hWndModeless = GetActiveWindow();
    if (hWndModeless != NULL)
    {
        if (IsDialogMessage(hWndModeless, pMsg))
                return TRUE;
    }

    return CWinApp::PreTranslateMessage(pMsg);

After this, on TAB key press, Focus started shifting from one control to
the other. BUT even if the focus is on a EDIT BOX, on TAB key press, the
focus shifts to the next control  - WHICH IS NOT DESIRABLE. i.e., If the
focus is on a EDIT BOX, on TAB key press, the focus SHOULD NOT shift to
the next control.

So, I tried to trap the TAB key press of the edit control, by
subclassing CEdit and overrided OnChar(). But when TAB key is pressed
OnChar() is not at all getting executed. So I failed in trapping it.

Can anybody please help me?

Regards,
Balaji



Mon, 09 Dec 2002 03:00:00 GMT  
 Problem with TAB control and a MODELESS dialog in a ATL COM DLL
Try handling on WM_KEYDOWN. If that does not come, try having a Windows
message hook in the dll and let it pass the keyboard messages to the
right control..

Quote:

> I have a ATL COM DLL in which one of the interface methods invokes a
> MODELESS dialog. If from a Front End application if I call the
> interface method, the MODELESS dialog pops up. Here I had a problem
> initially. The problem was: After invoking the MODELESS dialog from
> the Front End, on TAB key press, Focus was not shifting from one
> control to the other. I solved the problem by writing the following
> code in the PreTranslateMessage of the Front End:

>     HWND hWndModeless = GetActiveWindow();
>     if (hWndModeless != NULL)
>     {
>         if (IsDialogMessage(hWndModeless, pMsg))
>                 return TRUE;
>     }

>     return CWinApp::PreTranslateMessage(pMsg);

> After this, on TAB key press, Focus started shifting from one control
> to the other. BUT even if the focus is on a EDIT BOX, on TAB key
> press, the focus shifts to the next control  - WHICH IS NOT DESIRABLE.
> i.e., If the focus is on a EDIT BOX, on TAB key press, the focus
> SHOULD NOT shift to the next control.

> So, I tried to trap the TAB key press of the edit control, by
> subclassing CEdit and overrided OnChar(). But when TAB key is pressed
> OnChar() is not at all getting executed. So I failed in trapping it.

> Can anybody please help me?

> Regards,
> Balaji

--
Girish Bharadwaj


Mon, 09 Dec 2002 03:00:00 GMT  
 Problem with TAB control and a MODELESS dialog in a ATL COM DLL
You'll never get Tab keypress in either WM_KEYDOWN or WM_CHAR handler
because IsDialogMessage() will interpret it. That is, unless you subclass
the control, handle WM_GETDLGCODE message and return DLGC_WANTTAB from it.
Also, if I remember right, you'll have to enable tabs for an edit control
with EM_SETTABSTOPS message. Or, you can handle tabs yourself.

With best wishes,
    Igor Tandetnik


I have a ATL COM DLL in which one of the interface methods invokes a
MODELESS dialog. If from a Front End application if I call the interface
method, the MODELESS dialog pops up. Here I had a problem initially. The
problem was: After invoking the MODELESS dialog from the Front End, on TAB
key press, Focus was not shifting from one control to the other. I solved
the problem by writing the following code in the PreTranslateMessage of the
Front End:
    HWND hWndModeless = GetActiveWindow();
    if (hWndModeless != NULL)

        if (IsDialogMessage(hWndModeless, pMsg))
                return TRUE;
    }

    return CWinApp::PreTranslateMessage(pMsg);
After this, on TAB key press, Focus started shifting from one control to the
other. BUT even if the focus is on a EDIT BOX, on TAB key press, the focus
shifts to the next control  - WHICH IS NOT DESIRABLE. i.e., If the focus is
on a EDIT BOX, on TAB key press, the focus SHOULD NOT shift to the next
control.
So, I tried to trap the TAB key press of the edit control, by subclassing
CEdit and overrided OnChar(). But when TAB key is pressed OnChar() is not at
all getting executed. So I failed in trapping it.
Can anybody please help me?
Regards,
Balaji



Mon, 09 Dec 2002 03:00:00 GMT  
 Problem with TAB control and a MODELESS dialog in a ATL COM DLL
WM_KEYDOWN didn't work. How to have a Windows message hook in the DLL? Can
you please help me more in this?

Best Regards,
Balaji

Quote:

> Try handling on WM_KEYDOWN. If that does not come, try having a Windows
> message hook in the dll and let it pass the keyboard messages to the
> right control..



Tue, 10 Dec 2002 03:00:00 GMT  
 Problem with TAB control and a MODELESS dialog in a ATL COM DLL
Thanks for your suggestion. I have subclassed the control and handled
WM_GETDLGCODE message and also returned DLGC_WANTTAB from it. It didn't work.
When I tried to call SendDlgItemMessage() with EM_SETTABSTOPS message, it
results in CRASH. Can you please help me more in this?

Regards,
Balaji

Quote:

> You'll never get Tab keypress in either WM_KEYDOWN or WM_CHAR handler
> because IsDialogMessage() will interpret it. That is, unless you subclass
> the control, handle WM_GETDLGCODE message and return DLGC_WANTTAB from it.
> Also, if I remember right, you'll have to enable tabs for an edit control
> with EM_SETTABSTOPS message. Or, you can handle tabs yourself.

> With best wishes,
>     Igor Tandetnik



Tue, 10 Dec 2002 03:00:00 GMT  
 Problem with TAB control and a MODELESS dialog in a ATL COM DLL
Search MSDN for WH_KEKBOARD or Modeless dialogs in DLLs in the knowledge
base. They should explain clearly what is required.

Quote:

> WM_KEYDOWN didn't work. How to have a Windows message hook in the DLL? Can
> you please help me more in this?

> Best Regards,
> Balaji


> > Try handling on WM_KEYDOWN. If that does not come, try having a Windows
> > message hook in the dll and let it pass the keyboard messages to the
> > right control..

--
Girish Bharadwaj


Tue, 10 Dec 2002 03:00:00 GMT  
 Problem with TAB control and a MODELESS dialog in a ATL COM DLL

Quote:

> I have a ATL COM DLL in which one of the interface methods
> invokes a MODELESS dialog. If from a Front End application
> if I call the interface method, the MODELESS dialog pops up.
> Here I had a problem initially. The problem was: After invoking
> the MODELESS dialog from the Front End, on TAB key press,
> Focus was not shifting from one control to the other. I solved
> the problem by writing the following code in the
> PreTranslateMessage of the Front End:

Don't do that. You don't want to tie your control to a specific container.

I cannot vouch for the contents of this KB article - but it seems to
demonstrate a generic way of ensuring an ActiveX conol implemented as a
dialog can get access to the necessary functionality:

http://support.microsoft.com/support/kb/articles/q175/5/03.asp

Chris.
--
VisualC++ & Win32 FAQ: http://www.mvps.org/vcfaq
My Win32 Page: http://www.mvps.org/user32



Tue, 10 Dec 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Problem with TAB control and a MODELESS dialog in a ATL COM DLL

2. ATL Dialog Template - Modal/Modeless Tab Stop Behaviour

3. Using TAB in modeless dialog loaded from dll

4. HELP - Using TAB in modeless dialog loaded from dll

5. Tab keys in a modeless dialog part of an activex dll

6. Problem using activex control inside ATL com dll

7. modeless dialog doesnt work in tab control

8. Q: tabbing not possible in modeless propertysheet / modeless dialog

9. modeless dialog in ATL DLL

10. atl dll with and mfc modeless dialog

11. Modeless dialog in COM DLL

12. Modeless dialogs in ATL controls

 

 
Powered by phpBB® Forum Software