add: break; } case WM_NCACTIVATE: { WORD state = LOWORD(wParam); wnd->OnNCActivate(state, hWnd); retval = wnd->DefWindowProc(message, wParam, lParam);
context: static LONG WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, int dialog, int tramp){  LONG retval;  wxWnd *wnd;  if (dialog) {    wnd = wxFindWinFromHandle(hWnd);    retval = 1; /* dialog: handled */  } else {#ifdef MZ_PRECISE_GC    wnd = wxFindWinFromHandle(hWnd);#else    wnd = (wxWnd *)GetWindowLong(hWnd, 0);#endif    retval = 0; /* most common expected result for windows */  }  if (!wnd) {    if (wxWndHook) {      wnd = wxWndHook;      wnd->handle = hWnd;    } else if (dialog) {      return 0;    } else {      wnd = wxFindWinFromHandle(hWnd);      if (!wnd)	return ::DefWindowProcW(hWnd, message, wParam, lParam);    }  }  /* Stop here if we don't have a valid handle in our wxWnd object. */  if (!wnd->handle) {    wnd->handle = hWnd;    retval = wnd->DefWindowProc(message, wParam, lParam);    wnd->handle = NULL;    return retval;  }  if (!wx_start_win_event(dialog ? "dialog" : "window", hWnd, message, wParam, lParam, tramp, &retval)) {    /* Something has gone wrong. Give up. */    return retval;  }  if (!dialog && tramp) {    switch (message) {    case WM_NCLBUTTONDOWN:    case WM_NCRBUTTONDOWN:    case WM_NCMBUTTONDOWN:    case WM_NCLBUTTONDBLCLK:    case WM_NCRBUTTONDBLCLK:    case WM_NCMBUTTONDBLCLK:      if (wParam != HTMENU)	break;    case WM_SYSKEYUP: /* ^^^ fallthrough ^^^ */      /* Guess that this could trigger a menu pop-up. */      /* Pre-emptively simulate WM_INITMENU message. */      wnd->OnMenuClick(NULL);      break;    }  }  wnd->last_msg = message;  wnd->last_wparam = wParam;  wnd->last_lparam = lParam;  switch (message) {  case WM_COPYDATA:    wxCopyData(lParam);    retval = 0;    break;  case WM_SETFONT:    retval = 0;    break;  case WM_INITDIALOG:    retval = 0;    break;  case WM_ACTIVATE:    {      WORD state = LOWORD(wParam);      WORD minimized = HIWORD(wParam);      HWND hwnd = (HWND)lParam;      wnd->OnActivate(state, minimized, hwnd);      if (dialog) retval = 0;      break;    }  case WM_SETFOCUS:    {      HWND hwnd = (HWND)wParam;      wnd->OnSetFocus(hwnd);      break;    }  case WM_KILLFOCUS:    {      HWND hwnd = (HWND)lParam;      wnd->OnKillFocus(hwnd);      break;    }  case WM_CREATE:    {      wnd->OnCreate((LPCREATESTRUCT)lParam);      if (dialog) retval = 0;      break;    }  case WM_PAINT:    {      if (!wnd->OnPaint()) {	if (dialog)	  retval = ::DefWindowProcW(hWnd, message, wParam, lParam);	else	  retval = wnd->DefWindowProc(message, wParam, lParam);      } else if (dialog)	retval = 0;      break;    }  case WM_QUERYDRAGICON:    {      HICON hIcon;      hIcon = wnd->OnQueryDragIcon();      if (hIcon)	retval = (LONG)hIcon;      else 	retval = wnd->DefWindowProc(message, wParam, lParam);      break;    }  case WM_SIZE:    if (wParam == SIZE_MINIMIZED)      break;  case WM_MOVE:    {      /* w & h ignored... */      wnd->OnSize(0, 0, wParam);      if (dialog) retval = 0;      break;    }  case WM_GETMINMAXINFO:    wnd->GetMinMaxInfo((MINMAXINFO *)lParam);    break;  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:    {      int x = (short)LOWORD(lParam);      int y = (short)HIWORD(lParam);      int et;      switch(message) {      case WM_RBUTTONDOWN:      case WM_RBUTTONDBLCLK:	et = wxEVENT_TYPE_RIGHT_DOWN;	break;      case WM_RBUTTONUP:	et = wxEVENT_TYPE_RIGHT_UP;	break;      case WM_MBUTTONDOWN:      case WM_MBUTTONDBLCLK:	et = wxEVENT_TYPE_MIDDLE_DOWN;	break;      case WM_MBUTTONUP:	et = wxEVENT_TYPE_MIDDLE_UP;	break;      case WM_LBUTTONDOWN:      case WM_LBUTTONDBLCLK:	et = wxEVENT_TYPE_LEFT_DOWN;	break;      case WM_LBUTTONUP:	et = wxEVENT_TYPE_LEFT_UP;	break;      }      wnd->OnButton(x, y, wParam, et);      break;    }  case WM_NCLBUTTONDOWN:  case WM_NCRBUTTONDOWN:  case WM_NCMBUTTONDOWN:  case WM_NCLBUTTONDBLCLK:  case WM_NCRBUTTONDBLCLK:  case WM_NCMBUTTONDBLCLK:  case WM_NCLBUTTONUP:  case WM_NCRBUTTONUP:  case WM_NCMBUTTONUP:    if ((wParam == HTVSCROLL) || (wParam == HTHSCROLL)) {	/* Fall through below */      int x = (short)LOWORD(lParam);      int y = (short)HIWORD(lParam);      int et;      switch(message) {      case WM_NCRBUTTONDOWN:      case WM_NCRBUTTONDBLCLK:	et = wxEVENT_TYPE_RIGHT_DOWN;	break;      case WM_NCRBUTTONUP:	et = wxEVENT_TYPE_RIGHT_UP;	break;      case WM_NCMBUTTONDOWN:      case WM_NCMBUTTONDBLCLK:	et = wxEVENT_TYPE_MIDDLE_DOWN;	break;      case WM_NCMBUTTONUP:	et = wxEVENT_TYPE_MIDDLE_UP;	break;      case WM_NCLBUTTONDOWN:      case WM_NCLBUTTONDBLCLK:	et = wxEVENT_TYPE_LEFT_DOWN;	break;      case WM_NCLBUTTONUP:	et = wxEVENT_TYPE_LEFT_UP;	break;      }      if (!wnd->OnButton(x, y, 0, et, 1)) {	retval = 1;	break;      }    }         if (dialog)      retval = 0;    else {      if (tramp 	  && ((wParam == HTVSCROLL) || (wParam == HTHSCROLL))	  && wnd->wx_window	  && wxSubType(wnd->wx_window->__type, wxTYPE_CANVAS)) {	/* To support interactive scrolling in canvases, we	   use a trampoline. See wxHiEventTrampoline in mred.cxx. */	wxDWP_Closure *c;	c = new wxDWP_Closure;	c->wnd = wnd;	c->message = message;	c->wParam = wParam;	c->lParam = lParam;	retval = wxHiEventTrampoline(call_dwp, (void *)c);      } else {	retval = wnd->DefWindowProc(message, wParam, lParam);      }    }    break;  case WM_MOUSEMOVE:    {      int x = (short)LOWORD(lParam);      int y = (short)HIWORD(lParam);      wnd->OnMouseMove(x, y, wParam);      break;    }  case WM_NCMOUSEMOVE:    {      int x = (short)LOWORD(lParam);      int y = (short)HIWORD(lParam);      if (!wnd->OnMouseMove(x, y, wParam, 1)) {	retval = 0;	break;      }            if (dialog)	retval = 1;      else	retval = wnd->DefWindowProc(message, wParam, lParam);      break;    }#ifndef WM_MOUSEWHEEL# define WM_MOUSEWHEEL 0x020A# define WHEEL_DELTA 120#endif  case WM_MOUSEWHEEL:    {      int delta = ((short)HIWORD(wParam)) / WHEEL_DELTA;      while (delta) {	WORD code;	if (delta < 0) {	  code = WXK_WHEEL_DOWN;	  delta++;	} else {	  code = WXK_WHEEL_UP;	  delta--;	}	wnd->OnChar(code, lParam, 1);      }      break;    }  case WM_DESTROY:    {      if (!wnd->OnDestroy())	retval = wnd->DefWindowProc(message, wParam, lParam);      break;    }  case WM_COMMAND:    {      WORD id = LOWORD(wParam);      HWND hwnd = (HWND)lParam;      WORD cmd = HIWORD(wParam);      if (!wnd->OnCommand(id, cmd, hwnd))	retval = wnd->DefWindowProc(message, wParam, lParam);      else if (dialog) 	retval = 0;      break;    }  case WM_INITMENU:    {      if (dialog)	retval = 0;      else {	/* We skip the call to OnMenuClick() because it's handled	   by WM_SYSKEYUP. WM_INITMENU seems to happen too late,	   at a point where we can't execute Scheme code. */	// wnd->OnMenuClick(wParam);      }      break;    }  case WM_MENUSELECT:    {      if (dialog)	retval = 0;      else {	// WORD id = LOWORD(wParam);	WORD flags = HIWORD(wParam);	HMENU sysmenu = (HMENU)lParam;	wnd->OnMenuSelect((WORD)wParam, flags, sysmenu);      }      break;    }  case WM_NOTIFY:    {      NMHDR *nm = (NMHDR *)lParam;      if (!nm || !wnd->OnCommand(LOWORD(wParam), nm->code, nm->hwndFrom))	retval = wnd->DefWindowProc(message, wParam, lParam);      else if (dialog) 	retval = 0;    }    break;  case WM_SYSKEYDOWN:    if ((wParam == VK_MENU) || (wParam == VK_F4)) { /* F4 is close */      wxUnhideCursor();      retval = wnd->DefWindowProc(message, wParam, lParam);    }  case WM_KEYUP:  case WM_KEYDOWN: /* ^^^ fallthrough */    {      // Avoid duplicate messages to OnChar      if ((message == WM_KEYUP)	  || ((wParam != VK_ESCAPE) 	      && (wParam != VK_SHIFT) 	      && (wParam != VK_CONTROL) 	      && (wParam != VK_SPACE) 	      && (wParam != VK_RETURN) 	      && (wParam != VK_TAB) 	      && (wParam != VK_BACK)))	wnd->OnChar((WORD)wParam, lParam, FALSE, message == WM_KEYUP);      break;    }  case WM_SYSCHAR:    if (wParam == VK_MENU) {      wxUnhideCursor();      retval = wnd->DefWindowProc(message, wParam, lParam);    }  case WM_CHAR: /* ^^^ fallthrough */    {      wnd->OnChar((WORD)wParam, lParam, TRUE);      break;    }  case WM_HSCROLL:  case WM_VSCROLL:    {      WORD code = LOWORD(wParam);      WORD pos = HIWORD(wParam);      HWND control = (HWND)lParam;      if (message == WM_HSCROLL)	wnd->OnHScroll(code, pos, control);      else	wnd->OnVScroll(code, pos, control);      break;    }  case WM_ERASEBKGND:    {      // Prevents flicker when dragging      if (!dialog && IsIconic(hWnd))	retval = 1;      else if (!wnd->OnEraseBkgnd((HDC)wParam))	retval = wnd->DefWindowProc(message, wParam, lParam);      else	retval = 1;      break;    }  case WM_MDIACTIVATE:    {      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);      retval = wnd->OnMDIActivate(activate, hWndActivate, hWndDeactivate);      break;    }  case WM_DROPFILES:    {      wnd->OnDropFiles(wParam);      break;    }  case WM_QUERYENDSESSION:    retval = 1;    break;  case WM_ENDSESSION:  case WM_CLOSE:    {      retval = 0;      if (wnd->wx_window && wnd->wx_window->IsShown()) {	if (wnd->OnClose()) {	  wnd->wx_window->Show(FALSE);	}      }      break;    }#ifndef WM_THEMECHANGED# define WM_THEMECHANGED 0x031A#endif  case WM_THEMECHANGED:    {      wnd->OnWinThemeChange();      if (dialog)	retval = 0;      else	retval = wnd->DefWindowProc(message, wParam, lParam);    }  case WM_NCPAINT:    {      if (wnd->NCPaint(wParam, lParam, &retval))	break;    }  default: /* ^^^ fallthrough ^^^ */    {      if (message == WM_IS_MRED) {	retval = 79;      } else if (dialog)	retval = 0;      else	retval = wnd->DefWindowProc(message, wParam, lParam);      break;    }  }    wnd->Propagate(message, wParam, lParam);	  wx_end_win_event(dialog ? "dialog" : "window", hWnd, message, tramp);  return retval;}