OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
applicat.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 TApplication. This defines the basic behavior
7/// for ObjectWindows applications.
8//----------------------------------------------------------------------------
9
10#include <owl/pch.h>
11#include <owl/applicat.h>
12#include <owl/framewin.h>
13#include <owl/docmanag.h>
14#include <owl/appdict.h>
15#include <owl/messageb.h>
16#include <owl/window.rh>
17#include <owl/tooltip.h>
18#include "tracewnd.h"
19#include <vector>
20
21#if defined(OWL_SUPPORT_BWCC)
22# include <owl/private/bwcc.h>
23#endif
24
25
26#if defined(BI_MULTI_THREAD_RTL)
27# include <owl/thread.h>
28#endif
29
30using namespace std;
31
32#if defined(__BORLANDC__)
33# pragma option -w-ccc // Disable "Condition is always true/false"
34# pragma option -w-inl // Disable warning in standard library.
35#endif
36
37namespace owl {
39} // OWL namespace
40
41
42namespace owl {
43
44/// \addtogroup internal
45/// @{
46
47
48/////////////////////////////////////////////////////
49/// global definitions for both modules if sectioning
50struct TEnumInfo {
51 HWND ModalWnd; ///< The window being made modal if needed
52 short Count; ///< Count of windows in Wnds below
53 HWND* Wnds; ///< list of windows that were disabled
54 WNDPROC* PrevWndProc;//
55};
56
57//////////////////////////////////////////////////////////////////////////////////
58// Multithread support
59//
60class TWaitHook{
61 public:
62 TWaitHook();
63 ~TWaitHook();
64
65 void SetCursor(TCursor* cursor, TAutoDelete = AutoDelete);
66
67 private:
68 void FreeCursors();
69 void SetWaitCursor();
70
71 private:
72 TEnumInfo Subclass;
73 TEnumInfo* LastStackTop;
74 uint Count;
75 uint HideCaretCount;
76 TCursor* Cursor;
77 bool DeleteOnClose;
78
79 TResult WaitWndMethod(HWND, TMsgId, TParam1, TParam2);
80 TResult DefWndProc(HWND, TMsgId, TParam1, TParam2);
81
82 public:
83 static LRESULT CALLBACK WaitWndProc(HWND, UINT, WPARAM, LPARAM);
84};
85
86//
87struct TEnumInfoStr
89: public TLocalObject
90#endif
91{
92
93 TEnumInfoStr():Info(nullptr),Hook(nullptr),Top(nullptr)
94 {
95 }
96 ~TEnumInfoStr()
97 {
98 }
99
100 TEnumInfo* GetInfo() { return Info; }
101 void SetInfo(TEnumInfo* info) { Info = info; }
102
103 TEnumInfo* Info;
104 TWaitHook* Hook;
105 TWaitCursor* Top;
106
107#if defined(BI_MULTI_THREAD_RTL)
108 TMRSWSection Lock;
109#endif
110};
111//
112//
113static TEnumInfoStr& GetEnumInfo();
114
115//
116//
117//
118#if !defined(BI_MULTI_THREAD_RTL)
119struct TApplicatData {
120#else
121struct TApplicatData : public TLocalObject {
122#endif
123 TApplicatData();
124 ~TApplicatData();
125
126 TMessageBox OwlMsgBox;
127
128#if defined(BI_MULTI_THREAD_RTL)
129 TMRSWSection Lock;
130#endif
131};
132
133//
134static TApplicatData& GetApplicatData();
135
136//
137//
138//
139#if defined(BI_MULTI_THREAD_RTL) //TMRSWSection::TLock lock(GetEnumInfo().Lock);
140#define LOCKENUMINFO(l,s) TMRSWSection::TLock __lock(l,s)
141#else
142#define LOCKENUMINFO(l,s)
143#endif
144
145//
146//
147//
148#if defined(BI_MULTI_THREAD_RTL) //GetApplicatData().Lock,true
149#define LOCKAPPLDATA(l,s) TMRSWSection::TLock __lock(l,s)
150#else
151#define LOCKAPPLDATA(l,s)
152#endif
153
154/// @}
155
156
158
159// System Menu command "Diagnostic Window".
160// This system command is present in debug builds only, i.e. when either of the symbols __TRACE and
161// __WARN is defined. For more details, see EvSysCommand where the ScmTrace command is handled.
162//
163const auto ScmTrace = 0xFEC0;
164
165// -----------------------------------------------------------------------------
166static int
167OWLDefaultMsgBox(HWND wnd, LPCTSTR text, LPCTSTR caption, uint type)
168{
170 return ::MessageBoxEx(wnd, text, caption, type, app ? app->GetLangId() : LangNeutral);
171}
172// -----------------------------------------------------------------------------
173TApplicatData::TApplicatData()
174: OwlMsgBox(OWLDefaultMsgBox)
175{
176}
177// -----------------------------------------------------------------------------
178TApplicatData::~TApplicatData()
179{
180}
181
182//////////////////////////////////////////////////////////////////////////////////////////////////
183// multithread support
184//
185static
186TApplicatData& GetApplicatData()
187{
188//#if defined(BI_MULTI_THREAD_RTL)
189// static TProcessContainer<TApplicatData> __ApplData;
190//#else
191 static TApplicatData __ApplData;
192//#endif
193 return __ApplData;
194}
195//
196static
197TEnumInfoStr& GetEnumInfo()
198{
199//#if defined(BI_MULTI_THREAD_RTL)
200// static TProcessContainer<TEnumInfoStr> __EnumInfo;
201//#else
202 static TEnumInfoStr __EnumInfo;
203//#endif
204 return __EnumInfo;
205}
206
207// -----------------------------------------------------------------------------
208//
209// Static members for initialization of app prior to initial construction
210//
211HINSTANCE TApplication::InitHInstance;
212HINSTANCE TApplication::InitHPrevInstance;
213int TApplication::InitCmdShow;
214
215
216// -----------------------------------------------------------------------------
217_OWLFUNC(TMessageBox)
218SetDefMessageBox(TMessageBox newMsgBox)
219{
220 TApplicatData& data = GetApplicatData();
221 LOCKAPPLDATA(data.Lock,true);
222 TMessageBox msgBox = data.OwlMsgBox;
223 data.OwlMsgBox = newMsgBox;
224 return msgBox;
225}
226// -----------------------------------------------------------------------------
227_OWLFUNC(int)
228OWLMessageBox(HWND wnd, const tstring& text, const tstring& caption, uint type)
229{
230 return OWLMessageBox(wnd, text.c_str(), caption.c_str(), type);
231}
232// -----------------------------------------------------------------------------
233_OWLFUNC(int)
235{
236 // If no parent is supplied need to use task modal to disable all toplevel
237 // windows in this task.
238 //
239 if (!wnd && !(type & MB_SYSTEMMODAL))
241
242 LPCTSTR _caption = caption; // Older compilers like Borland C++ 5.5 do not allow assigning new value to caption
243 if (_caption == nullptr)
245 return (GetApplicatData().OwlMsgBox)(wnd, text, _caption, type);
246}
247// -----------------------------------------------------------------------------
248_OWLFUNC(int)
249OWLMessageBox(TWindow* wnd, TResId resId, const tstring& caption, uint type, TModule* module)
250{
251 return OWLMessageBox(wnd, resId, caption.c_str(), type, module);
252}
253// -----------------------------------------------------------------------------
254_OWLFUNC(int)
255OWLMessageBox(TWindow* wnd, TResId resId, LPCTSTR caption, uint type, TModule* module)
256{
257 TModule& m = module ? *module : wnd && wnd->GetModule() ? *wnd->GetModule() : GetGlobalModule();
258 tstring text = m.LoadString(resId.GetInt());
259 LPCTSTR _caption = caption; // Older compilers like Borland C++ 5.5 do not allow assigning new value to caption
260 if (_caption == nullptr && wnd && wnd->GetApplication())
261 _caption = wnd->GetApplication()->GetName();
262
263 HWND h = wnd ? wnd->GetHandle() : static_cast<HWND>(nullptr);
264 return OWLMessageBox(h, text, _caption, type);
265}
266
267// -----------------------------------------------------------------------------
268//
269/// Gets WinMain's 3rd param.
270//
271tstring&
272TApplication::GetInitCmdLine()
273{
274 static tstring InitCmdLine;
275 return InitCmdLine;
276};
277
278//
279/// Constructor for use in OwlMain(). Gets members from statics set earlier by
280/// a call to InitWinMainParams() in Owl's WinMain.
281//
282/// Creates a new TApplication object named name. You can use owl::Module to specify the
283/// global module pointer that points to this application. The appDict parameter
284/// specifies which dictionary this application will insert itself into. To override
285/// the default ObjectWindows TAppDictionary object, pass a pointer to a
286/// user-supplied appDict object.
287//
288TApplication::TApplication(LPCTSTR name, TModule*& module, TAppDictionary* appDict)
289:
290 TModule(name, InitHInstance, GetInitCmdLine()),
291 TMsgThread(TMsgThread::Current),
292 // Copy over values that were stashed in static members before this instance
293 // was constructed.
294 //
295 hPrevInstance(InitHPrevInstance), nCmdShow(InitCmdShow),
296 DocManager(nullptr), MainWindow(nullptr),
297 LangId(LangUserDefault),
298 Tooltip(nullptr),
299 CmdLine(GetInitCmdLine()),
300 WaitCount(0),
301 WaitHandles(nullptr),
304#endif
307#endif
308 CurrentEvent(),
309 CurrentException(),
310 CondemnedWindows(nullptr),
311 Dictionary(appDict ? appDict : &(OWLGetAppDictionary()))
312{
313 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructing @") << (void*)this);
314
315 Dictionary->Add(this);
316 module = this;
317
318 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructed @") << (void*)this);
319}
320
321//
322/// String-aware overload
323//
325 :
326 TModule(name, InitHInstance, GetInitCmdLine()),
327 TMsgThread(TMsgThread::Current),
328 // Copy over values that were stashed in static members before this instance
329 // was constructed.
330 //
331 hPrevInstance(InitHPrevInstance), nCmdShow(InitCmdShow),
332 DocManager(nullptr), MainWindow(nullptr),
333 LangId(LangUserDefault),
334 Tooltip(nullptr),
335 CmdLine(GetInitCmdLine()),
336 WaitCount(0),
337 WaitHandles(nullptr),
340#endif
343#endif
344 CurrentEvent(),
345 CurrentException(),
346 CondemnedWindows(nullptr),
347 Dictionary(appDict ? appDict : &(OWLGetAppDictionary()))
348{
349 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructing @") << (void*)this);
350
351 Dictionary->Add(this);
352 module = this;
353
354 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructed @") << (void*)this);
355}
356
357//
358/// Constructor for use in user defined WinMain() when all the args are
359/// available
360//
361/// Creates a TApplication object with the application name (name), the application
362/// instance handle (instance), the previous application instance handle
363/// (prevInstance), the command line invoked (cmdLine), and the main window show
364/// flag (cmdShow). The appDict parameter specifies which dictionary this
365/// application will insert itself into. To override the default ObjectWindows
366/// TAppDictionary object, pass a pointer to a user-supplied appDict object.
367///
368/// If you want to create your own WinMain, use this constructor because it provides
369/// access to the various arguments provided by WinMain. You can use module to to
370/// specify the global module pointer that points to this application.
371//
373 (
377 const tstring& cmdLine,
378 int cmdShow,
379 TModule*& module,
381 )
382:
384 TMsgThread(TMsgThread::Current),
385 hPrevInstance(prevInstance), nCmdShow(cmdShow),
386 DocManager(nullptr), MainWindow(nullptr),
387 LangId(LangUserDefault),
388 Tooltip(nullptr),
389 CmdLine(cmdLine),
390 WaitCount(0),
391 WaitHandles(nullptr),
394#endif
397#endif
398 CurrentEvent(),
399 CurrentException(),
400 CondemnedWindows(nullptr),
401 Dictionary(appDict ? appDict : &(OWLGetAppDictionary()))
402{
403 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructing @") << (void*)this);
404
405 Dictionary->Add(this);
406 module = this;
407
408 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructed @") << (void*)this);
409}
410
411//
412/// String-aware overload
413//
415(
416 const tstring& name,
419 const tstring& cmdLine,
420 int cmdShow,
421 TModule*& module,
423)
424 :
426 TMsgThread(TMsgThread::Current),
427 hPrevInstance(prevInstance), nCmdShow(cmdShow),
428 DocManager(nullptr), MainWindow(nullptr),
429 LangId(LangUserDefault),
430 Tooltip(nullptr),
431 CmdLine(cmdLine),
432 WaitCount(0),
433 WaitHandles(nullptr),
436#endif
439#endif
440 CurrentEvent(),
441 CurrentException(),
442 CondemnedWindows(nullptr),
443 Dictionary(appDict ? appDict : &(OWLGetAppDictionary()))
444{
445 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructing @") << (void*)this);
446
447 Dictionary->Add(this);
448 module = this;
449
450 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication constructed @") << (void*)this);
451}
452
453//
454/// ~TApplication destroys the TApplication object.
455//
457{
458 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication destructing @") << (void*)this);
459
460 DeleteCondemned();
461
462#if defined(OWL_SUPPORT_CTL3D)
463 // Unregister ourselves from the Ctl3d DLL if it is loaded.
464 //
465 if (Ctl3dModule) {
466 Ctl3dModule->Unregister(*this);
467 delete Ctl3dModule;
468 }
469#endif
470#if defined(OWL_SUPPORT_BWCC)
471 // Unregister ourselves from the BWCC DLL if it is loaded.
472 if (BWCCModule) {
473 BWCCModule->IntlTerm();
474 delete BWCCModule;
475 }
476#endif
477
478 // Delete the main window if still present, may be destroyed but not deleted
479 // Set MainWindow to 0 first to prevent it from calling ::PostQuitMessage
480 //
481 TWindow* mainWindow = SetMainWindow(nullptr);
482 if (mainWindow) {
483 mainWindow->Destroy();
484 delete mainWindow;
485 delete Tooltip; // if SetMainWindow(0) need manually delete Tooltip
486 }
487
488 delete DocManager;
489
490 // Remove this app from the application dictionary that it is in
491 //
492 Dictionary->Remove(this);
493
494 TRACEX(OwlApp, OWL_CDLEVEL, _T("TApplication destructed @") << (void*)this);
495}
496
497
498//
499/// Open a modal message box, Under WIN32 the language id setting is used.
500//
501int
503{
504 // Default caption to this application's name
505 //
506 if (caption == nullptr)
507 caption = GetName();
508
509 // If no parent is supplied need to use task modal to disable all toplevel
510 // windows in this task.
511 //
512 if (!wnd && !(type & MB_SYSTEMMODAL))
514
515#if defined(OWL_SUPPORT_BWCC)
516 // Use the BWCC message box if BWCC is enabled
517 //
518 if (BWCCEnabled() && GetBWCCModule()) {
519 return GetBWCCModule()->MessageBox( wnd, text, caption, type);
520 }
521 else
522#endif
523 // Otherwise, 3d-ize the message box if ctl3d is enabled
524 //
525#if defined(OWL_SUPPORT_CTL3D)
526 {
528 int retValue = (GetApplicatData().OwlMsgBox)(wnd, text, caption, type);
530 return retValue;
531 }
532#else
533 return (GetApplicatData().OwlMsgBox)(wnd, text, caption, type);
534#endif
535}
536
537//
538/// Handle initialization for the first executing instance of the OWL
539/// application. Under Win32, every app instance is treated as the first.
540//
541/// Derived classes can override this to perform app initialization, or they
542/// can use the derived class constructor.
543//
544/// The following sample program calls InitApplication the first time an instance of
545/// the program begins.
546/// \code
547/// class TTestApp : public TApplication {
548/// public:
549/// TTestApp(): TApplication("Instance Tester")
550/// { strcpy(WindowTitle, "Additional Instance");}
551/// protected:
552/// char WindowTitle[20];
553/// void InitApplication() { strcpy(WindowTitle, "First Instance"); }
554/// void InitMainWindow() { MainWindow = new TFrameWindow(0, WindowTitle); }
555/// };
556/// static TTestApp App;
557/// \endcode
558//
559void
561{
562 TRACEX(OwlApp, 1, _T("TApplication::InitApplication() called @") << (void*)this);
563}
564
565
566//
567/// Performs each instance initialization necessary for the application. Unlike
568/// InitApplication(), which is called for the first instance of an application,
569/// InitInstance is called whether or not there are other executing instances of the
570/// application. InitInstance calls InitMainWindow(), and then creates and shows the
571/// main window element by TWindow::Create and TWindow::Show. If the main window
572/// cannot be created, a TXInvalidMainWindow exception is thrown.
573//
574/// \note If you redefine this member function, be sure to explicitly call
575/// TApplication::InitInstance.
576//
577void
579{
581
582 TRACEX(OwlApp, 1, _T("TApplication::InitInstance() called @") << (void*)this);
583
585
586 if (MainWindow) {
587 MainWindow->SetFlag(wfMainWindow);
588 MainWindow->Create();
589
590#if defined(__TRACE) || defined(__WARN)
591
592 TSystemMenu sysMenu{MainWindow->GetHandle()};
593 if (sysMenu.IsOK())
594 {
595 sysMenu.AppendMenu(MF_SEPARATOR);
596 sysMenu.AppendMenu(MF_STRING, ScmTrace, _T("Diagnostic Window"));
597 }
598
599#endif
600
601 MainWindow->ShowWindow(nCmdShow);
602 }
603 else
605}
606
607
608//
609/// Initialize the application's main window. Derived classes should override
610/// this to construct, initialize and set the main window using SetMainWindow().
611//
612/// By default, InitMainWindow constructs a generic TFrameWindow object with the
613/// name of the application as its caption. You can redefine InitMainWindow to
614/// construct a useful main window object of TFrameWindow (or a class derived from
615/// TFrameWindow) and store it in MainWindow. The main window must be a top-level
616/// window; that is, it must be derived from TFrameWindow. A typical use is
617/// \code
618/// virtual void TMyApp_InitMainWindow(){
619/// SetMainWindow(TMyWindow(nullptr, Caption));
620/// }
621/// \endcode
622/// InitMainWindow can be overridden to create your own custom window.
623//
624void
629
630
631//
632/// Handle termination for each executing instance of the application. Called
633/// at the end of a Run() with the final return status.
634//
635int
637{
638 TRACEX(OwlApp, 1, _T("TApplication::TermInstance() called @") << (void*)this);
639
640#if defined(__TRACE) || defined(__WARN)
641
642 // If open, destroy the Diagnostic Window.
643 // See ProcessAppMsg, where the window is created.
644 //
647
648#endif
649
650 return TMsgThread::TermInstance(status);
651}
652
653//
654/// Set (or reset) the main window. Return, but do not destroy the previous
655/// main window.
656//
659{
660 if (MainWindow) {
661 MainWindow->ClearFlag(wfMainWindow);
662 uint32 style = MainWindow->GetExStyle();
663 if (style & WS_EX_APPWINDOW)
664 MainWindow->SetExStyle(style & ~WS_EX_APPWINDOW);
665 if(Tooltip && Tooltip->GetParentO()==MainWindow)
666 Tooltip->SetParent(nullptr);
667 }
668
669 TFrameWindow* oldMainWindow = MainWindow;
670 MainWindow = window;
671
672 if (MainWindow) {
673 MainWindow->SetFlag(wfMainWindow);
674 uint32 style = MainWindow->GetExStyle();
675 if (!(style & WS_EX_APPWINDOW))
676 MainWindow->SetExStyle(style | WS_EX_APPWINDOW);
677 // set new parent only if MainWindow created
678 if(Tooltip && Tooltip->GetParentO()==nullptr && MainWindow->GetHandle())
679 Tooltip->SetParent(MainWindow);
680 }
681 return oldMainWindow;
682}
683
684//
685/// Smart-pointer-aware overload.
686//
687auto TApplication::SetMainWindow(std::unique_ptr<TFrameWindow> f) -> std::unique_ptr<TFrameWindow>
688{
689 auto old = std::unique_ptr<TFrameWindow>{SetMainWindow(f.get())};
690 f.release(); // We took ownership.
691 return old;
692}
693
694//
695/// Set (or resets) the document manager, return the previous one if present
696//
699{
700 TDocManager* oldDocManager = DocManager;
701 DocManager = docManager;
702 return oldDocManager;
703}
704
705//
706/// Smart-pointer-aware overload.
707//
708auto TApplication::SetDocManager(std::unique_ptr<TDocManager> d) -> std::unique_ptr<TDocManager>
709{
710 auto old = std::unique_ptr<TDocManager>{SetDocManager(d.get())};
711 d.release(); // We took ownership.
712 return old;
713}
714
715#if defined(BI_MULTI_THREAD_RTL)
716//
717/// BI_MULTI_THREAD_RTL only: Overrides TEventHandler::Dispatch() to handle
718/// multi-thread synchonization.
719//
721{
722 TApplication::TQueueLock lock(*this);
724}
725#endif
726
727//
728/// Run this application, return when application terminates
729//
730/// Initialize instances, create and display their main window (calls
731/// InitApplication for the first executing instance and calls InitInstance for
732/// all instances). Run the application's message loop. Each of the virtual
733/// functions called are expected to throw an exception if there is an error.
734///
735/// Exceptions are propagated out of this function, but the message queue is still
736/// flushed and TermInstance called in the event of an exception.
737//
738int
740{
741 try
742 {
743 if (!MainWindow)
744 {
745 if (!hPrevInstance)
747 InitInstance();
748 }
749 LoopRunning = true;
750 int status = MessageLoop();
751 FlushQueue();
752 LoopRunning = false;
753 return TermInstance(status);
754 }
755 catch (...)
756 {
757 FlushQueue();
758 LoopRunning = false;
759 TermInstance(-1);
760 throw;
761 }
762}
763
764//
765/// Start this application and return immediately. Used for component DLLs
766//
767/// Initializes instances, creating and displaying their main window (calls
768/// InitApplication for the first executing instance and calls InitInstance for
769/// all instances). Each of the virtual functions called are expected to throw
770/// an exception if there is an error. Any exceptions are handled and converted
771/// to an error code which is then returned. Returns 0 on success.
772/// Does not run message loop.
773//
774int
776{
777 int status = 0;
778 try {
779 if (!hPrevInstance)
781 InitInstance();
782 }
783 catch (TXOwl& x) {status = x.Unhandled(this, 0);}
784 catch (TXBase& x) {status = Error(x, 0);}
785 catch (...) {status = -1;}
786 return status;
787}
788
789//
790/// Operates the application's message loop, which runs during the lifetime of the
791/// application. MessageLoop queries for messages. If one is received, it processes
792/// it by calling ProcessAppMsg. If the query returns without a message, MessageLoop
793/// calls IdleAction to perform some processing during the idle time.
794///
795/// MessageLoop calls PumpWaitingMessages to get and dispatch waiting messages.
796/// MessageLoop can be broken if BreakMessageLoop is set by EndModal.
797//
798int
800{
801 long idleCount = 0;
803 while (!BreakMessageLoop)
804 {
805 try
806 {
807 if (!IdleAction(idleCount++))
808 {
809 DWORD r = MsgWaitForMultipleObjects(WaitCount, WaitHandles, FALSE, INFINITE, QS_ALLINPUT);
810 if (r >= WAIT_OBJECT_0 && r < WAIT_OBJECT_0 + WaitCount)
811 ObjectSignaled(WaitHandles[r - WAIT_OBJECT_0], false);
812 else if (r >= WAIT_ABANDONED_0 && r < WAIT_ABANDONED_0 + WaitCount)
813 ObjectSignaled(WaitHandles[r - WAIT_ABANDONED_0], true);
814 }
816 idleCount = 0;
817 ResumeThrow();
818 }
819 catch (...)
820 {
821 BreakMessageLoop = true;
823 throw;
824 }
825 }
826 BreakMessageLoop = false;
827 return MessageLoopResult;
828}
829
830//
831/// Called each time there are no messages in the queue. Idle count is
832/// incremented each time, & zeroed when messages are pumped. Return
833/// whether or not more processing needs to be done.
834//
835/// Default behavior is to give the main window an opportunity to do idle
836/// processing by invoking its IdleAction() member function when
837/// "idleCount" is 0
838//
839bool
841{
842 TRACEX(OwlApp, 1, _T("TApplication::IdleAction() called @") << (void*)this <<
843 _T(" idleCount ") << idleCount);
844 bool more = false;
845 if (MainWindow)
846 more = MainWindow->IdleAction(idleCount);
847
848#if defined(__TRACE) || defined(__WARN)
849
850 // If open, let the Diagnostic Window process diagnostics.
851 // See TApplication::ProcessAppMsg, where the window is opened (or closed).
852 //
853 const auto diagIdleAction = [](long idleCount)
854 {
855 LOCKAPPLDATA(GetApplicatData().Lock, true);
856 bool more = false;
857 const auto t = TTraceWindow::GetInstance();
858 if (t && t->IdleAction(idleCount))
859 more = true;
860 return more;
861 };
863 more = true;
864
865#endif
866
867 return more;
868}
869
870//
871/// Called for each message that is pulled from the queue, to perform all
872/// translation & dispatching.
873///
874/// Return true to drop out of pump
875//
876bool
878{
879 // Let the app preprocess the message. If it is not eaten, then translate
880 // it, & dispatch it. If no HWND, then first find/dispatch it directly
881 // to the app (for PostAppMessage() functionality)
882 //
883 if (!ProcessAppMsg(msg)) {
885 if (!msg.hwnd) {
886 TEventInfo cmdEventInfo(msg.message, static_cast<uint>(msg.wParam));
887 if (Find(cmdEventInfo)) {
888 Dispatch(cmdEventInfo, msg.wParam, msg.lParam);
889 return true;
890 }
891 else {
892 TEventInfo eventInfo(msg.message);
893 if (Find(eventInfo)) {
894 Dispatch(eventInfo, msg.wParam, msg.lParam);
895 return true;
896 }
897 }
898 }
900 DeleteCondemned();
901 ResumeThrow();
902 }
903 return false;
904}
905
906//
907/// Called after each message is pulled from the queue, and before it is
908/// dispatched. Return true if the message was handled completely here.
909//
910/// Checks for any special processing that is required for modeless dialog box,
911/// accelerator, and MDI accelerator messages. Calls the virtual
912/// TWindow::PreProcessMsg function of the window receiving the message. If your
913/// application does not create modeless dialog boxes, does not respond to
914/// accelerators, and is not an MDI application, you can improve performance by
915/// overriding this member function to return false.
916//
917bool
919{
920 // Check if this message might be worth relaying to the tooltip window
921 //
922 if (Tooltip && Tooltip->IsWindow()) {
923 if (msg.hwnd == *MainWindow || MainWindow->IsChild(msg.hwnd)) {
924 if (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST) {
925 Tooltip->RelayEvent(msg);
926 }
927 }
928 }
929
930 // Start with the window that the event was destined for and allow it
931 // and its parent (and its parent...) an opportunity to preprocess the
932 // event
933 //
934 for (HWND hWnd = msg.hwnd; hWnd; hWnd = ::GetParent(hWnd)) {
935 // NT seems very picky about calls to ::GetWindowThreadProcessId
936 // with the HWND of the desktop. Hence we'll abort this loop
937 // when encountering the desktop. Specially useful when dealing with
938 // DropDown[List] ComboBoxes thunked by OWL when hit the ComboLBox
939 // window which is parented to the Desktop.
940 //
941 static HWND deskTopHwnd = ::GetDesktopWindow();
942 if (hWnd == deskTopHwnd)
943 break;
944
945 TWindow* win = GetWindowPtr(hWnd);
946
947 if (win && win->PreProcessMsg(msg))
948 return true;
949 }
950
951 return false;
952}
953
955{
956 bool exists = false;
957 int index;
958
959 if (WaitHandles)
960 {
961 for (int i = 0; i < static_cast<int>(WaitCount); i++) //JJH added static_cast
962 if (WaitHandles[i] == handle)
963 {
964 exists = true;
965 index = i;
966 }
967 }
968
969 if (wait)
970 {
971 if (!exists)
972 {
973 LPHANDLE newHandles = new HANDLE[WaitCount + 1];
974 for (int i = 0; i < static_cast<int>(WaitCount); i++) //JJH added static_cast
975 newHandles[i] = WaitHandles[i];
976 delete[] WaitHandles;
977 WaitHandles = newHandles;
978 WaitHandles[WaitCount] = handle;
979 WaitCount++;
980 }
981 }
982 else
983 {
984 if (exists)
985 {
986 if (WaitCount == 1)
987 {
988 delete[] WaitHandles;
989 WaitHandles = nullptr;
990 WaitCount = 0;
991 }
992 else
993 {
994 LPHANDLE newHandles = new HANDLE[WaitCount - 1];
995
996 int i;
997 for (i = 0; i < index; i++)
998 newHandles[i] = WaitHandles[i];
999 for (i = index + 1; i < static_cast<int>(WaitCount); i++) //JJH added static_cast
1000 newHandles[i-1] = WaitHandles[i];
1001 delete[] WaitHandles;
1002 WaitHandles = newHandles;
1003 WaitCount--;
1004 }
1005 }
1006 }
1007}
1008
1009//
1010/// Stores the given exception so that it can be rethrown later by a call to ResumeThrow.
1011/// Calls PostQuitMessage to break the application message loop, thus ensuring that the
1012/// application will not linger in a corrupt state.
1013//
1014void
1016{
1017 TRACEX(OwlApp, 0, _T("TApplication::SuspendThrow: Suspending exception and posting quit-message."));
1018 CurrentException = e;
1020}
1021
1022//
1023/// Rethrows the suspended exception stored by a previous call to SuspendThrow.
1024/// Otherwise, if no exception has been suspended, does nothing.
1025//
1026void
1028{
1029 if (CurrentException == nullptr) return;
1030
1031 TRACEX(OwlApp, 0, _T("TApplication::ResumeThrow: Rethrowing suspended exception."));
1032 exception_ptr e = CurrentException;
1033 CurrentException = exception_ptr(); // clear
1035}
1036
1037
1038//
1039/// If TApplication's message loop is not used, this function should be called after
1040/// each message is dispatched
1041//
1042void
1044{
1045 DeleteCondemned();
1046 ResumeThrow();
1047
1048 MSG msg;
1049 if (!::PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE))
1050 IdleAction(0);
1051}
1052
1053
1054//
1055//
1056//
1057void
1059{
1060 if (!Tooltip) {
1061 // To circumvent this scenario, we'll look for a window which is fairly
1062 // stable/rooted as owner of the tooltip. Ideally, we'll get the
1063 // application's main window.
1064 //
1065 TWindow* tipParent = MainWindow;
1066 if(!MainWindow->GetHandle())
1067 tipParent = nullptr;
1068 // Create and initialize tooltip
1069 //
1071 }
1072 else {
1073 if (Tooltip->GetHandle())
1074 Tooltip->Activate(enable);
1075 }
1076}
1077
1078//
1079/// Set tooltip . Assume we now own the ToolTip
1080//
1081void
1083{
1084 // Cleanup; via Condemned list if tooltip was created
1085 //
1086 if (Tooltip) {
1087 if (Tooltip->GetHandle())
1088 Tooltip->SendMessage(WM_CLOSE);
1089 else
1090 delete Tooltip;
1091 }
1092
1093 // Store new tooltip and create if necessary
1094 // Create only if MainWindows already created
1095 Tooltip = tooltip;
1096 if (Tooltip && !Tooltip->GetHandle() &&
1097 MainWindow && MainWindow->GetHandle()) {
1098 if(!Tooltip->GetParentO())
1099 Tooltip->SetParent(MainWindow);
1100 // Make sure tooltip is disabled so it does not take input focus
1101 Tooltip->ModifyStyle(0,WS_DISABLED);
1102 Tooltip->Create();
1103 }
1104}
1105
1106//
1107/// Does internal processing of system menu messages.
1108/// In particular, it handles the command "Diagnostic Window" on the system menu in debug builds.
1109//
1110void TApplication::EvSysCommand([[maybe_unused]] uint cmd, const TPoint&)
1111{
1112
1113#if defined(__TRACE) || defined(__WARN)
1114
1115 // If the user selects ScmTrace ("Diagnostic Window") from the main window's system menu,
1116 // then create the Diagnostic Window, if it does not already exist, or destroy it, if it does.
1117 // See InitInstance, where the menu item is created for the debug build.
1118 // See IdleAction, where diagnostic messages are processed.
1119 // See TermInstance, where the window is closed on exit.
1120 //
1121 switch (cmd & 0xFFF0)
1122 {
1123 case ScmTrace:
1124 {
1125 LOCKAPPLDATA(GetApplicatData().Lock, false);
1128 else
1129 {
1130 const auto t = TTraceWindow::GetInstance(true);
1131 t->Create();
1132 t->ShowWindow(SW_SHOWNORMAL);
1133 }
1134 return;
1135 }
1136 }
1137
1138 // Update the checkmark on the system menu command "Diagnostic Window".
1139 //
1140 if (cmd & (SC_KEYMENU | SC_MOUSEMENU))
1141 if (const auto w = GetMainWindow())
1142 if (const auto h = w->GetHandle())
1143 {
1145 TSystemMenu{h}.CheckMenuItem(ScmTrace, MF_BYCOMMAND | c);
1146 }
1147
1148#endif
1149
1150 if (const auto m = GetMainWindow())
1151 m->DefaultProcessing();
1152}
1153
1154//
1155/// Close down main window if application receives a CM_EXIT command.
1156//
1157void
1158TApplication::CmExit()
1159{
1160 TFrameWindow* frame = GetMainWindow();
1161 if (frame) {
1162 frame->SendMessage(WM_CLOSE);
1163 DeleteCondemned();
1164 }
1165}
1166
1167//
1168/// Overrides TEventHandler::Find.
1169/// If a DocManager has been installed, TDocManager::Find is called first to give it an opportunity
1170/// to handle the event.
1171///
1172/// \note Since TApplication needs a custom implementation of Find, the common implementation
1173/// provided by the response table macros can not be used. For that reason, the response table for
1174/// TApplication is implemented explicitly within this function.
1175//
1176auto TApplication::Find(TEventInfo& eventInfo, TEqualOperator equal) -> bool
1177{
1178 const auto r = DocManager ? DocManager->Find(eventInfo, equal) : false;
1179 if (r) return true;
1180
1181#if OWL_NEW_RESPONSE_TABLE
1182
1183 using TEntry = TResponseTableEntry;
1184
1185#else
1186
1187 using TEntry = TResponseTableEntry<TApplication>;
1188 using TMyPMF = TResponseTableEntry<TApplication>::PMF; // Needed for the reponse table macros.
1189
1190#endif
1191
1192 using TMyClass = TApplication; // Needed for the reponse table macros.
1193 static const TEntry entries[] =
1194 {
1196 EV_COMMAND(CM_EXIT, CmExit),
1197 {} // Sentinel is required.
1198 };
1199 eventInfo.Object = reinterpret_cast<TGeneric*>(this);
1200 return SearchEntries(reinterpret_cast<const TGenericTableEntry*>(entries), eventInfo, equal) ||
1202}
1203
1204//
1205/// Determine whether the application can be closed.
1206/// Makes sure the MainWindow can close & doc manager can close.
1207//
1208/// Returns true if it is OK for the application to close. By default, CanClose
1209/// calls the CanClose member function of its main window and returns true if both
1210/// the main window and the document manager (TDocManager) can be closed. If any of
1211/// the CanClose functions return false, the application does not close.
1212///
1213/// This member function is seldom redefined; closing behavior is usually redefined
1214/// in the main window's CanClose member function, if needed.
1215//
1216bool
1218{
1220 return (!MainWindow || MainWindow->CanClose())
1221 && (!DocManager ||!DocManager->Find(eventInfo)
1222 || DocManager->Dispatch(eventInfo, 0, 0));
1223}
1224
1225//
1226/// Called by the main window to provide an oportunity to preprocess the main
1227/// window's menubar before it is installed.
1228/// Normally delegated to the doc manager to install a file menu as needed
1229//
1230void
1232{
1234 if (DocManager && DocManager->Find(eventInfo)) {
1235 DocManager->Dispatch(eventInfo, TParam1(hMenubar), 0);
1236 MainWindow->DrawMenuBar();
1237 }
1238}
1239
1240//
1241/// Condemns the given window to be deleted the at the next available safe time.
1242///
1243/// Appends the window to the list of condemned windows.
1244///
1245/// \note Condemned windows should be removed (see TApplication::Uncondemn) if they are destructed
1246/// in the mean time through some other mechanism (i.e. stack, aggregate, etc).
1247///
1248/// \note It is assumed that the condemned window was constructed using `new`. If it was
1249/// constructed by other means, do not pass it to this function. Instead ensure it is destructed in
1250/// the appropriate way.
1251///
1252/// \note While it in previous versions of OWLNext was unsafe for a window in the process of
1253/// destruction to condemn other windows (e.g. child or buddy), it is now safe to do so.
1254//
1255void
1257{
1258 PRECONDITION(win);
1259 TRACEX(OwlApp, 1, _T("Condemning window @") << (void*)win << *win);
1260 win->SetParent(nullptr);
1261
1262 // Insert the new window to be deleted at the end of the list.
1263 //
1264 win->SetNext(nullptr);
1265 if (CondemnedWindows)
1266 {
1267 TWindow* eol;
1268 for (eol = CondemnedWindows; eol->Next(); eol = eol->Next())
1269 if (eol==win)
1270 {
1271 CHECK(!"Double condemn is not nice!");
1272 return; //already condemned
1273 }
1274 eol->SetNext(win);
1275 }
1276 else{
1277 CondemnedWindows = win;
1278 }
1279}
1280
1281//
1282/// Removes the given window from the list of condemned windows.
1283/// If the given window is not in the list of condemned windows, the function does nothing.
1284//
1285void
1287{
1288 if (win && CondemnedWindows) {
1289 TWindow* w = nullptr;
1290 if (CondemnedWindows != win)
1291 for (w = CondemnedWindows; w->Next() != win; w = w->Next())
1292 if (!w->Next())
1293 return;
1294
1295 TRACEX(OwlApp, 1, _T("Uncondemning window @") << (void*)win << *win);
1296 if (w)
1297 w->SetNext(win->Next());
1298 else
1299 CondemnedWindows = win->Next();
1300 }
1301}
1302
1303//
1304/// Deletes all entries in the list of condemned windows.
1305///
1306/// If new additions to the list of condemned windows are made in the process of deleting the
1307/// condemned windows, these additions are also deleted, and so on, until the list of condemned
1308/// windows is empty.
1309///
1310/// \note It is assumed that the condemned windows were constructed using `new`, as each entry is
1311/// destructed using `delete`.
1312//
1313void
1314TApplication::DeleteCondemned()
1315{
1316 // Note that deleting a condemned window will cause its destructor to be called, which may call
1317 // TApplication::Condemn as part of the destruction (e.g. condemning its children or a buddy).
1318 // The original code did not support this, as it simply walked the linked list while deleting the
1319 // nodes, thereby possibly crashing or ignoring additions to the list while traversing it. For
1320 // more robust code, we now copy the condemned windows into a temporary vector, then clear the
1321 // list (ready for additions), and finally delete the condemned windows collected in the vector.
1322 // In case there were additions while deleting, we repeat this sequence until the condemned list
1323 // is empty.
1324 //
1325 do
1326 {
1327 auto c = vector<TWindow*>{};
1328 while (CondemnedWindows)
1329 {
1330 const auto next = CondemnedWindows->Next();
1331 c.push_back(CondemnedWindows);
1332 CondemnedWindows = next;
1333 }
1334 for (const auto w : c)
1335 {
1336 TRACEX(OwlApp, 1, _T("Deleting condemned window @") << w << *w);
1337 delete w;
1338 }
1339 }
1340 while (CondemnedWindows);
1341}
1342
1343
1344
1345//
1346/// Constructs a TXInvalidMainWindow object with a default IDS_INVALIDMAINWINDOW
1347//
1353
1356{
1357 return new TXInvalidMainWindow(*this);
1358}
1359
1360//
1361/// Throws the exception object. Throw must be implemented in any class derived from
1362/// TXOwl.
1363//
1364void
1366{
1367 throw *this;
1368}
1369
1370//
1371/// Throws a TXInvalidMainWindow exception.
1372//
1373void
1378
1379
1380//
1381/// Enum[Thread/Task]Windows callback. Counts or disables given window based on
1382/// whether or not window list has been allocated yet.
1383//
1384static bool CALLBACK
1385disableWnds(HWND hWnd, TEnumInfo * ei)
1386{
1387 if (!(::GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)) {
1388 if (hWnd != ei->ModalWnd && ::IsWindowEnabled(hWnd)) {
1389 if (!ei->Wnds) {
1390 ei->Count++; // no buffer yet, we are just counting
1391 }
1392 else {
1393 *(ei->Wnds++) = hWnd;
1394 ::EnableWindow(hWnd, false);
1395 }
1396 }
1397 }
1398 return true;
1399}
1400
1401//
1402/// Terminate the modal state initiated by BeginModal. Needs topmost ei block,
1403/// and cleans the block up as needed inorder to be safe to be called twice.
1404//
1405static void termModal(TEnumInfo& ei)
1406{
1407 // Re-enable window(s) that are disabled in BeginModal()
1408 //
1409 if (ei.Wnds) {
1410 for (HWND* hWnd = ei.Wnds; *hWnd; hWnd++)
1411 ::EnableWindow(*hWnd, true);
1412 delete[] ei.Wnds;
1413 ei.Wnds = nullptr;
1414 }
1415 else {
1416 if (ei.ModalWnd && IsWindow(ei.ModalWnd)) {
1417 ::EnableWindow(ei.ModalWnd, true);
1418 ei.ModalWnd = nullptr;
1419 }
1420 }
1421}
1422
1423//
1424/// Called to begin a modal window's modal message loop. After determining which
1425/// window to disable, BeginModal saves the current status of the window, disables
1426/// the window, calls MessageLoop, and then reenables the window when the message
1427/// loop is finished. The flags determine how BeginModal treats the window. flags
1428/// can be one of the following values:
1429///
1430/// - \c \b MB_APPLMODAL The window to be disabled (which is usually an ancestor of the
1431/// modal window) is identified by window. If window is 0, no window is disabled.
1432/// - \c \b MB_SYSTEMMODAL The window to become system modal is identified by window.
1433/// - \c \b MB_TASKMODAL All top-level windows are disabled, and window is ignored.
1434///
1435/// BeginModal returns -1 if an error occurs.
1436//
1437int
1439{
1440 // lock enuminfo if multithreading
1441 TEnumInfo ei = { nullptr, 0, nullptr, nullptr};
1442 TEnumInfo* lastStackTop;
1443 {
1444 TEnumInfoStr& data = GetEnumInfo();
1445 LOCKENUMINFO(data.Lock, false); // Y.B. do we have do lock here ?????????
1446 lastStackTop = data.GetInfo(); // Keep last stackTop to restore later
1447 data.SetInfo(&ei); // Point stackTop to topmost ei
1448 }
1449
1450 // The concept of SYSTEM MODAL applies only to the 16-bit environment of
1451 // Windows. The semantics of TASKMODAL is the closest to SYSMODAL in
1452 // 32-bit - specially in relation to the meaning of the 'window' parameter.
1453 // So we'll coerce SYSTEM MODAL to TASK MODAL
1454 //
1455 if (flags & MB_SYSTEMMODAL) {
1456 flags &= ~MB_SYSTEMMODAL;
1457 flags |= MB_TASKMODAL;
1458 }
1459
1460 // Check modal state
1461 //
1462 if (flags & MB_TASKMODAL) {
1463 LOCKENUMINFO(GetEnumInfo().Lock, false); // lock data
1464 // Save the window to make modal
1465 //
1466 if (window)
1467 ei.ModalWnd = window->GetHandle();
1468
1469 // Count windows to disable
1470 //
1472 TParam2(static_cast<TEnumInfo *>(&ei))))
1473 return -1;
1474
1475 // Allocate list of windows to disable, disable windows that are
1476 // enabled and then stuff them into the list.
1477 //
1478 HWND* hWnds = ei.Wnds = new HWND[ei.Count + 1];
1479 memset(ei.Wnds, 0, sizeof(TModule::THandle)*(ei.Count + 1));
1480
1481 EnumThreadWindows(GetCurrentThreadId(), reinterpret_cast<WNDENUMPROC>(disableWnds),
1482 TParam2(reinterpret_cast<TEnumInfo *>(&ei)));
1483
1484 ei.Wnds = hWnds; // Restore alloc'd pointer since enumerator bumps it
1485 }
1486
1487 else if (window) {
1488
1489 // In MB_APPMODAL mode, we simply disable the window specified
1490 //
1491 ei.ModalWnd = window->GetHandle(); // Remember who to re-enable later
1492 CHECK(ei.ModalWnd);
1493 window->EnableWindow(false);
1494 }
1495
1496 // Enter message loop, saving & restoring the current status & getting the
1497 // returned result.
1498 //
1499 int result;
1500 try {
1501 result = MessageLoop();
1502 }
1503 catch (...) {
1504 TEnumInfoStr& data = GetEnumInfo();
1505 LOCKENUMINFO(data.Lock, false);
1506 termModal(ei);
1507 data.SetInfo(lastStackTop);
1508 throw;
1509 }
1510
1511 {
1512 TEnumInfoStr& data = GetEnumInfo();
1513 LOCKENUMINFO(data.Lock, false);
1514 data.SetInfo(lastStackTop);
1515 termModal(ei); // Just in case termModal was missed in EndModal
1516 }
1517
1518 // Return the result from the modal window's EndModal call
1519 //
1520 return result;
1521}
1522
1523//
1524/// Cause the current modal message loop to break and have it return a result
1525/// Re-enable the disabled windows here, if the EnumInfo is available.
1526//
1527void
1529{
1530 MessageLoopResult = result;
1531 BreakMessageLoop = true;
1532 TEnumInfoStr& data = GetEnumInfo();
1533 if (data.GetInfo()){
1534 LOCKENUMINFO(data.Lock, false);
1535 termModal(*data.GetInfo());
1536 }
1537}
1538
1539//----------------------------------------------------------------------------
1540#if defined(OWL_SUPPORT_BWCC)
1541
1542#if !defined(BWCCVERSION) // solely foe WARNX
1543#define BWCCVERSION 0x0200 // version 2.00
1544#endif
1545
1546//
1547/// Loads and registers either BWCC.DLL if you are running 16-bit applications or
1548/// BWCC32.DLL if you are running 32-bit applications.
1549/// To disable BWCC, set enable to false.
1550/// Library is not free'd on disable to reduce re-loads if enabling on the fly
1551/// \note BWCC is now obsolete and should be used only for backward compatibility
1552void
1553TApplication::EnableBWCC(bool enable, uint language)
1554{
1555 if (enable) {
1556 if (!BWCCModule) {
1557 try {
1558 BWCCModule = new TBwccDll();
1559 BWCCModule->IntlInit(language);
1560 BWCCModule->Register(GetHandle());
1561
1562 WARNX(OwlApp, BWCCModule->GetVersion() < BWCCVERSION, 0, \
1563 _T("Old version of BWCC DLL found"));
1564 }
1565 catch (...) {
1566 TRACEX(OwlApp, 0, _T("Unable to create instance of TBwccDll"));
1567 return;
1568 }
1569 }
1570 }
1571 BWCCOn = enable;
1572}
1573
1574#endif //#if defined(OWL_SUPPORT_BWCC)
1575//----------------------------------------------------------------------------
1576#if defined(OWL_SUPPORT_CTL3D)
1577
1578//
1579/// Enables or disables the use of the CTL3D DLL. If enable is true, EnableCtl3d
1580/// loads and registers the CTL3D.DLL if it is not already enabled.
1581/// \note Usage of Ctl3d is now obsolete and should be used only for backward compatibility
1582//
1583void
1584TApplication::EnableCtl3d(bool enable)
1585{
1586 // As per Article Q125684 of Microsoft Development Library:
1587 // "If major version is 4 or greater, the application should not
1588 // implement CTL3D".
1589 // 'How to Use CTL3D Under the Windows 95 Operating System'
1590 //
1591 if (TSystem::GetMajorVersion() >= 4)
1592 return;
1593
1594 // Load the Ctl3d DLL if needed & register our instance
1595 //
1596 if (enable) {
1597 if (!Ctl3dModule) {
1598 try {
1599 Ctl3dModule = new TCtl3dDll();
1600 Ctl3dModule->Register(*this);
1601 }
1602 catch (...) {
1603 TRACEX(OwlApp, 0, _T("Unable to create instance of TCtl3dDll"));
1604 return;
1605 }
1606 }
1607 }
1608 Ctl3dOn = enable;
1609}
1610
1611//
1612/// Enable or disable Ctl3d's use of auto-subclassing.
1613//
1614/// Caller should turn on autosubclassing before creating a non-owl dialog to
1615/// make it 3d, & turn it off immediatly after.
1616///
1617/// Enables or disables CTL3D's use of autosubclassing if CTL3D is already enabled
1618/// using Ctl3dEnabled. If autosubclassing is enabled, any non-ObjectWindows dialog
1619/// boxes have a 3-D effect. The common dialog classes and TDocManager use this
1620/// function both to turn on autosubclassing before creating a non-ObjectWindows
1621/// dialog box to make it three-dimensional and to turn off autosubclassing
1622/// immediately after the dialog box is destroyed.
1623//
1624void
1625TApplication::EnableCtl3dAutosubclass(bool enable) const
1626{
1627 if (Ctl3dEnabled()) {
1628 if (enable) {
1629 Ctl3dModule->Register(*this);
1630 Ctl3dModule->AutoSubclass(*this);
1631 }
1632 else {
1633 Ctl3dModule->Unregister(*this);
1634 }
1635 }
1636}
1637
1638#endif //#if defined(OWL_SUPPORT_CTL3D)
1639//----------------------------------------------------------------------------
1640#if defined(OWL_SUPPORT_BWCC)
1641
1642//
1643/// Predefined DLLs that TApplication knows how to find.
1644//
1645 const tchar BwccDllName[] = _T("BWCC32.DLL");
1646
1647//
1648/// Load the BWCC DLL dynamically.
1649/// Bind the member functions to the exported functions.
1650//
1651/// This is how TApplication::EnableBWCC uses TBwccDll:
1652/// \code
1653/// if (!BWCCModule) {
1654/// try {
1655/// BWCCModule = new TBwccDll();
1656/// BWCCModule->IntlInit(language);
1657/// BWCCModule->Register(GetHandle());
1658///
1659/// WARNX(OwlApp, BWCCModule->GetVersion() < BWCCVERSION, 0, \\
1660/// _T("Old version of BWCC DLL found"));
1661/// }
1662/// catch (...) {
1663/// TRACEX(OwlApp, 0, _T("Unable to create instance of TBwccDll"));
1664/// return;
1665/// }
1666/// \endcode
1667//
1668TBwccDll::TBwccDll()
1669:
1670 TModule(BwccDllName, true, true, false), // shouldLoad, mustLoad and !addToList
1671
1672 IntlInit(*this, "BWCCIntlInit"),
1673 Register(*this, "BWCCRegister"),
1674 IntlTerm(*this, "BWCCIntlTerm"),
1675
1676 SpecialLoadDialog(*this, "SpecialLoadDialog"),
1677 MangleDialog(*this, "MangleDialog"),
1678 DefDlgProc(*this, "BWCCDefDlgProc"),
1679 DefGrayDlgProc(*this, "BWCCDefGrayDlgProc"),
1680 DefWindowProc(*this, "BWCCDefWindowProc"),
1681 DefMDIChildProc(*this, "BWCCDefMDIChildProc"),
1682 MessageBox(*this, "BWCCMessageBox"),
1683 GetPattern(*this, "BWCCGetPattern"),
1684 GetVersion(*this, "BWCCGetVersion")
1685{
1686}
1687
1688#endif //#if defined(OWL_SUPPORT_BWCC)
1689//----------------------------------------------------------------------------
1690#if defined(OWL_SUPPORT_CTL3D)
1691
1692//
1693/// Predefined DLLs that TApplication knows how to find.
1694//
1695 const tchar Ctl3dDllName[] = _T("CTL3D32.DLL");
1696
1697//
1698/// Load the Ctl3d DLL dynamically.
1699/// Bind the member functions to the exported functions.
1700//
1701TCtl3dDll::TCtl3dDll()
1702:
1703 TModule(Ctl3dDllName, true, true, false), // shouldLoad, mustLoad and !addToList
1704
1705 Register(*this, "Ctl3dRegister"),
1706 Unregister(*this, "Ctl3dUnregister"),
1707 AutoSubclass(*this, "Ctl3dAutoSubclass"),
1708 CtlColorEx(*this, "Ctl3dCtlColorEx"),
1709 SubclassDlg(*this, "Ctl3dSubclassDlg"),
1710 SubclassDlgEx(*this, "Ctl3dSubclassDlgEx"),
1711 GetVer(*this, "Ctl3dGetVer"),
1712 Enabled(*this, "Ctl3dEnabled"),
1713 ColorChange(*this, "Ctl3dColorChange"),
1714 SubclassCtl(*this, "Ctl3dSubclassCtl"),
1715 DlgFramePaint(*this, "Ctl3dDlgFramePaint"),
1716 WinIniChange(*this, "Ctl3dWinIniChange")
1717{
1718}
1719
1720#endif //#if defined(OWL_SUPPORT_CTL3D)
1721//----------------------------------------------------------------------------
1722
1723#if OWL_PERSISTENT_STREAMS
1724
1725// Broken apart: IMPLEMENT_STREAMABLE1(TApplication, TModule);
1726// to replace the ctor
1727//
1728IMPLEMENT_STREAMABLE_CLASS(TApplication);
1729IMPLEMENT_STREAMER(TApplication);
1730IMPLEMENT_STREAMABLE_POINTER(TApplication)
1731
1732//
1733// IMPLEMENT_STREAMABLE_CTOR1(TApplication, TModule), plus TMsgThread init
1734//
1736:
1737 TModule(streamableInit),
1738 TMsgThread(TMsgThread::Current)
1739{
1740}
1741
1742//
1743//
1744//
1745void*
1746TApplication::Streamer::Read(ipstream& is, uint32 /*version*/) const
1747{
1748 TApplication* o = GetObject();
1749 if (o != owl::Module)
1750 is >> *owl::Module; // set reference to OWL module
1751 return o;
1752}
1753
1754//
1755//
1756//
1757void
1758TApplication::Streamer::Write(opstream& os) const
1759{
1760 TApplication* o = GetObject();
1761 if (o != owl::Module)
1762 os << *owl::Module; // write out reference to OWL module, no data written
1763}
1764
1765#else
1766
1768
1769#endif
1770
1771//----------------------------------------------------------------------------
1772
1773// TWaitCursor data
1774
1775inline bool FilterWindow (HWND hWnd){
1776 return !::IsWindowEnabled (hWnd) || !::IsWindowVisible (hWnd);
1777}
1778//
1779/// Enum[Thread/Task]Windows callback. Counts or subclasses given window based on
1780/// whether or not window list has been allocated yet.
1781//
1782static bool CALLBACK
1783subclassWnds(HWND hWnd, TEnumInfo * ei)
1784{
1785 if (!FilterWindow (hWnd)) {
1786 if (!ei->Wnds) {
1787 ei->Count++; // no buffer yet, we are just counting
1788 }
1789 else {
1790 *(ei->Wnds++) = hWnd;
1791 *(ei->PrevWndProc++) = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(TWaitHook::WaitWndProc)));
1792 }
1793 }
1794 return true;
1795}
1796//
1797enum{
1801//
1802TWaitHook::TWaitHook()
1803:
1804 LastStackTop(nullptr),
1805 HideCaretCount(0),
1806 Cursor(nullptr),
1807 DeleteOnClose(false)
1808{
1809 memset(&Subclass,0,sizeof(Subclass));
1810
1811 TEnumInfoStr& data = GetEnumInfo();
1812 LastStackTop = data.GetInfo(); // Keep last stackTop to restore later
1813 data.SetInfo(&Subclass); // Point stackTop to topmost ei
1814
1815 // Count windows to subclass
1816 //
1817 if (!::EnumThreadWindows(GetCurrentThreadId(), reinterpret_cast<WNDENUMPROC>(subclassWnds),
1818 TParam2(reinterpret_cast<TEnumInfo *>(&Subclass))))
1819 return;
1820
1821 // Allocate list of windows to disable, disable windows that are
1822 // enabled and then stuff them into the list.
1823 //
1824 HWND* hWnds = Subclass.Wnds = new HWND[Subclass.Count + 1];
1825 WNDPROC* fProc = Subclass.PrevWndProc = new WNDPROC[Subclass.Count + 1];
1826 memset(Subclass.Wnds, 0, sizeof(HWND)*(Subclass.Count + 1));
1827 memset(Subclass.PrevWndProc, 0, sizeof(WNDPROC)*(Subclass.Count + 1));
1828
1829 EnumThreadWindows(GetCurrentThreadId(), reinterpret_cast<WNDENUMPROC>(subclassWnds),
1830 TParam2(reinterpret_cast<TEnumInfo *>(&Subclass)));
1831
1832 Subclass.Wnds = hWnds; // Restore alloc'd pointer since enumerator bumps it
1833 Subclass.PrevWndProc = fProc; // Restore alloc'd pointer
1834
1835 HideCaret(nullptr);
1836 HideCaretCount = 1;
1837 Cursor = new TCursor(::LoadCursor(nullptr, IDC_WAIT));
1838 DeleteOnClose = true;
1839 SetWaitCursor();
1840}
1841//
1842TWaitHook::~TWaitHook()
1843{
1844 for (int i = 0; i < Subclass.Count; i++)
1845 ::SetWindowLongPtr(Subclass.Wnds[i], GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(Subclass.PrevWndProc[i]));
1846
1847 delete [] Subclass.Wnds;
1848 delete [] Subclass.PrevWndProc;
1849
1850 while(HideCaretCount--)
1851 ShowCaret(nullptr);
1852
1853 TPoint pt;
1854 ::GetCursorPos(&pt);
1855 ::SetCursorPos(pt.x, pt.y);
1856
1857 GetEnumInfo().SetInfo(LastStackTop); // Restore stackttop
1858
1859 FreeCursors();
1860}
1861//
1862void TWaitHook::FreeCursors()
1863{
1864 if(DeleteOnClose)
1865 delete Cursor;
1866 Cursor = nullptr;
1867}
1868//
1869void TWaitHook::SetCursor(TCursor* cursor, TAutoDelete del)
1870{
1871 FreeCursors();
1872 Cursor = cursor;
1873 DeleteOnClose = del == AutoDelete;
1874}
1875//
1876void TWaitHook::SetWaitCursor()
1877{
1878 ::SetCursor(*Cursor);
1879}
1880//
1881LRESULT CALLBACK TWaitHook::WaitWndProc(HWND wnd, UINT msg, WPARAM param1, LPARAM param2)
1882{
1883 return GetEnumInfo().Hook->WaitWndMethod(wnd, msg, param1, param2);
1884}
1885//
1886TResult TWaitHook::WaitWndMethod(HWND wnd, TMsgId msg, TParam1 param1, TParam2 param2)
1887{
1889 switch (msg){
1890 case WM_SETCURSOR:
1891 SetWaitCursor();
1892 return TRUE;
1893
1894 case WM_MOUSEACTIVATE:
1895 hTopMostWindow = reinterpret_cast<HWND>(param1);
1896
1897 if (hTopMostWindow == wnd)
1898 return MA_ACTIVATEANDEAT;
1899
1900 return ::DefWindowProc(wnd, msg, param1, param2);
1901
1902 case WM_SETFOCUS:
1903 DefWndProc (wnd, msg, param1, param2);
1904 HideCaret(nullptr);
1905 ++HideCaretCount;
1906 return 0;
1907 }
1908
1909 if ((msg >= WM_KEYFIRST && msg <= WM_KEYLAST) ||
1910 (msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST) ||
1911 (msg >= WM_NCMOUSEFIRST && msg <= WM_NCMOUSELAST))
1912 {
1913 return 0; // ::DefWindowProc (wnd, msg, param1, param2);
1914 }
1915 return DefWndProc (wnd, msg, param1, param2);
1916}
1917//
1918TResult TWaitHook::DefWndProc(HWND wnd, TMsgId msg, TParam1 param1, TParam2 param2)
1919{
1920 for(int i = 0; i < static_cast<int>(Subclass.Count); i++){
1921 if (Subclass.Wnds[i] == wnd)
1922 return CallWindowProc(Subclass.PrevWndProc[i], wnd, msg, param1, param2);
1923 }
1924 PRECONDITION(0);
1925 return 0;
1926}
1927
1928//----------------------------------------------------------------------------
1929//
1930/// Changes the cursor to cursor. If TAutoDelete is set to AutoDelete the cursor
1931/// resource is deleted when the wait cursor is destoryed.
1932//
1933void TWaitCursor::SetCursor(TCursor* cursor, TAutoDelete del)
1934{
1935 TEnumInfoStr& data = GetEnumInfo();
1936 LOCKENUMINFO(data.Lock, false);
1937 if(data.Hook)
1938 data.Hook->SetCursor(cursor,del);
1939}
1940
1941//----------------------------------------------------------------------------
1942
1943//
1944/// Called by the constructors to add this cursor into the applications chain.
1945//
1946void TWaitCursor::Init()
1947{
1948 TEnumInfoStr& data = GetEnumInfo();
1949 LOCKENUMINFO(data.Lock, false);
1950 Next = data.Top;
1951 data.Top = this;
1952 if(!Next){
1953 PRECONDITION(data.Hook == 0);
1954 data.Hook = new TWaitHook;
1955 }
1956}
1957//
1958/// Restores the previous cursor.
1959//
1960TWaitCursor::~TWaitCursor()
1961{
1962 TEnumInfoStr& data = GetEnumInfo();
1963 LOCKENUMINFO(data.Lock, false);
1964
1965 const auto ok = data.Top == this; // Must be destructed in reverse order.
1966 WARN(!ok, _T("TWaitCursor::~TWaitCursor: Terminating due to failed precondition."));
1967 if (!ok) terminate();
1968
1969 if(data.Top){
1970 data.Top = Next;
1971 if(!Next){
1972 delete data.Hook;
1973 data.Hook = nullptr;
1974 }
1975 }
1976}
1977//
1978/// Restores old state of cursor.
1979//
1980void TWaitCursor::Restore()
1981{
1982 TEnumInfoStr& data = GetEnumInfo();
1983 LOCKENUMINFO(data.Lock, false);
1984
1985 delete data.Hook;
1986 data.Hook = nullptr;
1987 data.Top = nullptr;
1988}
1989//----------------------------------------------------------------------------
1990//
1991/// Sends text to the applications TMessageBar::SetHintText function if it has one.
1992//
1993void TWaitCursor::Message(const tstring& msg)
1994{
1995 TEnumInfoStr& data = GetEnumInfo();
1996 LOCKENUMINFO(data.Lock, true);
1997 if(data.Top == this && data.Hook){
1999 if(!app)
2000 return;
2001
2002 TFrameWindow* frame= app->GetMainWindow();
2003 if (frame){
2006 if(messageBar){
2007 messageBar->SetHintText(msg);
2008 messageBar->UpdateWindow();
2009 }
2010 }
2011 }
2012}
2013//-----------------------------------------------------------------------------
2014//
2015TLangModule::TLangModule(const tstring& prefix, const TApplication& appl)
2016:
2017 Prefix(prefix),
2018 Module(nullptr),
2019 Application(&const_cast<TApplication&>(appl)),
2020 LangId(static_cast<unsigned short>(-1)) //JJH added static_cast
2021{
2022 SetLanguage(appl.GetLangId());
2023}
2024//-----------------------------------------------------------------------------
2026{
2027 if(Module && Module != Application)
2028 delete Module;
2029}
2030//-----------------------------------------------------------------------------
2032{
2034
2035 tchar szLocName[10];
2037 if(retval)
2038 mname += szLocName;
2039 else
2040 mname += _T("ENU");
2041 mname += _T(".DLL");
2042 TModule* module = new TModule(mname.c_str(),true, false, true); // shouldLoad, !mustLoad and addToList
2043 if(module->GetHandle() <= HINSTANCE(HINSTANCE_ERROR)){
2044 delete module;
2046 locname += _T("ENU.DLL");
2047 module = new TModule(locname.c_str(),true, false, true); // shouldLoad, !mustLoad and addToList
2048 if(module->GetHandle() > HINSTANCE(HINSTANCE_ERROR))
2049 mname = locname;
2050 else{
2051 delete module;
2052 module = Application;
2053 }
2054 }
2055 if(Module && Module != Application)
2056 delete Module;
2057 Module = module;
2058
2059 // init LangId
2061 if(pProc)
2062 pProc();
2063}
2064//-----------------------------------------------------------------------------
2065//-----------------------------------------------------------------------------
2066
2067} // OWL namespace
2068//===============================================================================
2069
2070
Definition of class TAppDictionary.
Definition of class TApplication.
Legacy support for Borland Windows Custom Controls (BWCC)
#define CHECK(condition)
Definition checks.h:239
#define WARNX(group, condition, level, message)
Definition checks.h:277
#define WARN(condition, message)
Definition checks.h:273
#define PRECONDITION(condition)
Definition checks.h:227
#define TRACEX(group, level, message)
Definition checks.h:263
#define DIAG_DEFINE_GROUP_INIT(f, g, e, l)
Definition checks.h:429
TAppDictionary implementation for DLLs only.
Definition appdict.h:30
TApplication * GetApplication(uint pid=0)
Looks up and returns the application associated with a given process ID.
Definition appdict.cpp:192
void Remove(TApplication *app)
Searches for the dictionary entry using the specified application (app).
Definition appdict.cpp:218
void Add(TApplication *app, uint pid=0)
Adds an application object (app) and corresponding process ID to this dictionary.
Definition appdict.cpp:205
Derived from TModule and TMsgThread and virtually derived from TEventHandler, TApplication acts as an...
Definition applicat.h:141
virtual bool ProcessAppMsg(MSG &msg)
Called after each message is pulled from the queue, and before it is dispatched.
Definition applicat.cpp:918
virtual void PreProcessMenu(HMENU hMenubar)
Called by the main window to provide an oportunity to preprocess the main window's menubar before it ...
virtual void ObjectSignaled(HANDLE, bool)
Definition applicat.h:236
void ResumeThrow()
Rethrows the suspended exception stored by a previous call to SuspendThrow.
auto TermInstance(int status) -> int override
Handle termination for each executing instance of the application.
Definition applicat.cpp:636
void SetTooltip(TTooltip *tooltip)
Assigns tooltip.
int MessageBox(HWND wnd, const tstring &text, const tstring &caption=tstring(), uint type=MB_OK) const
Definition applicat.h:774
virtual void WaitOnObject(HANDLE handle, bool wait)
Definition applicat.cpp:954
virtual void EnableTooltip(bool enable=true)
auto IdleAction(long idleCount) -> bool override
Called each time there are no messages in the queue.
Definition applicat.cpp:840
void PostDispatchAction()
Call this function after each msg dispatch if TApplication's message loop is not used.
void SuspendThrow(std::exception_ptr)
Stores the given exception so that it can be rethrown later by a call to ResumeThrow.
int BeginModal(TWindow *window, int flags=MB_APPLMODAL)
Called to begin a modal window's modal message loop.
auto MessageLoop() -> int override
Operates the application's message loop, which runs during the lifetime of the application.
Definition applicat.cpp:799
TWindow * GetWindowPtr(HWND hWnd) const
Get the TWindow pointer belonging to this app given an hWnd.
Definition applicat.h:665
virtual void InitApplication()
Handle initialization for the first executing instance of the OWL application.
Definition applicat.cpp:560
TFrameWindow * SetMainWindow(TFrameWindow *window)
Set (or reset) the main window.
Definition applicat.cpp:658
auto Run() -> int override
Run this application, return when application terminates.
Definition applicat.cpp:739
auto Find(TEventInfo &, TEqualOperator=nullptr) -> bool override
Overrides TEventHandler::Find.
virtual void InitMainWindow()
Initialize the application's main window.
Definition applicat.cpp:625
auto ProcessMsg(MSG &) -> bool override
Called for each message that is pulled from the queue, to perform all translation & dispatching.
Definition applicat.cpp:877
void Condemn(TWindow *win)
Condemns the given window to be deleted the at the next available safe time.
virtual bool CanClose()
Determine whether the application can be closed.
TApplication(LPCTSTR name=nullptr, TModule *&=owl::Module, TAppDictionary *=nullptr)
Constructor for use in OwlMain().
Definition applicat.cpp:288
virtual int Start() noexcept
Start this application and return immediately. Used for component DLLs.
Definition applicat.cpp:775
void InitInstance() override
Performs each instance initialization necessary for the application.
Definition applicat.cpp:578
~TApplication() override
~TApplication destroys the TApplication object.
Definition applicat.cpp:456
TFrameWindow * GetMainWindow()
Return the current main window.
Definition applicat.h:592
TDocManager * SetDocManager(TDocManager *docManager)
Set (or resets) the document manager, return the previous one if present.
Definition applicat.cpp:698
void EndModal(int result)
Cause the current modal message loop to break and have it return a result Re-enable the disabled wind...
void Uncondemn(TWindow *win)
Removes the given window from the list of condemned windows.
TCursor, derived from TGdiBase, represents the GDI cursor object class.
Definition gdiobjec.h:730
TDocManager creates a document manager object that manages the list of current documents and register...
Definition docmanag.h:100
A nested class, TEventInfo provides specific information about the type of message sent,...
Definition eventhan.h:170
virtual bool Find(TEventInfo &info, TEqualOperator op=0)
Searches the list of response table entries looking for a match.
Definition eventhan.cpp:371
TResult Dispatch(TEventInfo &info, TParam1, TParam2=0)
Takes the message data from TEventInfo's Msg data member and dispatches it to the correct event-handl...
Definition eventhan.cpp:396
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 SetLanguage(const TLangId &langId)
TApplication * Application
Definition applicat.h:552
virtual ~TLangModule()
void(* InitLanguage)()
Definition applicat.h:537
TModule * Module
Definition applicat.h:551
Derived from TGadgetWindow, TMessageBar implements a message bar with one text gadget as wide as the ...
Definition messageb.h:36
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TMsgThread implements basic behavior for threads that own message queues, including mutex locking for...
Definition msgthred.h:45
bool BreakMessageLoop
Message loop is broken via WM_QUIT.
Definition msgthred.h:106
virtual void InitInstance()
Handles initialization for each executing instance of the message thread.
Definition msgthred.cpp:189
virtual int TermInstance(int status)
Handles termination for each executing instance of the message thread.
Definition msgthred.cpp:202
bool LoopRunning
Track if the loop is running.
Definition msgthred.h:110
int MessageLoopResult
Return value from message loop.
Definition msgthred.h:107
void FlushQueue()
Flushes all real messages from the message queue.
Definition msgthred.cpp:147
bool PumpWaitingMessages()
The inner message loop.
Definition msgthred.cpp:123
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
A template class, TResponseTableEntry lets you define a pattern for entries into a response table.
Definition eventhan.h:217
static uint GetMajorVersion()
Definition system.cpp:81
TSystemMenu creates a system menu object that then becomes the existing system menu.
Definition menu.h:175
TTooltip encapsulates a tooltip window - i.e.
Definition tooltip.h:175
void RelayEvent(MSG &)
Passes a mouse message to the tooltip control for processing.
Definition tooltip.h:524
void Activate(bool activate=true)
Set state of tooltip.
Definition tooltip.h:394
static void DestroyInstance()
Definition tracewnd.cpp:150
static auto GetInstance(bool shouldCreateIfNeccessary=false) -> TTraceWindow *
Definition tracewnd.cpp:143
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
void SetNext(TWindow *next)
Sets the next window in the sibling list.
Definition window.h:1762
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
virtual bool EnableWindow(bool enable)
Allows the given window to receive input from the keyboard of mouse.
Definition window.h:2172
void DrawMenuBar()
DrawMenuBar redraws the menu bar.
Definition window.h:3313
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
Definition window.cpp:644
virtual bool Create()
Creates the window interface element to be associated with this ObjectWindows interface element.
Definition window.cpp:2399
void SetFlag(uint mask)
Sets the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
Definition window.h:1783
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
uint32 SetExStyle(uint32 style)
Sets the extra style bits of the window.
Definition window.cpp:3583
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
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
Definition window.cpp:3591
virtual bool CanClose()
Use this function to determine if it is okay to close a window.
Definition window.cpp:2795
void ClearFlag(uint mask)
Clears the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
Definition window.h:1790
TWindow * Next()
Returns a pointer to the next sibling window in the window's sibling list.
Definition window.h:1755
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
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
auto ChildWithId(int id) const -> const TWindow *
Definition window.h:681
Derived from xmsg, TXBase is the base class for ObjectWindows and ObjectComponents exception-handling...
Definition exbase.h:41
A nested class, TXInvalidMainWindow describes an exception that results from an invalid Window.
Definition applicat.h:498
TXInvalidMainWindow * Clone()
TXInvalidMainWindow()
Constructs a TXInvalidMainWindow object with a default IDS_INVALIDMAINWINDOW.
static void Raise()
Throws a TXInvalidMainWindow exception.
void Throw()
Throws the exception object.
TXOwl is root class of the ObjectWindows exception hierarchy.
Definition except.h:38
#define _T(x)
Definition cygwin.h:51
#define WM_OWLCANCLOSE
Definition dispatch.h:4109
#define WM_OWLPREPROCMENU
Definition dispatch.h:4108
Definition of class TDocManager.
Definition of class TFrameWindow.
#define IMPLEMENT_STREAMABLE_POINTER(cls)
Definition objstrm.h:1596
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
#define IMPLEMENT_STREAMABLE_CLASS(cls)
Definition objstrm.h:1573
#define IMPLEMENT_STREAMABLE1(cls, base1)
Definition objstrm.h:1725
StreamableInit
Definition objstrm.h:98
#define IMPLEMENT_STREAMER(cls)
Definition objstrm.h:1641
@ AutoDelete
Definition gdibase.h:70
@ streamableInit
Definition objstrm.h:98
virtual int Unhandled(TModule *appModule, uint promptResId)
Per-exception class unhandled-handler, will default to the per-module unhandled-handler.
Definition except.cpp:155
#define LOCKAPPLDATA(l, s)
Definition applicat.cpp:151
#define LOCKENUMINFO(l, s)
Definition applicat.cpp:142
THandle GetHandle() const
Return the instance handle of the library module represented by the TModule obect.
Definition module.h:1233
LPCTSTR GetName() const
Returns the name of the module.
Definition module.h:1224
FARPROC GetProcAddress(TNarrowResId) const
Returns the entry-point address of the specified exported function if found, otherwise returns NULL.
Definition module.h:1281
virtual int Error(TXBase &x, uint captionResId, uint promptResId=0)
Replaceable exception handler; may be redefined to process OWL exceptions if canResume is false,...
Definition module.cpp:522
@ wfMainWindow
This frame window is the main window.
Definition window.h:63
Definition of class TMessageBar.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
@ WM_NCMOUSELAST
@ WM_NCMOUSEFIRST
UINT TMsgId
Message ID type.
Definition dispatch.h:53
bool FilterWindow(HWND hWnd)
int OWLMessageBox(HWND wnd, const tstring &text, const tstring &caption, uint type)
Definition applicat.cpp:228
EV_WM_SYSCOMMAND
Definition floatfra.cpp:26
unsigned long uint32
Definition number.h:34
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
Definition lclstrng.h:26
char tchar
Definition defs.h:77
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
int(* TMessageBox)(HWND wnd, LPCTSTR text, const LPCTSTR caption, uint type)
Definition applicat.h:57
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
const TLangId LangNeutral
Definition lclstrng.h:32
const TLangId LangUserDefault
Definition lclstrng.h:31
TModule * Module
Definition global.cpp:34
TAppDictionary & OWLGetAppDictionary()
Global exported TAppDictionary in Owl.
Definition appdict.cpp:35
OWL_DIAGINFO
Definition animctrl.cpp:14
const int IDW_STATUSBAR
Definition messageb.h:25
LRESULT TResult
Result type.
Definition dispatch.h:52
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
const auto ScmTrace
Definition applicat.cpp:163
#define OWL_CDLEVEL
Definition defs.h:171
#define OWL_INI
Definition defs.h:170
#define _OWLFUNC(p)
Definition defs.h:341
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
Definition of the TTooltip class and helper objects.
Definition of private class TTraceWindow.
#define EV_COMMAND(id, method)
Response table entry for a menu/accelerator/push button message.
Definition windowev.h:171
#define WS_EX_APPWINDOW
Definition wsysinc.h:63