OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
picklist.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of classes TPickListPopup & TPickListDialog
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_PICKLIST_H)
10#define OWL_PICKLIST_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/dialog.h>
18#include <owl/listbox.h>
19
20
21namespace owl {
22
23#include <owl/preclass.h>
24
25/// \addtogroup ctrl
26/// @{
27/// \class TPickListPopup
28// ~~~~~ ~~~~~~~~~~~~~~
29/// The PickList allows selection of an item from a popup list. The list can
30/// have an optional title, provided by string or string resource id.
31///
32/// Strings can be added after construction using AddString()
33///
34/// The 0-based selection is returned from Execute(), or can be retrieved later
35/// using GetResult()
36//
38 public:
39 TPickListPopup(TWindow* parent, LPCTSTR title = 0);
40 TPickListPopup(TWindow* parent, const tstring& title);
42
43 void ClearStrings();
44 int AddString(LPCTSTR str);
45 int AddString(const tstring& str) {return AddString(str.c_str());}
46 int Execute(); // Returns index picked (1 based), 0 if cancelled
47 int GetResult() const;
48
49 protected:
50 TResult EvCommand(uint id, THandle hWndCtl, uint notifyCode);
51
53 int Count;
54
55 private:
56 int Result;
57};
58
59/// @}
60
61/// \addtogroup ctrl
62/// @{
63//
64/// \class TPickListDialog
65// ~~~~~ ~~~~~~~~~~~~~~~
66/// The PickListDialog allows selection of an item from a list in a dialog with
67/// OK and Cancel buttons. An initial string list can be provided, and an
68/// initial selection. Also, the dialog template and title can be overriden.
69///
70/// Strings can be added after construction using AddString()
71///
72/// The 0-based selection is returned from Execute(), or can be retrieved later
73/// using GetResult()
74//
76 public:
79 int initialSelection = 0,
81 LPCTSTR title = 0,
82 TModule* module = 0);
83
85 TWindow* parent,
89 const tstring& title,
90 TModule* module = 0);
91
92 ~TPickListDialog() override;
93
94 void ClearStrings();
95 int AddString(LPCTSTR str);
96 int AddString(const tstring& str) {return AddString(str.c_str());}
97 int GetResult() const;
98
99 protected:
100 void SetupWindow() override;
101 void CmOK();
102 void CmCancel();
103
104 private:
105 TListBox List;
106 int Result;
107 TStringArray* Strings;
108 bool NewedStrings;
109
111};
112/// @}
113
114#include <owl/posclass.h>
115
116
117//----------------------------------------------------------------------------
118// Inline implementation
119//
120
121//
122/// Returns the result of the selection.
123//
124inline int
126{
127 return Result;
128}
129
130//
131/// Returns the result of the selection.
132//
133inline int
135{
136 return Result;
137}
138
139} // OWL namespace
140
141
142#endif // OWL_PICKLIST_H
Typically used to obtain information from a user, a dialog box is a window inside of which other cont...
Definition dialog.h:85
An interface object that represents a corresponding list box element.
Definition listbox.h:43
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
The PickListDialog allows selection of an item from a list in a dialog with OK and Cancel buttons.
Definition picklist.h:75
int GetResult() const
Returns the result of the selection.
Definition picklist.h:134
int AddString(const tstring &str)
Definition picklist.h:96
The PickList allows selection of an item from a popup list.
Definition picklist.h:37
TPopupMenu Popup
Definition picklist.h:52
int GetResult() const
Returns the result of the selection.
Definition picklist.h:125
int AddString(const tstring &str)
Definition picklist.h:45
TPopupMenu creates an empty pop-up menu to add to an existing window or pop-up menu.
Definition menu.h:189
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
Definition of TDialog class and TDialogAttr struct.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Definition of class TListBox and TlistBoxData.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
LRESULT TResult
Result type.
Definition dispatch.h:52
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338