OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
window.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Base window class TWindow definition, including HWND encapsulation.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_WINDOW_H)
10#define OWL_WINDOW_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/wsyscls.h>
19#include <owl/color.h>
20#include <owl/objstrm.h>
21#include <owl/clipboar.h>
22#include <owl/windowev.h>
23
24
25//FMM
26#include <owl/applicat.h>
27#include <owl/menu.h>
28#include <owl/window.rh>
29#include <stdarg.h>
30#include <utility>
31#include <memory>
32#include <cstddef>
33
36
37namespace owl {
38
39#include <owl/preclass.h>
40
41class _OWLCLASS TApplication;
42class _OWLCLASS TModule;
43class _OWLCLASS TScroller;
44class _OWLCLASS TRegion;
45class _OWLCLASS TWindow;
46class _OWLCLASS TDC;
47class _OWLCLASS TNotify;
48class _OWLCLASS TXWindow;
49class _OWLCLASS TTooltip;
50
51/// \addtogroup window
52/// @{
53
54//
55/// \enum TWindowFlag
56// ~~~~ ~~~~~~~~~~~
57/// Define bit masks for the internally used flag attributes of TWindow.
59 wfAlias = 0x0001, ///< TWindow is an alias to a preexisting HWND
60 wfAutoCreate = 0x0002, ///< Create the HWND when our parent is created
61 wfFromResource = 0x0004, ///< Handle comes from HWND created from resource
62 wfShrinkToClient = 0x0008, ///< Shrink a frame window to its client's size
63 wfMainWindow = 0x0010, ///< This frame window is the main window
64 wfFullyCreated = 0x0020, ///< Window is fully created & not being destroyed
65 wfStreamTop = 0x0040, ///< This window is the topmost one to stream
66 wfPredefinedClass = 0x0080, ///< Window class used belongs to a predefined Windows class and was not defined by OWL
67 wfTransfer = 0x0100, ///< Participates in the Transfer mechanism.
68 wfUnHidden = 0x0200, ///< Used temporarily when destroying MDI child
69 wfUnDisabled = 0x0400, ///< Used temporarily when destroying MDI child
70 wfDeleteOnClose = 0x0800, ///< Window is condemned on EvClose.
71 ///< Indicates that a modeless dialog's pointer is to be deleted when
72 ///< it receives a WM_CLOSE message, causing its class's destructor to be called
73 ///< immediately. Default behavior is to leave the dialog pointer alone. Setting this
74 ///< flag has no effect on modal dialogs. To set this flag for a modeless dialog
75 ///< object, add the following statement to the constructor of your TDialog-derived
76 ///< class:
77 ///< \code
78 ///< SetFlag(wfDeleteOnClose);
79 ///< \endcode
80 wfPropagateIdle = 0x1000, ///< Pass down IdleAction
81 wfModalWindow = 0x2000, ///< Was created via TWindow::Execute
82 wfDetached = 0x4000, ///< Window handle has been detached
83 wfInsertAtEdge = 0x8000 ///< (Decoration) Window to be inserted against frame's edge
84};
85
86//
87/// \enum TTransferDirection
88// ~~~~ ~~~~~~~~~~~~~~~~~~
89/// The TTransferDirection enum describes the constants that the transfer
90/// function uses to determine how to transfer data to and from the transfer buffer
91//
93 tdGetData, ///< Get data from the window into the buffer
94 tdSetData, ///< Set data from the buffer into the window
95 tdSizeData ///< Return the size of data transferred by the class.
96};
97
98//
99/// \enum TEventStatus
100// ~~~~ ~~~~~~~~~~~~
101/// Mixin window event implementation return status
102//
103/// Event status constants indicate the status of a mix-in window event
104/// implementation, for example, a keyboard event. The TEventStatus constants
105/// indicate whether or not additional handlers are needed.
106//
108 esPartial, ///< Additional handlers may be invoked
109 esComplete ///< No additional handlers are needed
111
112//
113/// \name Special background color flags for EvEraseBkgnd processing
114/// @{
115#define NoColor TColor::None ///< let DefWindowProc erase
116#define NoErase TColor::Transparent ///< don't erase, wait for Paint
117/// @}
118
119//
120// Windows 3.1 windowsx.h name conflicts
121//
122#if defined(GetFirstChild)
123# undef GetFirstChild
124#endif
125
126#if defined(MapWindowRect)
127# undef MapWindowRect
128#endif
129
130#if defined(GetWindowFont)
131# undef GetWindowFont
132#endif
133
134#if defined(SetWindowFont)
135# undef SetWindowFont
136#endif
137
138//----------------------------------------------------------------------------
139
140#if defined(OWL5_COMPAT)
141
142//
143// Member and non-member action and conditional function types used with
144// ForEach and FirstThat.
145//
146
147/// Defines the signature of the callback function passed to the ForEach method of
148/// TWindow.
149typedef void (*TActionFunc)(TWindow* win, void* param);
150
151/// Defines the signature of the callback function used by the FirstThat function of
152/// TWindow.
153typedef bool (*TCondFunc)(TWindow* win, void* param);
154
155/// Defines the signature of the callback function passed to the ForEach method of
156/// TWindow.
157typedef void (TWindow::*TActionMemFunc)(TWindow* win, void* param);
158
159/// Defines the signature of the member function used by the FirstThat function of
160/// TWindow.
161typedef bool (TWindow::*TCondMemFunc)(TWindow* win, void* param);
162
163#endif
164
165/// @}
166/// \addtogroup newctrl
167/// @{
168
169//----------------------------------------------------------------------------
170//
171/// \class TDrawItem
172// ~~~~~ ~~~~~~~~~
173/// Class will be base class for owner draw items: ListBox,ComboBox,Menu atc.
174/// lParam member of DRAWITEMSTRUCT will point to instance of derived from this class
175/// Note: OwnerDraw Buttons isn't support lParam !!!!!
176//
177// trick for dynamic_cast<>(), don't derive from it!!!!!!!!!!!!!
179 public:
180//FMM
182 enum TDrawItemId { drawId = 0x69777264, /*'drwi'*/ };
184 virtual ~TDrawItemBase(){}
185 uint32 __itemId; // don't use __itemId
186};
187
189 public:
190//FMM 2 lines below
191 typedef const char* Type_id;
193 //virtual ~TDrawItem(){} // use base
194 virtual void Draw(DRAWITEMSTRUCT &) {}
195 virtual void Measure(MEASUREITEMSTRUCT &) {}
196 virtual int Compare(COMPAREITEMSTRUCT &) { return 0;}
197};
198
199/// @}
200//
201/// \addtogroup enabler
202/// @{
203//
204/// \class TCommandEnabler
205// ~~~~~ ~~~~~~~~~~~~~~~
206/// Base class for an extensible interface for auto enabling/disabling of
207/// commands (menu items, tool bar buttons, ...)
208//
210 public:
212
213 uint GetId() const;
214
215 virtual void Enable(bool enable = true); // Also sets Handled
216
217/// Changes the text associated with a command sender; for example, text associated
218/// with a menu item or text on a button.
219 virtual void SetText(LPCTSTR text) = 0;
220 void SetText(const tstring& s) {SetText(s.c_str());}
221
222 /// Enumeration describing the 3-states or availability of a command. This state
223 /// applies to buttons, such as those used for tool bars, or to control bar gadgets.
224 //
226 Unchecked, ///< Command is not enabled
227 Checked, ///< Command is enabled
228 Indeterminate ///< Command is unavaiable
229 };
230
231/// Changes the check state of the command sender to either unchecked, checked, or
232/// indeterminate. This state applies to buttons, such as those used for tool bars,
233/// or to control bar gadgets. Pass a TCommandState enum
234 virtual void SetCheck(int check) = 0;
235
236 //
237 /// Overload; allows you to pass a bool safely.
238 /// Sets the state to Checked if true is passed, and to Unchecked otherwise.
239 //
241 {SetCheck(isChecked ? Checked : Unchecked);}
242
243 bool SendsCommand() const;
244
245 bool GetHandled();
246
247 bool IsReceiver(HWND hReceiver);
248 HWND GetReceiver() const;
249 void SetReceiver(HWND hReceiver);
250
251 protected:
252 void SetHandled();
253
255/// Command ID for the enabled command.
256 const uint Id;
257
259/// The message responder (the window) that receives the command.
260 HWND HWndReceiver;
261
262 protected:
263 /// Enumeration describing whether the associated command has been
264 /// enabled or disabled, and whether the command generates WM_COMMAND
265 /// messages.
266 //
268 WasHandled = 1, ///< Command was enabled or disabled
269 NonSender = 2 ///< Command does not generate WM_COMMAND messages
270 };
271
272 /// TCommandStatus flags
273 /// Is TCommandStatus::WasHandled if the command enabler has been handled.
274 //
276
278};
279
280/// @}
281
282/// \addtogroup window
283/// @{
284
285//
286/// \struct TWindowAttr
287// ~~~~~~ ~~~~~~~~~~~~
288/// Holds TWindow attributes set during construction of a window. Your program
289/// controls a window's creation by passing these values to one of TWindow's
290/// creation routines. If the window is streamed, these attributes are also used for
291/// re-creation.
292/// \note Don't rely on these to track once Handle
293/// has been created, use member functions to access information.
294//
296{
297/// Contains the values that define the style, shape, and size of your window.
298/// Although TWindow sets Attr.Style to WS_CHILD and WS_VISIBLE, you can also use
299/// other combinations of the following style constants:
300/// - \c \b WS_BORDER Creates a window with a thin lined border
301/// - \c \b WS_CAPTION Creates a window with a title bar.
302/// - \c \b WS_CHILD Creates a child windows. Cannot be used with popup styles.
303/// - \c \b WS_CHILDWINDOW Creates a child window.
304/// - \c \b WS_CLIPCHILDREN Used when creating a parent window. Excludes the area occupied
305/// by child windows when drawing takes place within the parent window.
306/// - \c \b WS_CLIPSIBLINGS Clips child windows relative to the child window that receives a
307/// paint message.
308/// - \c \b WS_DISABLED Creates a window that cannot receive user input.
309/// - \c \b WS_DLGFRAME Creates a window having a typical dialog box style (without a title
310/// bar).
311/// - \c \b WS_GROUP Indicates the first control in a group of controls, which the user can
312/// change by pressing the direction keys.
313/// - \c \b WS_HSCROLL Window has a horizontal scroll bar.
314/// - \c \b WS_MAXIMIZE Window is initially maximized.
315/// - \c \b WS_MAXIMIZEBOX Window has a maximize button.
316/// - \c \b WS_MINIMIZE Window is initially minimized.
317/// - \c \b WS_MINIMIZEBOX Window has a minimize button.
318/// - \c \b WS_OVERLAPPED Creates an overlapped window with a title bar and a border.
319/// - \c \b WS_OVERLAPPEDWINDOW Overlapped window has the WS_OVERLAPPED, WS_CAPTION,
320/// WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles.
321/// - \c \b WS_POPUP Creates a popup window. Cannot be used with child window styles.
322/// - \c \b WS_POPUPWINDOW Creates a popup window with WS_BORDER, WS_POPUP, and WS_SYSMENU
323/// styles. The WS_CAPTION and WS_POPUPWINDOW styles combine to create a system
324/// menu.
325/// - \c \b WS_SYSMENU Window has a system menu box in its title bar. Must also indicate
326/// the WS_CAPTION style.
327/// - \c \b WS_TABSTOP Control can receive the keyboard focus when TAB key is pressed.
328/// - \c \b WS_THICKFRAME Window has a border that lets you change the window size.
329/// - \c \b WS_VISIBLE Window is initially visible.
330/// - \c \b WS_VSCROLL Window has a vertical scroll bar.
332
333/// Contains the extended style values of your window. These can be any one of the
334/// extended style constants (WS_EX_DLGMODALFRAME, WS_EX_NOPARENTNOTIFY,
335/// WS_EX_TOPMOST, WS_EX_SHADOW). See TWindow::AdjustWindowRectEx for a
336/// description of these constants.
338
339 int X; ///< horizontal position of top left corenr of the window
340 int Y; ///< vertical position of top left corenr of the window
341 int W; ///< width of the window
342 int H; ///< height of the window
343
344/// Contains the resource ID for the menu associated with this window. If no menu
345/// exists, Menu is 0.
347
348/// Contains the identifier of the child window. For a dialog box control, Id is its
349/// resource identifier. If Win32 is defined, Id is set to GetWindowLong ; otherwise
350/// Id is set to GetWindowWord.
351 int Id;
352
353/// Contains a value that is passed to Windows when the window is created. This
354/// value identifies a data block that is then available in the message response
355/// functions associated with WM_CREATE. Param is used by TMDIClient and can be
356/// useful when converting non-ObjectWindows code.
358
359/// Holds the resource ID for the window's accelerator table.
361};
362
363//
364/// \class TWindow
365// ~~~~~ ~~~~~~~
366/// TWindow, derived from TEventHandler and TStreamableBase, provides
367/// window-specific behavior and encapsulates many functions that control window
368/// behavior and specify window creation and registration attributes.
369///
370/// TWindow is a generic window that can be resized and moved. You can construct an
371/// instance of TWindow, though normally you use TWindow as a base for your
372/// specialized window classes. In general, to associate and disassociate a TWindow
373/// object with a window element, you need to follow these steps:
374/// - 1. Construct an instance of a TWindow.
375/// - 2. Call Create or Execute, which creates the interface element (HWND) and then
376/// calls SetupWindow, which calls the base SetupWindow for normal processing, which
377/// in turn involves
378/// - Creating the HWindow and any child HWindows.
379/// - Calling TransferData to setup the transfer of data between the
380/// parent and child windows.
381/// - 3. To destroy the interface element, choose one of the following actions,
382/// depending on your application:
383/// - Call Destroy to destroy the interface element unconditionally.
384/// - Call CloseWindow, which calls CanClose to test if it is OK to
385/// destroy the interface element.
386/// - 4. There are two ways to destroy the interface object:
387/// - If the object has been new'd, use delete.
388/// - If the object has not been new'd, the compiler automatically
389/// destructs the object.
390///
391/// The ObjectWindows destroy process consists of two parts: (1) call Destroy to
392/// destroy the interface element and (2) then delete the C++ object. However, it is
393/// perfectly valid to call Destroy on the interface element without deleting the
394/// C++ object and then to call Create at a later time to re-create the window.
395/// Because it is also valid to construct a C++ window object on the stack or as an
396/// aggregated member, the Destroy function cannot assume it should delete the C++
397/// object.
398///
399/// The user-generated WM_CLOSE event handler, EvClose, also causes a C++ object to
400/// be deleted by passing the this pointer to the application. The C++ object is
401/// deleted automatically because the EvClose event frequently occurs in response to
402/// a user action, and this is the most convenient place for the deletion to take
403/// place. Later, when it's safe to do so, the application then deletes the window
404/// pointer. Because the stack often contains selectors that refer to the addresses
405/// of objects that may become invalid during the delete process, it is not safe to
406/// delete the this pointer while events are still being processed. If the addresses
407/// become invalid, they could cause trouble when they are reloaded from the stack.
408///
409/// TWindow is the base class for all window classes, including TFrameWindow,
410/// TControl, TDialog, and TMDIChild. The ObjectWindows hierarchy diagram shows the
411/// many classes that are derived from TWindow.
412//
413class _OWLCLASS TWindow : virtual public TEventHandler,
414 virtual public TStreamableBase {
415 public:
416 // Class scoped types
417 //
418 typedef HWND THandle; ///< TWindow encapsulates an HWND
419
420 /// \todo Make protected or private
421 void TraceWindowPlacement(); //DLN debug
422
423 // Constructors and destructor for TWindow
424 //
425 explicit TWindow(TWindow* parent, LPCTSTR title = nullptr, TModule* module = nullptr);
426 explicit TWindow(TWindow* parent, const tstring& title, TModule* module = nullptr);
427 explicit TWindow(HWND handle, TModule* module = nullptr);
428
429 virtual ~TWindow() override;
430
431 /// \name Children iteration functions
432 /// @{
433
434#if defined(OWL5_COMPAT)
435
436 void ForEach(TActionFunc action, void* paramList = nullptr);
437 void ForEach(TActionMemFunc action, void* paramList = nullptr);
438 TWindow* FirstThat(TCondFunc test, void* paramList = nullptr) const;
439 TWindow* FirstThat(TCondMemFunc test, void* paramList = nullptr);
440
441#endif
442
443 //
444 /// Utility class template used as an iterator type template for TChildrenRangeTemplate.
445 /// Enables the use of range-based for-loops and standard iterator-based algorithms on the
446 /// child list of a window.
447 //
448 template <class T>
450 {
451 public:
452 using iterator_category = std::forward_iterator_tag;
453 using value_type = T;
455 using pointer = T*;
456 using reference = T&;
457
460 : Parent{&parent},
461 CurrentChild{parent.GetFirstChild()},
462 NextChild{CurrentChild ? CurrentChild->Next() : nullptr}
463 {}
464
465 auto operator *() const -> reference { return *CurrentChild; }
466 auto operator ->() const -> pointer { return CurrentChild; }
468 {
469 if (CurrentChild)
470 {
471 // The implementation here is awkward since we want the traversal to be backwards
472 // compatible with the old TWindow::ForEach. In particular, we want to allow CurrentChild
473 // to be deleted without breaking the traversal. We also want to support the possibility
474 // that the whole children list has been wiped out (in which case `Parent->GetLastChild`
475 // will return `nullptr`). However, as is good programming practice, traversal should not
476 // rely on iterators staying valid while mutating the underlying data structure. Client
477 // code should assume that iterators will be invalidated.
478 //
479 const auto last = Parent->GetLastChild();
480 CurrentChild = (last != nullptr && CurrentChild != last) ? NextChild : nullptr;
481 NextChild = CurrentChild ? CurrentChild->Next() : nullptr;
482 }
483 return *this;
484 }
485
486 friend auto operator ==(const TChildrenIteratorTemplate& a, const TChildrenIteratorTemplate& b) { return a.CurrentChild == b.CurrentChild; }
487 friend auto operator !=(const TChildrenIteratorTemplate& a, const TChildrenIteratorTemplate& b) { return !(a == b); }
488
489 private:
490 pointer Parent;
491 pointer CurrentChild;
492 pointer NextChild;
493 };
494
497
498 //
499 /// Utility class template used as a return type for TWindow::GetChildren.
500 /// Enables the use of range-based for-loops and standard iterator-based algorithms on the
501 /// child list of a window.
502 //
503 template <class T>
505 {
506 public:
507 using value_type = T;
508 using size_type = int;
509 using pointer = T*;
510 using const_pointer = const T*;
511 using reference = T&;
512 using const_reference = const T&;
513
516
518 TChildrenRangeTemplate(reference parent) : Parent{&parent} {}
519 auto begin() { return iterator{*Parent}; }
520 auto end() { return iterator{}; }
521 auto begin() const { return const_iterator{*Parent}; }
522 auto end() const { return const_iterator{}; }
523 auto cbegin() const { return begin(); }
524 auto cend() const { return end(); }
525 auto size() const { return static_cast<size_type>(Parent->NumChildren()); }
526
527 private:
528 pointer Parent;
529 };
530
533
534 //
535 /// Returns a TWindow::TChildrenRange that can be iterated by standard means.
536 /// This function allows iteration over the children using range-based for-loops or algorithms
537 /// based on ranges and iterators, such as those in the C++ standard library. For example:
538 /// \code
539 /// for (auto& w : parent.GetChildren())
540 /// w.SetWindowFont(parent.GetWindowFont());
541 ///
542 /// const auto c = GetChildren();
543 /// const auto grandChildrenCount = std::accumulate(c.cbegin(), c.cend(), 0,
544 /// [](int n, const TWindow& w)
545 /// {
546 /// return n + w.NumChildren();
547 /// });
548 /// \endcode
549 //
550 auto GetChildren() { return TChildrenRange{*this}; }
551
552 //
553 /// Const overload of TWindow::GetChildren.
554 //
555 auto GetChildren() const { return TConstChildrenRange{*this}; }
556
557 TWindow* Next();
558 auto Next() const -> const TWindow* { return const_cast<TWindow*>(this)->Next(); }
559 TWindow* Previous();
560 auto Previous() const -> const TWindow* { return const_cast<TWindow*>(this)->Previous(); }
561 TWindow* GetFirstChild();
562 auto GetFirstChild() const -> const TWindow* { return const_cast<TWindow*>(this)->GetFirstChild(); }
563 TWindow* GetLastChild();
564 auto GetLastChild() const -> const TWindow* { return const_cast<TWindow*>(this)->GetLastChild(); }
565 uint NumChildren() const;
566
567 /// @}
568
569 /// \name Query and set the Owl window flags.
570 /// Accepts TWindowFlag args, possibly or'd together.
571 /// @{
572 void SetFlag(uint mask);
573 void ClearFlag(uint mask);
574 bool IsFlagSet(uint mask);
575 /// @}
576
577 /// \name Sets/clears auto-create flag
578 /// It indicates that the TWindow should be
579 /// created if a create is sent while in the parent's child list
580 /// @{
581 void EnableAutoCreate();
582 void DisableAutoCreate();
583 /// @}
584
585 /// \name Retrieves/assigns tooltip of/to window
586 /// @{
587 virtual TTooltip* GetTooltip() const;
588 virtual void EnableTooltip(bool enable=true);
589 void SetTooltip(TTooltip* tooltip);
590 /// @}
591
592 /// \name Sets/clears transfer flag
593 /// It indicates that the TWindow can/will transfer data via the transfer mechanism
594 /// @{
595 void EnableTransfer();
596 void DisableTransfer();
597 /// @}
598
599 /// \name Window's default module access functions
600 // !CQ SetModule() should be protected!
601 /// @{
602 TModule* GetModule() const;
603 void SetModule(TModule* module);
604 /// @}
605
606 /// \name Convenience functions - forwards the call to the module associated with this window.
607 /// @{
614 std::string LoadHtml(TResId id) const {PRECONDITION(Module); return Module->LoadHtml(id);}
615 /// @}
616
617 TApplication* GetApplication() const;
618 virtual bool Register();
619
620 TScroller* GetScroller();
621 void SetScroller(TScroller* scroller);
622
623 /// \name Create/destroy an native window to be associated with this window
624 /// @{
625 virtual bool Create();
626 bool CreateChildren();
627 virtual void Destroy(int retVal = 0);
628 /// @}
629
630 /// \name Create a modal window, and perform actual modal execute call
631 /// @{
632 virtual int Execute();
633 virtual int DoExecute();
634 /// @}
635
636 // Request this window to close itself
637 //
638 virtual void CloseWindow(int retVal = 0);
639
640 /// \name Unconditionally shut down a given window.
641 /// Destroy() is called to
642 /// destroy the Handle, & then the window is deleted. Non-static version
643 /// is safe as long as it is inline and not called on itself
644 /// @{
645 static void ShutDownWindow(TWindow* win, int retVal = 0);
646 void ShutDownWindow(int retVal = 0);
647 /// @}
648
649 /// \name Attach or detach a window handle to a TWindow object.
650 /// Used when a child re-creates itself.
651 /// @{
652 void AttachHandle(HWND handle);
653 void DetachHandle();
654 /// @}
655
656#if defined(BI_MULTI_THREAD_RTL)
657 //Override TEventHandler::Dispatch() to handle multi-thread
658 //synchronization
659 //
660 virtual TResult Dispatch(TEventInfo&, TParam1, TParam2 = 0);
661#endif
662
663 /// \name Message preprocessing
664 /// Called from TApplication::ProcessAppMsg() to give the window an
665 /// opportunity to perform preprocessing of the Windows message
666 /// @{
667 virtual bool PreProcessMsg(MSG& msg);
668 virtual bool IdleAction(long idleCount);
669 virtual bool HoldFocusHWnd(HWND hLose, HWND hGain);
670 /// @}
671
672 TWindowAttr& GetWindowAttr();
673 const TWindowAttr& GetWindowAttr() const;
674
675 LPCTSTR GetCaption() const;
676
677
678 /// \name Child and parenting
679 /// @{
680 int GetId() const;
681 auto ChildWithId(int id) const -> const TWindow* { return const_cast<TWindow*>(this)->ChildWithId(id); }
682 auto ChildWithId(int id) -> TWindow*;
683 HWND GetParentH() const; // Native handle version
684 TWindow* GetParentO() const; // OWL object version
685 TWindow* GetParent() const; // New version -- returns object
686 virtual void SetParent(TWindow* newParent);
687 void SetNext(TWindow* next);
688 /// @}
689
690 /// \name Other attributes
691 /// @{
692 virtual bool SetDocTitle(LPCTSTR docname, int index);
693 bool SetDocTitle(const tstring& docname, int index) {return SetDocTitle(docname.c_str(), index);}
694 void SetCaption(LPCTSTR title);
695 void SetCaption(const tstring& title) {SetCaption(title.c_str());}
696 void SetCaption(uint resourceStringId);
697 bool SetCursor(TModule* module, TResId resId);
698 auto GetBkgndColor() const -> TColor;
699 void SetBkgndColor(TColor color, bool shouldUpdate = true);
700 auto GetTextColor() const->TColor;
701 void SetTextColor(TColor color, bool shouldUpdate = true);
702 void SetAcceleratorTable(TResId resId);
703 /// @}
704
705 //Can close virtual tests whether all children and this window are ready
706 //and able to close
707 //
708 virtual bool CanClose();
709
710 /// \name Message forwarding
711 /// Forward the current event to "handle" using either PostMessage() or
712 /// SendMessage(). Owl window version calls directly to window proc on send.
713 /// @{
714 TResult ForwardMessage(HWND handle, bool send = true);
715 TResult ForwardMessage(bool send = true);
716 /// @}
717
718 // Send message to all children
719 //
720 void ChildBroadcastMessage(TMsgId, TParam1 = 0, TParam2 = 0);
721
722 /// \name Notify a window (parent usually) of a child action.
723 /// @{
724 void SendNotification(int id, int notifyCode, HWND hCtl, TMsgId = WM_COMMAND);
725 void SendNotification(HWND receiver, int id, int notifyCode, HWND hCtl, TMsgId = WM_COMMAND);
726 TResult SendNotification(int id, NMHDR&, TMsgId = WM_NOTIFY);
727 TResult SendNotification(HWND receiver, uint id, NMHDR&, TMsgId = WM_NOTIFY);
728 /// @}
729
730#if defined(OWL5_COMPAT)
731
732 // Obsolete. Forwards the call to message handler.
733 //
734 TResult ReceiveMessage(TMsgId msg, TParam1 p1 = 0, TParam2 p2 = 0)
735 {return ReceiveMessage(Handle, msg, p1, p2);}
736
737#endif
738
739 TResult HandleMessage(TMsgId, TParam1 = 0, TParam2 = 0);
740
741 /// \name Windows message handlers
742 /// Virtual functions called to handle a message, and to deal with an
743 /// unhandled message in a default way.
744 /// @{
745 virtual TResult WindowProc(TMsgId, TParam1, TParam2);
746 virtual TResult DefWindowProc(TMsgId, TParam1, TParam2);
747 /// @}
748
749 // Called by WindowProc() to handle WM_COMMANDs
750 //
751 virtual TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode);
752
753 // Called by WindowProc() to handle WM_NOTIFYs
754 //
755 virtual TResult EvNotify(uint id, TNotify & notifyInfo);
756
757 /// \name Called by WindowProc() to handle WM_COMMAND_ENABLE, & helper function
758 /// @{
759 virtual void EvCommandEnable(TCommandEnabler& ce);
760 void RouteCommandEnable(HWND hInitCmdTarget, TCommandEnabler& ce);
761 /// @}
762
763 // Default processing, deals with special cases or calls DefWindowProc
764 //
765 TResult DefaultProcessing();
766
767 // Paint function called by base classes when responding to WM_PAINT
768 //
769 virtual void Paint(TDC& dc, bool erase, TRect& rect);
770
771 /// \name Transfer buffer functionality
772 /// @{
773#if defined(OWL5_COMPAT)
774 void SetTransferBuffer(void* transferBuffer);
775#endif
776
777 void SetTransferBuffer(void* transferBuffer, uint size);
778
779 template <class TBuffer>
780 void SetTransferBuffer(TBuffer* transferBuffer);
781
782 template <class TElement, uint Count>
783 void SetTransferBuffer(TElement (&transferBuffer)[Count]);
784
785 void* GetTransferBuffer() const {return TransferBuffer;}
786 uint GetTransferBufferSize() const {return TransferBufferSize;}
787
788 virtual uint Transfer(void* buffer, TTransferDirection direction);
789 virtual void TransferData(TTransferDirection direction);
790 /// @}
791
792 // Installs the instance window procedure and saves the previous window
793 // procedure in "DefaultProc"
794 //
795 void SubclassWindowFunction();
796
797 //-----------------------------------
798 // Encapsulated native HWND functions inline
799 //
800
801 /// \name Allow a TWindow& to be used as an HWND in Windows API calls
802 /// @{
803 HWND GetHandle() const;
804 operator HWND() const;
805 bool IsWindow() const;
806 /// @}
807
808 /// \name Messages
809 /// @{
810 TResult SendMessage(TMsgId, TParam1 = 0, TParam2 = 0) const;
811 TResult SendDlgItemMessage(int childId, TMsgId, TParam1 = 0, TParam2 = 0);
812 bool PostMessage(TMsgId, TParam1 = 0, TParam2 = 0);
813 static HWND GetCapture();
814 HWND SetCapture();
815 static void ReleaseCapture();
816 static HWND GetFocus();
817 HWND SetFocus();
818 bool IsWindowEnabled() const;
819 virtual bool EnableWindow(bool enable);
820 void SetRedraw(bool redraw);
821
822 bool TrackMouseEvent(uint flags = TME_HOVER | TME_LEAVE, int hoverTime = HOVER_DEFAULT);
823 bool CancelMouseEvent(uint flags = TME_HOVER | TME_LEAVE);
824 TRACKMOUSEEVENT QueryMouseEventTracking() const;
825 /// @}
826
827 /// \name Window coordinates, dimensions...
828 /// @{
829
830 //
831 //
832 //
833 void ClientToScreen(TPoint& point) const;
834
835 //
836 /// Function-style version of ClientToScreen
837 //
839 {TPoint q = p; ClientToScreen(q); return q;}
840
841 //
842 /// Maps the given points, specified in client coordinates in this window, to screen coordinates.
843 //
844 void MapClientToScreen(TPoint* p, int count) const
845 {::MapWindowPoints(GetHandle(), HWND_DESKTOP, p, count);}
846
847 //
848 /// Overload for array
849 /// See MapClientToScreen(TPoint*, int).
850 //
851 template <size_t Count>
852 void MapClientToScreen(TPoint (&p)[Count]) const
853 {MapClientToScreen(&p[0], Count);}
854
855 //
856 /// Functional-style overload for TRect; converts the given rectangle coordinates and returns the result.
857 /// See MapClientToScreen(TPoint*, int).
858 //
860 {TRect q = r; MapClientToScreen(q, 2); return q;}
861
862 //
863 //
864 //
865 void ScreenToClient(TPoint& point) const;
866
867 //
868 /// Functional-style version of ScreenToClient
869 //
871 {TPoint q = p; ScreenToClient(q); return q;}
872
873 //
874 /// Maps the given points, specified in screen coordinates, to client coordinates in this window.
875 //
876 void MapScreenToClient(TPoint* p, int count) const
877 {::MapWindowPoints(HWND_DESKTOP, GetHandle(), p, count);}
878
879 //
880 /// Overload for array
881 /// See MapScreenToClient(TPoint*, int).
882 //
883 template <size_t Count>
884 void MapScreenToClient(TPoint (&p)[Count]) const
885 {MapScreenToClient(&p[0], Count);}
886
887 //
888 /// Functional-style overload for TRect; converts the given rectangle coordinates and returns the result.
889 /// See MapScreenToClient(TPoint*, int).
890 //
892 {TRect q = r; MapScreenToClient(q, 2); return q;}
893
894 //
895 //
896 //
897 void MapWindowPoints(HWND hWndTo, TPoint* pts, int count) const;
898
899 //
900 /// Overload for TWindow
901 /// See MapWindowPoints(HWND, TPoint*, int).
902 //
903 void MapWindowPoints(const TWindow& wndTo, TPoint* p, int n) const
904 {MapWindowPoints(wndTo.GetHandle(), p, n);}
905
906 //
907 /// Overload for array
908 /// See MapWindowPoints(HWND, TPoint*, int).
909 //
910 template <size_t Count>
911 void MapWindowPoints(HWND hWndTo, TPoint (&p)[Count]) const
912 {MapWindowPoints(hWndTo, &p[0], Count);}
913
914 //
915 /// Overload for TWindow and array
916 /// See MapWindowPoints(HWND, TPoint*, int).
917 //
918 template <size_t Count>
919 void MapWindowPoints(const TWindow& wndTo, TPoint (&p)[Count]) const
920 {MapWindowPoints(wndTo, &p[0], Count);}
921
922 //
923 /// Functional-style overload for TPoint; converts the given point coordinates and returns the result.
924 /// See MapWindowPoints(HWND, TPoint*, int).
925 //
927 {TPoint q = p; MapWindowPoints(hWndTo, &q, 1); return q;}
928
929 //
930 /// Overload for TWindow and TPoint
931 /// See MapWindowPoints(HWND, const TPoint&).
932 //
933 TPoint MapWindowPoints(const TWindow& wndTo, const TPoint& p) const
934 {return MapWindowPoints(wndTo.GetHandle(), p);}
935
936 //
937 /// Functional-style overload for TRect; converts the given rectangle coordinates and returns the result.
938 /// See MapWindowPoints(HWND, TPoint*, int).
939 //
941 {TRect q = r; MapWindowPoints(hWndTo, q, 2); return q;}
942
943 //
944 /// Overload for TWindow and TRect
945 /// See MapWindowPoints(HWND, const TRect&).
946 //
947 TRect MapWindowPoints(const TWindow& wndTo, const TRect& r) const
948 {return MapWindowPoints(wndTo.GetHandle(), r);}
949
950 //
951 /// Maps the window's rectangle (GetWindowRect) to client coordinates in the given destination window.
952 //
954 {TRect r = GetWindowRect(); ::MapWindowPoints(HWND_DESKTOP, hWndTo, r, 2); return r;}
955
956 //
957 /// Overload for TWindow
958 /// See MapWindowRect(HWND).
959 //
961 {return MapWindowRect(wndTo.GetHandle());}
962
963 //
964 /// Maps the window's client rectangle (GetClientRect) to client coordinates in the given destination window.
965 //
967 {TRect r = GetClientRect(); MapWindowPoints(hWndTo, r, 2); return r;}
968
969 //
970 /// Overload for TWindow
971 /// See MapClientRect(HWND).
972 //
974 {return MapClientRect(wndTo.GetHandle());}
975
976 void GetClientRect(TRect& rect) const;
977 TRect GetClientRect() const;
978 static HWND WindowFromPoint(const TPoint& point);
979 HWND ChildWindowFromPoint(const TPoint& point) const;
980 void GetWindowRect(TRect& rect) const;
981 TRect GetWindowRect() const;
982 static void AdjustWindowRect(TRect& rect, uint32 style, bool menu);
983 static void AdjustWindowRectEx(TRect& rect, uint32 style, bool menu, uint32 exStyle);
984
985 //
986 /// Returns the window rectangle of the given window, specified in this window's client coordinates.
987 //
989 {
990 TRect r;
991 ::GetWindowRect(hWnd, &r);
992 ::MapWindowPoints(HWND_DESKTOP, GetHandle(), r, 2);
993 return r;
994 }
995
996 //
997 /// Overload for TWindow
998 /// See GetChildRect(HWND).
999 //
1001 {return GetChildRect(wnd.GetHandle());}
1002
1003 /// @}
1004
1005 /// \name Window and class Words and Longs, window properties
1006 /// @{
1007 auto GetClassName(LPTSTR className, int maxCount) const -> int;
1008 long GetClassLong(int index) const;
1009 long SetClassLong(int index, long newLong);
1010 uint16 GetClassWord(int index) const;
1011 uint16 SetClassWord(int index, uint16 newWord);
1012 LONG_PTR GetWindowLongPtr(int index) const;
1013 LONG_PTR SetWindowLongPtr(int index, LONG_PTR newLong);
1014 long GetWindowLong(int index) const;
1015 long SetWindowLong(int index, long newLong);
1016 uint16 GetWindowWord(int index) const;
1017 uint16 SetWindowWord(int index, uint16 newWord);
1018 WNDPROC GetWindowProc() const;
1019 WNDPROC SetWindowProc(WNDPROC wndProc);
1020 int EnumProps(PROPENUMPROC proc);
1021 HANDLE GetProp(uint16 atom) const;
1022 HANDLE RemoveProp(uint16 atom) const;
1023 bool SetProp(uint16 atom, HANDLE data) const;
1024 HANDLE GetProp(LPCTSTR str) const;
1025 HANDLE GetProp(const tstring& str) const {return GetProp(str.c_str());}
1026 HANDLE RemoveProp(LPCTSTR str) const;
1027 HANDLE RemoveProp(const tstring& str) const {return RemoveProp(str.c_str());}
1028 bool SetProp(LPCTSTR str, HANDLE data) const;
1029 bool SetProp(const tstring& str, HANDLE data) const {return SetProp(str.c_str(), data);}
1030 /// @}
1031
1032 /// \name Dual mode accessors.
1033 /// Work with Attr and other members as well as the underlying window information
1034 /// @{
1035 uint32 GetStyle() const;
1036 uint32 SetStyle(uint32 style);
1037 uint32 GetExStyle() const;
1038 uint32 SetExStyle(uint32 style);
1039 bool ModifyStyle(uint32 offBits, uint32 onBits,
1040 uint swpFlags = 0);
1041 bool ModifyExStyle(uint32 offBits, uint32 onBits,
1042 uint swpFlags = 0);
1043 /// @}
1044
1045 /// \name Window placement(X,Y) and display
1046 /// @{
1047 bool MoveWindow(int x, int y, int w, int h, bool repaint = false);
1048 bool MoveWindow(const TRect& rect, bool repaint = false);
1049 virtual bool ShowWindow(int cmdShow);
1050 void ShowOwnedPopups(bool show);
1051 bool IsWindowVisible() const;
1052 bool IsZoomed() const;
1053 bool IsIconic() const;
1054 int GetWindowTextLength() const;
1055 int GetWindowText(LPTSTR str, int maxCount) const;
1056 tstring GetWindowText() const;
1057 void SetWindowText(LPCTSTR str);
1058 void SetWindowText(const tstring& str) {SetWindowText(str.c_str());}
1059 void SetWindowText(uint resourceStringId);
1060 WINDOWPLACEMENT GetWindowPlacement() const;
1061 void SetWindowPlacement(const WINDOWPLACEMENT& place);
1062
1063#if defined(OWL5_COMPAT)
1064
1065 bool GetWindowPlacement(WINDOWPLACEMENT* place) const;
1066 bool SetWindowPlacement(const WINDOWPLACEMENT* place);
1067
1068#endif
1069
1070 /// @}
1071
1072 /// \name Window positioning(Z), sibling relationships
1073 /// @{
1074 void BringWindowToTop();
1075 static HWND GetActiveWindow();
1076 HWND SetActiveWindow();
1077 static HWND GetDesktopWindow();
1078 HWND GetLastActivePopup() const;
1079 HWND GetNextWindow(uint dirFlag) const;
1080 HWND GetTopWindow() const;
1081 HWND GetWindow(uint cmd) const;
1082 bool SetWindowPos(HWND hWndInsertAfter,
1083 const TRect& rect,
1084 uint flags);
1085 bool SetWindowPos(HWND hWndInsertAfter,
1086 int x, int y, int w, int h,
1087 uint flags);
1088 /// @}
1089
1090 /// \name Window painting: invalidating, validating & updating
1091 /// @{
1092 virtual void Invalidate(bool erase = true);
1093 virtual void InvalidateRect(const TRect& rect, bool erase = true);
1094 void InvalidateRgn(HRGN hRgn, bool erase = true);
1095 void Validate();
1096 void ValidateRect(const TRect& rect);
1097 void ValidateRgn(HRGN hRgn);
1098 void UpdateWindow();
1099 bool FlashWindow(bool invert);
1100 bool GetUpdateRect(TRect& rect, bool erase = true) const;
1101 int GetUpdateRgn(TRegion& rgn, bool erase = true) const;
1102 bool LockWindowUpdate(bool lock=true);
1103 bool RedrawWindow(TRect* update,
1106 auto GetWindowRgn(TRegion&) const -> int;
1107 void ResetWindowRgn(bool repaint = false) {SetWindowRgn(nullptr, repaint);} ///< Calls `SetWindowRgn(nullptr, repaint)`. \see TWindow::SetWindowRgn(HRGN, bool)
1108 auto SetWindowRgn(HRGN, bool repaint = false) -> bool;
1109 auto SetWindowRgn(const TRegion&, bool repaint = false) -> bool = delete; ///< \see TWindow::SetWindowRgn(TRegion&&, bool)
1110 auto SetWindowRgn(TRegion&& r, bool repaint = false) -> bool;
1111
1112 /// @}
1113 /// \name Scrolling and scrollbars
1114 /// @{
1115
1116 bool GetScrollInfo(int bar, SCROLLINFO* scrollInfo) const;
1117 SCROLLINFO GetScrollInfo(int bar, uint mask = SIF_ALL) const;
1118 int SetScrollInfo(int bar, SCROLLINFO* scrollInfo, bool redraw = true);
1119 int GetScrollPos(int bar) const;
1120 int SetScrollPos(int bar, int pos, bool redraw = true);
1121 int GetScrollTrackPos(int bar) const;
1122 void GetScrollRange(int bar, int& minPos, int& maxPos) const;
1123 typedef std::pair<int, int> TScrollRange;
1124 TScrollRange GetScrollRange(int bar) const;
1125 void SetScrollRange(int bar, int minPos, int maxPos, bool redraw = true);
1126 void SetScrollRange(int bar, const TScrollRange&, bool redraw = true);
1127 int GetScrollPage(int bar) const;
1128 void SetScrollPage(int bar, int page, bool redraw = true);
1129
1130 bool EnableScrollBar(uint sbFlags = SB_BOTH, uint arrowFlags = ESB_ENABLE_BOTH);
1131 void ShowScrollBar(int bar, bool show = true);
1132 void ScrollWindow(int dx, int dy, const TRect* scroll = nullptr, const TRect* clip = nullptr);
1133 void ScrollWindowEx(
1134 int dx,
1135 int dy,
1136 const TRect* scroll = 0,
1137 const TRect* clip = 0,
1138 HRGN hUpdateRgn = nullptr,
1139 TRect* update = 0,
1140 uint flags = 0);
1141
1142 /// @}
1143 /// \name Parent/child with Ids
1144 /// @{
1145 int GetDlgCtrlID() const;
1146 HWND GetDlgItem(int childId) const;
1147 uint GetDlgItemInt(int childId,
1148 bool* translated = 0,
1149 bool isSigned = true) const;
1150 void SetDlgItemInt(int childId,
1151 uint value,
1152 bool isSigned = true) const;
1153 int GetDlgItemText(int childId, LPTSTR text, int maxValue) const;
1154 tstring GetDlgItemText(int childId) const;
1155 void SetDlgItemText(int childId, LPCTSTR text) const;
1156 void SetDlgItemText(int childId, const tstring& text) const {SetDlgItemText(childId, text.c_str());}
1158 uint IsDlgButtonChecked(int buttonId) const;
1159 bool IsChild(HWND hWnd) const;
1160 HWND GetNextDlgGroupItem(HWND hWndCtrl,
1161 bool previous = false) const;
1162 HWND GetNextDlgTabItem(HWND hWndCtrl,
1163 bool previous = false) const;
1164 void CheckDlgButton(int buttonId, uint check);
1165 void CheckRadioButton(int firstButtonId,
1166 int lastButtonId,
1167 int checkButtonId);
1168
1169 void SetDlgItemFont(int childId, HFONT f, bool redraw = false) const
1170 {TWindow(GetDlgItem(childId)).SetWindowFont(f, redraw);}
1171
1173 {return TWindow(GetDlgItem(childId)).GetWindowFont();}
1174
1175 //
1176 /// Returns the window rectangle of the given child, specified in this window's client coordinates.
1177 //
1179 {return GetChildRect(GetDlgItem(childId));}
1180
1181 /// @}
1182
1183 /// \name Menus and menubar
1184 /// @{
1185 HMENU GetMenu() const;
1186 HMENU GetSystemMenu(bool revert = false) const;
1187 bool SetMenu(HMENU hMenu);
1188 bool HiliteMenuItem(HMENU hMenu, uint idItem, uint hilite);
1189 void DrawMenuBar();
1190 /// @}
1191
1192 /// \name Timer
1193 /// @{
1194 bool KillTimer(UINT_PTR timerId);
1196 /// @}
1197
1198 /// \name Caret, cursor, font
1199 /// @{
1200 void CreateCaret(HBITMAP hBitmap);
1201 void CreateCaret(bool isGray, int width, int height);
1202 static uint GetCaretBlinkTime();
1203 static void GetCaretPos(TPoint& point);
1204 static TPoint GetCaretPos() {TPoint p; GetCaretPos(p); return p;}
1205 void HideCaret();
1206 static void SetCaretBlinkTime(uint16 milliSecs);
1207 static void SetCaretPos(int x, int y);
1208 static void SetCaretPos(const TPoint& pos);
1209 void ShowCaret();
1210 static void DestroyCaret();
1211 static void GetCursorPos(TPoint& pos);
1212 static TPoint GetCursorPos() {TPoint p; GetCursorPos(p); return p;}
1213 static TPoint GetMessagePos() {return TPoint(::GetMessagePos());}
1214 void SetWindowFont(HFONT font, bool redraw = true);
1215 void SetWindowFont(const TFont& font, bool redraw = true);
1216 HFONT GetWindowFont();
1217 /// @}
1218
1219
1220 /// \name Hot keys
1221 /// @{
1222 bool RegisterHotKey(int idHotKey, uint modifiers, uint virtKey);
1223 bool UnregisterHotKey(int idHotKey);
1224 /// @}
1225
1226 /// \name Misc
1227 /// @{
1228 bool WinHelp(LPCTSTR helpFile, uint command, ULONG_PTR data) const;
1229 bool WinHelp(const tstring& helpFile, uint command, ULONG_PTR data) const {return WinHelp(helpFile.c_str(), command, data);}
1230 void AssignContextMenu(TPopupMenu* menu);
1231 TPopupMenu* GetContextMenu() const;
1232 int MessageBox(LPCTSTR text, LPCTSTR caption = 0, uint flags = MB_OK) const;
1233 int MessageBox(const tstring& text, const tstring& caption = tstring(), uint flags = MB_OK) const;
1234 int MessageBox(uint resId, LPCTSTR caption = 0, uint flags = MB_OK) const;
1235 int MessageBox(uint resId, const tstring& caption, uint flags = MB_OK) const;
1236
1238 auto MessageBoxIndirect(TResId icon, const tstring& text, const tstring& caption, uint flags = MB_OK) const -> int;
1239
1240 auto FormatMessageBox(const tstring& formatStr, const tstring& caption, uint flags, ...) const -> int;
1241 auto FormatMessageBox(const tstring&, std::nullptr_t, uint, ...) const -> int = delete;
1242
1243 HTASK GetWindowTask() const;
1244 void DragAcceptFiles(bool accept);
1245
1246 TCurrentEvent& GetCurrentEvent();
1247 void SethAccel(HACCEL);
1248 /// @}
1249
1250 protected:
1251 /// \name These events are processed by TWindow
1252 /// @{
1253 void EvClose();
1254 bool EvCreate(CREATESTRUCT&);
1255 void EvDestroy();
1256 int EvCompareItem(uint ctrlId, const COMPAREITEMSTRUCT& compareInfo);
1257 void EvDeleteItem(uint ctrlId, const DELETEITEMSTRUCT& deleteInfo);
1258 void EvDrawItem(uint ctrlId, const DRAWITEMSTRUCT& drawInfo);
1259 void EvMeasureItem(uint ctrlId, MEASUREITEMSTRUCT & measureInfo);
1260 void EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
1261 void EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
1262 void EvMove(const TPoint& clientOrigin);
1263 void EvNCDestroy();
1264 bool EvQueryEndSession(uint flags);
1265 void EvSize(uint sizeType, const TSize& size);
1266 void EvLButtonDown(uint modKeys, const TPoint& point);
1267 bool EvEraseBkgnd(HDC);
1268 void EvPaint();
1269 void EvSysColorChange();
1270 /// @}
1271
1272 /// \name Input validation message handler
1273 /// @{
1274 void EvChildInvalid(HWND hWnd);
1275 /// @}
1276
1277 /// \name System messages
1278 /// @{
1279 void EvCompacting(uint compactRatio);
1280 void EvDevModeChange(LPCTSTR devName);
1281 void EvEnable(bool enabled);
1282 void EvEndSession(bool endSession, uint flags);
1283 void EvFontChange();
1284 void EvSysCommand(uint cmdType, const TPoint& point);
1285 void EvTimeChange();
1286 void EvTimer(uint timerId);
1287 void EvSettingChange(uint flags, LPCTSTR section) {DefaultProcessing(); InUse(flags); InUse(section);}
1288
1289#if defined(OWL5_COMPAT)
1290
1291 void EvWinIniChange(LPCTSTR section); // WM_SETTINGCHANGE supercedes WM_WININICHANGE.
1292
1293#endif
1294
1295 /// @}
1296
1297 /// \name Window manager messages
1298 /// @{
1299 void EvActivate(uint active,
1300 bool minimized,
1301 HWND hWndOther /* may be 0 */);
1302 void EvActivateApp(bool active, DWORD threadId);
1303 void EvCancelMode();
1304 void EvGetMinMaxInfo(MINMAXINFO & minmaxinfo);
1305
1306#if defined(OWL5_COMPAT)
1307
1308 void EvGetText(uint bufSize, LPTSTR buf);
1309 uint EvGetTextLength();
1310
1311#else
1312
1313 int EvGetText(int bufSize, LPTSTR buf);
1314 int EvGetTextLength();
1315
1316#endif
1317
1318 void EvKillFocus(HWND hWndGetFocus /* may be 0 */);
1319 uint EvMouseActivate(HWND hTopLevel, uint hitCode, TMsgId);
1320 /// @}
1321
1322 /// \name The following are called under Win32 only
1323 /// @{
1324
1325#if defined(OWL5_COMPAT)
1326
1327 void EvHotKey(int idHotKey) {DefaultProcessing(); InUse(idHotKey);}
1328
1329#else
1330
1331 void EvHotKey(int idHotKey, uint modifiers, uint vk) {DefaultProcessing(); InUse(idHotKey | modifiers | vk);}
1332
1333#endif
1334
1335 bool EvCopyData(HWND hwnd, const COPYDATASTRUCT&);
1336
1338 void EvParentNotify(const TParentNotify&);
1339 HICON EvQueryDragIcon();
1340 bool EvQueryOpen();
1341 void EvQueueSync();
1342 bool EvSetCursor(HWND hWndCursor, uint codeHitTest, TMsgId mouseMsg);
1343 void EvSetFocus(HWND hWndLostFocus /* may be 0 */);
1344 HFONT EvGetFont();
1345 void EvSetFont(HFONT hFont, bool redraw);
1346 void EvSetRedraw(bool redraw);
1347 void EvSetText(LPCTSTR text);
1348 void EvShowWindow(bool show, uint status);
1349 void EvWindowPosChanged(const WINDOWPOS& windowPos);
1350 bool EvWindowPosChanging(WINDOWPOS&);
1351 /// @}
1352
1353 /// \name Controls
1354 /// @{
1355 HBRUSH EvCtlColor(HDC hDC, HWND hWndChild, uint ctlType);
1356 /// @}
1357
1358 /// \name Keyboard input
1359 /// @{
1360 void EvChar(uint key, uint repeatCount, uint flags);
1361 void EvDeadChar(uint deadKey, uint repeatCount, uint flags);
1362 void EvKeyDown(uint key, uint repeatCount, uint flags);
1363 void EvKeyUp(uint key, uint repeatCount, uint flags);
1364 void EvSysChar(uint key, uint repeatCount, uint flags);
1365 void EvSysDeadChar(uint key, uint repeatCount, uint flags);
1366 void EvSysKeyDown(uint key, uint repeatCount, uint flags);
1367 void EvSysKeyUp(uint key, uint repeatCount, uint flags);
1368 /// @}
1369
1370 /// \name Mouse input
1371 /// @{
1372 void EvLButtonDblClk(uint modKeys, const TPoint& point);
1373 void EvLButtonUp(uint modKeys, const TPoint& point);
1374 void EvMButtonDblClk(uint modKeys, const TPoint& point);
1375 void EvMButtonDown(uint modKeys, const TPoint& point);
1376 void EvMButtonUp(uint modKeys, const TPoint& point);
1377 void EvMouseMove(uint modKeys, const TPoint& point);
1378 void EvMouseHWheel(uint modKeys, int zDelta, const TPoint& point);
1379 void EvMouseWheel(uint modKeys, int zDelta, const TPoint& point);
1380 void EvRButtonDblClk(uint modKeys, const TPoint& point);
1381 void EvRButtonDown(uint modKeys, const TPoint& point);
1382 void EvRButtonUp(uint modKeys, const TPoint& point);
1383 /// @}
1384
1385
1386 /// \name Menu related messages
1387 /// @{
1388 void EvInitMenu(HMENU hMenu);
1389 void EvInitMenuPopup(HMENU hPopupMenu, uint index, bool isSysMenu);
1390 int32 EvMenuChar(uint nChar, uint menuType, HMENU hMenu);
1391 void EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu);
1392 void EvContextMenu(HWND childHwnd, int x, int y);
1393 /// @}
1394
1395 /// \name Dialog [Menu] messages
1396 /// @{
1397 uint EvGetDlgCode(const MSG* msg);
1398 void EvEnterIdle(uint source, HWND hWndDlg);
1399 /// @}
1400
1401 /// \name Print manager messages
1402 /// @{
1403 void EvSpoolerStatus(uint jobStatus, uint jobsLeft);
1404 /// @}
1405
1406 /// \name Clipboard messages
1407 /// @{
1408 void EvAskCBFormatName(uint bufLen, LPTSTR buffer);
1409 void EvChangeCBChain(HWND hWndRemoved, HWND hWndNext);
1410 void EvDrawClipboard();
1411 void EvDestroyClipboard();
1412 void EvHScrollClipboard(HWND hCBViewer, uint scrollCode, uint pos);
1413 void EvPaintClipboard(HWND hWnd, const PAINTSTRUCT&);
1414 void EvRenderAllFormats();
1415 void EvRenderFormat(uint dataFormat);
1416 void EvSizeClipboard(HWND hWndViewer, const TRect&);
1417 void EvVScrollClipboard(HWND hCBViewer, uint scrollCode, uint pos);
1418 /// @}
1419
1420 /// \name Palette manager messages
1421 /// @{
1422 void EvPaletteChanged(HWND hWndPalChg);
1423 void EvPaletteIsChanging(HWND hWndPalChg);
1424 bool EvQueryNewPalette();
1425 /// @}
1426
1427 /// \name Drag-n-drop messages
1428 /// @{
1429 void EvDropFiles(TDropInfo dropInfo);
1430 /// @}
1431
1432 /// \name List box messages
1433 /// @{
1434 int EvCharToItem(uint ch, HWND hWndListBox, int caretIndex);
1435 int EvVKeyToItem(uint key, HWND hWndListBox, int caretIndex);
1436 /// @}
1437
1438 /// \name Non-client messages
1439 /// @{
1440 bool EvNCActivate(bool active);
1441 uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS&);
1442 bool EvNCCreate(CREATESTRUCT&);
1443 uint EvNCHitTest(const TPoint&);
1444 void EvNCLButtonDblClk(uint codeHitTest, const TPoint&);
1445 void EvNCLButtonDown(uint codeHitTest, const TPoint&);
1446 void EvNCLButtonUp(uint codeHitTest, const TPoint&);
1447 void EvNCMButtonDblClk(uint codeHitTest, const TPoint&);
1448 void EvNCMButtonDown(uint codeHitTest, const TPoint&);
1449 void EvNCMButtonUp(uint codeHitTest, const TPoint&);
1450 void EvNCMouseMove(uint codeHitTest, const TPoint&);
1451 void EvNCPaint(HRGN);
1452 void EvNCRButtonDblClk(uint codeHitTest, const TPoint&);
1453 void EvNCRButtonDown(uint codeHitTest, const TPoint&);
1454 void EvNCRButtonUp(uint codeHitTest, const TPoint&);
1455 /// @}
1456
1457 /// \name Icon messages
1458 /// @{
1459 HICON EvGetIcon(bool isBigIcon) {InUse(isBigIcon); return reinterpret_cast<HICON>(DefaultProcessing());}
1460 HICON EvSetIcon(bool isBigIcon, HICON) {InUse(isBigIcon); return reinterpret_cast<HICON>(DefaultProcessing());}
1461 /// @}
1462
1463 /// \name Callback procs for hooking TWindow to native window
1464 /// @{
1465 static LRESULT CALLBACK InitWndProc(HWND, UINT msg, WPARAM, LPARAM);
1466 /// @}
1467
1468 protected:
1469 // Constructor & subsequent initializer for use with virtual derivations
1470 // Immediate derivitives must call Init() before constructions are done.
1471 //
1472 TWindow();
1473 void Init(TWindow* parent, LPCTSTR title, TModule* module);
1474 void Init(TWindow* parent, const tstring& title, TModule* module) {Init(parent, title.c_str(), module);}
1475 void Init(HWND hWnd, TModule* module);
1476
1477 virtual THandle PerformCreate();
1478
1479 void SetHandle(THandle);
1480
1481 // Resynching state
1482 //
1483 void GetHWndState(bool forceStyleSync = false);
1484 void GetWindowTextTitle();
1485
1486 virtual void GetWindowClass(WNDCLASS& wndClass);
1487 virtual auto GetWindowClassName() -> TWindowClassName;
1488
1489 void PerformSetupAndTransfer();
1490 virtual void SetupWindow();
1491 virtual void CleanupWindow();
1492
1493 void DispatchScroll(uint scrollCode, uint thumbPos, HWND hWndCtrl);
1494
1495 void LoadAcceleratorTable();
1496 virtual void RemoveChild(TWindow* child);
1497
1498 TWindow* GetWindowPtr(HWND hWnd) const;
1499
1500 // Member data // !CQ need to add accessors for many of these
1501 //
1503
1504 /// Holds the handle to the associated MS-Windows window, which you'll need to
1505 /// access if you make calls directly to Windows API functions.
1506 //
1507 HWND Handle;
1508
1509/// Points to the window's caption. When there is a valid HWindow, Title will yield
1510/// the same information as ::GetWindowText if you use TWindow::SetCaption to set
1511/// it.
1512 LPTSTR Title; // Logical title. Usually the same as window text
1513
1514/// Points to the interface object that serves as the parent window for this interface object.
1515 TWindow* Parent; // Owl parent, use GetParentO(), SetParent()
1516
1517/// Holds a TWindowAttr structure, which contains the window's creation attributes.
1518/// These attributes, which include the window's style, extended style, position,
1519/// size, menu ID, child window ID, and menu accelerator table ID, are passed to the
1520/// function that creates the window.
1521 TWindowAttr Attr;
1522
1523/// Holds the address of the default window procedure. DefWindowProc calls
1524/// DefaultProc to process Windows messages that are not handled by the window.
1525 WNDPROC DefaultProc;
1526
1527/// Points to the scroller object that supports either the horizontal or vertical
1528/// scrolling for this window.
1529 TScroller* Scroller; // Scrolling helper object
1530
1532
1533 /// Holds the handle to the current Windows accelerator table associated with this window.
1534 //
1535 HACCEL HAccel;
1536
1537/// Holds the module ID for the specified cursor. A value of 0 indicates a standard system cursor.
1538 TModule* CursorModule;
1539
1540/// Holds the cursor resource ID for the window's cursor. If the data member
1541/// CursorModule is 0, CursorResId can be one of the following IDC_Xxxx constants
1542/// that represent different kinds of cursors:
1543/// - \c \b IDC_ARROW Customary arrow cursor
1544/// - \c \b IDC_CROSS Crosshair cursor
1545/// - \c \b IDC_IBEAM I-beam cursor
1546/// - \c \b IDC_ICON Unfilled icon cursor
1547/// - \c \b IDC_SIZE A smaller square in the right inside corner of a larger square
1548/// - \c \b IDC_SIZENESW Dual-pointing cursor with arrows pointing southwest and northeast
1549/// - \c \b IDC_SIZENS Dual-pointing cursor with arrows pointing south and north
1550/// - \c \b IDC_SIZENWSE Dual-pointing cursor with arrows pointing southeast and northwest
1551/// - \c \b IDC_SIZEWE Dual-pointing cursor with arrows pointing east and west
1552/// - \c \b IDC_UPARROW Vertical arrow cursor
1553/// - \c \b IDC_WAIT Hourglass cursor
1554 TResId CursorResId;
1555
1556/// Holds a handle to the window's cursor. The cursor is retrieved using
1557/// CursorModule and CursorResId and set using SetCursor.
1558 HCURSOR HCursor;
1559 TPopupMenu* ContextPopupMenu; ///< Popup menu used for right click
1560 TTooltip* Tooltip; // Tooltip
1561
1562#if defined(OWL5_COMPAT)
1563 protected_data: // TransferBuffer is proteced or maybe even public.
1564#else
1565 private: // TransferBuffer is always private.
1566#endif
1567
1568/// Points to a buffer to be used in transferring data in and out of the TWindow
1569/// object. A TWindow object assumes that the buffer contains data used by the
1570/// windows in its child list. If TransferBuffer is 0, no data is to be transferred.
1571 void* TransferBuffer;
1572
1573/// Specifies the size of the transfer buffer pointed to by TransferBuffer.
1574 uint TransferBufferSize;
1575
1576 private:
1577 WNDPROC InstanceProc; ///< The window proc for this window instance
1578 TApplication* Application; ///< Application that this window belongs to
1579 TModule* Module; ///< Default module used for getting resources
1580 uint32 Flags;
1581 uint16 ZOrder;
1582 TWindow* ChildList;
1583 TWindow* SiblingList;
1584 UINT_PTR UniqueId;
1585 TColor BkgndColor; // Overriding background color. See SetBkgndColor.
1586 TColor TextColor; // Text color assigned by EvCtlColor.
1587 std::unique_ptr<TFont> Font; // Private font assigned by SetWindowFont.
1588
1589 static UINT_PTR LastUniqueId;
1590
1591 // Instance window proc interface
1592 //
1593 WNDPROC CreateInstanceProc();
1594 WNDPROC GetInstanceProc() const;
1595 void InitInstanceProc();
1596 void FreeInstanceProc();
1597
1598 // Internal functions
1599 //
1600 HMENU MakeMenuOrId();
1601 void PerformInit(TWindow* parent, TModule* module);
1602 void AssignZOrder();
1603 void AddChild(TWindow* child);
1604 int IndexOf(const TWindow* child) const;
1605 TWindow* At(int position);
1606 const TWindow* At(int position) const { return const_cast<TWindow*>(this)->At(position); }
1607 void SetUniqueId();
1608
1609 TResult ReceiveMessage(HWND, TMsgId, TParam1 = 0, TParam2 = 0) noexcept;
1610 friend void* GetMessageReceiverMemberFunctionAddress();
1611 friend TResult CALLBACK DispatchWindowMessage(TWindow* w, TMsgId msg, TParam1 param1, TParam2 param2);
1612
1613 //
1614 /// Obsolete virtual function; replaced by 'void PerformCreate()'.
1615 /// This function has been retained, but made 'private' and 'final', so that old overrides and
1616 /// calls by client code are detected and rejected.
1617 //
1618 virtual void PerformCreate(int menuOrId) final = delete;
1619
1620 // Hidden to prevent accidental copying or assignment
1621 //
1622 TWindow(const TWindow&);
1623 TWindow& operator =(const TWindow&);
1624
1625 //
1626 // The virtual function GetWindowClassName was originally named GetClassName.
1627 // To prevent accidental non-overriding virtual functions in derived classes, we define
1628 // GetClassName with a private dummy type as return type. If a derived class now tries to
1629 // override GetClassName, it will cause a compilation error. The user will have to update the
1630 // derived class to override GetWindowClassName instead.
1631 //
1632 class TDummy_GetClassNameHasBeenReplacedByGetWindowClassName_ {};
1633 virtual auto GetClassName() -> TDummy_GetClassNameHasBeenReplacedByGetWindowClassName_ {return {};}
1634
1635 DECLARE_RESPONSE_TABLE(TWindow);
1636 DECLARE_STREAMABLE_OWL(TWindow, 3);
1637}; // class TWindow
1638
1640
1641//
1642/// \class TXWindow
1643// ~~~~~ ~~~~~~~~
1644/// A nested class, TXWindow describes an exception that results from trying to
1645/// create an invalid window.
1646//
1647class _OWLCLASS TXWindow : public TXOwl {
1648 public:
1650
1651 TXWindow(const TXWindow& src);
1652 int Unhandled(TModule* app, uint promptResId);
1653
1654 TXWindow* Clone();
1655 void Throw();
1656
1657 static void Raise(TWindow* win = nullptr, uint resourceId = IDS_INVALIDWINDOW);
1658
1659 TWindow* GetWindow() const;
1660
1662/// Points to the window object that is associated with the exception.
1663 TWindow* Window;
1664};
1665
1666/// @}
1667
1668#include <owl/posclass.h>
1669
1670//----------------------------------------------------------------------------
1671
1672//
1673/// A TActionFunc defined in window.cpp
1674//
1675void DoEnableAutoCreate(TWindow* win, void*);
1676
1677//
1678/// Raw function to retrieve a TWindow pointer given an HWND from the a given
1679/// app, or any app (app==0). Use the TWindow or TApplication member versions
1680/// in new code for more protection.
1681//
1683
1684#if defined(__TRACE) || defined(__WARN)
1685_OWLCFUNC(std::ostream&) operator <<(std::ostream& os, const TWindow& w);
1686#endif
1687
1688//----------------------------------------------------------------------------
1689// Inline implementations
1690//
1691
1692//
1693/// Retrieves the id of the command.
1694//
1696{
1697 return Id;
1698}
1699
1700//
1701/// Returns true if this command enabler sends a command message.
1702//
1704{
1705 return !(Flags & NonSender);
1706}
1707
1708//
1709/// Return true if the command enabler has been handled.
1710//
1712{
1713 return Flags & WasHandled;
1714}
1715
1716//
1717/// Returns true if receiver is the same as the message responder originally set up
1718/// in the constructor.
1719//
1721{
1722 return hReceiver == HWndReceiver;
1723}
1724
1725//
1726/// Returns the handle of the window that this enabler was destined for.
1727//
1729{
1730 return HWndReceiver;
1731}
1732
1733//
1734/// Sets the receiver for the enabler.
1735//
1737{
1738 HWndReceiver = hReceiver;
1739}
1740
1741//
1742/// Marks that the enabler has been handled.
1743//
1745{
1746 Flags |= WasHandled;
1747}
1748
1749//----------------------------------------------------------------------------
1750// TWindow inlines
1751//
1752
1753//
1754/// Returns a pointer to the next sibling window in the window's sibling list.
1756{
1757 return SiblingList;
1758}
1759
1760//
1761/// Sets the next window in the sibling list.
1763{
1764 SiblingList = next;
1765}
1766
1767//
1768/// Returns a pointer to the first child window, which is the first window created
1769/// in the interface object's child list.
1771 return ChildList ? ChildList->SiblingList : nullptr;
1772}
1773
1774//
1775/// Returns a pointer to the last child window in the interface object's child list.
1777 return ChildList;
1778}
1779
1780//
1781/// Sets the specified TWindow wfXxxx constant flags (for example wfAlias,
1782/// wfTransfer, and so on) in the Flags member.
1784 Flags |= uint32(mask);
1785}
1786
1787//
1788/// Clears the specified TWindow wfXxxx constant flags (for example wfAlias,
1789/// wfTransfer, and so on) in the Flags member.
1791 Flags &= uint32(~mask);
1792}
1793
1794//
1795/// Returns the state of the bit flag in Attr.Flags whose mask is supplied. Returns
1796/// true if the bit flag is set, and false if not set.
1798 return (Flags & mask) ? true : false;
1799}
1800
1801//
1802/// Ensures that an associated child window interface element is created and
1803/// displayed along with its parent window. By default, this feature is enabled for
1804/// windows and controls, but disabled for dialog boxes.
1808
1809//
1810/// Disables the feature that allows an associated child window interface element to
1811/// be created and displayed along with its parent window. Call DisableAutoCreate
1812/// for pop-up windows and controls if you want to create and display them at a time
1813/// later than their parent windows.
1817
1818//
1819// get Tooltip
1820//
1822 return Tooltip;
1823}
1824
1825//
1826/// Enables the transfer mechanism, which allows state data to be transferred
1827/// between the window and a transfer buffer.
1830}
1831
1832//
1833/// Disables (for the interface object) the transfer mechanism, which allows state
1834/// data to be transferred to and from a transfer buffer.
1838
1839//
1840/// Returns a pointer to the module object.
1842 return Module;
1843}
1844
1845//
1846/// Sets the default module for this window.
1847inline void TWindow::SetModule(TModule* module){
1848 Module = module;
1849}
1850
1851//
1852/// Gets a pointer to the TApplication object associated with this. Use
1853/// GetApplication to obtain access to data and functions in the TApplication
1854/// object.
1856 return Application;
1857}
1858
1859//
1860inline WNDPROC TWindow::GetInstanceProc() const{
1861 return InstanceProc;
1862}
1863
1864//
1865/// Returns the associated scroller object for this window.
1866//
1868 return Scroller;
1869}
1870
1871//
1872/// This inline version of ShutDownWindow calls the static version of
1873/// ShutDownWindow.
1875 ShutDownWindow(this, retVal);
1876}
1877
1878//
1879/// Returns Attr.Id, the ID used to find the window in a specified parent's child
1880/// list.
1881inline int TWindow::GetId() const{
1882 return Attr.Id;
1883}
1884
1885/// Returns the TWindowAttr structure, which contains the window's creation attributes.
1887{
1888 return Attr;
1889}
1890
1891/// Returns the TWindowAttr structure, which contains the window's creation attributes.
1893{
1894 return Attr;
1895}
1896
1897/// Returns the Title member of TWindow. Returns 0 if the caption has not yet been set.
1898/// \note It may differ from the actual window caption, if not set via TWindow::SetCaption().
1899/// TWindow::GetWindowTextTitle() can be used to keep Title synchronized.
1901{
1902 return Title;
1903}
1904
1905
1906//
1907/// Returns the overriding background color set for the window.
1908/// If the window has no overriding background color, then TColor::None is returned.
1909/// In this case the WNDCLASS::hbrBackground setting will determine the background color.
1910/// If the window performs no background erasing, then TColor::Transparent is returned.
1911/// See TWindow::SetBkgndColor, TWindow::EvEraseBkgnd and TWindow::EvCtlColor.
1912//
1913inline auto TWindow::GetBkgndColor() const -> TColor
1914{
1915 return BkgndColor;
1916}
1917
1918//
1919/// Sets the background color for the window.
1920/// If the given color is TColor::None, the WNDCLASS::hbrBackground setting will determine the
1921/// background color. If the given color is TColor::Transparent, no background erasing will be
1922/// performed. Otherwise, the given color will override WNDCLASS::hbrBackground.
1923/// See TWindow::EvEraseBkgnd and TWindow::EvCtlColor.
1924//
1926{
1927 if (color == BkgndColor) return;
1928 BkgndColor = color;
1929 if (shouldUpdate && GetHandle())
1930 Invalidate();
1931}
1932
1933//
1934/// Returns the overriding text color set for the window.
1935/// If the window has no overriding text color, then TColor::None is returned.
1936/// In this case the system setting will determine the text color.
1937/// \sa TWindow::EvCtlColor
1938//
1939inline auto TWindow::GetTextColor() const -> TColor
1940{
1941 return TextColor;
1942}
1943
1944//
1945/// Sets the text color for the window.
1946/// If the given color is TColor::None, the system setting will determine the text color.
1947/// \note TColor::Transparent is not supported.
1948/// If `true` (default) is passed for `shouldUpdate`, then the whole window is invalidated.
1949/// \sa TWindow::EvCtlColor
1950//
1952{
1954 if (color == TextColor) return;
1955 TextColor = color;
1956 if (shouldUpdate && GetHandle())
1957 Invalidate();
1958}
1959
1960#if defined(OWL5_COMPAT)
1961//
1962/// Sets TransferBuffer only - for backward compatibility
1964 TransferBuffer = transferBuffer;
1965 TransferBufferSize = 0;
1966}
1967#endif
1968
1969//
1970/// Sets TransferBuffer and TransferBufferSize.
1972 TransferBuffer = transferBuffer;
1973 TransferBufferSize = size;
1974}
1975
1976//
1977/// Sets TransferBuffer and TransferBufferSize.
1978/// The size is inferred from the type of the passed pointer.
1979template <class TBuffer>
1983
1984//
1985/// Sets TransferBuffer and TransferBufferSize.
1986/// The size is inferred from the type of the passed array.
1987template <class TElement, uint Count>
1991
1992//----------------------------------------------------------------------------
1993// HWND wrappers
1994//
1995
1996//
1997/// Return the handle of the parent.
1998//
2000 return GetHandle() ? ::GetParent(GetHandle()) : nullptr;
2001}
2002
2003//
2004/// Return the OWL's parent for this window.
2005//
2007 return Parent;
2008}
2009
2010//
2011/// Retrieves the OWL object of the parent window. If none exists, returns 0.
2012//
2014 return GetParentO();
2015}
2016
2017//
2018/// Returns the handle of the window.
2019//
2021 return Handle;
2022}
2023
2024//
2025/// Allows a TWindow& to be used as an HWND in Windows API calls by providing an
2026/// implicit conversion from TWindow to HWND.
2027inline TWindow::operator HWND() const{
2028 return GetHandle();
2029}
2030
2031//
2032/// Sets the window handle in a derived class. Used by derived classes that create
2033/// their window handle in a class-specific way.
2035 Handle = handle;
2036}
2037
2038//
2039/// Returns true if an HWND is being used.
2040inline bool TWindow::IsWindow() const{
2041 return ::IsWindow(GetHandle());
2042}
2043
2044//
2045/// Returns the current event to be processed in the message queue.
2046//
2050
2051//
2052/// Repacks a command message (msg) so that a child window (hCtl) can send a message
2053/// to its parent regardless of whether this is a WIN16 or WIN32 application.
2054inline void
2058
2059//
2060/// Repacks a command message (msg) so that a child window (hCtl) can send a message
2061/// to its parent regardless of whether this is a WIN16 or WIN32 application.
2062inline void
2069
2070//
2071/// Repacks a command message (msg) so that a child window (hCtl) can send a message
2072/// to its parent regardless of whether this is a WIN16 or WIN32 application.
2073inline TResult
2075 return SendMessage(msg, TParam1(id), TParam2(&nmhdr));
2076}
2077
2078//
2079/// Repacks a command message (msg) so that a child window (hCtl) can send a message
2080/// to its parent regardless of whether this is a WIN16 or WIN32 application.
2081//
2082inline TResult
2084 return ::SendMessage(receiver, msg, TParam1(id), TParam2(&nmhdr));
2085}
2086
2087//
2088/// Sends a message (msg) to the control specified in childId.
2089/// \note Wrapper for Windows API.
2090//
2091inline TResult
2094 return ::SendDlgItemMessage(GetHandle(), childId, msg, p1, p2);
2095}
2096
2097//
2098/// Posts a message (msg) to the window in the application's message queue.
2099/// PostMessage returns without waiting for the corresponding window to process the
2100/// message.
2101/// \note Wrapper for Windows API.
2102//
2105 return ::PostMessage(GetHandle(), msg, p1, p2);
2106}
2107
2108//
2109/// Returns the handle of the window that has captured the mouse.
2110/// \note Wrapper for Windows API.
2111//
2113 return ::GetCapture();
2114}
2115
2116//
2117/// Sets the mouse capture to the current window. All mouse input is directed to
2118/// this window.
2119/// \note Wrapper for Windows API.
2120//
2123 return ::SetCapture(GetHandle());
2124}
2125
2126//
2127/// Releases the mouse capture from this window.
2128/// \note Wrapper for Windows API.
2129//
2132}
2133
2134//
2135/// Gets a handle to the window that has the focus. Use the function SetFocus to set
2136/// the keyboard focus to this window.
2137/// \note Wrapper for Windows API.
2138//
2140 return ::GetFocus();
2141}
2142
2143//
2144/// Sets the keyboard focus to current window and activates the window that receives
2145/// the focus by sending a WM_SETFOCUS message to the window. All future keyboard
2146/// input is directed to this window, and any previous window that had the input
2147/// focus loses it. If successful, SetFocus returns a handle to the window that has
2148/// the focus; otherwise, it returns NULL.
2149/// \note Wrapper for Windows API.
2150//
2153 return ::SetFocus(GetHandle());
2154}
2155
2156//
2157/// Returns true if the window is enabled. Use the function EnableWindow to enable
2158/// or disable a window.
2159/// \note Wrapper for Windows API.
2160//
2161inline bool TWindow::IsWindowEnabled() const{
2163 return ::IsWindowEnabled(GetHandle());
2164}
2165
2166//
2167/// Allows the given window to receive input from the keyboard of mouse. If enable
2168/// is true, the window can receive input. Use the function IsWindowEnabled to
2169/// determine if the window has been enabled.
2170/// \note Wrapper for Windows API.
2171//
2174 return ::EnableWindow(GetHandle(), enable);
2175}
2176
2177//
2178/// Sends a WM_SETREDRAW message to a window so that changes can be redrawn (redraw
2179/// = true) or to prevent changes from being redrawn (redraw = false).
2180/// \note Wrapper for Windows API.
2181//
2186
2187//
2188/// Uses the screen coordinates specified in point to calculate the client window's
2189/// coordinates and then places the new coordinates into point.
2190/// \note Wrapper for Windows API.
2191//
2196
2197//
2198/// Maps a set of points in one window to a relative set of points in another
2199/// window. hWndTo specifies the window to which the points are converted. points
2200/// points to the array containing the points. If hWndTo is 0, the points are
2201/// converted to screen coordinates. count specifies the number of points structures
2202/// in the array.
2203/// \note Wrapper for Windows API.
2204//
2205inline void
2211
2212//
2213/// Gets the coordinates of the window's client area (the area in a window you can
2214/// use for drawing).
2215/// \note Wrapper for Windows API.
2216//
2218 TRect rect;
2220 return rect;
2221}
2222
2223//
2224/// Returns the handle of the window in which the specified point (point) lies.
2225/// \note Wrapper for Windows API.
2226//
2228 return ::WindowFromPoint(point);
2229}
2230
2231//
2232/// Determines which of the child windows contains the point specified in TPoint.
2233/// Returns a handle to the window that contains the point, or 0 if the point lies
2234/// outside the parent window.
2235/// \note Wrapper for Windows API.
2236//
2237inline HWND
2240 return ::ChildWindowFromPoint(GetHandle(), point);
2241}
2242
2243//
2244/// Converts the client coordinates specified in point to screen coordinates for the
2245/// new window.
2246/// \note Wrapper for Windows API.
2247//
2252
2253//
2254/// Gets the screen coordinates of the window's rectangle.
2255/// \note Wrapper for Windows API.
2256//
2258 TRect rect;
2260 return rect;
2261}
2262
2263//
2264/// Calculates the size of the window rectangle according to the indicated
2265/// client-rectangle size. rect refers to the structure that contains the client
2266/// rectangle's coordinates. style specifies the style of the window. menu is true
2267/// if the window has a menu.
2268/// \note Wrapper for Windows API.
2269//
2270inline void
2272{
2273 ::AdjustWindowRect(&rect, style, menu);
2274}
2275
2276//
2277/// Calculates the size of a window rectangle that has an extended style. TRect
2278/// refers to the class that contains the client rectangle's coordinates. style
2279/// specifies the window styles of the window to be adjusted. menu returns true if
2280/// the window has a menu. exStyle indicates the extended styles to be used for the
2281/// window. Extended styles include the following styles:
2282/// - \c \b WS_EX_ACCEPTFILES The window can make use of drag and drop files.
2283/// - \c \b WS_EX_DLGMODALFRAME The window has a double border that can be created with a
2284/// title bar if the WS_CAPTION style flag is specified.
2285/// - \c \b WS_EX_NOPARENTNOTIFY The child window created from this style does not send
2286/// parent notify messages to the parent window when the child is created or
2287/// destroyed.
2288/// - \c \b WS_EX_TOPMOST A window having this style is placed above windows that are not
2289/// topmost and remains above the non-topmost windows even when it's deactivated.
2290/// - \c \b WS_EX_TRANSPARENT A window having this style is transparent, that is, any
2291/// windows beneath this window are not concealed by this window.
2292///
2293/// \note Wrapper for Windows API.
2294//
2295inline void
2297{
2298 ::AdjustWindowRectEx(&rect, style, menu, exStyle);
2299}
2300
2301//
2302/// Returns the Windows class name for this object's window handle.
2303/// This function is a wrapper for the Windows API function GetClassName.
2304/// http://msdn.microsoft.com/en-us/library/windows/desktop/ms633582.aspx
2305//
2306inline
2307auto TWindow::GetClassName(LPTSTR className, int maxCount) const -> int
2308{
2309 PRECONDITION(GetHandle());
2310 return ::GetClassName(GetHandle(), className, maxCount);
2311}
2312
2313//
2314/// Retrieves the 32-bit value containing information about the window class. If
2315/// unsuccessful, returns 0. Depending on the value of index, GetClassLong can
2316/// retrieve the following information:
2317/// - \c \b GCL_CBCLSEXTRA Size in bytes of memory associated with this class
2318/// - \c \b GCL_CBWINDEXTRA Size of extra window memory associated with each window
2319/// - \c \b GCL_HBRBACKGROUND Handle of the background brush associated with the class
2320/// - \c \b GCL_HCURSOR Handle of the cursor
2321/// - \c \b GCL_HICON Handle of the icon
2322/// - \c \b GCL_HMODULE Handle of the module that registered the class
2323/// - \c \b GCL_MENUNAME Address of the menu name string
2324/// - \c \b GCL_STYLE The style bits associated with a window class
2325/// - \c \b GCL_WNDPROC Address of the window procedure associated with this class
2326inline long TWindow::GetClassLong(int index) const{
2328 return ::GetClassLong(GetHandle(), index);
2329}
2330
2331//
2332/// Sets the long value at the specified offset (index). Depending on the value of
2333/// index, SetClassLong sets a handle to a background brush, cursor, icon, module,
2334/// menu, window function, or extra class bytes.
2335inline long TWindow::SetClassLong(int index, long newLong){
2337 return ::SetClassLong(GetHandle(), index, newLong);
2338}
2339
2340//
2341/// Gets a 16-bit value containing information about the class or style of the
2342/// window. If unsuccessful; returns 0. Depending on the value of index,
2343/// GetClassWord can retrieve the following information:
2344/// - \c \b GCW_CBCLSEXTRA Number of additional class information
2345/// - \c \b GCW_CBWINDEXTRA Number of bytes of additional window information
2346/// - \c \b GCW_HBRBACKGROUND Handle of the background brush
2347/// - \c \b GCW_HCURSOR Handle of the cursor
2348/// - \c \b GCW_HICON Handle of the icon
2349/// - \c \b GCW_HMODULE Handle of the module
2350/// - \c \b GCW_STYLE The style bits associated with a window class
2351inline uint16 TWindow::GetClassWord(int index) const{
2353 return ::GetClassWord(GetHandle(), index);
2354}
2355
2356//
2357/// Sets the word value at the specified offset (index). Depending on the value of
2358/// index, SetClassLong sets the number of bytes of class information, of additional
2359/// window information, or the style bits. Unlike SetClassLong, SetClassWord uses
2360/// one of the following GCW_xxxx Class Word constants:
2361/// - \c \b GCW_HBRBACKGROUND Sets a handle for a background brush.
2362/// - \c \b GCW_HCURSOR Sets a handle of a cursor.
2363/// - \c \b GCW_HICON Sets a handle of an icon.
2364/// - \c \b GCW_STYLE Sets a style bit for a window class.
2367 return ::SetClassWord(GetHandle(), index, newWord);
2368}
2369
2370//
2371/// Retrieves information about the window depending on the value stored in index.
2372/// The values returned, which provide information about the window, include the
2373/// following GWL_Xxxx window style constants:
2374/// - \c \b GWL_EXSTYLE The extended window style
2375/// - \c \b GWL_STYLE The window style (position, device context creation, size, and so on)
2376///
2377/// \note The constants GWL_WNDPROC, GWL_HINSTANCE, GWL_HWDPARENT, GWL_USERDATA should not be used anymore.
2378/// They are replaced with GWLP_WNDPROC, GWLP_HINSTANCE, GWLP_HWNDPARENT, GWLP_USERDATA which should be passed
2379/// to GetWindowLongPtr()/SetWindowLongPtr()
2380///
2381/// In the case of a dialog box, additional information can be retrieved, such as:
2382/// - \c \b DWL_DLGPROC The address of the procedure processed by the dialog box
2383/// - \c \b DWL_MSGRESULT The value that a message processed by the dialog box returns
2384/// - \c \b DWL_USER Additional information that pertains to the application, such as
2385/// pointers or handles the application uses.
2386//
2387inline long
2389{
2391 return ::GetWindowLong(GetHandle(), index);
2392}
2393
2394//
2395/// Changes information about the window. Depending on the value of index,
2396/// SetWindowLong sets a handle to a background brush, cursor, icon, module, menu,
2397/// or window function. The window style can be one of the GWL_xxxx values that
2398/// represent styles.
2399inline long
2401{
2403 return ::SetWindowLong(GetHandle(), index, newLong);
2404}
2405
2406//
2407/// Retrieves information about the window depending on the value stored in index.
2408/// The values returned, which provide information about the window, include the
2409/// following GWLP_Xxxx window style constants:
2410/// - \c \b GWLP_WNDPROC The address of the window procedure being processed
2411/// - \c \b GWLP_HINSTANCE
2412/// - \c \b GWLP_HWNDPARENT
2413/// - \c \b GWLP_USERDATA
2414/// - \c \b GWLP_ID
2415///
2416//
2417inline LONG_PTR
2419{
2421 return ::GetWindowLongPtr(GetHandle(), index);
2422}
2423
2424//
2425/// Changes information about the window. For a list of constants, see GetWindowLongPtr()
2426//
2427inline LONG_PTR
2429{
2431 return ::SetWindowLongPtr(GetHandle(), index, newLong);
2432}
2433
2434//
2435/// Retrieves information about this window depending on the value of index.
2436/// GetWindowWord returns one of the following values that indicate information
2437/// about the window:
2438/// - \c \b GWW_HINSTANCE The instance handle of the module owning the window
2439/// - \c \b GWW_HWNDPARENT The handle of the parent window
2440/// - \c \b GWW_ID The ID number of the child window
2441inline uint16
2443{
2445 return ::GetWindowWord(GetHandle(), index);
2446}
2447
2448//
2449/// Changes information about the window. index specifies a byte offset of the word
2450/// to be changed to the new value (newWord).
2451inline uint16
2453{
2455 return ::SetWindowWord(GetHandle(), index, newWord);
2456}
2457
2458inline WNDPROC
2464
2465//
2466inline WNDPROC
2472
2473//
2474/// Enumerates all the items in the property list of the current window and passes
2475/// them one by one to the callback function indicated in proc. The process
2476/// continues until every item has been enumerated or until proc returns zero. proc
2477/// holds the address of the callback function.
2478/// \note Wrapper for Windows API.
2479//
2480inline int
2482{
2484 return ::EnumProps(GetHandle(), proc);
2485}
2486
2487//
2488/// Returns a handle to the property list of the specified window. atom contains a
2489/// value that identifies the character string whose handle is to be retrieved. If
2490/// the specified string is not found in the property list for this window, returns
2491/// NULL.
2492/// \note Wrapper for Windows API.
2493//
2494inline HANDLE
2496{
2498 return ::GetProp(GetHandle(), reinterpret_cast<LPCTSTR>(atom));
2499}
2500
2501//
2502/// Removes the property specified by atom from the application's property list.
2503/// atom indicates the string to be removed. Returns the handle of the given string
2504/// or NULL if no string exists in the window's property list.
2505/// \note Wrapper for Windows API.
2506//
2507inline HANDLE
2509{
2511 return ::RemoveProp(GetHandle(), reinterpret_cast<LPCTSTR>(atom));
2512}
2513
2514//
2515/// Adds an item to the property list of the specified window. atom contains a value
2516/// that identifies the data entry to be added to the property list.
2517/// \note Wrapper for Windows API.
2518inline bool
2520{
2522 return ::SetProp(GetHandle(), reinterpret_cast<LPCTSTR>(atom), data);
2523}
2524
2525//
2526/// Returns a handle to the property list of the specified window. Unlike the Syntax
2527/// 1 GetProp function, string points to the string whose handle is to be retrieved.
2528/// If the specified string is not found in the property list for this window,
2529/// returns NULL.
2530/// \note Wrapper for Windows API.
2531//
2532inline HANDLE
2534{
2536 return ::GetProp(GetHandle(), str);
2537}
2538
2539//
2540/// Removes the property specified by str, a null-terminated string, from the
2541/// application's property list. Returns the handle of the given string or NULL if
2542/// no string exists in the window's property list.
2543/// \note Wrapper for Windows API.
2544//
2545inline HANDLE
2547{
2549 return ::RemoveProp(GetHandle(), str);
2550}
2551
2552//
2553/// Adds an item to the property list of the specified window. str points to the
2554/// string used to identify the entry data to be added to the property list.
2555/// \note Wrapper for Windows API.
2556//
2557inline bool
2559{
2561 return ::SetProp(GetHandle(), str, data);
2562}
2563
2564//
2565/// Repositions the specified window. x and y specify the new upper left coordinates
2566/// of the window; w and h specify the new width and height, respectively. If
2567/// repaint is false, the window is not repainted after it is moved.
2568/// \note MoveWindow calls thru TWindow::SetWindowPos to allow moving before creation
2569//
2570inline bool
2571TWindow::MoveWindow(int x, int y, int w, int h, bool repaint)
2572{
2573 return SetWindowPos(nullptr, x, y, w, h,
2575 (repaint ? 0 : SWP_NOREDRAW));
2576}
2577
2578//
2579/// Repositions the window. rect references the left and top coordinates and the
2580/// width and height of the new screen rectangle. If repaint is false, the window is
2581/// not repainted after it is moved.
2582inline bool
2584{
2585 return MoveWindow(rect.left, rect.top, rect.Width(), rect.Height(), repaint);
2586}
2587
2588//
2589/// Shows or hides all owned pop-up windows according to the value of show.
2590/// \note Wrapper for Windows API.
2591//
2592inline void
2598
2599//
2600/// Returns true if the window is visible. By default, TWindow's constructor sets
2601/// the window style attribute (WS_VISIBLE) so that the window is visible.
2602/// \note Wrapper for Windows API.
2603//
2604inline bool
2606{
2607 if(GetHandle())
2608 return ::IsWindowVisible(GetHandle());
2609 return Attr.Style & WS_VISIBLE;
2610}
2611
2612//
2613/// Returns true if window is zoomed or maximized.
2614/// \note Wrapper for Windows API.
2615//
2616inline bool
2618{
2620 return ::IsZoomed(GetHandle());
2621}
2622
2623//
2624/// Returns true if window is iconic or minimized.
2625/// \note Wrapper for Windows API.
2626//
2627inline bool
2629{
2631 return ::IsIconic(GetHandle());
2632}
2633
2634//
2635/// Returns the length, in characters, of the specified window's title. If the
2636/// window is a control, returns the length of the text within the control. If the
2637/// window does not contain any text, GetWindowTextLength returns 0.
2638/// \note Wrapper for Windows API.
2639//
2640inline int
2642{
2644 return ::GetWindowTextLength(GetHandle());
2645}
2646
2647//
2648/// Copies the window's title into a buffer pointed to by string. maxCount indicates
2649/// the maximum number of characters to copy into the buffer. A string of characters
2650/// longer than maxCount is truncated. GetWindowText returns the length of the
2651/// string or 0 if no title exists.
2652/// \note Wrapper for Windows API.
2653//
2654inline int
2656{
2658 return ::GetWindowText(GetHandle(), str, maxCount);
2659}
2660
2661
2662//
2663/// Sets the window's text to the given string (by copying).
2664/// Note that this does not update this window's Title member. Use SetCaption if the window's Title
2665/// member needs to be synchronized with the window's text.
2666/// \note Wrapper for Windows API.
2667//
2668inline void
2674
2675//
2676/// Sets the window title to the resource string identified by the given id.
2677//
2678inline void
2683
2684//
2685/// Brings a pop-up or child window to the top of the stack of overlapping windows
2686/// and activates it.
2687/// \note Wrapper for Windows API.
2688//
2689inline void
2695
2696//
2697/// Retrieves the handle of the active window. Returns 0 if no window is associated
2698/// with the calling thread.
2699/// \note Wrapper for Windows API.
2700//
2701inline HWND
2703{
2704 return ::GetActiveWindow();
2705}
2706
2707//
2708/// Activates a top-level window. Returns a handle to the previously active window.
2709/// \note Wrapper for Windows API.
2710//
2711inline HWND
2713{
2715 return ::SetActiveWindow(GetHandle());
2716}
2717
2718//
2719/// Returns a handle to the desktop window.
2720/// \note Wrapper for Windows API.
2721//
2722inline HWND
2724{
2725 return ::GetDesktopWindow();
2726}
2727
2728
2729//
2730/// Finds the handle associated with either the next or previous window in the
2731/// window manager's list. dirFlag specifies the direction of the search. Under the
2732/// Win 32 API, GetNextWindow returns either the next or the previous window's
2733/// handle. If the application is not running under Win32, GetNextWindow returns the
2734/// next window's handle.
2735/// \note Wrapper for Windows API.
2736//
2737inline HWND
2739{
2741 return ::GetWindow(GetHandle(), flag);
2742}
2743
2744//
2745/// Returns the last active pop-up window in the list.
2746/// \note Wrapper for Windows API.
2747//
2748inline HWND
2750{
2752 return ::GetLastActivePopup(GetHandle());
2753}
2754
2755//
2756/// Returns the handle of the window that has the indicated relationship to this
2757/// window. cmd, which indicates the type of relationship to be obtained, can be
2758/// one of the following values:
2759/// - \c \b GW_CHILD If the given window is a parent window, the return value indicates the
2760/// child window at the top of the Z order (the position of a window in a series of
2761/// overlapping windows arranged in a stack). Otherwise, the return value is 0. Only
2762/// child windows are examined.
2763/// - \c \b GW_HWNDFIRST The return value indicates the window at the top of the Z order.
2764/// If this window is a topmost window, the return value identifies the topmost
2765/// window at the top of the Z order. If this window is a top-level window, the
2766/// return value identifies the top-level window at the bottom of the Z order. If
2767/// this window is a child window, the return value indicates the sibling window at
2768/// the bottom of the Z order.
2769/// - \c \b GW_HWNDNEXT The return value identifies the window below the given window in the
2770/// Z order. If this window is a topmost window, the return value identifies the
2771/// topmost window below this window. If this window is a top-level window, the
2772/// return value indicates the top-level window below this window. If this window is
2773/// a child window, the return value indicates the sibling window below this window.
2774/// - \c \b GW_HWNDPREV The return value identifies the window above the given window in the
2775/// Z order. If this window is a topmost window, the return value identifies the
2776/// topmost window above this window. If this window is a top-level window, the
2777/// return value indicates the top-level window above this window. If this window is
2778/// a child window, the return value indicates the sibling window above this window.
2779/// - \c \b GW_OWNER The return value identifies this window's owner window, if one exists.
2780///
2781/// \note Wrapper for Windows API.
2782//
2783inline HWND
2785{
2786// PRECONDITION(GetHandle());
2787 return ::GetWindow(GetHandle(), flag);
2788}
2789
2790//
2791/// Returns a handle to the top window currently owned by this parent window. If no
2792/// children exist, GetTopWindow returns 0.
2793/// \note Wrapper for Windows API.
2794//
2795inline HWND
2797{
2799 return ::GetTopWindow(GetHandle());
2800}
2801
2802//
2803/// Changes the size of the window pointed to by rect. flags contains one of the
2804/// SWP_Xxxx Set Window Position constants (described below) that specify the size
2805/// and position of the window. If flags is set to SWP_NOZORDER, SetWindowPos
2806/// ignores the hWndInsertAfter parameter and retains the current ordering of the
2807/// child, pop-up, or top-level windows.
2808inline bool
2810{
2812 rect.left, rect.top, rect.Width(), rect.Height(), flags);
2813}
2814
2815//
2816/// Invalidates (mark for painting) the entire client area of a window. The window
2817/// then receives a message to redraw the window. By default, the background of the
2818/// client area is marked for erasing.
2819/// \note Wrapper for Windows API.
2820//
2821inline void
2827
2828//
2829/// Invalidates a specified client area. By default, the background of the client
2830/// area to be invalidated is marked for erasing.
2831/// \note Wrapper for Windows API.
2832//
2833inline void
2839
2840//
2841/// Invalidates a client area within a region specified by the hRgn parameter when
2842/// the application receives a WM_PAINT message. The region to be invalidated is
2843/// assumed to have client coordinates. If hRgn is 0, the entire client area is
2844/// included in the region to be updated. The parameter erase specifies whether the
2845/// background with the update region needs to be erased when the region to be
2846/// updated is determined. If erase is true, the background is erased; if erase is
2847/// false, the background is not erased when the Paint function is called. By
2848/// default, the background within the region is marked for erasing.
2849/// \note Wrapper for Windows API.
2850//
2851inline void
2857
2858//
2859/// Calls the function ValidateRect to validate (that is, remove from the area to be
2860/// updated) the entire client area (the area you can use for drawing).
2861/// \note Wrapper for Windows API.
2862//
2863inline void
2865{
2867 ::ValidateRect(GetHandle(), nullptr);
2868}
2869
2870//
2871/// Validates a portion of the client area indicated by rect.
2872/// \note Wrapper for Windows API.
2873//
2874inline void
2880
2881//
2882/// Validates the client area within a region of the current window. hRgn is a
2883/// handle to the client area that is to be removed from the region to be updated.
2884/// If hRgn is NULL, the entire client area is removed from the region to be
2885/// updated.
2886/// \note Wrapper for Windows API.
2887//
2888inline void
2894
2895//
2896/// Updates the client area of the specified window by immediately sending a
2897/// WM_PAINT message.
2898/// \note Wrapper for Windows API.
2899//
2900inline void
2906
2907//
2908/// Changes the window from active to inactive or vice versa. If invert is nonzero,
2909/// the window is flashed. If invert is 0, the window is returned to its original
2910/// state–either active or inactive.
2911/// \note Wrapper for Windows API.
2912//
2913inline bool
2915{
2917 return ::FlashWindow(GetHandle(), invert);
2918}
2919
2920//
2921/// Retrieves the screen coordinates of the rectangle that encloses the updated
2922/// region of the specified window. erase specifies whether GetUpdateRect should
2923/// erase the background of the updated region.
2924/// \note Wrapper for Windows API.
2925//
2926inline bool
2928{
2930 return ::GetUpdateRect(GetHandle(), &rect, erase);
2931}
2932
2933//
2934/// Prevents or enables window drawing for one window at a time. If the window is
2935/// locked, returns true; otherwise, returns false, which indicates either that an
2936/// error occurred or that some other window is already locked.
2937/// If any drawing is attempted within a locked window or locked child windows, the
2938/// extent of the attempted operation is saved within a bounding rectangle. When the
2939/// window is then unlocked, the area within the rectangle is invalidated, causing a
2940/// paint message to be sent to this window. If any drawing occurred while the
2941/// window was locked for updates, the area is invalidated.
2942/// \note Wrapper for Windows API.
2943//
2944inline bool
2946{
2948 return ::LockWindowUpdate(lock?GetHandle():nullptr);
2949}
2950
2951//
2952/// Redraws the rectangle specified by update and the region specified by
2953/// hUpdateRgn. redrawFlags can be a combination of one or more of the following
2954/// RDW_Xxxx Redraw Window constants used to invalidate or validate a window:
2955///
2956/// Flags that invalidate a window
2957/// - \c \b RDW_ERASE When the window is repainted, it receives a WM_ERASEBKGND message. If
2958/// - \c \b RDW_INVALIDATE is not also specified, this flag has no effect.
2959/// - \c \b RDW_FRAME Any part of the non-client area of the window receives a WM_NCPAINT
2960/// message if it intersects the region to be updated.
2961/// - \c \b RDW_INTERNALPAINT A WM_PAINT message is posted to the window whether or not it
2962/// contains an invalid region.
2963/// - \c \b RDW_INVALIDATE Invalidates either hUpdateRgn or update. In cases where both are
2964/// 0, the entire window becomes invalid.
2965///
2966/// Flags that validate a window
2967/// - \c \b RDW_NOERASE The window is prevented from receiving any WM_ERASEBKGND messages.
2968/// - \c \b RDW_NOFRAME The window is prevented from receiving any WM_NCPAINT messages. The
2969/// flag RDW_VALIDATE must also be used with this flag.
2970/// - \c \b RDW_NOINTERNALPAINT The window is prevented from receiving internal WM_PAINT
2971/// messages, but does not prevent the window from receiving WM_PAINT messages from
2972/// invalid regions.
2973/// - \c \b RDW_VALIDATE Validates update and hUpdateRgn. However, if both are 0, the
2974/// entire window area is validated. The flag does not have any effect on internal
2975/// WM_PAINT messages.
2976///
2977/// Flags that control when the window is repainted
2978/// - \c \b RDW_ERASENOW Before the function returns, the specified windows will receive
2979/// WM_NCPAINT and WM_ERASEBKGND messages.
2980/// - \c \b RDW_UPDATENOW Before the function returns, the specified windows will receive
2981/// WM_NCPAINT, WM_ERASEBKGND, as well as WM_PAINT messages.
2982///
2983/// \note Wrapper for Windows API.
2984//
2985inline bool
2991
2992//
2993/// Obtains a copy of the region of the window within which the system permits drawing.
2994/// Returns the type of region.
2995/// \note Wrapper for Windows API.
2996/// \sa http://msdn.microsoft.com/en-us/library/dd144950.aspx
2997//
2998inline auto TWindow::GetWindowRgn(TRegion& r) const -> int
2999{
3000 PRECONDITION(GetHandle());
3001 return ::GetWindowRgn(GetHandle(), r.GetHandle());
3002}
3003
3004//
3005/// Sets the area within the window where the system permits drawing.
3006/// If the call is successful the system takes ownership of the given region.
3007/// You must then not make any further function calls with this region handle.
3008/// \note Wrapper for Windows API.
3009/// \sa https://msdn.microsoft.com/en-us/library/dd145102.aspx
3010//
3011inline auto TWindow::SetWindowRgn(HRGN r, bool repaint) -> bool
3012{
3013 PRECONDITION(GetHandle());
3014 return ::SetWindowRgn(GetHandle(), r, repaint) != 0;
3015}
3016
3017//
3018/// Disables or enables one or both of the scroll bar arrows on the scroll bars
3019/// associated with this window. sbFlags, which specifies the type of scroll bar,
3020/// can be one of the Scroll Bar constants (SB_CTL, SB_HORZ, SB_VERT, or SB_BOTH).
3021/// By default, the arrows on both the horizontal and vertical scroll bars are
3022/// either enabled or disabled. arrowFlags, which indicates whether the scroll bar
3023/// arrows are enabled or disabled, can be one of the Enable Scroll Bar constants
3024/// (ESB_ENABLE_BOTH, ESB_DISABLE_LTUP, ESB_DISABLE_RTDN, ESB_DISABLE_BOTH). By
3025/// default, the arrows on both the horizontal and vertical scroll bars are enabled.
3026/// \note Wrapper for Windows API.
3027//
3028inline bool
3030{
3032 return ::EnableScrollBar(GetHandle(), sbFlags, arrowFlags);
3033}
3034
3035//
3036/// Displays or hides the scroll bar. bar specifies whether the bar is a control
3037/// itself or part of the window's nonclient area. If bar is part of the nonclient
3038/// area, it can be one of the SB_Xxxx scroll bar constants (specifically, SB_BOTH,
3039/// SB_HORZ, or SB_VERT). If it is a control, it should be SB_CTRL. If show is true,
3040/// the scroll bar is displayed; if false, it is hidden.
3041/// \note Wrapper for Windows API.
3042//
3043inline void TWindow::ShowScrollBar(int bar, bool show)
3044{
3047}
3048
3049//
3050/// Scrolls a window in the vertical (dx) and horizontal (dy) directions. scroll
3051/// indicates the area to be scrolled. If 0, the entire client area is scrolled.
3052/// clip specifies the clipping rectangle to be scrolled. Only the area within clip
3053/// is scrolled. If clip is 0, the entire window is scrolled.
3054/// \note Wrapper for Windows API.
3055//
3056inline void
3058{
3061}
3062
3063//
3064/// Scrolls a window in the vertical (dx) and horizontal (dy) directions. scroll
3065/// indicates the area to be scrolled. If 0, the entire client area is scrolled.
3066/// clip specifies the clipping rectangle to be scrolled. Only the area within clip
3067/// is scrolled. If clip is 0, the entire window is scrolled. update indicates the
3068/// region that will receive the boundaries of the area that becomes invalidated as
3069/// a result of scrolling. flags, which determines how the window's children are
3070/// scrolled, can be one of the following SW_Xxxx Scroll Window constants:
3071/// - \c \b SW_ERASE Erases the invalidated region after sending an erase background
3072/// message to the window indicated by the SW_INVALIDATE flag value.
3073/// - \c \b SW_INVALIDATE Invalidates the region indicated by the hUpdate parameter.
3074/// - \c \b SW_SCROLLCHILDREN Scrolls all the child window intersecting the rectangle
3075/// pointed to by the scroll parameter.
3076/// \note Wrapper for Windows API.
3077//
3078inline void
3080 int dx,
3081 int dy,
3082 const TRect* scroll,
3083 const TRect* clip,
3085 TRect* update,
3086 uint flags)
3087{
3090}
3091
3092//
3093/// Returns the ID of the control.
3094/// \note Wrapper for Windows API.
3095//
3096inline int
3098{
3100 return ::GetDlgCtrlID(GetHandle());
3101}
3102
3103//
3104/// Retrieves the handle of a control specified by childId.
3105/// \note Wrapper for Windows API.
3106//
3107inline HWND
3109{
3111 return ::GetDlgItem(GetHandle(), childId);
3112}
3113
3114//
3115/// Sets the child window with the Id (childId) in the window to the integer value
3116/// specified in value. If isSigned is true, the value is signed.
3117/// \note Wrapper for Windows API.
3118//
3119inline void
3125
3126//
3127/// Retrieves the text of a control specified by childId. text points to the text
3128/// buffer to receive the text. maxLen specifies the maximum length of the caption,
3129/// which is truncated if it exceeds this length.
3130/// \note Wrapper for Windows API.
3131//
3132inline int
3134{
3136 return ::GetDlgItemText(GetHandle(), childId, text, maxLen);
3137}
3138
3139//
3140/// Sets the title or text of a control in a dialog box. childId identifes the
3141/// control. text points to the text buffer containing the text that is to be copied
3142/// into the control.
3143/// \note Wrapper for Windows API.
3144//
3145inline void
3151
3152//
3153/// Indicates if the child button specified in the integer parameter, buttonId, is
3154/// checked, or if a button is grayed, checked, or neither. If the return value is
3155/// 0, the button is unchecked. If the return value is 1, the button is checked. If
3156/// the return value is 3, the button state is undetermined. This function sends a
3157/// BM_GETCHECK message to the specified button control.
3158/// \note Wrapper for Windows API.
3159//
3160inline uint
3162{
3164 return ::IsDlgButtonChecked(GetHandle(), buttonId);
3165}
3166
3167//
3168/// Returns true if the window is a child window or a descendant window of this
3169/// window. A window is considered a child window if it is the direct descendant of
3170/// a given parent window and the parent window is in a chain of windows leading
3171/// from the original overlapped or pop-up window down to the child window. hWnd
3172/// identifies the window to be tested.
3173/// \note Wrapper for Windows API.
3174//
3175inline bool
3177{
3179 return ::IsChild(GetHandle(), hWnd);
3180}
3181
3182//
3183/// Returns either the next or the previous control in the dialog box. hWndCtrl
3184/// identifies the control in the dialog box where the search begins. If previous is
3185/// 0, GetNextDlgGroupItem searches for the next control. If previous is nonzero, it
3186/// searches for the previous control.
3187/// \note Wrapper for Windows API.
3188//
3189inline HWND
3191{
3193 return ::GetNextDlgGroupItem(GetHandle(), hWndCtrl, previous);
3194}
3195
3196//
3197/// Returns the handle of the first control that lets the user press the Tab key to
3198/// move to the next control (that is, the first control with the WS_TABSTOP style
3199/// associated with it). hWndCtrl identifies the control in the dialog box where the
3200/// search begins. If previous is 0, GetNextDlgTabItem searches for the next
3201/// control. If previous is nonzero, it searches for the previous control.
3202/// \note Wrapper for Windows API.
3203//
3204inline HWND
3206{
3208 return ::GetNextDlgTabItem(GetHandle(), hWndCtrl, previous);
3209}
3210
3211//
3212/// Places a check mark in (or removes a check mark from) the button specified in
3213/// buttonId. If check is nonzero, the check mark is placed next to the button; if
3214/// 0, the check mark is removed. For buttons having three states, check can be 0
3215/// (clear), 1 (checked), or 2 (gray).
3216/// \note Wrapper for Windows API.
3217//
3218inline void
3224
3225//
3226/// Checks the radio button specified by checkButtonId and removes the check mark
3227/// from the other radio buttons in the group. firstButtonId and lastButtonId
3228/// specify the first and last buttons, respectively, in the group.
3229/// \note Wrapper for Windows API.
3230//
3231inline void
3237
3238//
3239/// Returns the handle to the menu of the indicated window. If the window has no
3240/// menu, the return value is 0.
3241/// \note Wrapper for Windows API.
3242//
3243inline HMENU
3245{
3247 return ::GetMenu(GetHandle());
3248}
3249
3250//
3251/// Returns a handle to the system menu so that an application can access the system
3252/// menu.
3253/// \note Wrapper for Windows API.
3254//
3255inline HMENU
3257{
3259 return ::GetSystemMenu(GetHandle(), revert);
3260}
3261
3262//
3263/// Returns the associated popup menu used by the window.
3264//
3265inline TPopupMenu*
3267{
3268 return ContextPopupMenu;
3269}
3270
3271//
3272/// Sets the specified window's menu to the menu indicated by hMenu. If hMenu is 0,
3273/// the window's current menu is removed. SetMenu returns 0 if the menu remains
3274/// unchanged; otherwise, it returns a nonzero value.
3275/// \note Wrapper for Windows API.
3276//
3277inline bool
3279{
3281 return ::SetMenu(GetHandle(), hMenu);
3282}
3283
3284//
3285/// Either highlights or removes highlighting from a top-level item in the menu.
3286/// idItem indicates the menu item to be processed. hilite (which contains a value
3287/// that indicates if the idItem is to be highlighted or is to have the highlight
3288/// removed) can be one or more of the following constants:
3289/// - \c \b MF_BYCOMMAND The idItem parameter contains the menu item's identifier.
3290/// - \c \b MF_BYPOSITION The idItem parameter contains the zero-based relative position of
3291/// the menu item.
3292/// - \c \b MF_HILITE Highlights the menu item. If this value is not specified, highlighting
3293/// is removed from the item.
3294/// - \c \b MF_UNHILITE Removes the menu item's highlighting.
3295/// If the menu is set to the specified condition, HiliteMenuItem returns true;
3296/// otherwise, it returns false.
3297///
3298/// \note Wrapper for Windows API.
3299//
3300inline bool
3302{
3304 return ::HiliteMenuItem(GetHandle(), hMenu, idItem, hilite);
3305}
3306
3307//
3308/// DrawMenuBar redraws the menu bar. This function should be called to redraw the
3309/// menu if the menu is changed after the window is created.
3310/// \note Wrapper for Windows API.
3311//
3312inline void
3318
3319//
3320/// Gets rid of the timer and removes any WM_TIMER messages from the message queue.
3321/// timerId contains the ID number of the timer event to be killed.
3322/// \note Wrapper for Windows API.
3323//
3324inline bool
3326{
3327 return ::KillTimer(GetHandle(), timerId);
3328}
3329
3330//
3331/// Creates a timer object associated with this window. timerID contains the ID
3332/// number of the timer to be created, timeout specifies the length of time in
3333/// milliseconds, and proc identifies the address of the function that's to be
3334/// notified when the timed event occurs. If proc is 0, WM_TIMER messages are placed
3335/// in the queue of the application that called SetTimer for this window.
3336/// \note Wrapper for Windows API.
3337//
3338inline UINT_PTR
3343
3344//
3345/// Creates a new caret for the system. HBITMAP specifies the bitmapped caret
3346/// shape.
3347/// \note Wrapper for Windows API.
3348//
3349inline void
3355
3356//
3357/// Create a new caret for the system with the specified shape, bitmap shade, width,
3358/// and height. If width or height is 0, the corresponding system-defined border
3359/// size is used.
3360/// \note Wrapper for Windows API.
3361//
3362inline void
3363TWindow::CreateCaret(bool isGray, int width, int height)
3364{
3366 ::CreateCaret(GetHandle(), reinterpret_cast<HBITMAP>(static_cast<UINT_PTR>(isGray ? 1 : 0)), width, height);
3367}
3368
3369//
3370/// DestroyCaret first checks the ownership of the caret. If a window in the current
3371/// task owns the caret, DestroyCaret destroys the caret and removes it from the
3372/// screen.
3373/// \note Wrapper for Windows API.
3374//
3375inline void
3380
3381//
3382/// Retrieves the caret blink rate in milliseconds.
3383/// \note Wrapper for Windows API.
3384//
3385inline uint
3387{
3388 return ::GetCaretBlinkTime();
3389}
3390
3391//
3392/// Gets the position of the caret in the coordinates of the client window. point
3393/// refers to the structure that receives the client coordinates of the caret.
3394/// \note Wrapper for Windows API.
3395//
3396inline void
3401
3402//
3403/// Removes the caret from the specified display screen. The caret is hidden only if
3404/// the current task's window owns the caret. Although the caret is not visible, it
3405/// can be displayed again using ShowCaret.
3406/// \note Wrapper for Windows API.
3407//
3408inline void
3414
3415//
3416/// Sets the caret blink rate in milliseconds.
3417/// \note Wrapper for Windows API.
3418//
3419inline void
3424
3425//
3426/// Sets the position of the caret in the coordinates of the client window. x and y
3427/// indicate the client coordinates of the caret.
3428/// \note Wrapper for Windows API.
3429//
3430inline void
3432{
3433 ::SetCaretPos(x, y);
3434}
3435
3436//
3437/// Sets the position of the caret in the coordinates of the client window. pos
3438/// indicates the client coordinates of the caret.
3439/// \note Wrapper for Windows API.
3440//
3441inline void
3443{
3444 ::SetCaretPos(pos.x, pos.y);
3445}
3446
3447//
3448/// Displays the caret in the specified shape in the active window at the current
3449/// position.
3450/// \note Wrapper for Windows API.
3451//
3452inline void
3458
3459//
3460/// Retrieves the cursor's current position (in window screen coordinates) and
3461/// copies the values into the structure pointed to by pos.
3462/// \note Wrapper for Windows API.
3463//
3464inline void
3469
3470//
3471/// Sets the font that a control uses to draw text.
3472/// The caller must make sure the font handle outlives the window.
3473/// \note Wrapper for Windows API.
3474//
3475inline void
3481
3482//
3483/// Gets the font the control uses to draw text. The return value is a handle of the
3484/// font the control uses. If a system default font is being used, GetWindowFont
3485/// returns NULL.
3486/// \note Wrapper for Windows API.
3487//
3488inline HFONT
3490{
3492 return reinterpret_cast<HFONT>(SendMessage(WM_GETFONT));
3493}
3494
3495//
3496/// Registers a hotkey ID with the current application. modifiers can be a
3497/// combination of keys that must be pressed to activate the specified hotkey, such
3498/// as HOTKEYF_SHIFT, HOTKEYF_CONTROL, and HOTKEYF_ALT.
3499inline bool
3501{
3503 return ::RegisterHotKey(GetHandle(), idHotKey, modifiers, virtKey);
3504}
3505
3506//
3507/// Unregisters a hotkey ID with the current application.
3508inline bool
3510{
3512 return ::UnregisterHotKey(GetHandle(), idHotKey);
3513}
3514
3515//
3516/// Invokes a specified help system. helpFile points to a string containing the
3517/// directory path and name of the help file. command, which indicates the type of
3518/// help requested, can be one of the Windows Help_xxxx constants such as
3519/// HELP_CONTEXT, HELP_HELPONHELP, HELP_INDEX, HELP_MULTIKEY, HELP_QUIT, or
3520/// HELP_SETINDEX. data contains keywords that indicate the help topic items.
3521/// For example, in the sample ObjectWindows file, HELP.CPP, WinHelp is called with
3522/// the arguments HELP_CONTEXT and HELP_MENUITEMA if the F1 key is pressed.
3523/// \code
3524/// void TOwlHelpWnd::CmMenuItemA()
3525/// {
3526/// if (F1Pressed) {
3527/// WinHelp(HelpFile, HELP_CONTEXT, HELP_MENUITEMA);
3528/// F1Pressed = false;
3529/// } else {
3530/// MessageBox("In Menu Item A command", Title, MB_ICONINFORMATION);
3531/// }
3532/// }
3533/// \endcode
3534/// You can also include bitmaps in your Help file by referencing their file names
3535/// or by copying them from the Clipboard. For more information about how to create
3536/// Help files, see the online Help documentation.
3537/// \note Wrapper for Windows API.
3538//
3539inline bool
3545
3546inline int
3548{
3549 return MessageBox(text.c_str(), caption.length() > 0 ? caption.c_str() : nullptr, flags);
3550}
3551
3552//
3553/// Returns a handle to the task that created the specified window.
3554/// \note Wrapper for Windows API.
3555//
3556inline HTASK
3558{
3560 return reinterpret_cast<HTASK>(static_cast<UINT_PTR>(::GetWindowThreadProcessId(GetHandle(), nullptr)));
3561}
3562
3563//
3564/// Calls TApplication:GetWindowPtr on the application associated with this window.
3565/// Then, given the handle to this window (hWnd), GetWindowPtr returns the TWindow
3566/// pointer associated with this window.
3568{
3570}
3571
3572//
3573// Inline member functions that call DefWindowProc()
3574//
3575
3576//
3577/// Default message handler for WM_ACTIVATE.
3578inline void TWindow::EvActivate(uint /*active*/,
3579 bool /*minimized*/,
3580 HWND /*hWndOther*//*may be 0*/)
3581{
3583}
3584
3585//
3586/// The default message handler for WM_ACTIVATEAPP.
3588{
3590}
3591
3592//
3593/// The default message handler for WM_ASKCBFORMATNAME.
3594inline void TWindow::EvAskCBFormatName(uint /*bufLen*/, LPTSTR /*buffer*/)
3595{
3597}
3598
3599//
3600/// The default message handler for WM_CANCELMODE.
3602{
3604}
3605
3606//
3607/// The default message handler for WM_CHANGECBCHAIN.
3608inline void TWindow::EvChangeCBChain(HWND /*hWndRemoved*/, HWND /*hWndNext*/)
3609{
3611}
3612
3613//
3614/// The default message handler for WM_CHAR.
3615inline void TWindow::EvChar(uint /*key*/, uint /*repeatCount*/, uint /*flags*/)
3616{
3618}
3619
3620//
3621/// The default message handler for WM_CHARTOITEM.
3622inline int TWindow::EvCharToItem(uint /*ch*/, HWND /*hWndListBox*/, int /*caretIndex*/)
3623{
3624 return static_cast<int>(DefaultProcessing());
3625}
3626
3627//
3628/// The default message handler for WM_VKEYTOITEM.
3629inline int TWindow::EvVKeyToItem(uint /*key*/, HWND /*hWndListBox*/, int /*caretIndex*/)
3630{
3631 return static_cast<int>(DefaultProcessing());
3632}
3633
3634//
3635/// The default message handler for WM_COMPACTING.
3636inline void TWindow::EvCompacting(uint /*compactRatio*/)
3637{
3639}
3640
3641//
3642inline bool TWindow::EvCopyData(HWND /*hwnd*/, const COPYDATASTRUCT& /*dataStruct*/)
3643{
3644 return DefaultProcessing();
3645}
3646
3647//
3648/// The default message handler for WM_DEADCHAR.
3649inline void TWindow::EvDeadChar(uint /*deadKey*/, uint /*repeatCount*/, uint /*flags*/)
3650{
3652}
3653
3654//
3655/// The default message handler for WM_DESTROYCLIPBOARD.
3657{
3659}
3660
3661//
3662/// The default message handler for WM_DEVMODECHANGE.
3663inline void TWindow::EvDevModeChange(LPCTSTR /*device*/)
3664{
3666}
3667
3668//
3669/// The default message handler for WM_DROPFILES.
3671{
3673}
3674
3675//
3676/// The default message handler for WM_DRAWCLIPBOARD.
3678{
3680}
3681
3682//
3683/// The default message handler for WM_ENABLE.
3684inline void TWindow::EvEnable(bool /*enabled*/)
3685{
3687}
3688
3689//
3690/// The default message handler for WM_FONTCHANGE.
3692{
3694}
3695
3696//
3697/// The default message handler for WM_GETDLGCODE.
3699{
3700 return static_cast<uint>(DefaultProcessing());
3701}
3702
3703//
3704/// The default message handler for WM_GETFONT.
3706{
3707 return reinterpret_cast<HFONT>(DefaultProcessing());
3708}
3709
3710//
3711/// The default message handler for WM_GETMINMAXINFO.
3713{
3715}
3716
3717#if defined(OWL5_COMPAT)
3718
3719//
3720/// The default message handler for WM_GETTEXT.
3721inline void TWindow::EvGetText(uint /*buffSize*/, LPTSTR /*buff*/)
3722{
3724}
3725
3726//
3727/// The default message handler for WM_GETTEXTLENGTH.
3729{
3730 return (uint)DefaultProcessing();
3731}
3732
3733#else
3734
3735//
3736/// The default message handler for WM_GETTEXT.
3737//
3738inline int TWindow::EvGetText(int /*buffSize*/, LPTSTR /*buff*/)
3739{
3740 return static_cast<int>(DefaultProcessing());
3741}
3742
3743//
3744/// The default message handler for WM_GETTEXTLENGTH.
3745//
3747{
3748 return static_cast<int>(DefaultProcessing());
3749}
3750
3751#endif
3752
3753//
3754/// The default message handler for WM_HSCROLLCLIPBOARD.
3755inline void TWindow::EvHScrollClipboard(HWND /*hWndCBViewer*/,
3756 uint /*scrollCode*/,
3757 uint /*pos*/)
3758{
3760}
3761
3762//
3763/// The default message handler for WM_INITMENU.
3764inline void TWindow::EvInitMenu(HMENU /*menu*/)
3765{
3767}
3768
3769//
3770/// The default message handler for WM_KEYDOWN.
3771inline void TWindow::EvKeyDown(uint /*key*/, uint /*repeatCount*/, uint /*flags*/)
3772{
3774}
3775
3776//
3777/// The default message handler for WM_KEYUP.
3778inline void TWindow::EvKeyUp(uint /*key*/, uint /*repeatCount*/, uint /*flags*/)
3779{
3781}
3782
3783//
3784/// The default message handler for WM_LBUTTONDBLCLK.
3785inline void TWindow::EvLButtonDblClk(uint /*modKeys*/, const TPoint&)
3786{
3788}
3789
3790//
3791/// The default message handler for WM_LBUTTONUP.
3792inline void TWindow::EvLButtonUp(uint /*modKeys*/, const TPoint&)
3793{
3795}
3796
3797//
3798/// The default message handler for WM_MBUTTONDBLCLK.
3799inline void TWindow::EvMButtonDblClk(uint /*modKeys*/, const TPoint&)
3800{
3802}
3803
3804//
3805/// The default message handler for WM_MBUTTONDOWN.
3806inline void TWindow::EvMButtonDown(uint /*modKeys*/, const TPoint&)
3807{
3809}
3810
3811//
3812/// The default message handler for WM_MBUTTONUP.
3813inline void TWindow::EvMButtonUp(uint /*modKeys*/, const TPoint&)
3814{
3816}
3817
3818//
3819/// The default message handler for WM_MENUCHAR.
3820inline int32 TWindow::EvMenuChar(uint /*nChar*/, uint /*menuType*/, HMENU /*hMenu*/)
3821{
3822 return static_cast<uint>(DefaultProcessing());
3823}
3824
3825//
3826/// The default message handler for WM_MENUSELECT.
3827inline void TWindow::EvMenuSelect(uint /*menuItemId*/, uint /*flags*/, HMENU /*hMenu*/)
3828{
3830}
3831
3832//
3833/// The default message handler for WM_MOUSEACTIVATE.
3834inline uint TWindow::EvMouseActivate(HWND /*hWndTopLevel*/, uint /*hitTestCode*/, TMsgId)
3835{
3836 return static_cast<uint>(DefaultProcessing());
3837}
3838
3839//
3840/// The default message handler for WM_MOUSEMOVE.
3841inline void TWindow::EvMouseMove(uint /*modKeys*/, const TPoint&)
3842{
3844}
3845
3846//
3847/// The default message handler for WM_NCACTIVATE.
3848inline bool TWindow::EvNCActivate(bool /*active*/)
3849{
3850 return static_cast<bool>(DefaultProcessing());
3851}
3852
3853//
3854/// The default message handler for WM_NCCALCSIZE.
3855inline uint TWindow::EvNCCalcSize(bool /*calcValidRects*/, NCCALCSIZE_PARAMS &)
3856{
3857 return static_cast<uint>(DefaultProcessing());
3858}
3859
3860//
3861/// The default message handler for WM_NCCREATE.
3863{
3864 return static_cast<bool>(DefaultProcessing());
3865}
3866
3867//
3868/// The default message handler for WM_NCHITTEST.
3870{
3871 return static_cast<uint>(DefaultProcessing());
3872}
3873
3874//
3875/// The default message handler for WM_NCLBUTTONDBLCLK.
3876inline void TWindow::EvNCLButtonDblClk(uint /*hitTest*/, const TPoint&)
3877{
3879}
3880
3881//
3882/// The default message handler for WM_NCLBUTTONDOWN.
3883inline void TWindow::EvNCLButtonDown(uint /*hitTest*/, const TPoint&)
3884{
3886}
3887
3888//
3889/// The default message handler for WM_NCLBUTTONUP.
3890inline void TWindow::EvNCLButtonUp(uint /*hitTest*/, const TPoint&)
3891{
3893}
3894
3895//
3896/// The default message handler for WM_NCMBUTTONDBLCLK.
3897inline void TWindow::EvNCMButtonDblClk(uint /*hitTest*/, const TPoint&)
3898{
3900}
3901
3902//
3903/// The default message handler for WM_NCMBUTTONDOWN.
3904inline void TWindow::EvNCMButtonDown(uint /*hitTest*/, const TPoint&)
3905{
3907}
3908
3909//
3910/// The default message handler for WM_NCMBUTTONUP.
3911inline void TWindow::EvNCMButtonUp(uint /*hitTest*/, const TPoint&)
3912{
3914}
3915
3916//
3917/// The default message handler for WM_NCMOUSEMOVE.
3918inline void TWindow::EvNCMouseMove(uint /*hitTest*/, const TPoint&)
3919{
3921}
3922
3923//
3924/// The default message handler for WM_NCPAINT.
3925inline void TWindow::EvNCPaint(HRGN /*region*/)
3926{
3928}
3929
3930//
3931/// The default message handler for WM_NCRBUTTONDBLCLK.
3932inline void TWindow::EvNCRButtonDblClk(uint /*hitTest*/, const TPoint&)
3933{
3935}
3936
3937//
3938/// The default message handler for WM_NCRBUTTONDOWN.
3939inline void TWindow::EvNCRButtonDown(uint /*hitTest*/, const TPoint&)
3940{
3942}
3943
3944//
3945/// The default message handler for WM_NCRBUTTONUP.
3946inline void TWindow::EvNCRButtonUp(uint /*hitTest*/, const TPoint&)
3947{
3949}
3950
3951//
3952/// The default message handler for WM_PAINTCLIPBOARD.
3954{
3956}
3957
3958//
3959/// The default message handler for WM_PALETTECHANGED.
3960inline void TWindow::EvPaletteChanged(HWND /*hWndPalChg*/)
3961{
3963}
3964
3965//
3966/// The default message handler for WM_PALETTEISCHANGING.
3967inline void TWindow::EvPaletteIsChanging(HWND /*hWndPalChg*/)
3968{
3970}
3971
3972//
3973/// The default message handler for WM_PARENTNOTIFY.
3975{
3977}
3978
3979//
3980/// Responds to a user-selected command from the System menu or when the user
3981/// selects the maximize or minimize box. Applications that modify the system menu
3982/// must process EvSysCommand messages. Any EvSysCommand messages not handled by the
3983/// application must be passed to DefaultProcessing. The parameter cmdType can be
3984/// one of the following system commands:
3985/// - \c \b SC_CLOSE Close the window.
3986/// - \c \b SC_HOTKEY Activate the specified window.
3987/// - \c \b SC_HSCROLL Scroll horizontally.
3988/// - \c \b SC_KEYMENU Retrieve a menu through a keystroke.
3989/// - \c \b SC_MAXIMIZE (or SC_ZOOM) Maximize the window.
3990/// - \c \b SC_MINIMIZE (or SC_ICON) Minimize the window.
3991/// - \c \b SC_MOUSEMENU Retrieve a menu through a mouse click.
3992/// - \c \b SC_NEXTWINDOW Move to the next window.
3993/// - \c \b SC_PREVWINDOW Move to the previous window.
3994/// - \c \b SC_SCREENSAVE Execute the specified screen saver.
3995/// - \c \b SC_SIZE Size the window
3996/// - \c \b SC_TASKLIST Activate the Windows Task Manager.
3997/// - \c \b SC_VSCROLL Scroll vertically.
3998///
3999/// In the following example, EvSysCommand either processes system messages or calls
4000/// DefaultProcessing:
4001/// \code
4002/// void MyWindow::EvSysCommand(uint cmdType, TPoint&)
4003/// {
4004/// switch (cmdType& 0xFFF0) {
4005/// case SC_MOUSEMENU:
4006/// case SC_KEYMENU:
4007/// break;
4008/// default:
4009/// DefaultProcessing();
4010/// }
4011/// }
4012/// \endcode
4013//
4014inline void TWindow::EvSysCommand(uint /*cmdType*/, const TPoint&)
4015{
4017}
4018
4019//
4020/// The default message handler for WM_QUERYDRAGICON.
4022{
4023 return reinterpret_cast<HICON>(DefaultProcessing());
4024}
4025
4026//
4027/// The default message handler for WM_QUERYNEWPALETTE.
4029{
4030 return static_cast<bool>(DefaultProcessing());
4031}
4032
4033//
4034/// The default message handler for WM_QUERYOPEN.
4036{
4037 return static_cast<bool>(DefaultProcessing());
4038}
4039
4040//
4041/// The default message handler for WM_QUEUESYNC.
4043{
4045}
4046
4047//
4048/// The default message handler for WM_RENDERALLFORMATS.
4050{
4052}
4053
4054//
4055/// The default message handler for WM_RENDERFORMAT.
4056inline void TWindow::EvRenderFormat(uint /*dataFormat*/)
4057{
4059}
4060
4061//
4062/// The default message handler for WM_RBUTTONDBLCLK.
4063inline void TWindow::EvRButtonDblClk(uint /*modKeys*/, const TPoint&)
4064{
4066}
4067
4068//
4069/// The default message handler for WM_RBUTTONDOWN.
4070inline void TWindow::EvRButtonDown(uint /*modKeys*/, const TPoint&)
4071{
4073}
4074
4075//
4076/// The default message handler for WM_RBUTTONUP.
4077inline void TWindow::EvRButtonUp(uint /*modKeys*/, const TPoint&)
4078{
4080}
4081
4082//
4083/// The default message handler for WM_SETFOCUS.
4084inline void TWindow::EvSetFocus(HWND /*hWndLostFocus*/)
4085{
4087}
4088
4089//
4090/// The default message handler for WM_SETFONT.
4091/// Manages the lifetime of the private font.
4092/// \sa SetWindowFont
4093//
4094inline void TWindow::EvSetFont(HFONT f, bool)
4095{
4097
4098 // If the font handle passed does not match the handle managed by our private TFont, then
4099 // the latter is no longer in use; so delete it. Note that this is just an optimization. The
4100 // font would eventually be deleted anyway, since it is managed by a smart pointer.
4101 //
4102 if (Font && f != Font->GetHandle())
4103 Font.reset();
4104}
4105
4106//
4107/// The default message handler for WM_SETREDRAW.
4108inline void TWindow::EvSetRedraw(bool)
4109{
4111}
4112
4113//
4114/// The default message handler for WM_SETTEXT.
4116{
4118}
4119
4120//
4121/// The default message handler for WM_SHOWWINDOW.
4122inline void TWindow::EvShowWindow(bool /*show*/, uint /*status*/)
4123{
4125}
4126
4127//
4128/// The default message handler for WM_SIZECLIPBOARD.
4129inline void TWindow::EvSizeClipboard(HWND /*hWndViewer*/, const TRect&)
4130{
4132}
4133
4134//
4135/// The default message handler for WM_SPOOLERSTATUS.
4136inline void TWindow::EvSpoolerStatus(uint /*jobStatus*/, uint /*jobsLeft*/)
4137{
4139}
4140
4141//
4142/// The default message handler for WM_SYSCHAR.
4143inline void TWindow::EvSysChar(uint /*key*/, uint /*repeatCount*/, uint /*flags*/)
4144{
4146}
4147
4148//
4149/// The default message handler for WM_SYSDEADCHAR.
4150inline void TWindow::EvSysDeadChar(uint /*key*/, uint /*repeatCount*/, uint /*flags*/)
4151{
4153}
4154
4155//
4156/// The default message handler for WM_SYSKEYDOWN.
4157inline void TWindow::EvSysKeyDown(uint /*key*/, uint /*repeatCount*/, uint /*flags*/)
4158{
4160}
4161
4162//
4163/// The default message handler for WM_SYSKEYUP.
4164inline void TWindow::EvSysKeyUp(uint /*key*/, uint /*repeatCount*/, uint /*flags*/)
4165{
4167}
4168
4169//
4170/// The default message handler for WM_TIMECHANGE.
4172{
4174}
4175
4176//
4177/// The default message handler for WM_TIMER.
4178inline void TWindow::EvTimer(uint /*timerId*/)
4179{
4181}
4182
4183#if defined(OWL5_COMPAT)
4184
4185//
4186/// The default message handler for WM_WININICHANGE.
4187inline void TWindow::EvWinIniChange(LPCTSTR /*section*/)
4188{
4190}
4191
4192#endif
4193
4194//
4195/// The default message handler for WM_VSCROLLCLIPBOARD.
4196inline void TWindow::EvVScrollClipboard(HWND /*hWndCBViewer*/,
4197 uint /*scrollCode*/,
4198 uint /*pos*/)
4199{
4201}
4202
4203//
4204/// The default message handler for WM_WINDOWPOSCHANGED.
4205inline void TWindow::EvWindowPosChanged(const WINDOWPOS& /*windowPos*/)
4206{
4208}
4209
4210//
4211/// The default message handler for WM_WINDOWPOSCHANGING.
4212inline bool TWindow::EvWindowPosChanging(WINDOWPOS & /*windowPos*/)
4213{
4214 return DefaultProcessing();
4215}
4216
4217} // OWL namespace
4218
4220
4221#endif // OWL_WINDOW_H
Definition of class TApplication.
#define PRECONDITION(condition)
Definition checks.h:227
Derived from TModule and TMsgThread and virtually derived from TEventHandler, TApplication acts as an...
Definition applicat.h:141
TCurrentEvent & GetCurrentEvent()
Return the current event from the message queue.
Definition applicat.h:652
Class wrapper for management of color values.
Definition color.h:245
static const TColor Transparent
a non-painting color
Definition color.h:319
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
uint GetId() const
Retrieves the id of the command.
Definition window.h:1695
uint Flags
TCommandStatus flags Is TCommandStatus::WasHandled if the command enabler has been handled.
Definition window.h:275
virtual void SetCheck(int check)=0
Changes the check state of the command sender to either unchecked, checked, or indeterminate.
bool GetHandled()
Return true if the command enabler has been handled.
Definition window.h:1711
bool IsReceiver(HWND hReceiver)
Returns true if receiver is the same as the message responder originally set up in the constructor.
Definition window.h:1720
virtual void SetText(LPCTSTR text)=0
Changes the text associated with a command sender; for example, text associated with a menu item or t...
void SetReceiver(HWND hReceiver)
Sets the receiver for the enabler.
Definition window.h:1736
TCommandState
Enumeration describing the 3-states or availability of a command.
Definition window.h:225
@ Unchecked
Command is not enabled.
Definition window.h:226
@ Checked
Command is enabled.
Definition window.h:227
void SetHandled()
Marks that the enabler has been handled.
Definition window.h:1744
bool SendsCommand() const
Returns true if this command enabler sends a command message.
Definition window.h:1703
void SetText(const tstring &s)
Definition window.h:220
void SetCheck(bool isChecked)
Overload; allows you to pass a bool safely.
Definition window.h:240
HWND GetReceiver() const
Returns the handle of the window that this enabler was destined for.
Definition window.h:1728
TCommandStatus
Enumeration describing whether the associated command has been enabled or disabled,...
Definition window.h:267
@ WasHandled
Command was enabled or disabled.
Definition window.h:268
@ NonSender
Command does not generate WM_COMMAND messages.
Definition window.h:269
Class will be base class for owner draw items: ListBox,ComboBox,Menu atc.
Definition window.h:178
virtual ~TDrawItemBase()
Definition window.h:184
virtual void Measure(MEASUREITEMSTRUCT &)
Definition window.h:195
virtual void Draw(DRAWITEMSTRUCT &)
Definition window.h:194
virtual int Compare(COMPAREITEMSTRUCT &)
Definition window.h:196
const char * Type_id
Definition window.h:191
TDropInfo is a simple class that supports file-name drag-and-drop operations using the WM_DROPFILES m...
Definition wsyscls.h:257
TEventHandler is a base class from which you can derive classes that handle messages.
Definition eventhan.h:162
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TPopupMenu creates an empty pop-up menu to add to an existing window or pop-up menu.
Definition menu.h:189
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
TRegion, derived from TGdiObject, represents GDI abstract shapes or regions.
Definition gdiobjec.h:581
Class TScroller implements the actual scroller object.
Definition scroller.h:46
The tagSIZE struct is defined as.
Definition geometry.h:234
Classes that inherit from TStreamableBase are known as streamable classes (their objects can be writt...
Definition objstrm.h:108
TTooltip encapsulates a tooltip window - i.e.
Definition tooltip.h:175
Utility class template used as an iterator type template for TChildrenRangeTemplate.
Definition window.h:450
std::forward_iterator_tag iterator_category
Definition window.h:452
TChildrenIteratorTemplate(reference parent)
Definition window.h:459
Utility class template used as a return type for TWindow::GetChildren.
Definition window.h:505
TChildrenRangeTemplate(reference parent)
Definition window.h:518
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TPoint MapWindowPoints(const TWindow &wndTo, const TPoint &p) const
Overload for TWindow and TPoint See MapWindowPoints(HWND, const TPoint&).
Definition window.h:933
void EvShowWindow(bool show, uint status)
The default message handler for WM_SHOWWINDOW.
Definition window.h:4122
void CreateCaret(HBITMAP hBitmap)
Creates a new caret for the system.
Definition window.h:3350
int EvVKeyToItem(uint key, HWND hWndListBox, int caretIndex)
The default message handler for WM_VKEYTOITEM.
Definition window.h:3629
HWND GetParentH() const
Return the handle of the parent.
Definition window.h:1999
HWND SetFocus()
Sets the keyboard focus to current window and activates the window that receives the focus by sending...
Definition window.h:2151
void EvEnable(bool enabled)
The default message handler for WM_ENABLE.
Definition window.h:3684
uint16 SetWindowWord(int index, uint16 newWord)
Changes information about the window.
Definition window.h:2452
static TPoint GetCursorPos()
Definition window.h:1212
static HWND GetActiveWindow()
Retrieves the handle of the active window.
Definition window.h:2702
static void AdjustWindowRectEx(TRect &rect, uint32 style, bool menu, uint32 exStyle)
Calculates the size of a window rectangle that has an extended style.
Definition window.h:2296
void ShowScrollBar(int bar, bool show=true)
Displays or hides the scroll bar.
Definition window.h:3043
void SetCaption(const tstring &title)
Definition window.h:695
HMENU LoadMenu(TResId id) const
Definition window.h:611
HWND SetCapture()
Sets the mouse capture to the current window.
Definition window.h:2121
static uint GetCaretBlinkTime()
Retrieves the caret blink rate in milliseconds.
Definition window.h:3386
TRect MapScreenToClient(const TRect &r) const
Functional-style overload for TRect; converts the given rectangle coordinates and returns the result.
Definition window.h:891
HWND ChildWindowFromPoint(const TPoint &point) const
Determines which of the child windows contains the point specified in TPoint.
Definition window.h:2238
void EvNCLButtonDown(uint codeHitTest, const TPoint &)
The default message handler for WM_NCLBUTTONDOWN.
Definition window.h:3883
static HWND GetDesktopWindow()
Returns a handle to the desktop window.
Definition window.h:2723
void SetNext(TWindow *next)
Sets the next window in the sibling list.
Definition window.h:1762
void EvLButtonUp(uint modKeys, const TPoint &point)
The default message handler for WM_LBUTTONUP.
Definition window.h:3792
void MapWindowPoints(HWND hWndTo, TPoint(&p)[Count]) const
Overload for array See MapWindowPoints(HWND, TPoint*, int).
Definition window.h:911
tstring LoadString(uint id) const
Definition window.h:608
uint IsDlgButtonChecked(int buttonId) const
Indicates if the child button specified in the integer parameter, buttonId, is checked,...
Definition window.h:3161
void SetDlgItemFont(int childId, HFONT f, bool redraw=false) const
Definition window.h:1169
static HWND GetCapture()
Returns the handle of the window that has captured the mouse.
Definition window.h:2112
void MapScreenToClient(TPoint(&p)[Count]) const
Overload for array See MapScreenToClient(TPoint*, int).
Definition window.h:884
bool KillTimer(UINT_PTR timerId)
Gets rid of the timer and removes any WM_TIMER messages from the message queue.
Definition window.h:3325
bool SetProp(const tstring &str, HANDLE data) const
Definition window.h:1029
bool EvWindowPosChanging(WINDOWPOS &)
The default message handler for WM_WINDOWPOSCHANGING.
Definition window.h:4212
auto GetChildren() const
Const overload of TWindow::GetChildren.
Definition window.h:555
auto SetWindowRgn(const TRegion &, bool repaint=false) -> bool=delete
TCurrentEvent & GetCurrentEvent()
Returns the current event to be processed in the message queue.
Definition window.h:2047
bool SetMenu(HMENU hMenu)
Sets the specified window's menu to the menu indicated by hMenu.
Definition window.h:3278
void SetDlgItemText(int childId, LPCTSTR text) const
Sets the title or text of a control in a dialog box.
Definition window.h:3146
void EvKeyDown(uint key, uint repeatCount, uint flags)
The default message handler for WM_KEYDOWN.
Definition window.h:3771
TRect MapWindowPoints(HWND hWndTo, const TRect &r) const
Functional-style overload for TRect; converts the given rectangle coordinates and returns the result.
Definition window.h:940
void EvQueueSync()
The default message handler for WM_QUEUESYNC.
Definition window.h:4042
HANDLE GetProp(const tstring &str) const
Definition window.h:1025
TApplication * GetApplication() const
Gets a pointer to the TApplication object associated with this.
Definition window.h:1855
static void SetCaretBlinkTime(uint16 milliSecs)
Sets the caret blink rate in milliseconds.
Definition window.h:3420
HACCEL LoadAccelerators(TResId id) const
Definition window.h:610
void Init(TWindow *parent, const tstring &title, TModule *module)
Definition window.h:1474
void EvMButtonDown(uint modKeys, const TPoint &point)
The default message handler for WM_MBUTTONDOWN.
Definition window.h:3806
static void DestroyCaret()
DestroyCaret first checks the ownership of the caret.
Definition window.h:3376
void CheckRadioButton(int firstButtonId, int lastButtonId, int checkButtonId)
Checks the radio button specified by checkButtonId and removes the check mark from the other radio bu...
Definition window.h:3232
HANDLE GetProp(uint16 atom) const
Returns a handle to the property list of the specified window.
Definition window.h:2495
void SetBkgndColor(TColor color, bool shouldUpdate=true)
Sets the background color for the window.
Definition window.h:1925
void EvPaletteIsChanging(HWND hWndPalChg)
The default message handler for WM_PALETTEISCHANGING.
Definition window.h:3967
static TPoint GetCaretPos()
Definition window.h:1204
void EvRButtonDown(uint modKeys, const TPoint &point)
The default message handler for WM_RBUTTONDOWN.
Definition window.h:4070
void EvSysKeyDown(uint key, uint repeatCount, uint flags)
The default message handler for WM_SYSKEYDOWN.
Definition window.h:4157
bool EnableScrollBar(uint sbFlags=SB_BOTH, uint arrowFlags=ESB_ENABLE_BOTH)
Disables or enables one or both of the scroll bar arrows on the scroll bars associated with this wind...
Definition window.h:3029
TPoint MapWindowPoints(HWND hWndTo, const TPoint &p) const
Functional-style overload for TPoint; converts the given point coordinates and returns the result.
Definition window.h:926
tstring GetWindowText() const
String-aware overload.
Definition window.cpp:4415
TRect GetDlgItemRect(int childId) const
Returns the window rectangle of the given child, specified in this window's client coordinates.
Definition window.h:1178
virtual bool EnableWindow(bool enable)
Allows the given window to receive input from the keyboard of mouse.
Definition window.h:2172
static HWND WindowFromPoint(const TPoint &point)
Returns the handle of the window in which the specified point (point) lies.
Definition window.h:2227
HICON EvGetIcon(bool isBigIcon)
Definition window.h:1459
uint EvMouseActivate(HWND hTopLevel, uint hitCode, TMsgId)
The default message handler for WM_MOUSEACTIVATE.
Definition window.h:3834
TWindow * GetLastChild()
Returns a pointer to the last child window in the interface object's child list.
Definition window.h:1776
auto GetLastChild() const -> const TWindow *
Definition window.h:564
HTASK GetWindowTask() const
Returns a handle to the task that created the specified window.
Definition window.h:3557
void EvNCRButtonDown(uint codeHitTest, const TPoint &)
The default message handler for WM_NCRBUTTONDOWN.
Definition window.h:3939
void DrawMenuBar()
DrawMenuBar redraws the menu bar.
Definition window.h:3313
void EvAskCBFormatName(uint bufLen, TCHAR *buffer)
The default message handler for WM_ASKCBFORMATNAME.
Definition window.h:3594
void EvRButtonDblClk(uint modKeys, const TPoint &point)
The default message handler for WM_RBUTTONDBLCLK.
Definition window.h:4063
bool SetWindowPos(HWND hWndInsertAfter, const TRect &rect, uint flags)
Changes the size of the window pointed to by rect.
Definition window.h:2809
TRect GetChildRect(HWND hWnd) const
Returns the window rectangle of the given window, specified in this window's client coordinates.
Definition window.h:988
void EvSysChar(uint key, uint repeatCount, uint flags)
The default message handler for WM_SYSCHAR.
Definition window.h:4143
void EvSpoolerStatus(uint jobStatus, uint jobsLeft)
The default message handler for WM_SPOOLERSTATUS.
Definition window.h:4136
HWND GetWindow(uint cmd) const
Returns the handle of the window that has the indicated relationship to this window.
Definition window.h:2784
auto GetChildren()
Returns a TWindow::TChildrenRange that can be iterated by standard means.
Definition window.h:550
void BringWindowToTop()
Brings a pop-up or child window to the top of the stack of overlapping windows and activates it.
Definition window.h:2690
void MapScreenToClient(TPoint *p, int count) const
Maps the given points, specified in screen coordinates, to client coordinates in this window.
Definition window.h:876
HWND GetDlgItem(int childId) const
Retrieves the handle of a control specified by childId.
Definition window.h:3108
void EvRenderFormat(uint dataFormat)
The default message handler for WM_RENDERFORMAT.
Definition window.h:4056
bool LockWindowUpdate(bool lock=true)
Prevents or enables window drawing for one window at a time.
Definition window.h:2945
void EvSysKeyUp(uint key, uint repeatCount, uint flags)
The default message handler for WM_SYSKEYUP.
Definition window.h:4164
auto Next() const -> const TWindow *
Definition window.h:558
HANDLE RemoveProp(uint16 atom) const
Removes the property specified by atom from the application's property list.
Definition window.h:2508
bool GetUpdateRect(TRect &rect, bool erase=true) const
Retrieves the screen coordinates of the rectangle that encloses the updated region of the specified w...
Definition window.h:2927
void EvActivateApp(bool active, DWORD threadId)
The default message handler for WM_ACTIVATEAPP.
Definition window.h:3587
void SetDlgItemText(int childId, uint resourceStringId) const
Definition window.h:1157
int GetId() const
Returns Attr.Id, the ID used to find the window in a specified parent's child list.
Definition window.h:1881
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
Definition window.h:2013
auto GetBkgndColor() const -> TColor
Returns the overriding background color set for the window.
Definition window.h:1913
bool UnregisterHotKey(int idHotKey)
Unregisters a hotkey ID with the current application.
Definition window.h:3509
auto GetWindowRgn(TRegion &) const -> int
Obtains a copy of the region of the window within which the system permits drawing.
Definition window.h:2998
void EvInitMenu(HMENU hMenu)
The default message handler for WM_INITMENU.
Definition window.h:3764
void EvPaintClipboard(HWND hWnd, const PAINTSTRUCT &)
The default message handler for WM_PAINTCLIPBOARD.
Definition window.h:3953
TWindow * GetWindowPtr(HWND hWnd) const
Calls TApplication:GetWindowPtr on the application associated with this window.
Definition window.h:3567
bool IsWindowEnabled() const
Returns true if the window is enabled.
Definition window.h:2161
HBITMAP LoadBitmap(TResId id) const
Definition window.h:609
void SetWindowFont(HFONT font, bool redraw=true)
Sets the font that a control uses to draw text.
Definition window.h:3476
LONG_PTR GetWindowLongPtr(int index) const
Retrieves information about the window depending on the value stored in index.
Definition window.h:2418
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
Definition window.h:2257
bool SetDocTitle(const tstring &docname, int index)
Definition window.h:693
virtual TTooltip * GetTooltip() const
Definition window.h:1821
void DisableAutoCreate()
Disables the feature that allows an associated child window interface element to be created and displ...
Definition window.h:1814
bool RedrawWindow(TRect *update, HRGN hUpdateRgn, uint redrawFlags=RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE)
Redraws the rectangle specified by update and the region specified by hUpdateRgn.
Definition window.h:2986
void SetHandle(THandle)
Sets the window handle in a derived class.
Definition window.h:2034
long GetClassLong(int index) const
Retrieves the 32-bit value containing information about the window class.
Definition window.h:2326
void SetTransferBuffer(void *transferBuffer, uint size)
Sets TransferBuffer and TransferBufferSize.
Definition window.h:1971
static void ShutDownWindow(TWindow *win, int retVal=0)
This version of ShutDownWindow unconditionally shuts down a given window, calls Destroy on the interf...
Definition window.cpp:3397
void ValidateRect(const TRect &rect)
Validates a portion of the client area indicated by rect.
Definition window.h:2875
int EnumProps(PROPENUMPROC proc)
Enumerates all the items in the property list of the current window and passes them one by one to the...
Definition window.h:2481
void Validate()
Calls the function ValidateRect to validate (that is, remove from the area to be updated) the entire ...
Definition window.h:2864
HICON EvQueryDragIcon()
The default message handler for WM_QUERYDRAGICON.
Definition window.h:4021
virtual void InvalidateRect(const TRect &rect, bool erase=true)
Invalidates a specified client area.
Definition window.h:2834
void EvNextDlgCtl(TParam1 handleOrDirectionFlag, bool isHandle)
Definition window.h:1337
TPoint MapClientToScreen(const TPoint &p) const
Function-style version of ClientToScreen.
Definition window.h:838
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
Definition window.h:2388
void EvDestroyClipboard()
The default message handler for WM_DESTROYCLIPBOARD.
Definition window.h:3656
void SetFlag(uint mask)
Sets the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
Definition window.h:1783
LONG_PTR SetWindowLongPtr(int index, LONG_PTR newLong)
Changes information about the window. For a list of constants, see GetWindowLongPtr()
Definition window.h:2428
auto SetWindowRgn(HRGN, bool repaint=false) -> bool
Sets the area within the window where the system permits drawing.
Definition window.h:3011
int32 EvMenuChar(uint nChar, uint menuType, HMENU hMenu)
The default message handler for WM_MENUCHAR.
Definition window.h:3820
void EvRButtonUp(uint modKeys, const TPoint &point)
The default message handler for WM_RBUTTONUP.
Definition window.h:4077
bool HiliteMenuItem(HMENU hMenu, uint idItem, uint hilite)
Either highlights or removes highlighting from a top-level item in the menu.
Definition window.h:3301
void SetTextColor(TColor color, bool shouldUpdate=true)
Sets the text color for the window.
Definition window.h:1951
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
static void SetCaretPos(int x, int y)
Sets the position of the caret in the coordinates of the client window.
Definition window.h:3431
void ShowCaret()
Displays the caret in the specified shape in the active window at the current position.
Definition window.h:3453
void EvTimeChange()
The default message handler for WM_TIMECHANGE.
Definition window.h:4171
void MapClientToScreen(TPoint(&p)[Count]) const
Overload for array See MapClientToScreen(TPoint*, int).
Definition window.h:852
static void ReleaseCapture()
Releases the mouse capture from this window.
Definition window.h:2130
TModule * GetModule() const
Returns a pointer to the module object.
Definition window.h:1841
static TPoint GetMessagePos()
Definition window.h:1213
TWindowAttr & GetWindowAttr()
Returns the TWindowAttr structure, which contains the window's creation attributes.
Definition window.h:1886
void MapWindowPoints(HWND hWndTo, TPoint *pts, int count) const
Maps a set of points in one window to a relative set of points in another window.
Definition window.h:2206
uint16 GetWindowWord(int index) const
Retrieves information about this window depending on the value of index.
Definition window.h:2442
HWND GetTopWindow() const
Returns a handle to the top window currently owned by this parent window.
Definition window.h:2796
void ResetWindowRgn(bool repaint=false)
Calls SetWindowRgn(nullptr, repaint).
Definition window.h:1107
bool EvQueryNewPalette()
The default message handler for WM_QUERYNEWPALETTE.
Definition window.h:4028
void InvalidateRgn(HRGN hRgn, bool erase=true)
Invalidates a client area within a region specified by the hRgn parameter when the application receiv...
Definition window.h:2852
void ScrollWindowEx(int dx, int dy, const TRect *scroll=0, const TRect *clip=0, HRGN hUpdateRgn=nullptr, TRect *update=0, uint flags=0)
Scrolls a window in the vertical (dx) and horizontal (dy) directions.
Definition window.h:3079
WNDPROC GetWindowProc() const
Definition window.h:2459
uint EvGetDlgCode(const MSG *msg)
The default message handler for WM_GETDLGCODE.
Definition window.h:3698
TRect MapWindowPoints(const TWindow &wndTo, const TRect &r) const
Overload for TWindow and TRect See MapWindowPoints(HWND, const TRect&).
Definition window.h:947
void EnableTransfer()
Enables the transfer mechanism, which allows state data to be transferred between the window and a tr...
Definition window.h:1828
bool EvCopyData(HWND hwnd, const COPYDATASTRUCT &)
Definition window.h:3642
HICON EvSetIcon(bool isBigIcon, HICON)
Definition window.h:1460
void SetRedraw(bool redraw)
Sends a WM_SETREDRAW message to a window so that changes can be redrawn (redraw = true) or to prevent...
Definition window.h:2182
void MapWindowPoints(const TWindow &wndTo, TPoint(&p)[Count]) const
Overload for TWindow and array See MapWindowPoints(HWND, TPoint*, int).
Definition window.h:919
TRect MapClientRect(const TWindow &wndTo) const
Overload for TWindow See MapClientRect(HWND).
Definition window.h:973
int EvGetText(int bufSize, TCHAR *buf)
The default message handler for WM_GETTEXT.
Definition window.h:3738
bool IsIconic() const
Returns true if window is iconic or minimized.
Definition window.h:2628
bool IsWindow() const
Returns true if an HWND is being used.
Definition window.h:2040
TPopupMenu * GetContextMenu() const
Returns the associated popup menu used by the window.
Definition window.h:3266
void EvFontChange()
The default message handler for WM_FONTCHANGE.
Definition window.h:3691
void ClientToScreen(TPoint &point) const
Converts the client coordinates specified in point to screen coordinates for the new window.
Definition window.h:2248
void ShowOwnedPopups(bool show)
Shows or hides all owned pop-up windows according to the value of show.
Definition window.h:2593
void EvActivate(uint active, bool minimized, HWND hWndOther)
Default message handler for WM_ACTIVATE.
Definition window.h:3578
void EvNCLButtonDblClk(uint codeHitTest, const TPoint &)
The default message handler for WM_NCLBUTTONDBLCLK.
Definition window.h:3876
void EvHotKey(int idHotKey, uint modifiers, uint vk)
Definition window.h:1331
HWND GetLastActivePopup() const
Returns the last active pop-up window in the list.
Definition window.h:2749
TRect MapClientToScreen(const TRect &r) const
Functional-style overload for TRect; converts the given rectangle coordinates and returns the result.
Definition window.h:859
bool IsChild(HWND hWnd) const
Returns true if the window is a child window or a descendant window of this window.
Definition window.h:3176
HWND SetActiveWindow()
Activates a top-level window.
Definition window.h:2712
void EvParentNotify(const TParentNotify &)
The default message handler for WM_PARENTNOTIFY.
Definition window.h:3974
TPoint MapScreenToClient(const TPoint &p) const
Functional-style version of ScreenToClient.
Definition window.h:870
HMENU GetMenu() const
Returns the handle to the menu of the indicated window.
Definition window.h:3244
void EvSizeClipboard(HWND hWndViewer, const TRect &)
The default message handler for WM_SIZECLIPBOARD.
Definition window.h:4129
bool EvNCCreate(CREATESTRUCT &)
The default message handler for WM_NCCREATE.
Definition window.h:3862
auto Previous() const -> const TWindow *
Definition window.h:560
void * GetTransferBuffer() const
Definition window.h:785
void EvNCPaint(HRGN)
The default message handler for WM_NCPAINT.
Definition window.h:3925
bool MoveWindow(int x, int y, int w, int h, bool repaint=false)
Repositions the specified window.
Definition window.h:2571
bool SetProp(uint16 atom, HANDLE data) const
Adds an item to the property list of the specified window.
Definition window.h:2519
void EvWindowPosChanged(const WINDOWPOS &windowPos)
The default message handler for WM_WINDOWPOSCHANGED.
Definition window.h:4205
TResult SendDlgItemMessage(int childId, TMsgId, TParam1=0, TParam2=0)
Sends a message (msg) to the control specified in childId.
Definition window.h:2092
void EvRenderAllFormats()
The default message handler for WM_RENDERALLFORMATS.
Definition window.h:4049
void DisableTransfer()
Disables (for the interface object) the transfer mechanism, which allows state data to be transferred...
Definition window.h:1835
uint16 SetClassWord(int index, uint16 newWord)
Sets the word value at the specified offset (index).
Definition window.h:2365
HCURSOR LoadCursor(TResId id) const
Definition window.h:612
LPCTSTR GetCaption() const
Returns the Title member of TWindow.
Definition window.h:1900
void EvDevModeChange(LPCTSTR devName)
The default message handler for WM_DEVMODECHANGE.
Definition window.h:3663
bool EvNCActivate(bool active)
The default message handler for WM_NCACTIVATE.
Definition window.h:3848
uint EvNCHitTest(const TPoint &)
The default message handler for WM_NCHITTEST.
Definition window.h:3869
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
Definition window.cpp:852
TRect GetClientRect() const
Gets the coordinates of the window's client area (the area in a window you can use for drawing).
Definition window.h:2217
auto GetFirstChild() const -> const TWindow *
Definition window.h:562
void EvHScrollClipboard(HWND hCBViewer, uint scrollCode, uint pos)
The default message handler for WM_HSCROLLCLIPBOARD.
Definition window.h:3755
void ScrollWindow(int dx, int dy, const TRect *scroll=nullptr, const TRect *clip=nullptr)
Scrolls a window in the vertical (dx) and horizontal (dy) directions.
Definition window.h:3057
UINT_PTR SetTimer(UINT_PTR timerId, uint timeout, TIMERPROC proc=0)
Creates a timer object associated with this window.
Definition window.h:3339
int GetDlgCtrlID() const
Returns the ID of the control.
Definition window.h:3097
void EvVScrollClipboard(HWND hCBViewer, uint scrollCode, uint pos)
The default message handler for WM_VSCROLLCLIPBOARD.
Definition window.h:4196
long SetClassLong(int index, long newLong)
Sets the long value at the specified offset (index).
Definition window.h:2335
void SetWindowText(LPCTSTR str)
Sets the window's text to the given string (by copying).
Definition window.h:2669
void EvSysCommand(uint cmdType, const TPoint &point)
Responds to a user-selected command from the System menu or when the user selects the maximize or min...
Definition window.h:4014
void UpdateWindow()
Updates the client area of the specified window by immediately sending a WM_PAINT message.
Definition window.h:2901
std::string LoadHtml(TResId id) const
Definition window.h:614
bool WinHelp(LPCTSTR helpFile, uint command, ULONG_PTR data) const
Invokes a specified help system.
Definition window.h:3540
void SetDlgItemText(int childId, const tstring &text) const
Definition window.h:1156
void EvMButtonDblClk(uint modKeys, const TPoint &point)
The default message handler for WM_MBUTTONDBLCLK.
Definition window.h:3799
void HideCaret()
Removes the caret from the specified display screen.
Definition window.h:3409
auto GetTextColor() const -> TColor
Returns the overriding text color set for the window.
Definition window.h:1939
void SetModule(TModule *module)
Sets the default module for this window.
Definition window.h:1847
void EvSetFocus(HWND hWndLostFocus)
The default message handler for WM_SETFOCUS.
Definition window.h:4084
void ClearFlag(uint mask)
Clears the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
Definition window.h:1790
void EvDropFiles(TDropInfo dropInfo)
The default message handler for WM_DROPFILES.
Definition window.h:3670
bool IsZoomed() const
Returns true if window is zoomed or maximized.
Definition window.h:2617
HMENU GetSystemMenu(bool revert=false) const
Returns a handle to the system menu so that an application can access the system menu.
Definition window.h:3256
void SendNotification(int id, int notifyCode, HWND hCtl, TMsgId=WM_COMMAND)
Repacks a command message (msg) so that a child window (hCtl) can send a message to its parent regard...
Definition window.h:2055
bool WinHelp(const tstring &helpFile, uint command, ULONG_PTR data) const
Definition window.h:1229
HWND GetNextWindow(uint dirFlag) const
Finds the handle associated with either the next or previous window in the window manager's list.
Definition window.h:2738
void EvNCMouseMove(uint codeHitTest, const TPoint &)
The default message handler for WM_NCMOUSEMOVE.
Definition window.h:3918
bool PostMessage(TMsgId, TParam1=0, TParam2=0)
Posts a message (msg) to the window in the application's message queue.
Definition window.h:2103
void EvNCRButtonDblClk(uint codeHitTest, const TPoint &)
The default message handler for WM_NCRBUTTONDBLCLK.
Definition window.h:3932
void ScreenToClient(TPoint &point) const
Uses the screen coordinates specified in point to calculate the client window's coordinates and then ...
Definition window.h:2192
TWindow * Next()
Returns a pointer to the next sibling window in the window's sibling list.
Definition window.h:1755
bool IsWindowVisible() const
Returns true if the window is visible.
Definition window.h:2605
int GetDlgItemText(int childId, TCHAR *text, int maxValue) const
Retrieves the text of a control specified by childId.
Definition window.h:3133
void CheckDlgButton(int buttonId, uint check)
Places a check mark in (or removes a check mark from) the button specified in buttonId.
Definition window.h:3219
HANDLE RemoveProp(const tstring &str) const
Definition window.h:1027
static void AdjustWindowRect(TRect &rect, uint32 style, bool menu)
Calculates the size of the window rectangle according to the indicated client-rectangle size.
Definition window.h:2271
void MapClientToScreen(TPoint *p, int count) const
Maps the given points, specified in client coordinates in this window, to screen coordinates.
Definition window.h:844
void EvMouseMove(uint modKeys, const TPoint &point)
The default message handler for WM_MOUSEMOVE.
Definition window.h:3841
HFONT GetWindowFont()
Gets the font the control uses to draw text.
Definition window.h:3489
int MessageBox(LPCTSTR text, LPCTSTR caption=0, uint flags=MB_OK) const
Creates and displays a message box that contains a message (text), a title (caption),...
Definition window.cpp:4284
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
long SetWindowLong(int index, long newLong)
Changes information about the window.
Definition window.h:2400
void EvTimer(uint timerId)
The default message handler for WM_TIMER.
Definition window.h:4178
WNDPROC SetWindowProc(WNDPROC wndProc)
Definition window.h:2467
void EvChangeCBChain(HWND hWndRemoved, HWND hWndNext)
The default message handler for WM_CHANGECBCHAIN.
Definition window.h:3608
void EvChar(uint key, uint repeatCount, uint flags)
The default message handler for WM_CHAR.
Definition window.h:3615
void EvKeyUp(uint key, uint repeatCount, uint flags)
The default message handler for WM_KEYUP.
Definition window.h:3778
void MapWindowPoints(const TWindow &wndTo, TPoint *p, int n) const
Overload for TWindow See MapWindowPoints(HWND, TPoint*, int).
Definition window.h:903
void EvLButtonDblClk(uint modKeys, const TPoint &point)
The default message handler for WM_LBUTTONDBLCLK.
Definition window.h:3785
uint GetTransferBufferSize() const
Definition window.h:786
bool IsFlagSet(uint mask)
Returns the state of the bit flag in Attr.Flags whose mask is supplied.
Definition window.h:1797
static HWND GetFocus()
Gets a handle to the window that has the focus.
Definition window.h:2139
int EvGetTextLength()
The default message handler for WM_GETTEXTLENGTH.
Definition window.h:3746
uint16 GetClassWord(int index) const
Gets a 16-bit value containing information about the class or style of the window.
Definition window.h:2351
void EvCompacting(uint compactRatio)
The default message handler for WM_COMPACTING.
Definition window.h:3636
void EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu)
The default message handler for WM_MENUSELECT.
Definition window.h:3827
void EvNCMButtonDown(uint codeHitTest, const TPoint &)
The default message handler for WM_NCMBUTTONDOWN.
Definition window.h:3904
TRect MapWindowRect(const TWindow &wndTo) const
Overload for TWindow See MapWindowRect(HWND).
Definition window.h:960
bool FlashWindow(bool invert)
Changes the window from active to inactive or vice versa.
Definition window.h:2914
void EvCancelMode()
The default message handler for WM_CANCELMODE.
Definition window.h:3601
HFONT EvGetFont()
The default message handler for WM_GETFONT.
Definition window.h:3705
uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS &)
The default message handler for WM_NCCALCSIZE.
Definition window.h:3855
bool EvQueryOpen()
The default message handler for WM_QUERYOPEN.
Definition window.h:4035
void EvSetText(LPCTSTR text)
The default message handler for WM_SETTEXT.
Definition window.h:4115
void EvSetRedraw(bool redraw)
The default message handler for WM_SETREDRAW.
Definition window.h:4108
TRect MapClientRect(HWND hWndTo) const
Maps the window's client rectangle (GetClientRect) to client coordinates in the given destination win...
Definition window.h:966
void EvMButtonUp(uint modKeys, const TPoint &point)
The default message handler for WM_MBUTTONUP.
Definition window.h:3813
void EvNCRButtonUp(uint codeHitTest, const TPoint &)
The default message handler for WM_NCRBUTTONUP.
Definition window.h:3946
void EvGetMinMaxInfo(MINMAXINFO &minmaxinfo)
The default message handler for WM_GETMINMAXINFO.
Definition window.h:3712
TRect MapWindowRect(HWND hWndTo) const
Maps the window's rectangle (GetWindowRect) to client coordinates in the given destination window.
Definition window.h:953
void EvDrawClipboard()
The default message handler for WM_DRAWCLIPBOARD.
Definition window.h:3677
void EnableAutoCreate()
Ensures that an associated child window interface element is created and displayed along with its par...
Definition window.h:1805
void EvSetFont(HFONT hFont, bool redraw)
The default message handler for WM_SETFONT.
Definition window.h:4094
HICON LoadIcon(TResId id) const
Definition window.h:613
HWND GetNextDlgTabItem(HWND hWndCtrl, bool previous=false) const
Returns the handle of the first control that lets the user press the Tab key to move to the next cont...
Definition window.h:3205
HFONT GetDlgItemFont(int childId) const
Definition window.h:1172
HWND GetNextDlgGroupItem(HWND hWndCtrl, bool previous=false) const
Returns either the next or the previous control in the dialog box.
Definition window.h:3190
void EvSysDeadChar(uint key, uint repeatCount, uint flags)
The default message handler for WM_SYSDEADCHAR.
Definition window.h:4150
void EvPaletteChanged(HWND hWndPalChg)
The default message handler for WM_PALETTECHANGED.
Definition window.h:3960
TWindow * GetFirstChild()
Returns a pointer to the first child window, which is the first window created in the interface objec...
Definition window.h:1770
TRect GetChildRect(const TWindow &wnd) const
Overload for TWindow See GetChildRect(HWND).
Definition window.h:1000
std::pair< int, int > TScrollRange
Definition window.h:1123
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
void SetWindowText(const tstring &str)
Definition window.h:1058
bool RegisterHotKey(int idHotKey, uint modifiers, uint virtKey)
Registers a hotkey ID with the current application.
Definition window.h:3500
int EvCharToItem(uint ch, HWND hWndListBox, int caretIndex)
The default message handler for WM_CHARTOITEM.
Definition window.h:3622
void EvNCMButtonDblClk(uint codeHitTest, const TPoint &)
The default message handler for WM_NCMBUTTONDBLCLK.
Definition window.h:3897
virtual void Invalidate(bool erase=true)
Invalidates (mark for painting) the entire client area of a window.
Definition window.h:2822
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
void EvNCMButtonUp(uint codeHitTest, const TPoint &)
The default message handler for WM_NCMBUTTONUP.
Definition window.h:3911
auto ChildWithId(int id) const -> const TWindow *
Definition window.h:681
void SetDlgItemInt(int childId, uint value, bool isSigned=true) const
Sets the child window with the Id (childId) in the window to the integer value specified in value.
Definition window.h:3120
void EvDeadChar(uint deadKey, uint repeatCount, uint flags)
The default message handler for WM_DEADCHAR.
Definition window.h:3649
TScroller * GetScroller()
Returns the associated scroller object for this window.
Definition window.h:1867
void ValidateRgn(HRGN hRgn)
Validates the client area within a region of the current window.
Definition window.h:2889
int GetWindowTextLength() const
Returns the length, in characters, of the specified window's title.
Definition window.h:2641
void EvNCLButtonUp(uint codeHitTest, const TPoint &)
The default message handler for WM_NCLBUTTONUP.
Definition window.h:3890
TXOwl is root class of the ObjectWindows exception hierarchy.
Definition except.h:38
A nested class, TXWindow describes an exception that results from trying to create an invalid window.
Definition window.h:1647
Definition of classes for clipboard Encapsulation.
Definition of windowing system color classes.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
HACCEL LoadAccelerators(TResId id) const
Wrapper for the Windows API.
Definition module.cpp:812
HCURSOR LoadCursor(TResId id) const
Wrapper for the Windows API.
Definition module.cpp:892
HICON LoadIcon(TResId name) const
Wrapper for the Windows API.
Definition module.cpp:933
int LoadString(uint id, TCHAR *buf, int maxChars) const
Loads a string resource identified by id into the buffer pointed to by buff.
Definition module.cpp:586
HMENU LoadMenu(TResId id) const
Wrapper for the Windows API.
Definition module.cpp:854
std::string LoadHtml(TResId) const
Loads the given HTML resource and returns it as a narrow string.
Definition module.cpp:971
HBITMAP LoadBitmap(TResId id) const
Wrapper for the Windows API.
Definition module.cpp:776
TEventStatus
Mixin window event implementation return status.
Definition window.h:107
TWindowFlag
Define bit masks for the internally used flag attributes of TWindow.
Definition window.h:58
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Definition window.h:92
@ esPartial
Additional handlers may be invoked.
Definition window.h:108
@ esComplete
No additional handlers are needed.
Definition window.h:109
@ wfDeleteOnClose
Window is condemned on EvClose.
Definition window.h:70
@ wfUnDisabled
Used temporarily when destroying MDI child.
Definition window.h:69
@ wfUnHidden
Used temporarily when destroying MDI child.
Definition window.h:68
@ wfAlias
TWindow is an alias to a preexisting HWND.
Definition window.h:59
@ wfModalWindow
Was created via TWindow::Execute.
Definition window.h:81
@ wfPredefinedClass
Window class used belongs to a predefined Windows class and was not defined by OWL.
Definition window.h:66
@ wfFromResource
Handle comes from HWND created from resource.
Definition window.h:61
@ wfMainWindow
This frame window is the main window.
Definition window.h:63
@ wfInsertAtEdge
(Decoration) Window to be inserted against frame's edge
Definition window.h:83
@ wfFullyCreated
Window is fully created & not being destroyed.
Definition window.h:64
@ wfDetached
Window handle has been detached.
Definition window.h:82
@ wfStreamTop
This window is the topmost one to stream.
Definition window.h:65
@ wfPropagateIdle
Pass down IdleAction.
Definition window.h:80
@ wfShrinkToClient
Shrink a frame window to its client's size.
Definition window.h:62
@ wfTransfer
Participates in the Transfer mechanism.
Definition window.h:67
@ wfAutoCreate
Create the HWND when our parent is created.
Definition window.h:60
@ tdSizeData
Return the size of data transferred by the class.
Definition window.h:95
@ tdSetData
Set data from the buffer into the window.
Definition window.h:94
@ tdGetData
Get data from the window into the buffer.
Definition window.h:93
Definition of Window Menu encapsulation class.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
signed long int32
Definition number.h:30
UINT TMsgId
Message ID type.
Definition dispatch.h:53
void SetDlgItemText(HWND ctrl, const tstring &text)
String overload.
Definition transfer.h:63
owl::opstream & operator<<(owl::opstream &os, const TColor &c)
Insert the color value into a persistent output stream.
Definition color.h:498
unsigned long uint32
Definition number.h:34
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).
Definition window.cpp:1557
void InUse(const T &arg)
Handy utility to avoid compiler warnings about unused parameters.
Definition defs.h:299
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
TDispatch< WM_PARENTNOTIFY >::TArgs TParentNotify
Alias for convenience.
Definition dispatch.h:2894
TModule * Module
Definition global.cpp:34
TParam1 MkParam1(uint lo, uint hi)
Definition dispatch.h:68
LRESULT TResult
Result type.
Definition dispatch.h:52
unsigned short uint16
Definition number.h:33
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
void CheckDlgButton(HWND ctrl, bool checked=true)
Sets the state of the given control to BST_CHECKED (or BST_UNCHECKED).
Definition transfer.h:87
tstring GetDlgItemText(HWND ctrl)
String overload.
Definition transfer.h:57
action
Definition regexp.cpp:133
void DoEnableAutoCreate(TWindow *win, void *)
A TActionFunc defined in window.cpp.
Definition window.cpp:2141
General definitions used by all ObjectWindows programs.
#define protected_data
Definition defs.h:208
#define HTASK
Definition defs.h:127
#define public_data
Definition defs.h:207
#define OWL_DISABLE_WARNING_POP
Definition defs.h:156
#define _OWLFUNC(p)
Definition defs.h:341
#define _OWLCFUNC(p)
Definition defs.h:342
#define _OWLCLASS
Definition defs.h:338
#define OWL_DISABLE_WARNING_ZERO_AS_NULL_POINTER
Definition defs.h:160
#define OWL_DISABLE_WARNING_PUSH
Definition defs.h:155
Current event structure for windows events.
Definition applicat.h:113
Holds TWindow attributes set during construction of a window.
Definition window.h:296
TResId Menu
Contains the resource ID for the menu associated with this window.
Definition window.h:346
LPVOID Param
Contains a value that is passed to Windows when the window is created.
Definition window.h:357
int X
horizontal position of top left corenr of the window
Definition window.h:339
int W
width of the window
Definition window.h:341
int H
height of the window
Definition window.h:342
int Y
vertical position of top left corenr of the window
Definition window.h:340
int Id
Contains the identifier of the child window.
Definition window.h:351
uint32 Style
Contains the values that define the style, shape, and size of your window.
Definition window.h:331
uint32 ExStyle
Contains the extended style values of your window.
Definition window.h:337
TResId AccelTable
Holds the resource ID for the window's accelerator table.
Definition window.h:360
Event response table macros for windows messages.
Classes for window system structure and type encapsulation.