-/***********************************************************************
- * ComboLBWndProc_common
- *
- * The real combo listbox wndproc
- */
-static LRESULT WINAPI ComboLBWndProc_common( HWND hwnd, UINT msg,
- WPARAM wParam, LPARAM lParam, BOOL unicode )
-{
- LRESULT lRet = 0;
- LB_DESCR *descr;
- LPHEADCOMBO lphc;
-
- if (!(descr = (LB_DESCR *)GetWindowLongA( hwnd, 0 )))
- {
- if (msg == WM_CREATE)
- {
- CREATESTRUCTA *lpcs = (CREATESTRUCTA *)lParam;
- TRACE_(combo)("\tpassed parent handle = %p\n",lpcs->lpCreateParams);
- lphc = (LPHEADCOMBO)(lpcs->lpCreateParams);
- return LISTBOX_Create( hwnd, lphc );
- }
- /* Ignore all other messages before we get a WM_CREATE */
- return unicode ? DefWindowProcW( hwnd, msg, wParam, lParam ) :
- DefWindowProcA( hwnd, msg, wParam, lParam );
- }
-
- //TRACE_(combo)("[%p]: msg %s wp %08x lp %08lx\n",
- // hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam );
-
- if ((lphc = descr->lphc) != NULL)
- {
- switch( msg )
- {
- case WM_MOUSEMOVE:
- if ( (CB_GETTYPE(lphc) != CBS_SIMPLE) )
- {
- POINT mousePos;
- BOOL captured;
- RECT clientRect;
-
- mousePos.x = (INT16)LOWORD(lParam);
- mousePos.y = (INT16)HIWORD(lParam);
-
- /*
- * If we are in a dropdown combobox, we simulate that
- * the mouse is captured to show the tracking of the item.
- */
- GetClientRect(hwnd, &clientRect);
-
- if (PtInRect( &clientRect, mousePos ))
- {
- captured = descr->captured;
- descr->captured = TRUE;
-
- LISTBOX_HandleMouseMove( hwnd, descr,
- mousePos.x, mousePos.y);
-
- descr->captured = captured;
-
- }
- else
- {
- LISTBOX_HandleMouseMove( hwnd, descr,
- mousePos.x, mousePos.y);
- }
-
- return 0;
-
- }
- break;
-
- case WM_LBUTTONUP:
- {
- POINT mousePos;
- RECT clientRect;
-
- /*
- * If the mouse button "up" is not in the listbox,
- * we make sure there is no selection by re-selecting the
- * item that was selected when the listbox was made visible.
- */
- mousePos.x = (INT16)LOWORD(lParam);
- mousePos.y = (INT16)HIWORD(lParam);
-
- GetClientRect(hwnd, &clientRect);
-
- /*
- * When the user clicks outside the combobox and the focus
- * is lost, the owning combobox will send a fake buttonup with
- * 0xFFFFFFF as the mouse location, we must also revert the
- * selection to the original selection.
- */
- if ( (lParam == (LPARAM)-1) ||
- (!PtInRect( &clientRect, mousePos )) )
- {
- LISTBOX_MoveCaret( hwnd, descr, lphc->droppedIndex, FALSE );
- }
- }
- return LISTBOX_HandleLButtonUp( hwnd, descr );
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- return LISTBOX_HandleLButtonDownCombo(hwnd, descr, msg, wParam,
- (INT16)LOWORD(lParam),
- (INT16)HIWORD(lParam) );
- case WM_NCACTIVATE:
- return FALSE;
- case WM_KEYDOWN:
- if( CB_GETTYPE(lphc) != CBS_SIMPLE )
- {
- /* for some reason(?) Windows makes it possible to
- * show/hide ComboLBox by sending it WM_KEYDOWNs */
-
- if( (!(lphc->wState & CBF_EUI) && wParam == VK_F4) ||
- ( (lphc->wState & CBF_EUI) && !(lphc->wState & CBF_DROPPED)
- && (wParam == VK_DOWN || wParam == VK_UP)) )
- {
- COMBO_FlipListbox( lphc, FALSE, FALSE );
- return 0;
- }
- }
- return LISTBOX_HandleKeyDown( hwnd, descr, wParam );
-
-#ifndef __REACTOS__
- case LB_SETCURSEL16:
-#endif
- case LB_SETCURSEL:
- lRet = unicode ? ListBoxWndProcW( hwnd, msg, wParam, lParam ) :
- ListBoxWndProcA( hwnd, msg, wParam, lParam );
- lRet =(lRet == LB_ERR) ? lRet : descr->selected_item;
- return lRet;
- case WM_NCDESTROY:
- if( CB_GETTYPE(lphc) != CBS_SIMPLE )
- lphc->hWndLBox = 0;
- break;
- }
- }
-
- /* default handling: call listbox wnd proc */
- lRet = unicode ? ListBoxWndProcW( hwnd, msg, wParam, lParam ) :
- ListBoxWndProcA( hwnd, msg, wParam, lParam );
-
- TRACE_(combo)("\t default on msg [%04x]\n", (UINT16)msg );
-
- return lRet;
-}
-
-/***********************************************************************
- * ComboLBWndProcA
- *
- * NOTE: in Windows, winproc address of the ComboLBox is the same
- * as that of the Listbox.
- */
-LRESULT WINAPI ComboLBWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
-{
- if (!IsWindow(hwnd)) return 0;
- return ComboLBWndProc_common( hwnd, msg, wParam, lParam, FALSE );
-}
-
-/***********************************************************************
- * ComboLBWndProcW
- */
-LRESULT WINAPI ComboLBWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
-{
- if (!IsWindow(hwnd)) return 0;
- return ComboLBWndProc_common( hwnd, msg, wParam, lParam, TRUE );
-}
-