OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
framewin.cpp
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/// Implementation of class TFrameWindow, a TWindow with additional features
7/// for frames, such as client window, menus, icons, etc.
8//----------------------------------------------------------------------------
9#include <owl/pch.h>
10
11#include <stdio.h>
12
13#include <owl/docking.h>
14#include <owl/framewin.h>
15#include <owl/applicat.h>
16#include <owl/menu.h>
17#include <owl/uimetric.h>
18#include <owl/bardescr.h>
19#include <algorithm>
20
21using namespace std;
22
23namespace owl {
24
25#if !defined(WM_SETICON)
26# define WM_SETICON 0x0080
27#endif
28
31
32
33DEFINE_RESPONSE_TABLE1(TFrameWindow, TWindow)
42
43//
44/// Overrides TCommandEnable::Enable. Enables or disables the menu options that
45/// control the appearance of the corresponding menu item.
46//
47void
49{
51 ::EnableMenuItem(HMenu, Position,
53}
54
55//
56/// Overrides TCommandEnable::SetText. Changes the text of the corresponding menu
57//
58void
60{
61 ::ModifyMenu(HMenu, Position, MF_BYPOSITION | MF_STRING, Id, str);
62}
63
64//
65/// Overrides TCommandEnable::SetCheck. Checks or unchecks the corresponding menu
66/// item. The state parameter reflects the menu item's state, which can be checked,
67/// unchecked, or indeterminate.
68//
69void
71{
72 ::CheckMenuItem(HMenu, Position,
74}
75
76//----------------------------------------------------------------------------
77
78//
79/// Constructs a window object with the parent window supplied in parent, which is
80/// zero if this is the main window. title, which by default is zero, contains the
81/// title displayed in the window's caption bar. clientWnd is the client window for
82/// this frame window or zero if none exists. shrinkToClient controls whether the
83/// client window will size to fit the frame or the frame window will fit the
84/// client. Note that this parameter only affects the size of the main window. When
85/// a client window is used in a frame window that doesn't have shrinktoClient set,
86/// the client window resizes to fit the frame window. When a client window is used
87/// in a frame window that has the shrinktoClient set, the frame window shrinks to
88/// fit the size of the client window.
89//
93 bool shrinkToClient,
94 TModule* module)
95{
96 // Initialize virtual base, in case the derived-most used default ctor
97 //
98 TWindow::Init(parent, title, module);
99
100
101 IconResId = 0; // remember that we still need to init
103}
104
105//
106/// String-aware overload
107//
109 TWindow* parent,
110 const tstring& title,
112 bool shrinkToClient,
113 TModule* module)
114{
115 TWindow::Init(parent, title, module);
116 IconResId = 0;
118}
119
120//
121/// Smart-pointer-aware overload.
122//
124{
125 TWindow::Init(parent, title, module);
126 IconResId = nullptr;
127 Init(client.get(), shrinkToClient);
128 client.release(); // We took ownership;
129}
130
131//
132/// Constructor for a TFrameWindow that is being used as an alias for a
133/// non-ObjectWindows window. hWnd is the handle to the existing window object that
134/// TFrameWindow controls; module contains the module passed to the base class's
135/// contructor.
136///
137/// This constructor is generally not used by derived
138/// classes, only as generic alias to a framewindow-like HWND
139//
141:
142 TWindow(THandle, module)
143{
144 Init(nullptr);
145}
148/// Protected constructor for use by immediate virtually derived classes.
149/// Immediate derivitives must call Init() before constructions are done.
150//
152{
153 IconResId = 0; // Zero this member to remember that we still need to init
154}
155
156//
157/// Normal initialization of a default constructed TFrameWindow. Is ignored
158/// if called more than once.
159///
160/// This initialize function is for use with virtually derived classes, which must
161/// call Init before construction is completed. This procedure provides necessary
162/// data to virtually derived classes and takes care of providing the data in the
163/// appropriate sequence.
164//
165void
167{
168 if (!IconResId) {
169 Attr.Style = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
170 Attr.X = Attr.W = CW_USEDEFAULT;
171
172 if (clientWnd)
173 Attr.Style |= WS_CLIPCHILDREN;
174
175 if (shrinkToClient)
177
179 }
180}
181
182//
183// Private initializer does a bulk of the common frame window initialization
184//
185void
187{
188 HWndRestoreFocus = nullptr;
189 KeyboardHandling = false;
190 ClientWnd = clientWnd;
191
192 MenuDescr = nullptr;
193 BarDescr = 0;
194 DeleteBar = false;
195 MergeModule = nullptr;
196
197 CurIcon = nullptr;
198 CurIconSm = nullptr;
199 IconModule = nullptr;
200 IconSmModule = nullptr;
202 #if !defined( MAINWIN )
204 #endif
205
206 MinimizedPos = TPoint(-1,-1); // Windows convention for never minimized
207
208 if (ClientWnd) {
209 ClientWnd->SetParent(this);
210 ClientWnd->EnableAutoCreate(); // in case client is a dialog
211 SetBkgndColor(NoErase); // no need to erase client area
212 }
213}
214
215//
216/// Destructor for a TFrameWindow
217//
218/// Deletes any associated menu descriptor.
219//
221{
223 if (GetApplication()->GetMainWindow() == this)
225
226 delete MenuDescr;
227 if(DeleteBar)
228 delete BarDescr;
229}
230
231//
232// Return a state mask representing the enabled menu items (up to 32)
233//
234static uint32
235GetMenuStateBits(HMENU hmenu, int count)
236{
237 uint32 bit = 1;
238 uint32 result = 0;
239
240 for (int i = 0; i < count; i++) {
241 uint state = GetMenuState(hmenu, i, MF_BYPOSITION);
242 if (state != static_cast<uint>(-1)) {
243 if (!(state & (MF_DISABLED | MF_GRAYED))) {
244 result |= bit;
245 }
246 }
247 bit <<= 1;
248 }
249
250 return result;
251}
252
253//
254/// Responds to WM_INITMENUPOPUP by performing a command enable run on each
255/// of the menu items in the popup menu
256///
257/// Sent before a pop-up menu is displayed, EvInitMenuPopup lets an application
258/// change the items on the menu before the menu is displayed. EvInitMenuPopup
259/// controls whether the items on the pop-up menu are enabled or disabled, checked
260/// or unchecked, or strings. HMENU indicates the menu handle. index is the index of
261/// the pop-up menu. sysMenu indicates if the pop-up menu is the system menu.
262//
263void
265{
266 if (!isSysMenu && hPopupMenu) {
267 const int count = ::GetMenuItemCount(hPopupMenu);
268
269 // Save current state of visible top level menus
270 //
271 uint32 preState = 0;
272 if (hPopupMenu == GetMenu())
273 preState = GetMenuStateBits(hPopupMenu, count);
274
276
277 // If the top level menu state changes, redraw the menu bar
278 //
279 if (hPopupMenu == GetMenu())
280 if (GetMenuStateBits(hPopupMenu, count) != preState)
281 DrawMenuBar();
282 }
283}
284
285//
286/// Overrides TWindow's virtual function. TApplication calls the main window's
287/// IdleAction when no messages are waiting to be processed. TFrameWindow uses this
288/// idle time to perform command enabling for the menu bar. It also forwards
289/// IdleAction to each of its children. IdleAction can be overridden to do
290/// background processing.
291//
292bool
294{
295 if (idleCount == 0) {
296 // do command enabling for the menu bar if this is the active task
297 //
298 if (GetFocus()) {
299 long style = ::GetWindowLong(*this, GWL_STYLE);
300 if (!(style & WS_CHILD)) {
301 if (IsWindow()) {
302 HMENU hMenu = ::GetMenu(*this);
303 if (IsMenu(hMenu)) {
306 }
307 }
308 }
309 }
310 }
311 // give child windows an opportunity to do any idle processing
312 //
314}
315
316//
317/// Locates and returns the child window that is the target of the command and
318/// command enable messages. If the current application does not have focus or if
319/// the focus is within a toolbar in the application, GetCommandTarget returns the
320/// most recently active child window.
321///
322/// If an alternative form of command processing is desired, a user's main window
323/// class can override this function. TFrameWindow's EvCommand and EvCommandEnable
324/// functions use GetCommandTarget to find the command target window. This member is
325/// not available under Presentation Manager.
326//
327HWND
329{
330 // Retrieve the focus window and our client
331 //
334
335 // 1. The first candidate is a focus window that's a child of our client
336 //
337 if (hFocus && client && client->IsChild(hFocus)) {
338 TRACEX(OwlCmd, 1, "TFrameWindow::GetCommandTarget - focus, "\
339 "child of client: " << static_cast<void*>(hFocus));
340 return hFocus;
341 }
342
343 // 2. The next option is our client window itself
344 //
345 if (client) {
346 TRACEX(OwlCmd, 1, "TFrameWindow::GetCommandTarget - client: " << *client);
347 return *client;
348 }
349
350 // 3. The next option is a focus window that's a child of ours
351 //
352 if (hFocus && IsChild(hFocus)) {
353 TRACEX(OwlCmd, 1, "TFrameWindow::GetCommandTarget - focus, "\
354 << static_cast<void*>(hFocus));
355 return hFocus;
356 }
357
358 // 4. If all of the above fail, resort to the last focus child of ours
359 //
360 if (HWndRestoreFocus) {
361#if defined(__TRACE) || defined(__WARN)
362 TWindow* win = GetWindowPtr(HWndRestoreFocus);
363 if (!win) {
364 TRACEX(OwlCmd, 1, "TFrameWindow::GetCommandTarget - HwndRestoreFocus, "\
365 << static_cast<void*>(HWndRestoreFocus));
366 } else {
367 TRACEX(OwlCmd, 1, "TFrameWindow::GetCommandTarget - HwndRestoreFocus, "\
368 << *win);
369 }
370#endif
371 return HWndRestoreFocus;
372 }
373
374 // 5. When all else fails, send ourselves in
375 //
376 TRACEX(OwlCmd, 1, "TFrameWindow::GetCommandTarget - self, " << *this);
377 return *this;
378}
379
380//
381/// Handle WM_COMMAND to provide extra processing for commands:
382/// Extra processing for commands: starts with the command target window
383/// (usually the focus window) and gives it and its parent windows an
384/// opportunity to handle the command.
385//
388{
389 TRACEX(OwlCmd, 1, "TFrameWindow::EvCommand - id(" << id << "), ctl(" <<
390 static_cast<void*>(hCtl) << "), code(" << notifyCode << ")");
391
392 // Walk the command chain from the command target back up to us or until
393 // we hit a child that is an owl window. Delegate to owl-child or forward to
394 // our base if no child is found.
395 //
396 if (hCtl == nullptr) {
398
399 // Check owl parentage too in case the HWNDs were reparented
400 //
401 while (hCmdTarget && hCmdTarget != GetHandle()) {
403
404 if (cmdTarget)
405 return cmdTarget->EvCommand(id, hCtl, notifyCode);
406
408 }
409 }
410
412}
413
414//
415/// Handle WM_COMMAND_ENABLE to provide command enable distribution and default
416/// support for windows without command enable handlers.
417///
418/// Handles checking and unchecking of the frame window's menu items.
419/// EvCommandEnable uses TWindow's RouteCommandEnable member function to perform the
420/// majority of this command enabling work.
421//
422void
424{
425 // Don't process for windows out of our window tree (esp. other apps)
426 //
428}
429
430//
431/// Overrides TWindow's virtual function. Performs preprocessing of window messages.
432/// If the child window has requested keyboard navigation, PreProcessMsg handles any
433/// accelerator key messages and then processes any other keyboard messages.
434//
435bool
437{
439 return true; // Processed accelerators
440
441 if (KeyboardHandling && msg.message >= WM_KEYFIRST &&
442 msg.message <= WM_KEYLAST)
443 {
444 HWND parent = ::GetParent(msg.hwnd);
445
446 // Retrieve the COMBO handle if we're in the EDIT ctrl parented to the
447 // combobox
448 //
449 tchar szClassName[0x10];
450 ::GetClassName(parent, szClassName, COUNTOF(szClassName));
451 if (!_tcsicmp(szClassName, _T("COMBOBOX")))
452 parent = ::GetParent(parent);
453 if (parent && ::IsDialogMessage(parent, &msg))
454 return true;
455 }
456
457 return false;
458}
459
460//
461/// Overrides TWindow's non-virtual SetMenu function, thus allowing derived classes
462/// the opportunity to implement this function differently from TWindow. SetMenu
463/// sets the window's menu to the menu indicated by newMenu. If newMenu is 0, the
464/// window's current menu is removed. SetMenu returns 0 if the menu remains
465/// unchanged; otherwise, it returns a nonzero value.
466///
467/// It also calls the application's PreProcessMenu() if it is the main window
468/// to let it make any changes just before setting.
469//
470bool
478
479//
480/// Perform a high-level menu assignment either before or after the HWND for the
481/// window has been created.
482///
483/// Sets Attr.Menu to the supplied menuResId and frees any previous strings pointed
484/// to by Attr.Menu. If HWindow is nonzero, loads and sets the menu of the window,
485/// destroying any previously existing menu.
486///
487/// Returns true if successful; false otherwise
488//
489
490bool
492{
493
494 if (menuResId != Attr.Menu) {
495 if (Attr.Menu.IsString())
496 delete[] Attr.Menu.GetString();
497
498 Attr.Menu = menuResId.IsString() ? TResId(strnewdup(menuResId)) : menuResId;
499 }
500
501 // If the window has been created then load and set the new menu and destroy
502 // the old menu
503 //
504 if (!GetHandle())
505 return true;
506
508 HMENU newMenu = LoadMenu(Attr.Menu);
509
510 if (!SetMenu(newMenu))
511 return false;
512
513 if (curMenu)
515
516 return true;
517}
518
519//
520/// Sets the icon in the module specified in iconModule to the resource ID specified
521/// in iconResId. See the sample file BMPVIEW.CPP for an example of painting an icon
522/// from a bitmap. You can set the iconResId to one of these predefined values as
523/// well as user-defined values:
524/// - \c \b IDI_APPLICATION Default icon used for applications
525/// - \c \b IDI_ASTERISK Asterisk used for an informative message
526/// - \c \b IDI_EXCLAMATION Exclamation mark used for a warning message
527/// - \c \b IDI_HAND Hand used for warning messages
528/// - \c \b IDI_QUESTION Question mark used for prompting a response
529//
530bool
532{
533 // Delete old icon if not system icon
534 //
535 if (CurIcon && IconModule) {
536 TUser::DestroyIcon(CurIcon);
537 CurIcon = nullptr;
538 }
539
540 IconModule = module;
541 IconResId = resId;
542
543 HINSTANCE hInstance = IconModule ? HINSTANCE(*IconModule) : HINSTANCE(nullptr);
544
545 if (IconResId != 0)
546 CurIcon = TUser::LoadIcon(hInstance, IconResId);
547
548 if (CurIcon && IsWindow())
549 SendMessage(WM_SETICON, true, reinterpret_cast<LPARAM>(static_cast<HICON>(CurIcon)));
550
551 return true;
552}
553
554//
555/// Set the Small Icon (16 x 16)
556//
557bool
559{
560 // Delete old small icon
561 //
562 if (CurIconSm && IconSmModule) {
563 TUser::DestroyIcon(CurIconSm);
564 CurIconSm = nullptr;
565 }
566
567 IconSmModule = module;
568 IconSmResId = resId;
569
570 HINSTANCE hInstance = IconSmModule ? HINSTANCE(*IconSmModule) : HINSTANCE(nullptr);
571 if (IconSmResId != 0) {
572 CurIconSm = reinterpret_cast<HICON>(::LoadImage(hInstance, IconSmResId.GetPointerRepresentation(), IMAGE_ICON,
575 if (!CurIconSm)
576 CurIconSm = TUser::LoadIcon(hInstance, IconSmResId);
577 }
578
579 if (CurIconSm && IsWindow())
580 SendMessage(WM_SETICON, false, reinterpret_cast<LPARAM>(static_cast<HICON>(CurIconSm)));
581
582 return true;
583}
584
585//
586/// Returns a pointer to the client window. If you are trying to access a
587/// window-based object in a TMDIChild (which is a frame window), you can use this
588/// function.
589//
590TWindow*
592{
593 return ClientWnd;
594}
595
596//
597/// Sets the client window to the specified window. Users are responsible for
598/// destroying the old client window if they want to eliminate it.
599///
600/// Assume clientWnd was parented to us.
601//
602TWindow*
604{
605 TWindow* oldClientWnd = ClientWnd;
606 HWND oldWnd = oldClientWnd ? oldClientWnd->GetHandle() : static_cast<HWND>(nullptr);
607 RemoveChild(ClientWnd);
608
609 if (HWndRestoreFocus == oldWnd)
610 HWndRestoreFocus = nullptr;
611
612 ClientWnd = clientWnd;
613
614 if (ClientWnd) {
615 ClientWnd->SetParent(this);
616 if (GetHandle()) {
617 if (!ClientWnd->GetHandle())
618 ClientWnd->Create();
619 ClientWnd->ShowWindow(SW_SHOWNOACTIVATE);
620 }
621 SetBkgndColor(NoErase); // no need to erase client area
622 ResizeClientWindow(true); // !CQ defer repaint?
623 }
624 else
625 SetBkgndColor(NoColor); // will need to erase client area
626
627 // Pass the focus to the new client, but only if we have it currently
628 //
629 if (ClientWnd && ClientWnd->GetHandle() && GetFocus() == GetHandle()) {
630 ClientWnd->SetFocus();
631 HWndRestoreFocus = ClientWnd->GetHandle();
632 }
633
634 return oldClientWnd;
635}
636
637//
638/// Smart-pointer-aware overload.
639//
641{
642 auto old = unique_ptr<TWindow>{SetClientWindow(c.get())};
643 c.release(); // We took ownership.
644 return old;
645}
646
647//
648/// If someone removes our client with a RemoveChild() call, update our client
649/// and restore focus ptrs.
650//
651void
653{
655 if (child) {
656 if (child == ClientWnd)
657 ClientWnd = nullptr;
658 if (child->GetHandle() == HWndRestoreFocus) {
659 HWndRestoreFocus = nullptr;
660 }
661 }
662}
663
664//
665/// Overrides TWindow's virtual function. Pastes the number of the view into the
666/// caption and then shows the number on the screen. This function can be overridden
667/// if you don't want to use the default implementation, which displays a number on
668/// the screen. That is, you might want to write "Two" instead of ":2" on the
669/// screen. For an example of the behavior of this function, see step 12 of the
670/// ObjectWindows tutorial, which renumbers the views if one of them is closed.
671///
672/// Generates a composite title based on the caption, docname, and index
673/// if it is > 0.
674/// \code
675/// [<Title> - ]<docname>[:<index>]
676/// \endcode
677//
678bool
680{
681 if (index >= 0) {
683
684 LPCTSTR c = GetCaption();
685 if (c && *c) {
686 title = c;
687 title += _T(" - ");
688 }
689
690 if (docname)
691 title += docname;
692
693 if (index > 0) {
694 title += _T(":");
695 tchar num[10];
696 _stprintf(num, _T("%d"), index );
697 title += num;
698 }
699
700 SetWindowText(title.c_str());
701 }// else if index negative, simply acknowledge that title will display
702 return true;
703}
704
705//
706// Obtain the real windows application icon. The IDI_APPLICATION icon is an
707// ugly black & white box, but when a class is registered with this icon it
708// gets substituted with a better windows icon. Worse case we end up with the
709// ugly box icon.
710//
711static HICON
712getAppIcon()
713{
714 static HICON hRealAppIcon = 0;
715 if (!hRealAppIcon) {
717 static tchar className[] = _T("IconSnarfer");
718 memset(&wndClass, 0, sizeof wndClass);
719 wndClass.hInstance = GetGlobalModule().GetHandle();
720 wndClass.hIcon = ::LoadIcon(nullptr, IDI_APPLICATION);
721 wndClass.lpszClassName = className;
722 wndClass.lpfnWndProc = ::DefWindowProc;
723 ::RegisterClass(&wndClass);
724 ::GetClassInfo(GetGlobalModule().GetHandle(), className, &wndClass);
725 hRealAppIcon = wndClass.hIcon;
726 ::UnregisterClass(className, GetGlobalModule().GetHandle());
727 }
728 return hRealAppIcon ? hRealAppIcon : ::LoadIcon(nullptr, IDI_APPLICATION);
729}
730
731//
732/// Responds to a WM_QUERYDRAGICON message sent to a minimized (iconic) window that
733/// is going to be dragged. Instead of the default icon, EvQueryDragIcon uses the
734/// icon that was set using SetIcon.
735/// This member is not available under Presentation Manager.
736//
737HICON
739{
740 // !JK Consider the following problems:
741 // !JK (1) If a derived class sets CurIcon (instantiated with something other
742 // !JK than a module & res id), this function will ignore it! Why do a
743 // !JK ::LoadIcon again? It won't actually load again anyway (see MS
744 // !JK Win16/Win32 doc). It doesn't reference count either.
745 // !JK
746 // !JK (2) If IconResId is non-zero but bad (i.e., ::LoadIcon fails), getAppIcon()
747 // !JK is returned; but if IconResId is zero, TWindow::EvQueryDragIcon() is
748 // !JK returned. What is the rationale behind returning one icon in the case
749 // !JK of a bad res id and a different icon in the case of a zero res id?
750 // !JK
751 // !JK This function body should be:
752 // !JK return (CurIcon)? CurIcon: TWindow::EvQueryDragIcon();
753 // !JK -or-
754 // !JK return (CurIcon)? CurIcon: getAppIcon();
755 if (IconResId) {
756 HINSTANCE hInstance = IconModule ? HINSTANCE(*IconModule) : HINSTANCE(nullptr);
757 HICON hIcon = TUser::LoadIcon(hInstance, IconResId);
758 return hIcon ? hIcon : getAppIcon();
759 // !CQ This LoadIcon() may be causing a resource leak. May need to keep icon
760 // !CQ We are keeping it!!! CurIcon!!!
761 }
762 else
764}
765
766namespace {
767
768auto IsEnabledVisibleChild_(long style) -> bool
769{
770 return (style & (WS_CHILD | WS_VISIBLE | WS_DISABLED)) == (WS_CHILD | WS_VISIBLE);
771}
772
773auto SearchForChildWithTab_(TWindow* win) -> TWindow*
774 {
775 for (auto& child : win->GetChildren())
776 {
777 if (!child.GetHandle()) continue;
778 long style = child.GetWindowLong(GWL_STYLE);
779 if (IsEnabledVisibleChild_(style))
780 {
781 if (style & WS_TABSTOP)
782 return &child;
783 else if (const auto result = SearchForChildWithTab_(&child))
784 return result;
785 }
786 }
787 return nullptr;
788 }
789
790} // namespace
791
792//
793// If the receiver doesn't have any children then returns 0. Otherwise
794// we search for the first child with WS_TABSTOP; If no child has WS_TABSTOP
795// then we return the first enabled visible child
796//
797// Does a depth-first search of nested child windows
798//
799// NOTE: we stop at the first child with WS_TABSTOP and do not search its
800// children...
801//
802TWindow*
803TFrameWindow::FirstChildWithTab()
804{
805 const auto win = SearchForChildWithTab_(this);
806 if (win) return win;
807
808 auto c = GetChildren();
809 const auto i = find_if(c.begin(), c.end(), [](TWindow& w)
810 { return w.GetHandle() && IsEnabledVisibleChild_(w.GetWindowLong(GWL_STYLE)); });
811 return (i != c.end()) ? &(*i) : nullptr;
812}
813
814//
815/// Overrides TWindow's virtual function. Responds to a request by a child window to
816/// hold its HWND when it is losing focus. Stores the child's HWND in
817/// HwndRestoreFocus.
818///
819/// return true if caller can stop searching for a window to hold its handle.
820//
821bool
823{
824 if (IsChild(hWndLose)) {
825 if (!hWndGain || !IsChild(hWndGain))
826 HWndRestoreFocus = hWndLose;
827 return true;
828 }
829 return hWndLose == GetHandle();
830}
831
832//
833/// Restores the focus to the active window. hWndLostFocus contains the handle for
834/// the window that lost focus.
835///
836/// Handle WM_SETFOCUS to return focus back to the child that had it most
837/// recently, or find the best one to give it to otherwise.
838//
839void
841{
843
844 if (!HWndRestoreFocus) {
846 if (cmdTgt && IsChild(cmdTgt))
847 HWndRestoreFocus = cmdTgt;
848 }
849
850// if (HWndRestoreFocus == hWndLostFocus)
851// HWndRestoreFocus = GetHandle();
852
853 if (HWndRestoreFocus) {
854 // Set focus to the saved HWND as long as it is still a valid window handle
855 //
856 if (::IsWindow(HWndRestoreFocus))
857 ::SetFocus(HWndRestoreFocus);
858 else
859 HWndRestoreFocus = nullptr;
860 }
861}
862
863//
864/// Responds to a message to notify the parent window that a given event has
865/// occurred. If the client window is destroyed, closes the parent window. If
866/// shrinkToClient is set and the child window has changed size, the frame is
867/// adjusted.
868/// When a TFrameWindow's client window is destroyed, the TFrameWindow object sees
869/// the WM_PARENTNOTIFY message and posts a close message to itself. Without this
870/// message, an empty frame would remain and the client window would then have to
871/// determine how to destroy the frame. If you don't want this to happen, you can
872/// derive from the frame window and have your application handle the EvParentNotify
873/// or EvClose messages.
874//
875void
877{
878 switch (n.Event)
879 {
880 case WM_DESTROY:
881 {
882 const TParentNotifyChildInfo& i = static_cast<const TParentNotifyChildInfo&>(n);
883 if (ClientWnd && ClientWnd->GetHandle() == i.Child)
884 PostMessage(WM_CLOSE); // Using ShutDownWindow() has side effects.
885 TWindow* c = GetWindowPtr(i.Child);
886 if (c)
887 c->ClearFlag(wfFullyCreated);
888 }
889 break;
890
891 case WM_SIZE: // TODO: This is not a documented event for the WM_PARENTNOTIFY message. Investigate.
892 {
893 const TParentNotifyChildInfo& i = static_cast<const TParentNotifyChildInfo&>(n);
894 if (IsFlagSet(wfShrinkToClient) && ClientWnd && ClientWnd->GetHandle() == i.Child && !IsIconic())
895 ResizeClientWindow(true);
896 }
897 break;
898 }
900}
901
902//
903/// Forwards the WM_QUERYNEWPALETTE message to the client window.
904//
905bool
907{
908 if (GetClientWindow())
909 return GetClientWindow()->ForwardMessage();
910 else
912}
913
914//
915/// Forwards the WM_PALETTECHANGED message to the client window.
916//
917void
925
926//
927// Resize & reposition the client window to fit in this frames client area
928// or resize the frame to fit around the client's client area if
929// wfShrinkToClient
930// Return true if a client was actualy resized.
931// Adjust clients styles & make sure they get set.
932//
933bool
934TFrameWindow::ResizeClientWindow(bool repaint)
935{
936/// bool hasThickFrame = Attr.Style & WS_THICKFRAME;
937/// Attr.Style |= WS_THICKFRAME;
938
939 // Nothing to resize if there's not Client window
940 //
941 if (!ClientWnd)
942 return false;
943
944 // Prevent recursion during resize by ignore calls from EvParentNotify and
945 // EvSize when we have already been called.
946 // Do this by disabling notifications while resizing using the
947 // wfShrinkToClient flag as a semaphore on the client
948 //
949 if (ClientWnd->IsFlagSet(wfShrinkToClient))
950 return true;
951 ClientWnd->SetFlag(wfShrinkToClient);
952
953 bool clientResized = false;
955 TSize childSize = ClientWnd->GetWindowRect().Size();
956
957 // First time through, strip client window of thick borders.
958 // If shrink-to-client, then must measure the client size first
959 // If the client has scrolls bars, we must hide them to obtain the correct
960 // size.
961 // Border style is left on & dealt with by hand below
962 //
963 const uint32 badClientStyles = WS_DLGFRAME | WS_THICKFRAME | // bad borders
964 WS_POPUP | WS_OVERLAPPED; // bad parenting
966 WS_EX_STATICEDGE; // more bad borders
967
968 if ((ClientWnd->GetStyle() & badClientStyles) ||
969 (ClientWnd->GetExStyle() & badClientExStyles)) {
971 TSize tstSize = ClientWnd->GetClientRect().Size();
972 ClientWnd->ShowScrollBar(SB_BOTH, false);
973 childSize = ClientWnd->GetClientRect().Size();
974 if (childSize != tstSize) {
975 int restore = SB_BOTH;
976 if (childSize.cx == tstSize.cx)
978 if (childSize.cy == tstSize.cy)
980 ClientWnd->ShowScrollBar(restore, true);
981 }
982 }
983 if (ClientWnd->GetStyle() & badClientStyles) {
984 bool reparent = (ClientWnd->GetStyle() & (WS_POPUP|WS_OVERLAPPED)) != 0;
985 uint32 style = ClientWnd->GetStyle();
986 style &= ~badClientStyles;
987 style |= WS_CHILD | WS_BORDER | WS_VISIBLE;
988 ClientWnd->SetStyle( style );
989 if (reparent)
990 ::SetParent(*ClientWnd, *this);
991 }
992 if (ClientWnd->GetExStyle() & badClientExStyles) {
993 uint32 exStyle = ClientWnd->GetExStyle();
994 exStyle &= ~badClientExStyles;
995 ClientWnd->SetExStyle( exStyle );
996 }
997 }
998 if (ClientWnd->GetStyle() & WS_BORDER) {
999 childSize = ClientWnd->GetClientRect().Size();
1000 }
1001 if (childSize != clientAreaSize) {
1003 TRect outside = GetWindowRect();
1004 TSize border = outside.Size() - clientAreaSize;
1005 SetWindowPos(nullptr, 0, 0,
1006 childSize.cx + border.cx, childSize.cy + border.cy,
1008 clientAreaSize = childSize; // Must move client, will not cause an EvSize
1009 }
1010 else {
1011 clientResized = true; // Client will get resized
1012 }
1013 }
1014 // If frame is sizeable, turn off flag so that user can then resize
1015 // after initial setup
1016 //
1017 if (Attr.Style & WS_THICKFRAME && !TYPESAFE_DOWNCAST(this, TFloatingSlip))
1019
1020
1021/// if (!hasThickFrame) {
1022/// Attr.Style &= ~WS_THICKFRAME;
1023/// }
1024
1025 // Handle simple border style by shoving the client's borders under the frame
1026 // This code MUST not resize the client if shrinkToClient
1027 // !CQ use SetWindowPos() to get at SWP_NOSIZE?
1028 //
1029 if (ClientWnd->GetStyle() & WS_BORDER) {
1030 int bx = TUIMetric::CxBorder;
1031 int by = TUIMetric::CyBorder;
1032 ClientWnd->MoveWindow(-bx, -by, clientAreaSize.cx+bx+bx,
1034 }
1035 else
1036 ClientWnd->MoveWindow(0, 0, clientAreaSize.cx, clientAreaSize.cy, repaint);
1037
1038 // Turn off semaphore bit
1039 //
1040 ClientWnd->ClearFlag(wfShrinkToClient);
1041 return clientResized;
1042}
1043
1044//
1045/// Calls TWindow::SetUpWindow to create windows in a child list. SetupWindow
1046/// performs the initial adjustment of the client window if one exists, assigns the
1047/// frame's menu based on the menu descriptor, and initializes HwndRestoreFocus.
1048//
1049void
1051{
1052 // Create windows in child list (this includes the client window)
1053 //
1055
1056 ResizeClientWindow(true); // !CQ defer repaint?
1057
1058 if (MinimizedPos != TPoint(-1,-1)) {
1059 auto windata = GetWindowPlacement();
1061 windata.showCmd = SW_SHOWNA;
1062 windata.ptMinPosition = MinimizedPos;
1064 }
1065
1066 // If SetMenuDescr() was called before window created, update the menu now
1067 //
1068 if (IsFlagSet(wfMainWindow) && MenuDescr) {
1069 HMENU curMenu = GetMenu();
1070 TMenu newMenu(*MenuDescr, NoAutoDelete);
1071 if (SetMenu(newMenu)) {
1072 if (curMenu)
1074 }
1075 else
1076 ::DestroyMenu(newMenu);
1077 }
1078
1079 // If we haven't set THandleRestoreFocus then pick the first child with tabstop
1080 //
1081 if (!HWndRestoreFocus) {
1082///TH Previous version would be to search for first child with tabstop.
1083///TH Why not use CommandTarget?
1084// !BB Because it breaks when GetCommandTarget returns a non-child window
1085// !BB Please, leave this code AS IS?
1086#if 1
1087 TWindow* win = FirstChildWithTab();
1088 HWndRestoreFocus = win ? win->GetHandle() : GetHandle();
1089#else
1091 if (cmdTgt && IsChild(cmdTgt))
1092 HWndRestoreFocus = cmdTgt;
1093#endif
1094 }
1095
1096 if (CurIcon)
1097 SendMessage(WM_SETICON, true, reinterpret_cast<LPARAM>(CurIcon));
1098
1099 if (CurIconSm)
1100 SendMessage(WM_SETICON, false, reinterpret_cast<LPARAM>(CurIconSm));
1101}
1102
1103//
1104/// Cleans up any associated icons.
1105//
1106void
1108{
1109 // icon cleanup
1110 //
1111 SetIcon(nullptr, 0);
1112 SetIconSm(nullptr, 0);
1113
1115}
1116
1117//
1118/// Tell child windows frame has minimized/maximized/restored
1119/// (They may want to change enabled state or release/restore resources)
1120//
1121void
1123{
1126 || sizeType == SIZE_RESTORED)
1127 {
1128 ChildBroadcastMessage(WM_OWLFRAMESIZE, sizeType, reinterpret_cast<TParam2>(&size));
1129 }
1130}
1131
1132//
1133/// Response method for an incoming WM_SIZE message
1134///
1135/// Resizes the client window' so that it is equivalent to the client rectangle's
1136/// size. Calls TWindow::EvSize() in response to an incoming WM_SIZE message.
1137///
1138/// If no WM_SIZE sent, forwards WM_SIZE message to client so it can recalc.
1139//
1140void
1142{
1144 TSize newSize = size;
1145
1146 if (ClientWnd) {
1147 bool sizeSent = false;
1148 if (sizeType != SIZE_MINIMIZED) {
1149 sizeSent = ResizeClientWindow(true); // !CQ defer repaint?
1150 newSize = ClientWnd->GetClientRect().Size();
1151 }
1152 if (!sizeSent)
1153 ClientWnd->ForwardMessage();
1154 }
1155
1157}
1158
1159
1160//
1161/// Sets the menu descriptor to the new menu descriptor.
1162//
1163void
1165{
1166 if (&menuDescr != MenuDescr) // Guard against self-assignment (the latter is useful for refreshing the menu).
1167 {
1168 delete MenuDescr;
1169 MenuDescr = new TMenuDescr(menuDescr);
1170 }
1171
1172 if (IsFlagSet(wfMainWindow) && GetHandle()) {
1173 HMENU curMenu = GetMenu();
1174 TMenu newMenu(*MenuDescr, NoAutoDelete);
1175 if (SetMenu(newMenu))
1177 else
1178 ::DestroyMenu(newMenu);
1179 }
1180}
1181
1182//
1183/// Sets the control bar descriptor to the new bar descriptor.
1184//
1185void
1187{
1188 if(DeleteBar)
1189 delete BarDescr;
1190 BarDescr = barDescr;
1191 DeleteBar = delonClose == AutoDelete;
1193 RestoreBar();
1194}
1195
1196//
1197/// Merges the given menu descriptor with this frame's own menu descriptor and
1198/// displays the resulting menu in this frame. See TMenuDescr for a description of
1199/// menu bar types that can be merged.
1200///
1201/// Optionally use an existing HMENU to merge into & set
1202//
1203bool
1205{
1206 if (!MenuDescr || !GetHandle())
1207 return false;
1208
1209 MergeModule = childMenuDescr.GetModule();
1210 TMenu curMenu(*this, NoAutoDelete);
1212
1213 MenuDescr->Merge(childMenuDescr, newMenu);
1214
1217
1218 if (SetMenu(newMenu)) {
1220 return true;
1221
1222 }
1223 else {
1225 return false;
1226 }
1227
1228}
1229
1230//
1231// Restores this frame window's menu to the one described by our menu
1232// descriptor
1233//
1234bool
1236{
1237 if (!MenuDescr)
1238 return false;
1239
1240 HMENU curMenu = GetMenu();
1241 TMenu newMenu(*MenuDescr, NoAutoDelete);
1242 if (SetMenu(newMenu)) {
1243 MergeModule = nullptr;
1245 }
1246 else
1247 ::DestroyMenu(newMenu);
1248 return true;
1249}
1250
1251
1252
1254
1255#if OWL_PERSISTENT_STREAMS
1256
1257//
1258// Reads data of the uninitialized TFrameWindow from the passed ipstream
1259//
1260
1261void*
1262TFrameWindow::Streamer::Read(ipstream& is, uint32 version) const
1263{
1264 TFrameWindow* o = GetObject();
1266 if (o->IsFlagSet(wfMainWindow))
1267 return o;
1268
1269 is >> o->ClientWnd;
1270 is >> o->KeyboardHandling;
1271 o->HWndRestoreFocus = 0;
1272
1273 bool hasMenuDescr = is.readByte();
1274 if (hasMenuDescr) {
1275 o->MenuDescr = new TMenuDescr;
1276 is >> *o->MenuDescr;
1277 }
1278 else
1279 o->MenuDescr = 0;
1280
1281 o->BarDescr = 0;
1282 if(version > 2){
1283 bool hasBarDescr = is.readByte();
1284 if (hasBarDescr) {
1285 o->BarDescr = new TBarDescr;
1286 is >> *o->BarDescr;
1287 }
1288 }
1289
1290 // stream in window icon information
1291 //
1292 is >> o->IconModule;
1293 is >> o->IconResId;
1294 if (version > 1) {
1295 is >> o->IconSmModule;
1296 is >> o->IconSmResId;
1297 }
1298 else {
1299 o->IconSmModule = 0;
1300 o->IconSmResId = 0;
1301 }
1302
1303 // load the window's icons
1304 //
1305 o->CurIcon = 0;
1306 o->CurIconSm = 0;
1307 o->SetIcon(o->IconModule, o->IconResId);
1308 o->SetIconSm(o->IconSmModule, o->IconSmResId);
1309
1310 is >> o->MergeModule;
1311 is >> o->MinimizedPos;
1312
1313 return o;
1314}
1315
1316//
1317// Writes data of the TFrameWindow to the passed opstream
1318//
1319void
1320TFrameWindow::Streamer::Write(opstream& os) const
1321{
1322 TFrameWindow* o = GetObject();
1323 WriteVirtualBase((TWindow*)o, os);
1324 if (o->IsFlagSet(wfMainWindow))
1325 return;
1326
1327 os << o->ClientWnd;
1328 os << o->KeyboardHandling;
1329
1330 os.writeByte(uint8(o->MenuDescr ? 1 : 0));
1331 if (o->MenuDescr)
1332 os << *o->MenuDescr;
1333
1334 // added in stream ver 3
1335 os.writeByte(uint8(o->BarDescr ? 1 : 0));
1336 if (o->BarDescr)
1337 os << *o->BarDescr;
1338
1339 os << o->IconModule;
1340 os << o->IconResId;
1341 os << o->IconSmModule; // added in stream ver 2
1342 os << o->IconSmResId; // added in stream ver 2
1343
1344 os << o->MergeModule;
1345 auto windata = o->GetWindowPlacement();
1346 os << TPoint(windata.ptMinPosition);
1347}
1348
1349#endif
1350
1351
1352} // OWL namespace
1353
Definition of class TApplication.
Class definition for TBarDescr.
#define DIAG_DECLARE_GROUP(group)
Definition checks.h:404
#define TRACEX(group, level, message)
Definition checks.h:263
virtual void PreProcessMenu(HMENU hMenubar)
Called by the main window to provide an oportunity to preprocess the main window's menubar before it ...
void ClearMainWindow()
Called by the main window (TFrameWindow) destructor to zero the MainWindow member.
Definition applicat.h:768
Descriptor of Bar Implementation.
Definition bardescr.h:71
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
virtual void Enable(bool enable=true)
Enables or disables the command sender.
Definition window.cpp:301
@ Checked
Command is enabled.
Definition window.h:227
Derived from TWindow, TFrameWindow controls such window-specific behavior as keyboard navigation and ...
Definition framewin.h:96
auto IdleAction(long idleCount) -> bool override
Overrides TWindow's virtual function.
Definition framewin.cpp:293
void Init(TWindow *clientWnd, bool shrinkToClient)
Normal initialization of a default constructed TFrameWindow.
Definition framewin.cpp:166
~TFrameWindow() override
Destructor for a TFrameWindow.
Definition framewin.cpp:220
virtual bool MergeMenu(const TMenuDescr &childMenuDescr)
Merges the given menu descriptor with this frame's own menu descriptor and displays the resulting men...
virtual TWindow * GetClientWindow()
Returns a pointer to the client window.
Definition framewin.cpp:591
void EvSize(uint sizeType, const TSize &size)
Response method for an incoming WM_SIZE message.
auto SetDocTitle(LPCTSTR docname, int index) -> bool override
Overrides TWindow's virtual function.
Definition framewin.cpp:679
void EvCommandEnable(TCommandEnabler &) override
Handle WM_COMMAND_ENABLE to provide command enable distribution and default support for windows witho...
Definition framewin.cpp:423
virtual bool RestoreBar()
Do nothing in TFrameWindow. Overriden in TDecoratedFrame.
Definition framewin.h:341
virtual bool SetMenu(HMENU newMenu)
Overrides TWindow's non-virtual SetMenu function, thus allowing derived classes the opportunity to im...
Definition framewin.cpp:471
void SetMenuDescr(const TMenuDescr &menuDescr)
Sets the menu descriptor to the new menu descriptor.
void CleanupWindow() override
Cleans up any associated icons.
void EvPaletteChanged(HWND hWndPalChg)
Forwards the WM_PALETTECHANGED message to the client window.
Definition framewin.cpp:918
virtual HWND GetCommandTarget()
Locates and returns the child window that is the target of the command and command enable messages.
Definition framewin.cpp:328
auto HoldFocusHWnd(HWND hWndLose, HWND hWndGain) -> bool override
Overrides TWindow's virtual function.
Definition framewin.cpp:822
auto PreProcessMsg(MSG &) -> bool override
Overrides TWindow's virtual function.
Definition framewin.cpp:436
void BroadcastResizeToChildren(uint sizeType, const TSize &size)
Tell child windows frame has minimized/maximized/restored (They may want to change enabled state or r...
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
Handle WM_COMMAND to provide extra processing for commands: Extra processing for commands: starts wit...
Definition framewin.cpp:387
bool EvQueryNewPalette()
Forwards the WM_QUERYNEWPALETTE message to the client window.
Definition framewin.cpp:906
virtual TWindow * SetClientWindow(TWindow *clientWnd)
Sets the client window to the specified window.
Definition framewin.cpp:603
void EvParentNotify(const TParentNotify &)
Responds to a message to notify the parent window that a given event has occurred.
Definition framewin.cpp:876
bool SetIconSm(TModule *iconModule, TResId iconResIdSm)
Set the Small Icon (16 x 16)
Definition framewin.cpp:558
bool SetIcon(TModule *iconModule, TResId iconResId)
Sets the icon in the module specified in iconModule to the resource ID specified in iconResId.
Definition framewin.cpp:531
HICON EvQueryDragIcon()
Responds to a WM_QUERYDRAGICON message sent to a minimized (iconic) window that is going to be dragge...
Definition framewin.cpp:738
virtual bool AssignMenu(TResId menuResId)
Perform a high-level menu assignment either before or after the HWND for the window has been created.
Definition framewin.cpp:491
void SetBarDescr(TBarDescr *barDescr, TAutoDelete=AutoDelete)
Sets the control bar descriptor to the new bar descriptor.
void EvSetFocus(HWND hWndLostFocus)
Restores the focus to the active window.
Definition framewin.cpp:840
void EvInitMenuPopup(HMENU hPopupMenu, uint index, bool isSysMenu)
Responds to WM_INITMENUPOPUP by performing a command enable run on each of the menu items in the popu...
Definition framewin.cpp:264
TFrameWindow()
< String-aware overload
Definition framewin.cpp:151
void SetupWindow() override
Calls TWindow::SetUpWindow to create windows in a child list.
void RemoveChild(TWindow *) override
If someone removes our client with a RemoveChild() call, update our client and restore focus ptrs.
Definition framewin.cpp:652
Menu with information used to allow merging.
Definition menu.h:206
bool Merge(const TMenuDescr &sourceMenuDescr)
Merges the functional groups of another menu descriptor into this menu descriptor.
Definition menudesc.cpp:328
The TMenu class encapsulates window menus.
Definition menu.h:77
Derived from TCommandEnabler, TMenuItemEnabler is a command enabler for menu items.
Definition framewin.h:39
void SetCheck(int check)
< String-aware overload
Definition framewin.cpp:70
void SetText(LPCTSTR text)
Overrides TCommandEnable::SetText. Changes the text of the corresponding menu.
Definition framewin.cpp:59
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
TSize Size() const
Returns the size of rectangle.
Definition geometry.h:1057
TPointer GetPointerRepresentation() const
Returns the encapsulated pointer.
Definition wsyscls.h:76
The tagSIZE struct is defined as.
Definition geometry.h:234
static const TUIMetric CyBorder
Definition uimetric.h:40
static const TUIMetric CySmIcon
Definition uimetric.h:84
static const TUIMetric CxBorder
Definition uimetric.h:39
static const TUIMetric CxSmIcon
Definition uimetric.h:83
static BOOL DestroyIcon(HICON)
Definition module.cpp:1078
static HICON LoadIcon(HINSTANCE, LPCTSTR)
Definition module.cpp:1067
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
HWND SetFocus()
Sets the keyboard focus to current window and activates the window that receives the focus by sending...
Definition window.h:2151
void ShowScrollBar(int bar, bool show=true)
Displays or hides the scroll bar.
Definition window.h:3043
HMENU LoadMenu(TResId id) const
Definition window.h:611
bool SetMenu(HMENU hMenu)
Sets the specified window's menu to the menu indicated by hMenu.
Definition window.h:3278
virtual void SetParent(TWindow *newParent)
Sets the parent for the specified window by setting Parent to the specified new Parent window object.
Definition window.cpp:738
TApplication * GetApplication() const
Gets a pointer to the TApplication object associated with this.
Definition window.h:1855
void ChildBroadcastMessage(TMsgId, TParam1=0, TParam2=0)
Sends the specified message to all immediate children using SendMessage.
Definition window.cpp:3340
void SetBkgndColor(TColor color, bool shouldUpdate=true)
Sets the background color for the window.
Definition window.h:1925
TWindow()
Protected constructor for use by immediate virtually derived classes.
Definition window.cpp:392
void DrawMenuBar()
DrawMenuBar redraws the menu bar.
Definition window.h:3313
bool SetWindowPos(HWND hWndInsertAfter, const TRect &rect, uint flags)
Changes the size of the window pointed to by rect.
Definition window.h:2809
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
Definition window.cpp:644
auto GetChildren()
Returns a TWindow::TChildrenRange that can be iterated by standard means.
Definition window.h:550
virtual bool Create()
Creates the window interface element to be associated with this ObjectWindows interface element.
Definition window.cpp:2399
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
Definition window.h:2013
TWindow * GetWindowPtr(HWND hWnd) const
Calls TApplication:GetWindowPtr on the application associated with this window.
Definition window.h:3567
virtual void RemoveChild(TWindow *child)
Removes a child window.
Definition window.cpp:707
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
Definition window.h:2257
void SetWindowPlacement(const WINDOWPLACEMENT &place)
Wrapper for Windows API.
Definition window.cpp:3967
HICON EvQueryDragIcon()
The default message handler for WM_QUERYDRAGICON.
Definition window.h:4021
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
Definition window.h:2388
void Init(TWindow *parent, LPCTSTR title, TModule *module)
Normal initialization of a default constructed TWindow.
Definition window.cpp:401
void SetFlag(uint mask)
Sets the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
Definition window.h:1783
WINDOWPLACEMENT GetWindowPlacement() const
Wrapper for Windows API.
Definition window.cpp:3950
uint32 SetExStyle(uint32 style)
Sets the extra style bits of the window.
Definition window.cpp:3583
bool EvQueryNewPalette()
The default message handler for WM_QUERYNEWPALETTE.
Definition window.h:4028
void RouteCommandEnable(HWND hInitCmdTarget, TCommandEnabler &ce)
Walks the chain of windows from the initial target window to this window.
Definition window.cpp:1161
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
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
uint32 GetExStyle() const
Gets the extra style bits of the window.
Definition window.cpp:3575
virtual void CleanupWindow()
Always called immediately before the HWindow becomes invalid, CleanupWindow gives derived classes an ...
Definition window.cpp:2640
void GetWindowRect(TRect &rect) const
Gets the screen coordinates of the window's rectangle and copies them into rect.
Definition window.cpp:3609
HMENU GetMenu() const
Returns the handle to the menu of the indicated window.
Definition window.h:3244
TResult HandleMessage(TMsgId, TParam1=0, TParam2=0)
Dispatches the given message using the response table.
Definition window.cpp:1392
bool MoveWindow(int x, int y, int w, int h, bool repaint=false)
Repositions the specified window.
Definition window.h:2571
virtual bool IdleAction(long idleCount)
Called when no messages are waiting to be processed, IdleAction performs idle processing as long as t...
Definition window.cpp:671
uint32 GetStyle() const
Gets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
Definition window.cpp:3558
LPCTSTR GetCaption() const
Returns the Title member of TWindow.
Definition window.h:1900
TResult ForwardMessage(HWND handle, bool send=true)
Forwards the window's current message.
Definition window.cpp:3302
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
void SetWindowText(LPCTSTR str)
Sets the window's text to the given string (by copying).
Definition window.h:2669
virtual TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode)
WindowProc calls EvCommand to handle WM_COMMAND messages.
Definition window.cpp:999
uint32 SetStyle(uint32 style)
Sets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
Definition window.cpp:3567
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
bool PostMessage(TMsgId, TParam1=0, TParam2=0)
Posts a message (msg) to the window in the application's message queue.
Definition window.h:2103
virtual bool ShowWindow(int cmdShow)
Displays this TWindow in a given state.
Definition window.cpp:3713
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
Definition window.cpp:2575
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
void EvSize(uint sizeType, const TSize &size)
Response method for an incoming WM_SIZE message.
Definition window.cpp:1632
void EnableAutoCreate()
Ensures that an associated child window interface element is created and displayed along with its par...
Definition window.h:1805
void EvPaletteChanged(HWND hWndPalChg)
The default message handler for WM_PALETTECHANGED.
Definition window.h:3960
void GetClientRect(TRect &rect) const
Gets the coordinates of the window's client area and then copies them into the object referred to by ...
Definition window.cpp:3624
void EvInitMenuPopup(HMENU hPopupMenu, uint index, bool isSysMenu)
Handle WM_INITMENUPOPUP while embeded to generate command enable messages for our server menu items.
Definition window.cpp:3809
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
#define _stprintf
Definition cygwin.h:88
#define _tcsicmp
Definition cygwin.h:76
#define _T(x)
Definition cygwin.h:51
#define WM_OWLFRAMESIZE
Notify children of frame resizing.
Definition dispatch.h:4114
TDockable classes: TDockableGadgetWindow & TDockableControlBar TDockingSlip classes: TFloatingSlip & ...
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
#define WM_SETICON
Definition framewin.cpp:26
Definition of class TFrameWindow.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
#define IMPLEMENT_STREAMABLE1(cls, base1)
Definition objstrm.h:1725
void ReadVirtualBase(Base *base, ipstream &in)
Definition objstrm.h:1190
void WriteVirtualBase(Base *base, opstream &out)
Definition objstrm.h:1169
@ AutoDelete
Definition gdibase.h:70
@ NoAutoDelete
Definition gdibase.h:70
THandle GetHandle() const
Return the instance handle of the library module represented by the TModule obect.
Definition module.h:1233
#define NoErase
don't erase, wait for Paint
Definition window.h:116
#define NoColor
let DefWindowProc erase
Definition window.h:115
@ wfMainWindow
This frame window is the main window.
Definition window.h:63
@ wfFullyCreated
Window is fully created & not being destroyed.
Definition window.h:64
@ wfShrinkToClient
Shrink a frame window to its client's size.
Definition window.h:62
char * strnewdup(const char *s, size_t minAllocSize=0)
Definition memory.cpp:25
Definition of Window Menu encapsulation class.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
EV_WM_INITMENUPOPUP
Definition framewin.cpp:35
EV_WM_PALETTECHANGED
Definition framewin.cpp:40
unsigned char uint8
Definition number.h:32
unsigned long uint32
Definition number.h:34
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
TDispatch< WM_PARENTNOTIFY >::TArgs TParentNotify
Alias for convenience.
Definition dispatch.h:2894
OWL_DIAGINFO
Definition animctrl.cpp:14
EV_WM_SETFOCUS
Definition edit.cpp:84
EV_WM_PARENTNOTIFY
Definition docking.cpp:966
END_RESPONSE_TABLE
Definition button.cpp:26
EV_WM_QUERYNEWPALETTE
Definition framewin.cpp:39
LRESULT TResult
Result type.
Definition dispatch.h:52
std::string tstring
Definition defs.h:79
EV_WM_QUERYDRAGICON
Definition framewin.cpp:34
unsigned int uint
Definition number.h:25
TDispatch< WM_PARENTNOTIFY >::TChildInfoArgs TParentNotifyChildInfo
Alias for convenience.
Definition dispatch.h:2895
TModule & GetGlobalModule()
Definition global.cpp:48
EV_WM_SIZE
Definition decframe.cpp:34
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
Definition defs.h:376
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
Definition of TUIMetric, a UI metrics provider class.
#define WS_EX_STATICEDGE
Definition wsysinc.h:60
#define WS_EX_WINDOWEDGE
Definition wsysinc.h:30