From: amitmane82 on
Hi All,

I have class CDesigner which is inherited from CWnd. I have object of
this class named m_Designer in parent window class.

Using m_Designer object I create pop-up window using method
m_Designer.CreateEx(.......). This method have parameter DWORD
dwStyle. Here I set the value WS_POPUPWINDOW. Now i have two windows
one is parent which is at background and in deactivated state. POPUP
window is on top and in active state.

Now the problem I have is that when I launch the POPUP window and
press the CTRL key at that time POPUP window lost the focus and it's
parent window becomes active. So please suggest me any solution for
this problem.
From: Joseph M. Newcomer on
One question is "why are you creating a popup window?" There are lots of good reasons to
need a popup window, but most commonly a modeless dialog window will solve most of these
issues, and a modeless dialog can co-exist in a friendly fashion with the MFC framework.
You are moving outside the MFC framework here, and there are lots of potential problems
when you do that. I don't know why Ctrl causes you to lose focus, but I'd suggest that if
you have not explicitly done a SetFocus() call to your new popup window or a child inside
it, that you still have keyboard focus in the parent, so Ctrl (or any key) is going to
result in a WM_KEYDOWN message to that window. Along the way, the new popup might get
redrawn and discover that, since it didn't have the focus, it should be redrawn without
focus.

Since you supplied no important details in your description (other than saying you did
CreateEx), there is no way to tell if you forgot to set the focus to this window, but
that's my first guess, given how little information is presented.
joe

On Thu, 3 Jun 2010 23:32:44 -0700 (PDT), "amitmane82(a)gmail.com" <amitmane82(a)gmail.com>
wrote:

>Hi All,
>
>I have class CDesigner which is inherited from CWnd. I have object of
>this class named m_Designer in parent window class.
>
>Using m_Designer object I create pop-up window using method
>m_Designer.CreateEx(.......). This method have parameter DWORD
>dwStyle. Here I set the value WS_POPUPWINDOW. Now i have two windows
>one is parent which is at background and in deactivated state. POPUP
>window is on top and in active state.
>
>Now the problem I have is that when I launch the POPUP window and
>press the CTRL key at that time POPUP window lost the focus and it's
>parent window becomes active. So please suggest me any solution for
>this problem.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm