📄 listbox.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#pragma once
#ifndef __LISTBOX_HPP__
#define __LISTBOX_HPP__
#include "Controls.hpp"
#include "CommonControl.hpp"
#include "PaintHelper.hpp"
#ifdef VIRTUAL_LISTBOX
#include <vector.hxx>
#endif
/*------------------------------------------------------------------------------
ListBoxImpl_t
Implementation of a VoIP ListBox
------------------------------------------------------------------------------*/
class ListBoxImpl_t :
public CommonControlImpl_t<ListBoxImpl_t, ListBox_t>
{
public:
ListBoxImpl_t();
~ListBoxImpl_t();
#ifdef VIRTUAL_LISTBOX
DECLARE_NO_SUPERCLASS();
#else
//Subclass the window
DECLARE_SUPERCLASS(L"Listbox");
#endif
LRESULT
ControlWindowProc(
UINT Message,
WPARAM wParam,
LPARAM lParam,
bool& Handled
);
private:
enum OwnerDrawType_e
{
OWNERDRAWFIXED = 1,
OWNERDRAWVAR = 2,
};
bool
IsValidIndex(
int Index
);
// Message handlers
LRESULT
OnCreate(
__in const CREATESTRUCT* pCreateStruct
);
LRESULT
OnPaint(
HDC hdc
);
LRESULT
OnDestroy(
void
);
LRESULT
OnKeydown(
int VirtualKey,
UINT KeyData
);
#ifdef VIRTUAL_LISTBOX
LRESULT
OnKillFocus(
WPARAM wParam,
LPARAM lParam
);
#endif
LRESULT
OnMouseButton(
WPARAM wParam,
LPARAM lParam
);
LRESULT
OnNotify(
int ControlId,
__in NMHDR* pNotificationHeader
);
LRESULT
OnSetFocus(
HWND OldFocus
);
LRESULT
OnSetRedraw(
BOOL Enabled
);
LRESULT
OnSetControlBackground(
UINT Message,
HDC hdc,
HWND Control
);
LRESULT
OnSettingChange(
WPARAM wParam
);
LRESULT
OnTimer(
void
);
LRESULT
OnAddItem(
int Index,
__in IVoIPDisplayItem* pItem
);
LRESULT
OnDeleteItem(
int Index
);
LRESULT
OnFindItem(
__in IVoIPDisplayItem* pItem
);
LRESULT
OnGetCount(
void
);
LRESULT
OnGetCurSel(
void
);
LRESULT
OnSetCurSel(
int IndexToSelect
);
LRESULT
OnGetItemData(
int Index
);
LRESULT
OnSetItemData(
int Index,
__in_opt IVoIPDisplayItem* pItem
);
LRESULT
OnGetItemRect(
int Index,
__out RECT* pRectangle
);
#ifdef AUTOMATION
LRESULT
OnGetText(
int Index,
__out_ecount(MAX_PATH) WCHAR* pBuffer
);
LRESULT
OnGetTextLen(
int Index
);
#endif
LRESULT
OnGetTopIndex(
void
);
LRESULT
OnSetTopIndex(
int Index
);
LRESULT
OnItemFromPoint(
unsigned short xCoordinate,
unsigned short yCoordinate
);
LRESULT
OnResetContent(
void
);
#ifdef VIRTUAL_LISTBOX
LRESULT
OnGetItemHeight(
int Index
);
#endif
LRESULT
DeleteItem(
__in DELETEITEMSTRUCT* pDeleteStruct
);
LRESULT
DrawItem(
__in DRAWITEMSTRUCT* pDrawStruct
);
LRESULT
MeasureItem(
__in MEASUREITEMSTRUCT* pMeasureStruct
);
private:
//Helper functions
HRESULT CreateMainBackBuffer(HDC hdc);
HRESULT
RepositionSubcontrols(
void
);
HRESULT
NotifyParentOfOffscreenItems(
void
);
HRESULT
RepositionDisplayItems(
void
);
int
GetNextSelectableIndex(
UINT IndexToSelect,
bool IsKeyUp
);
void
SimulateItemActivated(
);
private:
// Member data
PaintHelper_t m_BackBuffer;
PaintHelper_t m_ItemBackBuffer;
bool m_RedrawingEnabled;
bool m_ListBoxHeightChanged; // Boolean varible indicates if the listbox window has been shrinked or not
bool m_PositionControlNotification; //If TRUE IVoIPDisplayItems will be notified
//when controls need to be positioned
bool m_CheckToolTip;
ToolTip_t m_ToolTip; //ToolTip Window Handler
DWORD m_dwToolTipTimer;
UINT m_OriginalHeight;
#ifdef VIRTUAL_LISTBOX
ce::vector<void*> m_Items;
ce::vector<short> m_VariableHeight;
int m_FixedItemHeight;
bool m_UseCaret;
int m_SelectedItem;
int m_TopItem;
OwnerDrawType_e m_OwnerDraw;
#endif
};
#endif //!defined __LISTBOX_HPP__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -