-// Main Windows 3 window proc
-long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
-{
-#if 0
- switch (message)
- {
- case WM_INITDIALOG:
- case WM_ACTIVATE:
- case WM_SETFOCUS:
- case WM_KILLFOCUS:
- case WM_CREATE:
- case WM_PAINT:
- case WM_QUERYDRAGICON:
- case WM_SIZE:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- case WM_MOUSEMOVE:
-// case WM_DESTROY:
- case WM_COMMAND:
- case WM_NOTIFY:
- case WM_MENUSELECT:
- case WM_INITMENUPOPUP:
- case WM_DRAWITEM:
- case WM_MEASUREITEM:
- case WM_KEYDOWN:
- case WM_KEYUP:
- case WM_CHAR: // Always an ASCII character
- case WM_HSCROLL:
- case WM_VSCROLL:
- case WM_CTLCOLORBTN:
- case WM_CTLCOLORDLG:
- case WM_CTLCOLORLISTBOX:
- case WM_CTLCOLORMSGBOX:
- case WM_CTLCOLORSCROLLBAR:
- case WM_CTLCOLORSTATIC:
- case WM_CTLCOLOREDIT:
- case WM_SYSCOLORCHANGE:
- case WM_ERASEBKGND:
- case WM_MDIACTIVATE:
- case WM_DROPFILES:
- case WM_QUERYENDSESSION:
-// case WM_CLOSE:
- case WM_GETMINMAXINFO:
- return MSWDefWindowProc(message, wParam, lParam );
- }
-#endif
-
-
- HWND hWnd = (HWND)m_hWnd;
-
- switch (message)
- {
-/*
- case WM_SETFONT:
- {
- return 0;
- }
-*/
- case WM_ACTIVATE:
- {
-#ifdef __WIN32__
- WORD state = LOWORD(wParam);
- WORD minimized = HIWORD(wParam);
- HWND hwnd = (HWND)lParam;
-#else
- WORD state = (WORD)wParam;
- WORD minimized = LOWORD(lParam);
- HWND hwnd = (HWND)HIWORD(lParam);
-#endif
- MSWOnActivate(state, (minimized != 0), (WXHWND) hwnd);
- return 0;
- break;
- }
- case WM_SETFOCUS:
- {
- HWND hwnd = (HWND)wParam;
-// return OnSetFocus(hwnd);
-
- if (MSWOnSetFocus((WXHWND) hwnd))
- return 0;
- else return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_KILLFOCUS:
- {
- HWND hwnd = (HWND)lParam;
-// return OnKillFocus(hwnd);
- if (MSWOnKillFocus((WXHWND) hwnd))
- return 0;
- else
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_CREATE:
- {
- MSWOnCreate((WXLPCREATESTRUCT) (LPCREATESTRUCT)lParam);
- return 0;
- break;
- }
- case WM_SHOWWINDOW:
- {
- MSWOnShow((wParam != 0), (int) lParam);
- break;
- }
- case WM_PAINT:
- {
- if (MSWOnPaint())
- return 0;
- else return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_QUERYDRAGICON:
- {
- HICON hIcon = 0;
- if ((hIcon = (HICON) MSWOnQueryDragIcon()))
- return (long)hIcon;
- else return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
-
- case WM_SIZE:
- {
- int width = LOWORD(lParam);
- int height = HIWORD(lParam);
- MSWOnSize(width, height, wParam);
- break;
- }
-
- case WM_WINDOWPOSCHANGING:
- {
- WINDOWPOS *pos = (WINDOWPOS *)lParam;
- MSWOnWindowPosChanging((void *)pos);
- break;
- }
-
- case WM_RBUTTONDOWN:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnRButtonDown(x, y, wParam);
- break;
- }
- case WM_RBUTTONUP:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnRButtonUp(x, y, wParam);
- break;
- }
- case WM_RBUTTONDBLCLK:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnRButtonDClick(x, y, wParam);
- break;
- }
- case WM_MBUTTONDOWN:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMButtonDown(x, y, wParam);
- break;
- }
- case WM_MBUTTONUP:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMButtonUp(x, y, wParam);
- break;
- }
- case WM_MBUTTONDBLCLK:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMButtonDClick(x, y, wParam);
- break;
- }
- case WM_LBUTTONDOWN:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnLButtonDown(x, y, wParam);
- break;
- }
- case WM_LBUTTONUP:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnLButtonUp(x, y, wParam);
- break;
- }
- case WM_LBUTTONDBLCLK:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnLButtonDClick(x, y, wParam);
- break;
- }
- case WM_MOUSEMOVE:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMouseMove(x, y, wParam);
- break;
- }
- case MM_JOY1BUTTONDOWN:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyDown(wxJOYSTICK1, x, y, wParam);
- break;
- }
- case MM_JOY2BUTTONDOWN:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyDown(wxJOYSTICK2, x, y, wParam);
- break;
- }
- case MM_JOY1BUTTONUP:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyUp(wxJOYSTICK1, x, y, wParam);
- break;
- }
- case MM_JOY2BUTTONUP:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyUp(wxJOYSTICK2, x, y, wParam);
- break;
- }
- case MM_JOY1MOVE:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyMove(wxJOYSTICK1, x, y, wParam);
- break;
- }
- case MM_JOY2MOVE:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyMove(wxJOYSTICK2, x, y, wParam);
- break;
- }
- case MM_JOY1ZMOVE:
- {
- int z = LOWORD(lParam);
- MSWOnJoyZMove(wxJOYSTICK1, z, wParam);
- break;
- }
- case MM_JOY2ZMOVE:
- {
- int z = LOWORD(lParam);
- MSWOnJoyZMove(wxJOYSTICK2, z, wParam);
- break;
- }
- case WM_DESTROY:
- {
- if (MSWOnDestroy())
- return 0;
- else return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_SYSCOMMAND:
- {
- return MSWOnSysCommand(wParam, lParam);
- break;
- }
- case WM_COMMAND:
- {
-#ifdef __WIN32__
- WORD id = LOWORD(wParam);
- HWND hwnd = (HWND)lParam;
- WORD cmd = HIWORD(wParam);
-#else
- WORD id = (WORD)wParam;
- HWND hwnd = (HWND)LOWORD(lParam) ;
- WORD cmd = HIWORD(lParam);
-#endif
- if (!MSWOnCommand(id, cmd, (WXHWND) hwnd))
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
-#if defined(__WIN95__)
- case WM_NOTIFY:
- {
- if (!MSWOnNotify(wParam, lParam))
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
-#endif
- case WM_MENUSELECT:
- {
-#ifdef __WIN32__
- WORD flags = HIWORD(wParam);
- HMENU sysmenu = (HMENU)lParam;
-#else
- WORD flags = LOWORD(lParam);
- HMENU sysmenu = (HMENU)HIWORD(lParam);
-#endif
- MSWOnMenuHighlight((WORD)wParam, flags, (WXHMENU) sysmenu);
- break;
- }
- case WM_INITMENUPOPUP:
- {
- MSWOnInitMenuPopup((WXHMENU) (HMENU)wParam, (int)LOWORD(lParam), (HIWORD(lParam) != 0));
- break;
- }
- case WM_DRAWITEM:
- {
- return MSWOnDrawItem((int)wParam, (WXDRAWITEMSTRUCT *)lParam);
- break;
- }
- case WM_MEASUREITEM:
- {
- return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam);
- break;
- }
- case WM_KEYDOWN:
- {
-// return Default();
-
- if (wParam == VK_SHIFT)
- return Default();
-
- else if (wParam == VK_CONTROL)
- return Default();
-
- // Avoid duplicate messages to OnChar
- else if ((wParam != VK_ESCAPE) && (wParam != VK_SPACE) && (wParam != VK_RETURN) && (wParam != VK_BACK) && (wParam != VK_TAB))
- {
- MSWOnChar((WORD)wParam, lParam);
- if (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE)
- return Default();
- }
- else
- return Default();
- break;
- }
- case WM_KEYUP:
- {
-/*
- if (wParam == VK_SHIFT)
- wxShiftDown = FALSE;
- else if (wParam == VK_CONTROL)
- wxControlDown = FALSE;
-*/
- break;
- }
- case WM_CHAR: // Always an ASCII character
- {
- MSWOnChar((WORD)wParam, lParam, TRUE);
- break;
- }
- case WM_HSCROLL:
- {
-#ifdef __WIN32__
- WORD code = LOWORD(wParam);
- WORD pos = HIWORD(wParam);
- HWND control = (HWND)lParam;
-#else
- WORD code = (WORD)wParam;
- WORD pos = LOWORD(lParam);
- HWND control = (HWND)HIWORD(lParam);
-#endif
- MSWOnHScroll(code, pos, (WXHWND) control);
- break;
- }
- case WM_VSCROLL:
- {
-#ifdef __WIN32__
- WORD code = LOWORD(wParam);
- WORD pos = HIWORD(wParam);
- HWND control = (HWND)lParam;
-#else
- WORD code = (WORD)wParam;
- WORD pos = LOWORD(lParam);
- HWND control = (HWND)HIWORD(lParam);
-#endif
- MSWOnVScroll(code, pos, (WXHWND) control);
- break;
- }
-#ifdef __WIN32__
- case WM_CTLCOLORBTN:
- {
- int nCtlColor = CTLCOLOR_BTN;
- HWND control = (HWND)lParam;
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);
- break;
- }
- case WM_CTLCOLORDLG:
- {
- int nCtlColor = CTLCOLOR_DLG;
- HWND control = (HWND)lParam;
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);\
- break;
- }
- case WM_CTLCOLORLISTBOX:
- {
- int nCtlColor = CTLCOLOR_LISTBOX;
- HWND control = (HWND)lParam;
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);
- break;
- }
- case WM_CTLCOLORMSGBOX:
- {
- int nCtlColor = CTLCOLOR_MSGBOX;
- HWND control = (HWND)lParam;
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);
- break;
- }
- case WM_CTLCOLORSCROLLBAR:
- {
- int nCtlColor = CTLCOLOR_SCROLLBAR;
- HWND control = (HWND)lParam;
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);
- break;
- }
- case WM_CTLCOLORSTATIC:
- {
- int nCtlColor = CTLCOLOR_STATIC;
- HWND control = (HWND)lParam;
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);
- break;
- }
- case WM_CTLCOLOREDIT:
- {
- int nCtlColor = CTLCOLOR_EDIT;
- HWND control = (HWND)lParam;
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);
- break;
- }
-#else
- case WM_CTLCOLOR:
- {
- HWND control = (HWND)LOWORD(lParam);
- int nCtlColor = (int)HIWORD(lParam);
- HDC pDC = (HDC)wParam;
- return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
- message, wParam, lParam);
- break;
- }
-#endif
- case WM_SYSCOLORCHANGE:
- {
- // Return value of 0 means, we processed it.
- if (MSWOnColorChange((WXHWND) hWnd, message, wParam, lParam) == 0)
- return 0;
- else
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_ERASEBKGND:
- {
- // Prevents flicker when dragging
- if (IsIconic(hWnd)) return 1;
-
- // EXPERIMENTAL
-// return 1;
- if (!MSWOnEraseBkgnd((WXHDC) (HDC)wParam))
- return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
- else return 1;
- break;
- }
- case WM_MDIACTIVATE:
- {
-#ifdef __WIN32__
- HWND hWndActivate = GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam,lParam);
- HWND hWndDeactivate = GET_WM_MDIACTIVATE_HWNDDEACT(wParam,lParam);
- BOOL activate = GET_WM_MDIACTIVATE_FACTIVATE(hWnd,wParam,lParam);
- return MSWOnMDIActivate((long) activate, (WXHWND) hWndActivate, (WXHWND) hWndDeactivate);
-#else
- return MSWOnMDIActivate((BOOL)wParam, (HWND)LOWORD(lParam),
- (HWND)HIWORD(lParam));
-#endif
- }
- case WM_DROPFILES:
- {
- MSWOnDropFiles(wParam);
- break;
- }
- case WM_INITDIALOG:
- {
- return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
- break;
- }
- case WM_QUERYENDSESSION:
- {
- // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
- return MSWOnClose();
- break;
- }
- case WM_CLOSE:
- {
- if (MSWOnClose())
- return 0L;
- else
- return 1L;
- break;
- }
-
- case WM_GETMINMAXINFO:
- {
- MINMAXINFO *info = (MINMAXINFO *)lParam;
- if (m_minSizeX != -1)
- info->ptMinTrackSize.x = (int)m_minSizeX;
- if (m_minSizeY != -1)
- info->ptMinTrackSize.y = (int)m_minSizeY;
- if (m_maxSizeX != -1)
- info->ptMaxTrackSize.x = (int)m_maxSizeX;
- if (m_maxSizeY != -1)
- info->ptMaxTrackSize.y = (int)m_maxSizeY;
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
-
-/*
-#if HAVE_SOCKET
- case WM_TIMER:
- {
- __ddeUnblock(hWnd, wParam);
- break;
- }
-
- case ASYNC_SELECT_MESSAGE:
- return ddeWindowProc(hWnd,message,wParam,lParam);
-#endif
-*/
-
- default:
- return MSWDefWindowProc(message, wParam, lParam );
- }
- return 0; // Success: we processed this command.
-}
-
-// Dialog window proc
-LONG APIENTRY _EXPORT
- wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- return 0;
-}
-
-wxList *wxWinHandleList = NULL;
-wxWindow *wxFindWinFromHandle(WXHWND hWnd)
-{
- wxNode *node = wxWinHandleList->Find((long)hWnd);
- if (!node)
- return NULL;
- return (wxWindow *)node->Data();
-}
-
-void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
-{
- // adding NULL hWnd is (first) surely a result of an error and
- // (secondly) breaks menu command processing
- wxCHECK( hWnd != NULL );
-
- if ( !wxWinHandleList->Find((long)hWnd) )
- wxWinHandleList->Append((long)hWnd, win);
-}
-
-void wxRemoveHandleAssociation(wxWindow *win)
-{
- wxWinHandleList->DeleteObject(win);
-}
-
-// Default destroyer - override if you destroy it in some other way
-// (e.g. with MDI child windows)
-void wxWindow::MSWDestroyWindow(void)
-{
-#if 0
-
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWDestroyWindow %d\n", handle);
-#endif
- MSWDetachWindowMenu();
-// SetWindowLong(handle, 0, (long)0);
- HWND oldHandle = handle;
- handle = NULL;
-
- ::DestroyWindow(oldHandle);
-
- // Menu is destroyed explicitly by wxMDIChild::DestroyWindow,
- // or when Windows HWND is deleted if MDI parent or
- // SDI frame.
-/*
- if (m_hMenu)
- {
- ::DestroyMenu(m_hMenu);
- m_hMenu = 0;
- }
- */
-#endif
-}
-
-void wxWindow::MSWCreate(const int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title,
- const int x, const int y, const int width, const int height,
- const WXDWORD style, const char *dialog_template, const WXDWORD extendedStyle)
-{
- bool is_dialog = (dialog_template != NULL);
- int x1 = CW_USEDEFAULT;
- int y1 = 0;
- int width1 = CW_USEDEFAULT;
- int height1 = 100;
-
- // Find parent's size, if it exists, to set up a possible default
- // panel size the size of the parent window
- RECT parent_rect;
- if (parent)
- {
- // Was GetWindowRect: JACS 5/5/95
- ::GetClientRect((HWND) parent->GetHWND(), &parent_rect);
-
- width1 = parent_rect.right - parent_rect.left;
- height1 = parent_rect.bottom - parent_rect.top;
- }
-
- if (x > -1) x1 = x;
- if (y > -1) y1 = y;
- if (width > -1) width1 = width;
- if (height > -1) height1 = height;
-
- HWND hParent = NULL;
- if (parent)
- hParent = (HWND) parent->GetHWND();
-
- wxWndHook = this;
-
- if (is_dialog)
- {
- // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
- // other compilers???
- // VZ: it's always needed for Win16 and never for Win32
-#ifdef __WIN32__
- m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
- (DLGPROC)wxDlgProc);
-#else
- DLGPROC dlgproc = (DLGPROC)MakeProcInstance((DLGPROC)wxWndProc, wxGetInstance());
-
- m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
- (DLGPROC)dlgproc);
-#endif
-
- if (m_hWnd == 0)
- MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
- "wxWindows Error", MB_ICONEXCLAMATION | MB_OK);
- else MoveWindow((HWND) m_hWnd, x1, y1, width1, height1, FALSE);
- }
- else
- {
- int controlId = 0;
- if (style & WS_CHILD)
- controlId = id;
- if (!title)
- title = "";
-
- m_hWnd = (WXHWND) CreateWindowEx(extendedStyle, wclass,
- title,
- style,
- x1, y1,
- width1, height1,
-// hParent, NULL, wxGetInstance(),
- hParent, (HMENU)controlId, wxGetInstance(),
- NULL);
-
- if (m_hWnd == 0)
- {
- char buf[300];
- sprintf(buf, "Can't create window of class %s! Weird.\nPossible Windows 3.x compatibility problem?",
- wclass);
- wxFatalError(buf,
- "Fatal wxWindows Error");
- }
- }
- wxWndHook = NULL;
- wxWinHandleList->Append((long)m_hWnd, this);
-
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWCreate %d\n", m_hWnd);
-#endif
-}
-
-void wxWindow::MSWOnCreate(WXLPCREATESTRUCT WXUNUSED(cs))
-{
-}
-
-bool wxWindow::MSWOnClose(void)
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnClose %d\n", handle);
-#endif
- return FALSE;
-}
-
-bool wxWindow::MSWOnDestroy(void)
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnDestroy %d\n", handle);
-#endif
- // delete our drop target if we've got one
- #if USE_DRAG_AND_DROP
- if ( m_pDropTarget != NULL ) {
- m_pDropTarget->Revoke(m_hWnd);
-
- delete m_pDropTarget;
- m_pDropTarget = NULL;
- }
- #endif
-
- return TRUE;
-}
-
-// Deal with child commands from buttons etc.
-
-bool wxWindow::MSWOnNotify(const WXWPARAM wParam, const WXLPARAM lParam)
-{
-#if defined(__WIN95__)
- // Find a child window to send the notification to, e.g. a toolbar.
- // There's a problem here. NMHDR::hwndFrom doesn't give us the
- // handle of the toolbar; it's probably the handle of the tooltip
- // window (anyway, it's parent is also the toolbar's parent).
- // So, since we don't know which hWnd or wxWindow originated the
- // WM_NOTIFY, we'll need to go through all the children of this window
- // trying out MSWNotify.
- // This won't work now, though, because any number of controls
- // could respond to the same generic messages :-(
-
-/* This doesn't work for toolbars, but try for other controls first.
- */
- NMHDR *hdr = (NMHDR *)lParam;
- HWND hWnd = (HWND)hdr->hwndFrom;
- wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd);
-
- if ( win )
- return win->MSWNotify(wParam, lParam);
- else
- {
- // Rely on MSWNotify to check whether the message
- // belongs to the window or not
- wxNode *node = GetChildren()->First();
- while (node)
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->MSWNotify(wParam, lParam) )
- return TRUE;
- node = node->Next();
- }
- }
-
- return FALSE;
-
-#endif
- return FALSE;
-}
-
-void wxWindow::MSWOnMenuHighlight(const WXWORD WXUNUSED(item), const WXWORD WXUNUSED(flags), const WXHMENU WXUNUSED(sysmenu))
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnMenuHighlight %d\n", handle);
-#endif
-}
-
-void wxWindow::MSWOnInitMenuPopup(const WXHMENU menu, const int pos, const bool isSystem)
-{
- if (!isSystem)
- OldOnInitMenuPopup(pos);
-}
-
-bool wxWindow::MSWOnActivate(const int state, const bool WXUNUSED(minimized), const WXHWND WXUNUSED(activate))
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle);
-#endif
-
-#if WXWIN_COMPATIBILITY
- GetEventHandler()->OldOnActivate(((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)));
-#else
- wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)),
- m_windowId);
- event.m_eventObject = this;
- GetEventHandler()->ProcessEvent(event);
-#endif
- return 0;
-}
-
-bool wxWindow::MSWOnSetFocus(const WXHWND WXUNUSED(hwnd))
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnSetFocus %d\n", m_hWnd);
-#endif
- // Deal with caret
- if (m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0))
- {
- ::CreateCaret((HWND) GetHWND(), NULL, m_caretWidth, m_caretHeight);
- if (m_caretShown)
- ::ShowCaret((HWND) GetHWND());
- }
-
-#if WXWIN_COMPATIBILITY
- GetEventHandler()->OldOnSetFocus();
-#else
- wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
- event.m_eventObject = this;
- GetEventHandler()->ProcessEvent(event);
-#endif
- return TRUE;
-}
-
-bool wxWindow::MSWOnKillFocus(const WXHWND WXUNUSED(hwnd))
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnKillFocus %d\n", m_hWnd);
-#endif
- // Deal with caret
- if (m_caretEnabled)
- {
- ::DestroyCaret();
- }
-
-#if WXWIN_COMPATIBILITY
- GetEventHandler()->OldOnKillFocus();
-#else
- wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
- event.m_eventObject = this;
- GetEventHandler()->ProcessEvent(event);
-#endif
- return TRUE;
-}
-
-void wxWindow::MSWOnDropFiles(const WXWPARAM wParam)
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd);
-#endif
-
- HANDLE hFilesInfo = (HANDLE)wParam;
- POINT dropPoint;
- DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint);
-
- // Get the total number of files dropped
- WORD gwFilesDropped = (WORD)DragQueryFile ((HDROP)hFilesInfo,
- (UINT)-1,
- (LPSTR)0,
- (UINT)0);
-
- wxString *files = new wxString[gwFilesDropped];
- int wIndex;
- for (wIndex=0; wIndex < (int)gwFilesDropped; wIndex++)
- {
- DragQueryFile (hFilesInfo, wIndex, (LPSTR) wxBuffer, 1000);
- files[wIndex] = wxBuffer;
- }
- DragFinish (hFilesInfo);
-
- wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files);
- event.m_eventObject = this;
- event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y;
-
- GetEventHandler()->ProcessEvent(event);
-
- delete[] files;
-}
-
-bool wxWindow::MSWOnDrawItem(const int id, WXDRAWITEMSTRUCT *itemStruct)
-{
-#if USE_OWNER_DRAWN
- if ( id == 0 ) { // is it a menu item?
- DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct;
- wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData);
- wxCHECK_RET( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
-
- // prepare to call OnDrawItem()
- wxDC dc;
- dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE);
- wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top,
- pDrawStruct->rcItem.right - pDrawStruct->rcItem.left,
- pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top);
- return pMenuItem->OnDrawItem(
- dc, rect,
- (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction,
- (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState
- );
- }
-#endif // owner-drawn menus
-
- wxWindow *item = FindItem(id);
-#if USE_DYNAMIC_CLASSES
- if (item && item->IsKindOf(CLASSINFO(wxControl)))
- {
- return ((wxControl *)item)->MSWOnDraw(itemStruct);
- }
- else
-#endif
- return FALSE;
-}
-
-bool wxWindow::MSWOnMeasureItem(const int id, WXMEASUREITEMSTRUCT *itemStruct)
-{
-#if USE_OWNER_DRAWN
- if ( id == 0 ) { // is it a menu item?
- MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
- wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
- wxCHECK_RET( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
-
- return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
- &pMeasureStruct->itemHeight);
- }
-#endif // owner-drawn menus
-
- wxWindow *item = FindItem(id);
-#if USE_DYNAMIC_CLASSES
- if (item && item->IsKindOf(CLASSINFO(wxControl)))
- {
- return ((wxControl *)item)->MSWOnMeasure(itemStruct);
- }
- else
-#endif
- return FALSE;
-}
-
-WXHBRUSH wxWindow::MSWOnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
- const WXUINT message, const WXWPARAM wParam, const WXLPARAM lParam)
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnCtlColour %d\n", m_hWnd);
-#endif
- if (nCtlColor == CTLCOLOR_DLG)
- {
- return OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
- }
-
- wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE);
-
- WXHBRUSH hBrush = 0;
-
- if ( item )
- hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
-
- // I think that even for dialogs, we may need to call DefWindowProc (?)
- // Or maybe just rely on the usual default behaviour.
- if ( !hBrush )
- hBrush = (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam);
-
- return hBrush ;
-}
-
-// Define for each class of dialog and control
-WXHBRUSH wxWindow::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
- WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
-{
- return (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam);
-}
-
-bool wxWindow::MSWOnColorChange(const WXHWND hWnd, const WXUINT message, const WXWPARAM wParam, const WXLPARAM lParam)
-{
- wxSysColourChangedEvent event;
- event.m_eventObject = this;
-
- // Check if app handles this.
- if (GetEventHandler()->ProcessEvent(event))
- return 0;
-
-#if WXWIN_COMPATIBILITY
- if (GetEventHandler()->OldOnSysColourChange())
- return 0;
-#endif
-
- // We didn't process it
- return 1;
-}
-
-// Responds to colour changes: passes event on to children.
-void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
-{
- wxNode *node = GetChildren()->First();
- while ( node )
- {
- // Only propagate to non-top-level windows
- wxWindow *win = (wxWindow *)node->Data();
- if ( win->GetParent() )
- {
- wxSysColourChangedEvent event2;
- event.m_eventObject = win;
- win->GetEventHandler()->ProcessEvent(event2);
- }
-
- node = node->Next();
- }
-}
-
-long wxWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
-{
- if ( m_oldWndProc )
- return ::CallWindowProc(CASTWNDPROC (FARPROC) m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
- else
- return ::DefWindowProc((HWND) GetHWND(), nMsg, wParam, lParam);
-}
-
-long wxWindow::Default()
-{
- return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
-}
-
-bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
-{
- if (!m_hWnd)
- return FALSE;
- else
- {
- // Suggestion by Andrew Davison to allow
- // a panel to accept character input in user edit mode
-
- // OK, what we probably want to do here for wxWin 2.0
- // is have a window style to indicate whether the window
- // should process dialog-style input, since we can't
- // otherwise tell whether it's supposed to do tab traversal
- // or not.
- if (GetWindowStyleFlag() & wxTAB_TRAVERSAL)
- return (::IsDialogMessage((HWND) m_hWnd, (MSG *)pMsg) != 0);
- else
- return FALSE;
- }
-}
-
-long wxWindow::MSWOnMDIActivate(const long WXUNUSED(flag), const WXHWND WXUNUSED(activate), const WXHWND WXUNUSED(deactivate))
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnMDIActivate %d\n", m_hWnd);
-#endif
- return 1;
-}
-
-void wxWindow::MSWDetachWindowMenu(void)
-{
- if (m_hMenu)
- {
- int N = GetMenuItemCount((HMENU) m_hMenu);
- int i;
- for (i = 0; i < N; i++)
- {
- char buf[100];
- int chars = GetMenuString((HMENU) m_hMenu, i, buf, 100, MF_BYPOSITION);
- if ((chars > 0) && (strcmp(buf, "&Window") == 0))
- {
- RemoveMenu((HMENU) m_hMenu, i, MF_BYPOSITION);
- break;
- }
- }
- }
-}
-
-bool wxWindow::MSWOnPaint(void)
-{
-#if WXWIN_COMPATIBILITY
- GetEventHandler()->OldOnPaint();
-#else
- wxPaintEvent event(m_windowId);
- event.m_eventObject = this;
- GetEventHandler()->ProcessEvent(event);
-#endif
- return TRUE;
-
-#if 0
-
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnPaint %d\n", m_hWnd);
-#endif
-#ifdef __WIN32__
- HRGN tRgn=CreateRectRgn(0,0,0,0); //Dummy call to get a handle!
- if (GetUpdateRgn(m_hWnd, tRgn, FALSE))
-#else
- RECT tRect;
- if (GetUpdateRect((HWND) m_hWnd, &tRect, FALSE))
-#endif
- {
- PAINTSTRUCT ps;
- // Hold a pointer to the dc so long as the OnPaint() message
- // is being processed
- HDC dc = BeginPaint(m_hWnd, &ps);
- bool isPanel = IsKindOf(CLASSINFO(wxWindow));
- m_paintHDC = (WXHDC) dc;
- RECT updateRect1 = ps.rcPaint;
- m_updateRect.x = updateRect1.left;
- m_updateRect.y = updateRect1.top;
- m_updateRect.width = updateRect1.right - updateRect1.left;
- m_updateRect.height = updateRect1.bottom - updateRect1.top;
-
- GetEventHandler()->OldOnPaint();
-
- m_paintHDC = 0;
- EndPaint((HWND) m_hWnd, &ps);
-#ifdef __WIN32__
- DeleteObject(tRgn);
-#endif
-
- if (isPanel)
- // Do default processing
- return FALSE;
- else
- return TRUE;
- }
-#ifdef __WIN32__
- DeleteObject(tRgn);
-#endif
- return FALSE;
-#endif
-}
-
-void wxWindow::MSWOnSize(const int w, const int h, const WXUINT WXUNUSED(flag))
-{
- if (m_inOnSize)
- return;
-
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnSize %d\n", m_hWnd);
-#endif
- if (!m_hWnd)
- return;
-
- m_inOnSize = TRUE;
-
-#if WXWIN_COMPATIBILITY
- GetEventHandler()->OldOnSize(w, h);
-#else
- wxSizeEvent event(wxSize(w, h), m_windowId);
- event.m_eventObject = this;
- GetEventHandler()->ProcessEvent(event);
-#endif
-
- m_inOnSize = FALSE;
-}
-
-void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos))
-{
- Default();
-}
-
-// Deal with child commands from buttons etc.
-bool wxWindow::MSWOnCommand(const WXWORD id, const WXWORD cmd, const WXHWND WXUNUSED(control))
-{
-#if DEBUG > 1
- wxDebugMsg("wxWindow::MSWOnCommand\n");
-#endif
- if (wxCurrentPopupMenu)
- {
- wxMenu *popupMenu = wxCurrentPopupMenu;
- wxCurrentPopupMenu = NULL;
- bool succ = popupMenu->MSWCommand(cmd, id);
- return succ;
- }
-#if DEBUG > 1
- char buf[80];
- sprintf(buf, "Looking for item %d...\n", id);
- wxDebugMsg(buf);
-#endif
-
- wxWindow *item = FindItem(id);
- if (item)
- {
- bool value = item->MSWCommand(cmd, id);
-#if DEBUG > 1
- if (value)
- wxDebugMsg("MSWCommand succeeded\n");
- else
- wxDebugMsg("MSWCommand failed\n");
-#endif
- return value;
- }
- else
- {
-#if DEBUG > 1
- wxDebugMsg("Could not find item!\n");
- char buf[100];
- wxDebugMsg("Item ids for this panel:\n");
-
- wxNode *current = GetChildren()->First();
- while (current)
- {
- wxObject *obj = (wxObject *)current->Data() ;
- if (obj->IsKindOf(CLASSINFO(wxControl)))
- {
- wxControl *item = (wxControl *)current->Data();
- sprintf(buf, " %d\n", (int)item->m_windowId);
- wxDebugMsg(buf);
- }
- current = current->Next();
- }
- wxYield();
-#endif
- return FALSE;
- }
-}
-
-long wxWindow::MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam)
-{
- switch (wParam)
- {
- case SC_MAXIMIZE:
- {
- wxMaximizeEvent event(m_windowId);
- event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
- return Default();
- else
- return 0;
- break;
- }
- case SC_MINIMIZE:
- {
- wxIconizeEvent event(m_windowId);
- event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
- return Default();
- else
- return 0;
- break;
- }
- default:
- return Default();
- }
- return 0;
-}
-
-void wxWindow::MSWOnLButtonDown(const int x, const int y, const WXUINT flags)
-{
-#if 0 // defined(__WIN32__) && !defined(WIN95)
- // DClick not clean supported on Win3.1, except if someone know
- // how to emulate Sleep()...
- // This means that your app will receive Down-Up-Dclick sequences
- // rather than Dclick
- if (m_doubleClickAllowed)
- {
- UINT time = GetDoubleClickTime() ;
- Sleep(time) ;
- MSG dummy ;
- if (PeekMessage(&dummy,m_hWnd,
- WM_LBUTTONDBLCLK,WM_LBUTTONDBLCLK,
- PM_NOREMOVE)
- )