static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win);
// find the window for the mouse event at the specified position
-static wxWindowMSW *FindWindowForMouseEvent(wxWindow *win, int *x, int *y);
+static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y); //TW:REQ:Univ
// wrapper around BringWindowToTop() API
static inline void wxBringWindowToTop(HWND hwnd)
#ifdef __WXUNIVERSAL__
// no borders, we draw them ourselves
- exstyle = 0;
+ exstyle &= ~(WS_EX_DLGMODALFRAME |
+ WS_EX_STATICEDGE |
+ WS_EX_CLIENTEDGE |
+ WS_EX_WINDOWEDGE);
msflags &= ~WS_BORDER;
#endif // wxUniversal
*exstyle |= WS_EX_DLGMODALFRAME;
break;
}
+
+ // to make the dialog navigation work with the nested panels we must
+ // use this style
+ if ( flags & wxTAB_TRAVERSAL )
+ {
+ *exstyle |= WS_EX_CONTROLPARENT;
+ }
}
return style;
return TRUE;
}
- //else: no default button
+ else // no default button
+ {
#endif // wxUSE_BUTTON
- // treat Enter as TAB: pass to the next control
+ // this is a quick and dirty test for a text
+ // control
+ if ( !(lDlgCode & DLGC_HASSETSEL) )
+ {
+ // don't process Enter, the control might
+ // need it for itself and don't let
+ // ::IsDialogMessage() have it as it can
+ // eat the Enter events sometimes
+ return FALSE;
+ }
+ //else: treat Enter as TAB: pass to the next
+ // control as this is the best thing to do
+ // if the text doesn't handle Enter itself
+ }
}
}
break;
// place edit control from being closed with Escape in a dialog
if ( msg->message != WM_KEYDOWN || msg->wParam != VK_ESCAPE )
{
- if ( ::IsDialogMessage(GetHwnd(), msg) )
+ // ::IsDialogMessage() can enter in an infinite loop when
+ // WS_EX_CONTROLPARENT is specified and the currently focused
+ // window is disabled or hidden, so don't call it in this case
+ HWND hwndFocus = ::GetFocus();
+ if ( !hwndFocus ||
+ ::IsWindowEnabled(hwndFocus) && ::IsWindowVisible(hwndFocus) )
{
- // IsDialogMessage() did something...
- return TRUE;
+ if ( ::IsDialogMessage(GetHwnd(), msg) )
+ {
+ // IsDialogMessage() did something...
+ return TRUE;
+ }
}
}
}
y = GET_Y_LPARAM(lParam);
// redirect the event to a static control if necessary
- wxWindow *win = FindWindowForMouseEvent(this, &x, &y);
-
- processed = win->HandleMouseEvent(message, x, y, wParam);
+ if (this == GetCapture())
+ {
+ processed = HandleMouseEvent(message, x, y, wParam);
+ }
+ else
+ {
+ wxWindowMSW *win = FindWindowForMouseEvent(this, &x, &y); //TW:REQ:Univ
+ processed = win->HandleMouseEvent(message, x, y, wParam);
+ }
}
}
break;
return nonDefault;
}
+WXHWND wxWindowMSW::MSWGetParent() const
+{
+ return m_parent ? m_parent->GetHWND() : NULL;
+}
+
bool wxWindowMSW::MSWCreate(const wxChar *wclass,
const wxChar *title,
const wxPoint& pos,
int x, y, w, h;
(void)MSWGetCreateWindowCoords(pos, size, x, y, w, h);
- // find the correct parent HWND
- wxWindow *parent = GetParent();
- bool isChild = (style & WS_CHILD) != 0;
- HWND hParent;
- if ( GetWindowStyleFlag() & wxPOPUP_WINDOW )
- {
- // popup windows should have desktop as parent because they shouldn't
- // be limited to the parents client area as child windows usually are
- hParent = ::GetDesktopWindow();
- }
- else // !popup
- {
- if ( (isChild || HasFlag(wxFRAME_TOOL_WINDOW)) && parent )
- {
- // this is either a normal child window or a top level window with
- // wxFRAME_TOOL_WINDOW style (see below)
- hParent = GetHwndOf(parent);
- }
- else
- {
- // this is either a window for which no parent was specified (not
- // much we can do then) or a frame without wxFRAME_TOOL_WINDOW
- // style: we should use NULL parent HWND for it or it would be
- // always on top of its parent which is not what we usually want
- // (in fact, we only want it for frames with the special
- // wxFRAME_TOOL_WINDOW as above)
- hParent = NULL;
- }
-
- }
-
// controlId is menu handle for the top level windows, so set it to 0
// unless we're creating a child window
int controlId;
- if ( isChild )
+ if ( style & WS_CHILD )
{
controlId = GetId();
wxWindowCreationHook hook(this);
m_hWnd = (WXHWND)::CreateWindowEx
- (
- extendedStyle,
- className,
- title ? title : wxT(""),
- style,
- x, y, w, h,
- hParent,
- (HMENU)controlId,
- wxGetInstance(),
- NULL // no extra data
- );
+ (
+ extendedStyle,
+ className,
+ title ? title : wxT(""),
+ style,
+ x, y, w, h,
+ (HWND)MSWGetParent(),
+ (HMENU)controlId,
+ wxGetInstance(),
+ NULL // no extra data
+ );
if ( !m_hWnd )
{
event.SetTimestamp(s_currentMsg.time);
event.m_eventObject = this;
+ event.SetId(GetId());
#if wxUSE_MOUSEEVENT_HACK
m_lastMouseX = x;
// Notice that this is not done for the mouse move events because this could
// (would?) be too slow, but only for clicks which means that the static texts
// still don't get move, enter nor leave events.
-static wxWindowMSW *FindWindowForMouseEvent(wxWindow *win, int *x, int *y)
+static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y) //TW:REQ:Univ
{
wxCHECK_MSG( x && y, win, _T("NULL pointer in FindWindowForMouseEvent") );