windows_programming_notes.nbk: Home | Index | Next Page: WM_CONTEXTMENU | Previous Page: WM_COMPACTING


 WM_COMPAREITEM

The system sends the WM_COMPAREITEM message to determine the relative position of a new item in the sorted list of an owner-drawn combo box or list box. Whenever the application adds a new item, the system sends this message to the owner of a combo box or list box created with the CBS_SORT or LBS_SORT style.

A window receives this message through its WindowProc function.

    LRESULT CALLBACK WindowProc(
      HWND hwnd,       // handle to window
      UINT uMsg,       // WM_COMPAREITEM (UINT)
      WPARAM wParam,   // control identifier
      LPARAM lParam    // item data (LPCOMPAREITEMSTRUCT)
    );

Parameters

Return Values

The return value indicates the relative position of the two items. It may be any of the values shown in the following table.

Value Meaning –1 Item 1 precedes item 2 in the sorted order. 0 Items 1 and 2 are equivalent in the sorted order. 1 Item 1 follows item 2 in the sorted order.

Remarks

When the owner of an owner-drawn combo box or list box receives this message, the owner returns a value indicating which of the items specified by the COMPAREITEMSTRUCT structure will appear before the other. Typically, the system sends this message several times until it determines the exact position for the new item.

If a dialog box procedure handles this message, it should cast the desired return value to a BOOL and return the value directly. The DWL_MSGRESULT value set by the SetWindowLong function is ignored.

Requirements

  Windows NT/2000 or later: Requires Windows NT 3.1 or later.
  Windows 95/98/Me: Requires Windows 95 or later.
  Header: Declared in Winuser.h; include Windows.h.

windows_programming_notes.nbk: Home | Index | Next Page: WM_CONTEXTMENU | Previous Page: WM_COMPACTING


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time