On Sat, 22 Sep 2012 18:19:57 UTC, James Moe wrote:
> The main message window in PMMail is a container in details view. An
> optional preview window is created as a MLE subclassed to the container.
> The container has an accelerator key to copy a message: ctrl+c. This
> overrides the standard function of the key combination which is to copy
> selected text.
> I have tried creating an accelerator key for the preview window
> thinking it would capture the event. It did not work. The container
> still gets the event first.
IIUC, you're trying override an accelerator so as to restore normal
copy-to-clipboard functionality when the MLE has the focus. However,
the relationship between the MLE and the container remains unclear.
* is the MLE really a child of the container or is it just program-
matically associated with it?
* does this MLE have a frame?
When PM has a character message for the focus window, it first sends
a WM_TRANSLATEACCEL msg to that window; mp1 points to a QMSG struct
containing the proposed WM_CHAR msg. Typically, WM_TRANSLATEACCEL
gets passed up the chain of parent windows until it reaches a frame.
The frame then calls WinTranslateAccel() with its *own* HWND as an
argument. If the key-combo matches an accelerator entry or a menu
item, the QMSG's hwnd, msg, mp1, and mp2 all get modified. Regardless
of the outcome, the contents of QMSG are then posted to QMSG.hwnd.
Given that, there are a couple of reasons this isn't working for you:
* you can't associate an accelerator table with an MLE - it has to
be associated with a frame. If you're calling WinSetAccelTable()
using the MLE's hwnd, it should be failing.
* if the msg is translated, QMSG.hwnd gets changed to the frame's
hwnd, so the WM_COMMAND is posted to the frame. The frame then
passes the msg to FID_CLIENT. Unless the MLE has its own frame,
the msg gets passed (presumably) to the container.
Final question: why bother with all this crap anyway? If your
subclassed MLE proc sees the WM_TRANSLATEACCEL for ctrl+c, then
translate the msg yourself. Leave hwnd as-is, change msg to
MLM_COPY, zero-out mp1 and mp2, then return TRUE. If the MLE
doesn't see that msg, then your container's subclass proc will
have to take one of two different actions when it receives your
IDM_COPY command depending on whether the MLE has the focus.
--
== == almost usable email address: Rich AT E-vertise DOT Com == ==