56 *Strings = *tCBD.Strings;
57 *ItemDatas = *tCBD.ItemDatas;
58 Selection = tCBD.Selection;
59 SelIndex = tCBD.SelIndex;
97 ItemDatas->Add(itemData);
108 if (index != CB_ERR) {
110 if (index <
static_cast<int>(Strings->Size()))
111 Selection = (*Strings)[index];
122 int numStrings = Strings->Size();
124 for (
int i = 0; i < numStrings; i++)
125 if (
_tcscmp((*Strings)[i].c_str(), str) == 0) {
129 if (Selection != str)
139 return static_cast<int>(Selection.length());
149 if (bufferSize > 0) {
150 _tcsncpy(buffer, Selection.c_str(), bufferSize-1);
151 buffer[bufferSize - 1] = 0;
180 int x,
int y,
int w,
int h,
185 TListBox(parent, id, x, y, w, h, module),
188 Attr.Style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP |
189 CBS_SORT | CBS_AUTOHSCROLL | WS_VSCROLL | style;
203 TListBox(parent, resourceId, module),
206 TRACEX(OwlControl,
OWL_CDLEVEL,
_T(
"TComboBox constructed from resource @") << (
void*)
this);
237 auto i = COMBOBOXINFO{
sizeof(COMBOBOXINFO)};
239 if (!ok)
throw TXOwl{
_T(
"::GetComboBoxInfo failed")};
272 TextLimit = textlimit;
292 return static_cast<int>(retValue);
301 std::pair<int, int> r(0,0);
314 if ((
GetWindowLong(GWL_STYLE) & CBS_DROPDOWN) == CBS_DROPDOWN)
330 int vertRes =
TDesktopDC().GetDeviceCaps(VERTRES);
331 if(rect.
Bottom() >= vertRes)
348 if (!buffer && direction !=
tdSizeData)
return 0;
357 for (
int i = 0; i != n; ++i)
378 for (
int i = 0; i != n; ++i)
420 TRACEX(OwlControl, 1,
_T(
"TComboBox::SetupWindow() @ ") << (
void*)
this);
451 TRACEX(OwlControl, 1,
_T(
"TComboBox::CleanupWindow() @ ") << (
void*)
this);
457#if OWL_PERSISTENT_STREAMS
466 is >> GetObject()->TextLimit;
474TComboBox::Streamer::Write(opstream& os)
const
477 os << GetObject()->TextLimit;
#define PRECONDITION(condition)
#define TRACEX(group, level, message)
uint GetItemsInContainer() const
An interface object that represents a transfer buffer for a TComboBox.
~TComboBoxData()
Destructor for TComboBoxData. Deletes Strings, ItemDatas, and Selection.
void AddStringItem(LPCTSTR str, LPARAM itemData, bool isSelected=false)
Adds a given string and uint32 item to the "Strings" and "ItemDatas" array and copies the string into...
TComboBoxData & operator=(const TComboBoxData &tCBD)
TStringArray & GetStrings()
Returns the array of strings (the Strings data member) to transfer to or from a combo box's associate...
int GetSelIndex()
Returns the index (the SelIndex data member) of the selected item in the strings array.
void Select(int index)
Selects an item at a given index.
tstring & GetSelection()
Returns the currently selected string (the Selection data member) to transfer to or from a combo box.
void SelectString(LPCTSTR str)
Selects "str", marking the matching String entry (if any) as selected.
const tstring & GetSelString() const
int GetSelStringLength() const
Returns the length of the selection string excluding the terminating 0.
TComboBoxData()
Constructs a TComboBoxData object, initializes Strings and ItemDatas to empty arrays,...
TLParamArray & GetItemDatas()
Returns the array of DWORDs to transfer to or from a combo box's associated list box.
void Clear()
Flushes the Strings and ItemDatas members.
void ResetSelections()
Resets the index of the selected item and the currently selected string.
void AddString(LPCTSTR str, bool isSelected=false)
Adds the specified string to the array of Strings.
You can use TComboBox to create a combo box or a combo box control in a parent TWindow,...
TComboBox(TWindow *parent, int id, int x, int y, int w, int h, uint32 style, uint textLimit, TModule *module=0)
Constructs a combo box object with the specified parent window (parent), control ID (Id),...
int GetEditSel(int &startPos, int &endPos)
Returns, in the supplied reference parameters, the starting and ending positions of the text selected...
virtual int GetString(TCHAR *str, int index) const
Retrieve the contents of the string at the passed index of list part of the associated combobox,...
void ShowList(bool show=true)
Shows or hides the drop down or drop down list combo box depending on the value of show.
virtual void ClearList()
Clear all the entries in list part of the associated combobox.
std::pair< int, int > GetEditSel()
Functional style overload.
auto GetInfo() const -> COMBOBOXINFO
Returns a COMBOBOXINFO struct containing information about the combobox.
void SetTextLimit(uint textlimit)
Sets the text length limit member and associated control.
int SetEditSel(int startPos, int endPos)
Selects characters that are between startPos and endPos in the edit control of the combo box.
void SetupWindow()
Limits the amount of text that the user can enter in the combo box's edit control to the value of Tex...
void GetDroppedControlRect(TRect &Rect) const
For combo boxes, gets the screen coordinates of the dropped down list box.
int GetText(TCHAR *str, int maxChars) const
Retrieves up to maxChars characters in the edit or static portion of the combo box.
virtual int SetSelStringExact(LPCTSTR find, int startIndex=-1)
DLN added.
virtual int AddString(LPCTSTR str)
Adds a string to an associated list part of a combo box.
virtual int SetItemData(int index, LPARAM itemData)
Sets the 32-bit value associated with the TComboBox's item.
void CleanupWindow()
Cleanup aliases created in SetupWindow.
virtual int GetCount() const
Return the number of entries in list part of the associated combobox.
virtual int GetSelIndex() const
Returns the index of the list selection or a negative value if none exists.
virtual int SetSelIndex(int index)
Selects a string of characters in a combo box.
virtual LPARAM GetItemData(int index) const
Returns the 32-bit value associated with the combo box's item.
void Transfer(TComboBoxData &data, TTransferDirection direction)
void SetText(LPCTSTR str)
Selects the first string in the associated list box that begins with the supplied str.
virtual auto GetWindowClassName() -> TWindowClassName
Returns the name of TComboBox's registration class, "ComboBox.".
TDesktopDC()
Default constructor for TDesktopDC objects.
An interface object that represents a corresponding list box element.
TListBox(TWindow *parent, int id, int x, int y, int w, int h, TModule *module=0)
Constructs a list box object with the supplied parent window (parent) library ID (module),...
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TRect is a mathematical class derived from tagRect.
int Height() const
Returns the height of this rectangle (bottom - top).
TRect & Offset(int dx, int dy)
Changes this rectangle so its corners are offset by the given delta values.
int Bottom() const
Returns the bottom value.
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
virtual void SetParent(TWindow *newParent)
Sets the parent for the specified window by setting Parent to the specified new Parent window object.
TWindow()
Protected constructor for use by immediate virtually derived classes.
HWND GetWindow(uint cmd) const
Returns the handle of the window that has the indicated relationship to this window.
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
virtual void CleanupWindow()
Always called immediately before the HWindow becomes invalid, CleanupWindow gives derived classes an ...
void SetWindowText(LPCTSTR str)
Sets the window's text to the given string (by copying).
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
HWND THandle
TWindow encapsulates an HWND.
HWND GetHandle() const
Returns the handle of the window.
TXOwl is root class of the ObjectWindows exception hierarchy.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of class TComboBox and TComboBoxData the base class for all combobox controls.
void ReadBaseObject(Base *base, ipstream &in)
void WriteBaseObject(Base *base, opstream &out)
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
@ tdSizeData
Return the size of data transferred by the class.
@ tdSetData
Set data from the buffer into the window.
@ tdGetData
Get data from the window into the buffer.
Object Windows Library (OWLNext Core).
TObjectArray< tstring > TStringArray
uint16 HiUint16(LRESULT r)
TWindow * GetWindowPtr(HWND, const TApplication *)
Raw function to retrieve a TWindow pointer given an HWND from the a given app, or any app (app==0).
LPARAM TParam2
Second parameter type.
uint16 LoUint16(LRESULT r)
TTypedArray< LPARAM, LPARAM, TStandardAllocator > TLParamArray
LRESULT TResult
Result type.
IMPLEMENT_STREAMABLE1(TApplication, TModule)
DIAG_DECLARE_GROUP(OwlThread)
#define CONST_CAST(targetType, object)