msflags |= WS_VISIBLE;
}
- return MSWCreate(wxCanvasClassName, NULL, pos, size, msflags, exstyle);
+ bool retVal = MSWCreate(wxCanvasClassName, NULL, pos, size, msflags, exstyle);
+ if (retVal)
+ SetWindowLong( (HWND)m_hWnd, GWL_WNDPROC, (LONG)wxWndProc);
+ return retVal;
}
// ---------------------------------------------------------------------------
// here we try to do all the job which ::IsDialogMessage() usually does
// internally
#if 1
- bool bProcess = TRUE;
- if ( msg->message != WM_KEYDOWN )
- bProcess = FALSE;
-
- if ( bProcess && (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
- bProcess = FALSE;
-
- if ( bProcess )
+ if ( msg->message == WM_KEYDOWN )
{
bool bCtrlDown = wxIsCtrlDown();
bool bShiftDown = wxIsShiftDown();
bool bForward = TRUE,
bWindowChange = FALSE;
+ // should we process this message specially?
+ bool bProcess = TRUE;
switch ( msg->wParam )
{
case VK_TAB:
// place edit control from being closed with Escape in a dialog
if ( msg->message != WM_KEYDOWN || msg->wParam != VK_ESCAPE )
{
- // ::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
+ // ::IsDialogMessage() can enter in an infinite loop when the
+ // currently focused window is disabled or hidden and its parent
+ // has WS_EX_CONTROLPARENT style, so don't call it in this case
bool canSafelyCallIsDlgMsg = TRUE;
HWND hwndFocus = ::GetFocus();
break;
}
+ if ( !(::GetWindowLong(hwndFocus, GWL_STYLE) & WS_CHILD) )
+ {
+ // it's a top level window, don't go further -- e.g. even
+ // if the parent of a dialog is disabled, this doesn't
+ // break navigation inside the dialog
+ break;
+ }
+
hwndFocus = ::GetParent(hwndFocus);
}
break;
}
- if (!processed)
+ if ( processed )
+ break;
+
#endif // __WXMICROWIN__
- {
- // VZ: why do we need it here? DefWindowProc() is supposed
- // to do this for us anyhow
- if ( message == WM_LBUTTONDOWN && AcceptsFocus() )
- SetFocus();
+ // VZ: if you find a situation when this is needed, tell
+ // me about it, do *not* uncomment this code as it
+ // causes other strange problems
+#if 0
+ if ( message == WM_LBUTTONDOWN && AcceptsFocus() )
+ SetFocus();
+#endif // 0
- int x = GET_X_LPARAM(lParam),
- y = GET_Y_LPARAM(lParam);
+ int x = GET_X_LPARAM(lParam),
+ y = GET_Y_LPARAM(lParam);
- // redirect the event to a static control if necessary
- 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);
- }
+ // redirect the event to a static control if necessary by
+ // finding one under mouse
+ wxWindowMSW *win;
+ if ( GetCapture() == this )
+ {
+ // but don't do it if the mouse is captured by this window
+ // because then it should really get this event itself
+ win = this;
+ }
+ else
+ {
+ win = FindWindowForMouseEvent(this, &x, &y);
}
+
+ processed = win->HandleMouseEvent(message, x, y, wParam);
}
break;
WXHWND wxWindowMSW::MSWGetParent() const
{
- return m_parent ? m_parent->GetHWND() : NULL;
+ return m_parent ? m_parent->GetHWND() : WXHWND(NULL);
}
bool wxWindowMSW::MSWCreate(const wxChar *wclass,
// ---------------------------------------------------------------------------
#ifdef __WIN95__
-// FIXME: VZ: I'm not sure at all that the order of processing is correct
+
bool wxWindowMSW::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{
#ifndef __WXMICROWIN__
HWND hWnd = hdr->hwndFrom;
wxWindow *win = wxFindWinFromHandle((WXHWND)hWnd);
- // is this one of our windows?
+ // if the control is one of our windows, let it handle the message itself
if ( win )
{
return win->MSWOnNotify(idCtrl, lParam, result);
}
+ // VZ: why did we do it? normally this is unnecessary and, besides, it
+ // breaks the message processing for the toolbars because the tooltip
+ // notifications were being forwarded to the toolbar child controls
+ // (if it had any) before being passed to the toolbar itself, so in my
+ // example the tooltip for the combobox was always shown instead of the
+ // correct button tooltips
+#if 0
// try all our children
wxWindowList::Node *node = GetChildren().GetFirst();
while ( node )
node = node->GetNext();
}
+#endif // 0
- // finally try this window too (catches toolbar case)
+ // by default, handle it ourselves
return MSWOnNotify(idCtrl, lParam, result);
#else // __WXMICROWIN__
return FALSE;
#endif
}
+#if wxUSE_TOOLTIPS
+
+bool wxWindowMSW::HandleTooltipNotify(WXUINT code,
+ WXLPARAM lParam,
+ const wxString& ttip)
+{
+ // I don't know why it happens, but the versions of comctl32.dll starting
+ // from 4.70 sometimes send TTN_NEEDTEXTW even to ANSI programs (normally,
+ // this message is supposed to be sent to Unicode programs only) -- hence
+ // we need to handle it as well, otherwise no tooltips will be shown in
+ // this case
+
+ if ( !(code == (WXUINT) TTN_NEEDTEXTA || code == (WXUINT) TTN_NEEDTEXTW) || ttip.empty() )
+ {
+ // not a tooltip message or no tooltip to show anyhow
+ return FALSE;
+ }
+
+ LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
+
+ if ( code == (WXUINT) TTN_NEEDTEXTA )
+ {
+ ttText->lpszText = (wxChar *)ttip.c_str();
+ }
+ else
+ {
+#if wxUSE_UNICODE
+ ttText->lpszText = (wxChar *)ttip.c_str();
+#else // !Unicode
+ size_t lenAnsi = ttip.length();
+
+ // some compilers (MetroWerks and Cygwin) don't like calling mbstowcs
+ // with NULL argument
+ #if defined( __MWERKS__ ) || defined( __CYGWIN__ )
+ size_t lenUnicode = 2*lenAnsi;
+ #else
+ size_t lenUnicode = mbstowcs(NULL, ttip, lenAnsi);
+ #endif
+
+ // using the pointer of right type avoids us doing all sorts of
+ // pointer arithmetics ourselves
+ wchar_t *dst = (wchar_t *)ttText->szText,
+ *pwz = new wchar_t[lenUnicode + 1];
+ mbstowcs(pwz, ttip, lenAnsi + 1);
+ memcpy(dst, pwz, lenUnicode*sizeof(wchar_t));
+
+ // put the terminating wide NUL
+ dst[lenUnicode] = L'\0';
+
+ delete [] pwz;
+#endif // Unicode/!Unicode
+ }
+
+ return TRUE;
+}
+
+#endif // wxUSE_TOOLTIPS
+
bool wxWindowMSW::MSWOnNotify(int WXUNUSED(idCtrl),
- WXLPARAM lParam,
- WXLPARAM* WXUNUSED(result))
+ WXLPARAM lParam,
+ WXLPARAM* WXUNUSED(result))
{
#if wxUSE_TOOLTIPS
- NMHDR* hdr = (NMHDR *)lParam;
- if ( (int)hdr->code == TTN_NEEDTEXT && m_tooltip )
+ if ( m_tooltip )
{
- TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
- ttt->lpszText = (wxChar *)m_tooltip->GetTip().c_str();
-
- // processed
- return TRUE;
+ NMHDR* hdr = (NMHDR *)lParam;
+ if ( HandleTooltipNotify(hdr->code, lParam, m_tooltip->GetTip()))
+ {
+ // processed
+ return TRUE;
+ }
}
#endif // wxUSE_TOOLTIPS
return FALSE;
}
+
#endif // __WIN95__
// ---------------------------------------------------------------------------
{
// there is no need to do anything for the top level windows
const wxWindow *parent = GetParent();
- if ( parent && !parent->IsTopLevel() )
+ while ( parent && !parent->IsTopLevel() )
{
LONG exStyle = ::GetWindowLong(GetHwndOf(parent), GWL_EXSTYLE);
if ( !(exStyle & WS_EX_CONTROLPARENT) )
::SetWindowLong(GetHwndOf(parent), GWL_EXSTYLE,
exStyle | WS_EX_CONTROLPARENT);
}
+
+ parent = parent->GetParent();
}
}
if ( hWndPalChange != GetHWND() )
{
// check to see if we our our parents have a custom palette
- wxWindow *win = this;
+ wxWindowMSW *win = this;
while ( win && !win->HasCustomPalette() )
{
win = win->GetParent();
#if wxUSE_PALETTE
// check to see if we our our parents have a custom palette
- wxWindow *win = this;
+ wxWindowMSW *win = this;
while (!win->HasCustomPalette() && win->GetParent()) win = win->GetParent();
if (win->HasCustomPalette()) {
/* realize the palette to see whether redrawing is needed */