OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
propsht.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 encapsulating PropertySheets and PropertyPages
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_PROPSHT_H)
10#define OWL_PROPSHT_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/defs.h>
18#include <owl/dialog.h>
19#include <owl/commctrl.h>
20
21
22namespace owl {
23
24// Documented but missing from system headers!
25//
26#if !defined(PSH_MULTILINETABS)
27# define PSH_MULTILINETABS 0x0010
28#endif
29
30#include <owl/preclass.h>
31
32class _OWLCLASS TIcon;
33class _OWLCLASS TPropertySheet;
34class _OWLCLASS TPropertyPage;
35class _OWLCLASS TTabControl;
36class _OWLCLASS TTabKeyDown;
37
38/// \addtogroup commctrl
39/// @{
40//
41// Prototypes of callbacks used to iterate through PropertyPages
42//
45
46
47
48//----------------------------------------------------------------------------
49// TPropertyPage
50//----------------------------------------------------------------------------
51
52//
53/// \class TPropertyPage
54// ~~~~~ ~~~~~~~~~~~~~
55/// The 'TPropertyPage' object represents a dialog box found within a property
56/// sheet. Each 'page' contains controls for setting a group of related
57/// properties. Each page has a tab that the user can select to bring the page
58/// to the foreground of the property sheet.
59//
61 public:
63 LPCTSTR title = 0, TResId iconRes = 0,
64 TModule* module = 0);
66 const tstring& title, TResId iconRes = 0,
67 TModule* module = 0);
69 TModule* module = 0);
70 ~TPropertyPage() override;
71
72 // Set attributes of the page
73 //
74 void SetIcon(const TIcon&);
75 void SetIcon(TResId iconResId);
76 void SetTitle(LPCTSTR);
77 void SetTitle(const tstring& s) {SetTitle(s.c_str());}
78 void SetTitle(int txtResId);
79 void SetFlags(uint32 flags);
80
81 // Retrieve Sheet object [i.e. Parent of page]
82 //
83 TPropertySheet* GetSheet() const;
84
85 // Operator to return HPROSHEETPAGE handle
86 //
87 operator HPROPSHEETPAGE() const;
88
89 // Retrieve information about this page
90 //
91 void CopyPageInfo(PROPSHEETPAGE& pgInfo) const;
92 PROPSHEETPAGE& GetPropSheetPage();
93
94 // Create/Destroy the HPROPSHEETPAGE handle that uniquely identifies this
95 // page.
96 //
97 HPROPSHEETPAGE CreatePropertyPage();
98 bool DestroyPropertyPage();
99
100 // Override this to process messages within the dialog function
101 // Return true if message handled, false if not.
102 //
103 auto DialogFunction(TMsgId, TParam1, TParam2) -> INT_PTR override;
104
105 // Overriden to patch PSN_FIRST-PSN_LAST notifications
106 //
107 auto EvNotify(uint id, TNotify&) -> TResult override;
108
109 // Overriden virtuals of TWindow/TDialog
110 //
111 auto Create() -> bool override;
112
113 // This is the callback invoked when the a property sheet page is created
114 // and destroyed
115 //
116 static UINT CALLBACK
117 PropCallback(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
118
119 // This is the callback invoked when notifications are sent to the pages
120 //
121 static INT_PTR CALLBACK
122 PropDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
123
124 protected:
125
126 //
127 // Handle Escape from Multiline Edit control
128 void EvClose();
129
130 // Virtual methods to handle the Sheet notifications. Some of these
131 // methods will most likely be overriden by TPropertyPage-derived classes
132 //
133 virtual int SetActive(TPshNotify&); ///< PSN_SETACTIVE
134 virtual bool KillActive(TPshNotify&); ///< PSN_KILLACTIVE
135 virtual int Apply(TPshNotify&); ///< PSN_APPLY
136 virtual void Reset(TPshNotify&); ///< PSN_RESET
137 virtual void Help(TPshNotify&); ///< PSN_HELP
138 virtual int WizBack(TPshNotify&); ///< PSN_WIZBACK
139 virtual int WizNext(TPshNotify&); ///< PSN_WIZNEXT
140 virtual bool WizFinish(TPshNotify&); ///< PSN_WIZFINISH
141 virtual bool QueryCancel(TPshNotify&); ///< PSN_QUERYCANCEL
142
143 /// Following structure holds information about this dialog when it is
144 /// inserted into a PropertySheet
145 //
147
148 /// Handle of this property page
149 //
151
152
153 private:
154 // Hidden to prevent accidental copying or assignment
155 //
158
159 // Initialization shared by constructors (not yet implemented)
160 //
161 //void Init(TResId resId, LPCTSTR title, TResId iconRes, uint32 flags);
162
163 /// Method that ties the C++ object presenting the page with the underlying
164 /// 'HWND' handle.
165 //
166 static void InitHandle(THandle pageHandle, LPPROPSHEETPAGE pageInfo);
167
168 /// Iterator callback allowing each page to register its children
169 //
170 static void RegisterPageChildObjects(TPropertyPage* page, void*);
171
172//copied from old unix owl (JAM 4-16-01)
173// CC 5.1 added def(UNIX) on the next line for CmOk and CmCancel to be defined
174#if (defined(UNIX) && !defined(WINELIB))
175
176 // The following methods are only valid when ObjectWindows is providing
177 // the underlying implementation of PropertySheet/Page. These methods are
178 // protected to support derived classes. However, your derived classes
179 // should be implemented to rely on these methods only when the Common
180 // Control library is unavailable and ObjectWindows is providing the
181 // underlying implementation of PropertySheet/PropertyPages.
182 //
183
184 // Caption of dialog as stored in resource
185 //
187
188 public:
189 void SetModified(bool modified);
190 bool IsModified() const;
191
192 protected:
193 void SetupWindow();
194
195 // Child notifications
196 //
197 void CmOk(); // IDOK
198 void CmCancel(); // IDCANCEL
199
200// !BB bool PreProcessMsg(MSG& msg);
201
202 private:
203 bool Modified;
204#endif
205
208};
209
210//
211/// \class TPropertySheet
212// ~~~~~ ~~~~~~~~~~~~~~
213/// TPropertySheet encapsulates a window which contains one or more overlapping
214/// child windows knowns as property pages. The sheet provides a container
215/// which display pages allowing the user to view and edit related properties
216/// grouped in individual pages.
217//
219 public:
220 TPropertySheet(TWindow* parent,
222 uint startPage = 0,
223 bool isWizard = false,
224 uint32 flags = PSH_DEFAULT,
225 TModule* module = 0);
226 TPropertySheet(TWindow* parent,
227 const tstring& title,
228 uint startPage = 0,
229 bool isWizard = false,
230 uint32 flags = PSH_DEFAULT,
231 TModule* module = 0);
232// !BB // !BB Nice, if you can pull it
233// !BB TPropertySheet(TWindow* parent, const PROPSHEETHEADER& propHdr,
234// !BB TModule* module = 0);
235 ~TPropertySheet() override;
236
237 // Override virtual functions defined by class TWindow
238 //
239 void SetupWindow() override;
240 void CleanupWindow() override;
241
242 void SetCaption(LPCTSTR title);
243 void SetCaption(const tstring& title) {SetCaption(title.c_str());}
244 auto Execute() -> int override;
245 auto Create() -> bool override;
246 INT_PTR Run(bool modal);
247
248 // Manipulate (add, remove, select) pages of the property sheet
249 //
250 void AddPage(TPropertyPage&);
251 bool SelectPage(TPropertyPage&);
252 bool SelectPage(int pgIndex);
253 bool SelectPage(TResId pgRes);
254 void RemovePage(TPropertyPage&);
255 void RemovePage(int pgIndex);
256 int GetPageCount() const;
257
258 // Inform sheet of changes in state of page
259 //
260 void PageChanged(const TPropertyPage&);
261 void PageUnchanged(TPropertyPage&);
262
263 // Have sheet simulate user actions
264 //
265 void PressButton(int button);
266 bool Apply();
267
268 // Query the pages of the sheet
269 //
270 int QuerySiblings(TParam1, TParam2);
271
272 // Inform sheet of special requirements
273 //
274 void RebootSystem();
275 void RestartWindows();
276
277 // Update sheet attributes: title, buttons, ...
278 //
279 void SetTitle(LPCTSTR text, uint32 style = PSH_PROPTITLE);
280 void SetTitle(const tstring& text, uint32 style = PSH_PROPTITLE) {SetTitle(text.c_str(), style);}
281 void SetFinishText(LPCTSTR text);
282 void SetFinishText(const tstring& text) {SetFinishText(text.c_str());}
283 void SetWizButtons(uint32 flags);
284 void CancelToClose();
285
286 // Retrieve handle to underlying tab control or current page
287 //
288 HWND GetTabControl() const;
289 HWND GetCurrentPage() const;
290
291 // Allow processing of dialog messages
292 //
293 bool IsDialogMessage(MSG & msg);
294
295 // Retrieve the structure describing the sheet
296 //
297 PROPSHEETHEADER& GetPropSheetHeader();
298
299 // Helper routines to query/iterate about/through pages
300 //
301 void ForEachPage(TActionPageFunc action, void* paramList = 0);
302 TPropertyPage* FirstPageThat(TCondPageFunc cond, void* paramList = 0);
303
304 // Tell OWL to subclass the sheet after it's created
305 //
306 void EnableSubclass(bool subclass);
307
308 // Set timer - for IdleAction() processing
309 //
310 bool EnableTimer();
311
312 protected:
313 bool SubClassSheet; ///< Should we subclass the sheet (OS only)
314 bool WantTimer; ///< Flags whether to start a timer
315 UINT_PTR TimerID; ///< Timer identifier
316
317 // Holds information necessary to create the property sheet
318 //
320
321 // Flags if sheet is a wizard
322 //
324
325 auto PreProcessMsg(MSG&) -> bool override;
326
327 private:
328 // Hidden to prevent accidental copying or assignment
329 //
332
333 // Helper routine to retrieve handle of pages
334 //
335 bool GetPageHandles();
336
337 // Method that ties the C++ object presenting the sheet
338 // with the underlying 'HWND' handle.
339 //
340 void InitHandle(THandle sheetHandle);
341
342 void EvTimer (uint timerId);
343
345
347};
348
349/// @}
350
351#include <owl/posclass.h>
352
353//----------------------------------------------------------------------------
354/// \name Property sheet notifications
355/// @{
356
357//
358/// Property sheets notify property pages of events via the standard WM_NOTIFY message.
359/// However, there is no Control ID involved in this particular flavour of notification.
360/// The WM_NOTIFY handler of ObjectWindows relies on the CtlID for subdispatching. Hence, we'll
361/// have PropPageID as the default identifier so that we do not have to repeat dispatching logic
362/// in the EvNotify of TPropertyPage.
363//
364const int PropPageID = 0xFFF0;
365
366//
367/// void method(TPshNotify&)
368//
369#define EV_PSN_APPLY(method) OWL_EV_NOTIFICATION(PSN_APPLY, ::owl::PropPageID, method)
370
371//
372/// int method(TNmObjectNotify&)
373//
374#define EV_PSN_GETOBJECT(method) OWL_EV_NOTIFICATION(PSN_GETOBJECT, ::owl::PropPageID, method)
375
376//
377/// void method(TPshNotify&)
378//
379#define EV_PSN_HELP(method) OWL_EV_NOTIFICATION(PSN_HELP, ::owl::PropPageID, method)
380
381//
382/// bool method(TPshNotify&)
383//
384#define EV_PSN_KILLACTIVE(method) OWL_EV_NOTIFICATION(PSN_KILLACTIVE, ::owl::PropPageID, method)
385
386//
387/// bool method(TPshNotify&)
388//
389#define EV_PSN_QUERYCANCEL(method) OWL_EV_NOTIFICATION(PSN_QUERYCANCEL, ::owl::PropPageID, method)
390
391//
392/// void method(TPshNotify&)
393//
394#define EV_PSN_RESET(method) OWL_EV_NOTIFICATION(PSN_RESET, ::owl::PropPageID, method)
395
396//
397/// int method(TPshNotify&)
398//
399#define EV_PSN_SETACTIVE(method) OWL_EV_NOTIFICATION(PSN_SETACTIVE, ::owl::PropPageID, method)
400
401//
402/// int method(TPshNotify&)
403//
404#define EV_PSN_WIZBACK(method) OWL_EV_NOTIFICATION(PSN_WIZBACK, ::owl::PropPageID, method)
405
406//
407/// bool method(TPshNotify&)
408//
409#define EV_PSN_WIZFINISH(method) OWL_EV_NOTIFICATION(PSN_WIZFINISH, ::owl::PropPageID, method)
410
411//
412/// int method(TPshNotify&)
413//
414#define EV_PSN_WIZNEXT(method) OWL_EV_NOTIFICATION(PSN_WIZNEXT, ::owl::PropPageID, method)
415
416/// @}
417
418//----------------------------------------------------------------------------
419// Inline implementations
420//
421inline
423{
424 hdr.hwndFrom = hwnd;
425 hdr.idFrom = id;
426 hdr.code = code;
427 lParam = lp;
428}
429
430//
431/// Returns the HPROPSHEETPAGE handle representing an unlying PropertyPage.
432/// \note This method is only functional when the Common Control library
433/// provides the underlying implementation of PropertyPages.
434///
435/// \note The 'CreatePropertyPage' method also returns the HPROPSHEETPAGE.
436/// However, it will attempt to create the page if the latter had not been
437/// created beforehand. The HPROPSHEETPAGE operator simply returns the
438/// page handle without attempting to create the page.
439//
440inline TPropertyPage::operator HPROPSHEETPAGE() const
441{
442 PRECONDITION(HPropPage);
443 return HPropPage;
444}
445
446//
447/// Return structure which describes the characteristics/attributes of page.
448//
449inline PROPSHEETPAGE&
454
455//
456/// Return pointer to parent/sheet object
457//
458inline TPropertySheet*
465
466
467/// Return structure which describes the characteristics/attributes of sheet.
468//
469inline PROPSHEETHEADER&
474
475//
476//
477inline void
479{
480 // Method must be invoked before the sheet is created
481 //
482 PRECONDITION(GetHandle() == 0);
484}
485
486
487
488} // OWL namespace
489
490
491
492#endif // OWL_PROPSHT_H
#define CHECK(condition)
Definition checks.h:239
#define PRECONDITION(condition)
Definition checks.h:227
Typically used to obtain information from a user, a dialog box is a window inside of which other cont...
Definition dialog.h:85
TIcon, derived from TGdiObject, represents the GDI object icon class.
Definition gdiobjec.h:670
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TNotify is a thin wrapper around the NMHDR structure.
Definition commctrl.h:91
The 'TPropertyPage' object represents a dialog box found within a property sheet.
Definition propsht.h:60
HPROPSHEETPAGE HPropPage
Handle of this property page.
Definition propsht.h:150
PROPSHEETPAGE & GetPropSheetPage()
Return structure which describes the characteristics/attributes of page.
Definition propsht.h:450
TPropertySheet * GetSheet() const
Return pointer to parent/sheet object.
Definition propsht.h:459
PROPSHEETPAGE PageInfo
Following structure holds information about this dialog when it is inserted into a PropertySheet.
Definition propsht.h:146
void SetTitle(const tstring &s)
Definition propsht.h:77
TPropertySheet encapsulates a window which contains one or more overlapping child windows knowns as p...
Definition propsht.h:218
void SetTitle(const tstring &text, uint32 style=PSH_PROPTITLE)
Definition propsht.h:280
bool SubClassSheet
Should we subclass the sheet (OS only)
Definition propsht.h:313
bool WantTimer
Flags whether to start a timer.
Definition propsht.h:314
UINT_PTR TimerID
Timer identifier.
Definition propsht.h:315
void EnableSubclass(bool subclass)
Definition propsht.h:478
PROPSHEETHEADER & GetPropSheetHeader()
Return structure which describes the characteristics/attributes of sheet.
Definition propsht.h:470
PROPSHEETHEADER HeaderInfo
Definition propsht.h:319
void SetCaption(const tstring &title)
Definition propsht.h:243
void SetFinishText(const tstring &text)
Definition propsht.h:282
TPshNotify(HWND hwnd, uint id, uint code, LPARAM lp)
Definition propsht.h:422
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
Definition of classes for CommonControl encapsulation.
Definition of TDialog class and TDialogAttr struct.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
bool(* TCondPageFunc)(TPropertyPage *pPage, void *param)
Definition propsht.h:44
void(* TActionPageFunc)(TPropertyPage *pPage, void *param)
Definition propsht.h:43
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
unsigned long uint32
Definition number.h:34
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
const int PropPageID
Property sheets notify property pages of events via the standard WM_NOTIFY message.
Definition propsht.h:364
LRESULT TResult
Result type.
Definition dispatch.h:52
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
action
Definition regexp.cpp:133
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269