ReactOS  0.4.15-dev-3453-gff89651
CACListView Class Reference

#include <CAutoComplete.h>

Inheritance diagram for CACListView:
Collaboration diagram for CACListView:

Public Member Functions

 CACListView ()
 
HWND Create (HWND hwndParent)
 
VOID SetFont (HFONT hFont)
 
INT GetVisibleCount ()
 
CStringW GetItemText (INT iItem)
 
INT ItemFromPoint (INT x, INT y)
 
INT GetCurSel ()
 
VOID SetCurSel (INT iItem)
 
VOID SelectHere (INT x, INT y)
 

Static Public Member Functions

static LPCWSTR GetWndClassName ()
 

Public Attributes

CAutoCompletem_pDropDown
 
INT m_cyItem
 

Protected Member Functions

LRESULT OnButtonUp (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonDown (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMRButtonDown (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMouseWheel (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCHitTest (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 

Detailed Description

Definition at line 35 of file CAutoComplete.h.

Constructor & Destructor Documentation

◆ CACListView()

CACListView::CACListView ( )

Definition at line 373 of file CAutoComplete.cpp.

374 {
375 }
#define CY_ITEM
#define NULL
Definition: types.h:112
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:38

Member Function Documentation

◆ Create()

HWND CACListView::Create ( HWND  hwndParent)

Definition at line 377 of file CAutoComplete.cpp.

378 {
379  ATLASSERT(m_hWnd == NULL);
380  DWORD dwStyle = WS_CHILD | /*WS_VISIBLE |*/ WS_CLIPSIBLINGS | LVS_NOCOLUMNHEADER |
382  HWND hWnd = ::CreateWindowExW(0, GetWndClassName(), L"Internet Explorer", dwStyle,
383  0, 0, 0, 0, hwndParent, NULL,
384  _AtlBaseModule.GetModuleInstance(), NULL);
385  SubclassWindow(hWnd); // do subclass to handle messages
386  // set extended listview style
388  SetExtendedListViewStyle(exstyle, exstyle);
389  // insert one column (needed to insert items)
391  column.fmt = LVCFMT_LEFT;
393  InsertColumn(0, &column);
394  return m_hWnd;
395 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define CX_LIST
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVS_NOCOLUMNHEADER
Definition: commctrl.h:2284
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define LVS_REPORT
Definition: commctrl.h:2262
HWND hWnd
Definition: settings.c:17
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define LVCFMT_LEFT
Definition: commctrl.h:2598
#define WS_CHILD
Definition: pedump.c:617
#define L(x)
Definition: ntvdm.h:50
#define SubclassWindow(hwnd, lpfn)
Definition: windowsx.h:517
static HWND hwndParent
Definition: cryptui.c:300
#define LVS_SINGLESEL
Definition: commctrl.h:2266
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LVS_EX_ONECLICKACTIVATE
Definition: commctrl.h:2735
static LPCWSTR GetWndClassName()
Definition: CAutoComplete.h:40
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define LVS_OWNERDATA
Definition: commctrl.h:2274
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVS_EX_TRACKSELECT
Definition: commctrl.h:2732
#define NULL
Definition: types.h:112
#define SM_CXVSCROLL
Definition: winuser.h:955
#define LV_COLUMNW
Definition: commctrl.h:2546
static int InsertColumn(int nCol, LPCWSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
Definition: column.c:82
#define LVS_OWNERDRAWFIXED
Definition: commctrl.h:2283

Referenced by CAutoComplete::OnCreate().

◆ GetCurSel()

INT CACListView::GetCurSel ( )

Definition at line 447 of file CAutoComplete.cpp.

448 {
449  return GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
450 }
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define LVNI_ALL
Definition: commctrl.h:2422

Referenced by CAutoComplete::GetDropDownStatus(), CAutoComplete::OnEditKeyDown(), CAutoComplete::OnListSelChange(), and CAutoComplete::OnListUpDown().

◆ GetItemText()

CStringW CACListView::GetItemText ( INT  iItem)

Definition at line 429 of file CAutoComplete.cpp.

430 {
431  // NOTE: LVS_OWNERDATA doesn't support LVM_GETITEMTEXT.
433  ATLASSERT(GetStyle() & LVS_OWNERDATA);
434  return m_pDropDown->GetItemText(iItem);
435 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
CStringW GetItemText(INT iItem) const
#define LVS_OWNERDATA
Definition: commctrl.h:2274
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:38

Referenced by CAutoComplete::GetDropDownStatus(), CAutoComplete::OnDrawItem(), and OnLButtonDown().

◆ GetVisibleCount()

INT CACListView::GetVisibleCount ( )

Definition at line 419 of file CAutoComplete.cpp.

420 {
421  if (m_cyItem <= 0) // avoid "division by zero"
422  return 0;
423  CRect rc;
424  GetClientRect(&rc);
425  return rc.Height() / m_cyItem;
426 }
int Height() const
Definition: atltypes.h:318
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by CAutoComplete::OnListUpDown(), CAutoComplete::OnVScroll(), and CAutoComplete::UpdateScrollBar().

◆ GetWndClassName()

static LPCWSTR CACListView::GetWndClassName ( )
inlinestatic

Definition at line 40 of file CAutoComplete.h.

40 { return WC_LISTVIEW; }
#define WC_LISTVIEW
Definition: commctrl.h:2259

Referenced by Create().

◆ ItemFromPoint()

INT CACListView::ItemFromPoint ( INT  x,
INT  y 
)

Definition at line 438 of file CAutoComplete.cpp.

439 {
440  LV_HITTESTINFO hittest;
441  hittest.pt.x = x;
442  hittest.pt.y = y;
443  return HitTest(&hittest);
444 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define LV_HITTESTINFO
Definition: commctrl.h:2504
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by OnLButtonDown(), CAutoComplete::OnNotify(), and SelectHere().

◆ OnButtonUp()

LRESULT CACListView::OnButtonUp ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 468 of file CAutoComplete.cpp.

469 {
470  TRACE("CACListView::OnButtonUp(%p)\n", this);
471  return 0; // eat
472 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ OnLButtonDown()

LRESULT CACListView::OnLButtonDown ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 476 of file CAutoComplete.cpp.

477 {
478  TRACE("CACListView::OnLButtonDown(%p)\n", this);
481  if (iItem != -1)
482  {
483  m_pDropDown->SelectItem(iItem); // select the item
484  CStringW strText = GetItemText(iItem); // get text of item
485  m_pDropDown->SetEditText(strText); // set text
486  m_pDropDown->SetEditSel(0, strText.GetLength()); // select all
487  m_pDropDown->HideDropDown(); // hide
488  }
489  return 0;
490 }
int GetLength() const
Definition: atlsimpstr.h:356
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
int32_t INT
Definition: typedefs.h:58
VOID SetEditText(LPCWSTR pszText)
#define TRACE(s)
Definition: solgame.cpp:4
VOID SetEditSel(INT ich0, INT ich1)
VOID SelectItem(INT iItem)
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
INT ItemFromPoint(INT x, INT y)
LPARAM lParam
Definition: combotst.c:139
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:38
CStringW GetItemText(INT iItem)

◆ OnMouseWheel()

LRESULT CACListView::OnMouseWheel ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 500 of file CAutoComplete.cpp.

501 {
502  TRACE("CACListView::OnMouseWheel(%p)\n", this);
504  LRESULT ret = DefWindowProcW(uMsg, wParam, lParam); // do default
506  return ret;
507 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TRACE(s)
Definition: solgame.cpp:4
int ret
VOID UpdateScrollBar()
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:38

◆ OnMRButtonDown()

LRESULT CACListView::OnMRButtonDown ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 493 of file CAutoComplete.cpp.

494 {
495  TRACE("CACListView::OnMRButtonDown(%p)\n", this);
496  return 0; // eat
497 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ OnNCHitTest()

LRESULT CACListView::OnNCHitTest ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 510 of file CAutoComplete.cpp.

511 {
512  TRACE("CACListView::OnNCHitTest(%p)\n", this);
514  POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; // in screen coordinates
515  ScreenToClient(&pt); // into client coordinates
516  HWND hwndTarget = m_pDropDown->ChildWindowFromPoint(pt);
517  if (hwndTarget != m_hWnd)
518  return HTTRANSPARENT; // pass through (for resizing the drop-down window)
519  bHandled = FALSE; // do default
520  return 0;
521 }
#define HTTRANSPARENT
Definition: winuser.h:2453
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define pt(x, y)
Definition: drawing.c:79
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LPARAM lParam
Definition: combotst.c:139
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:38

◆ SelectHere()

VOID CACListView::SelectHere ( INT  x,
INT  y 
)

Definition at line 462 of file CAutoComplete.cpp.

463 {
465 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
VOID SetCurSel(INT iItem)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
INT ItemFromPoint(INT x, INT y)

◆ SetCurSel()

VOID CACListView::SetCurSel ( INT  iItem)

Definition at line 453 of file CAutoComplete.cpp.

454 {
455  if (iItem == -1)
456  SetItemState(-1, 0, LVIS_SELECTED); // select none
457  else
458  SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
459 }
#define LVIS_SELECTED
Definition: commctrl.h:2319

Referenced by CAutoComplete::OnListUpDown(), CAutoComplete::OnNotify(), SelectHere(), and CAutoComplete::SelectItem().

◆ SetFont()

VOID CACListView::SetFont ( HFONT  hFont)

Definition at line 398 of file CAutoComplete.cpp.

399 {
400  SendMessageW(WM_SETFONT, (WPARAM)hFont, TRUE); // set font
401 
402  // get listview item height
403  m_cyItem = CY_ITEM;
404  HDC hDC = GetDC();
405  if (hDC)
406  {
407  HGDIOBJ hFontOld = ::SelectObject(hDC, hFont);
408  TEXTMETRICW tm;
409  if (::GetTextMetricsW(hDC, &tm))
410  {
411  m_cyItem = (tm.tmHeight * 3) / 2; // 3/2 of text height
412  }
413  ::SelectObject(hDC, hFontOld);
414  ReleaseDC(hDC);
415  }
416 }
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
#define CY_ITEM
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
UINT_PTR WPARAM
Definition: windef.h:207
HFONT hFont
Definition: main.c:53
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
Definition: time.h:68
static HDC hDC
Definition: 3dtext.c:33
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETFONT
Definition: winuser.h:1637

Referenced by CAutoComplete::OnCreate().

Member Data Documentation

◆ m_cyItem

INT CACListView::m_cyItem

◆ m_pDropDown


The documentation for this class was generated from the following files: