16#include <owl/window.rh>
21#if defined(OWL_SUPPORT_BWCC)
26#if defined(BI_MULTI_THREAD_RTL)
32#if defined(__BORLANDC__)
73 TEnumInfo* LastStackTop;
100 TEnumInfo* GetInfo() {
return Info; }
101 void SetInfo(TEnumInfo*
info) { Info =
info; }
107#if defined(BI_MULTI_THREAD_RTL)
113static TEnumInfoStr& GetEnumInfo();
118#if !defined(BI_MULTI_THREAD_RTL)
119struct TApplicatData {
128#if defined(BI_MULTI_THREAD_RTL)
134static TApplicatData& GetApplicatData();
139#if defined(BI_MULTI_THREAD_RTL)
140#define LOCKENUMINFO(l,s) TMRSWSection::TLock __lock(l,s)
142#define LOCKENUMINFO(l,s)
148#if defined(BI_MULTI_THREAD_RTL)
149#define LOCKAPPLDATA(l,s) TMRSWSection::TLock __lock(l,s)
151#define LOCKAPPLDATA(l,s)
173TApplicatData::TApplicatData()
174: OwlMsgBox(OWLDefaultMsgBox)
178TApplicatData::~TApplicatData()
186TApplicatData& GetApplicatData()
197TEnumInfoStr& GetEnumInfo()
212HINSTANCE TApplication::InitHPrevInstance;
213int TApplication::InitCmdShow;
220 TApplicatData&
data = GetApplicatData();
257 TModule&
m =
module ? *module : wnd && wnd->GetModule() ? *wnd->GetModule() : GetGlobalModule();
272TApplication::GetInitCmdLine()
295 hPrevInstance(InitHPrevInstance), nCmdShow(InitCmdShow),
299 CmdLine(GetInitCmdLine()),
315 Dictionary->
Add(
this);
331 hPrevInstance(InitHPrevInstance), nCmdShow(InitCmdShow),
335 CmdLine(GetInitCmdLine()),
351 Dictionary->
Add(
this);
405 Dictionary->
Add(
this);
447 Dictionary->
Add(
this);
462#if defined(OWL_SUPPORT_CTL3D)
470#if defined(OWL_SUPPORT_BWCC)
531 <<
_T(
": NULL handle without either MB_TASKMODAL or MB_SYSTEMMODAL is not allowed;")
532 <<
_T(
"Applying MB_TASKMODAL."));
535 <<
_T(
": MB_TASKMODAL with non-null handle behaves like MB_APPLMODAL (the default); ")
536 <<
_T(
"Use NULL handle for task-modal behaviour."));
538#if defined(OWL_SUPPORT_BWCC)
548#if defined(OWL_SUPPORT_CTL3D)
585 TRACEX(
OwlApp, 1,
_T(
"TApplication::InitApplication() called @") << (
void*)
this);
605 TRACEX(
OwlApp, 1,
_T(
"TApplication::InitInstance() called @") << (
void*)
this);
613#if defined(__TRACE) || defined(__WARN)
661 TRACEX(
OwlApp, 1,
_T(
"TApplication::TermInstance() called @") << (
void*)
this);
663#if defined(__TRACE) || defined(__WARN)
688 if(Tooltip && Tooltip->
GetParentO()==MainWindow)
712 auto old = std::unique_ptr<TFrameWindow>{SetMainWindow(f.get())};
733 auto old = std::unique_ptr<TDocManager>{SetDocManager(
d.get())};
738#if defined(BI_MULTI_THREAD_RTL)
745 TApplication::TQueueLock
lock(*
this);
808 catch (...) {status = -1;}
865 TRACEX(
OwlApp, 1,
_T(
"TApplication::IdleAction() called @") << (
void*)
this <<
871#if defined(__TRACE) || defined(__WARN)
945 if (Tooltip && Tooltip->
IsWindow()) {
946 if (
msg.hwnd == *MainWindow || MainWindow->
IsChild(
msg.hwnd)) {
998 newHandles[
i] = WaitHandles[
i];
999 delete[] WaitHandles;
1000 WaitHandles = newHandles;
1001 WaitHandles[WaitCount] =
handle;
1011 delete[] WaitHandles;
1012 WaitHandles =
nullptr;
1020 for (
i = 0;
i < index;
i++)
1021 newHandles[
i] = WaitHandles[
i];
1023 newHandles[
i-1] = WaitHandles[
i];
1024 delete[] WaitHandles;
1025 WaitHandles = newHandles;
1040 TRACEX(
OwlApp, 0,
_T(
"TApplication::SuspendThrow: Suspending exception and posting quit-message."));
1041 CurrentException =
e;
1052 if (CurrentException ==
nullptr)
return;
1054 TRACEX(
OwlApp, 0,
_T(
"TApplication::ResumeThrow: Rethrowing suspended exception."));
1120 MainWindow && MainWindow->
GetHandle()) {
1136#if defined(__TRACE) || defined(__WARN)
1144 switch (
cmd & 0xFFF0)
1165 if (
const auto h =
w->GetHandle())
1174 m->DefaultProcessing();
1181TApplication::CmExit()
1201 const auto r = DocManager ? DocManager->Find(
eventInfo,
equal) :
false;
1204#if OWL_NEW_RESPONSE_TABLE
1216 static const TEntry
entries[] =
1243 return (!MainWindow || MainWindow->
CanClose())
1284 TRACEX(
OwlApp, 1,
_T(
"Condemning window @") << (
void*)win << *win);
1288 if (!CondemnedWindows)
1290 CondemnedWindows = win;
1300 WARNX(
OwlApp,
true, 0,
_T(
"TApplication::Condemn: Redundant condemnation, win: ") << *win);
1317 if (win && CondemnedWindows) {
1319 if (CondemnedWindows != win)
1320 for (
w = CondemnedWindows;
w->Next() != win;
w =
w->Next())
1324 TRACEX(
OwlApp, 1,
_T(
"Uncondemning window @") << (
void*)win << *win);
1326 w->SetNext(win->
Next());
1328 CondemnedWindows = win->
Next();
1343TApplication::DeleteCondemned()
1357 while (CondemnedWindows)
1359 const auto next = CondemnedWindows->
Next();
1360 c.push_back(CondemnedWindows);
1361 CondemnedWindows =
next;
1363 for (
const auto w :
c)
1369 while (CondemnedWindows);
1417 if (
hWnd !=
ei->ModalWnd && ::IsWindowEnabled(
hWnd)) {
1423 ::EnableWindow(
hWnd,
false);
1434static void termModal(TEnumInfo&
ei)
1440 ::EnableWindow(*
hWnd,
true);
1445 if (
ei.ModalWnd && IsWindow(
ei.ModalWnd)) {
1446 ::EnableWindow(
ei.ModalWnd,
true);
1447 ei.ModalWnd =
nullptr;
1470 TEnumInfo
ei = {
nullptr, 0,
nullptr,
nullptr};
1473 TEnumInfoStr&
data = GetEnumInfo();
1501 TParam2(
static_cast<TEnumInfo *
>(&
ei))))
1511 TParam2(
reinterpret_cast<TEnumInfo *
>(&
ei)));
1533 TEnumInfoStr&
data = GetEnumInfo();
1541 TEnumInfoStr&
data = GetEnumInfo();
1561 TEnumInfoStr&
data = GetEnumInfo();
1562 if (
data.GetInfo()){
1564 termModal(*
data.GetInfo());
1569#if defined(OWL_SUPPORT_BWCC)
1571#if !defined(BWCCVERSION)
1572#define BWCCVERSION 0x0200
1592 _T(
"Old version of BWCC DLL found"));
1605#if defined(OWL_SUPPORT_CTL3D)
1613TApplication::EnableCtl3d(
bool enable)
1654TApplication::EnableCtl3dAutosubclass(
bool enable)
const
1669#if defined(OWL_SUPPORT_BWCC)
1702 Register(*
this,
"BWCCRegister"),
1709 DefWindowProc(*
this,
"BWCCDefWindowProc"),
1711 MessageBox(*
this,
"BWCCMessageBox"),
1713 GetVersion(*
this,
"BWCCGetVersion")
1719#if defined(OWL_SUPPORT_CTL3D)
1730TCtl3dDll::TCtl3dDll()
1734 Register(*
this,
"Ctl3dRegister"),
1735 Unregister(*
this,
"Ctl3dUnregister"),
1741 Enabled(*
this,
"Ctl3dEnabled"),
1752#if OWL_PERSISTENT_STREAMS
1767 TMsgThread(TMsgThread::Current)
1775TApplication::Streamer::Read(ipstream&
is,
uint32 )
const
1777 TApplication*
o = GetObject();
1787TApplication::Streamer::Write(opstream&
os)
const
1789 TApplication*
o = GetObject();
1805 return !::IsWindowEnabled (
hWnd) || !::IsWindowVisible (
hWnd);
1831TWaitHook::TWaitHook()
1836 DeleteOnClose(
false)
1838 memset(&Subclass,0,
sizeof(Subclass));
1840 TEnumInfoStr&
data = GetEnumInfo();
1841 LastStackTop =
data.GetInfo();
1842 data.SetInfo(&Subclass);
1847 TParam2(
reinterpret_cast<TEnumInfo *
>(&Subclass))))
1855 memset(Subclass.Wnds, 0,
sizeof(
HWND)*(Subclass.Count + 1));
1856 memset(Subclass.PrevWndProc, 0,
sizeof(
WNDPROC)*(Subclass.Count + 1));
1859 TParam2(
reinterpret_cast<TEnumInfo *
>(&Subclass)));
1861 Subclass.Wnds =
hWnds;
1862 Subclass.PrevWndProc =
fProc;
1866 Cursor =
new TCursor(::LoadCursor(
nullptr,
IDC_WAIT));
1867 DeleteOnClose =
true;
1871TWaitHook::~TWaitHook()
1873 for (
int i = 0;
i < Subclass.Count;
i++)
1876 delete [] Subclass.Wnds;
1877 delete [] Subclass.PrevWndProc;
1879 while(HideCaretCount--)
1883 ::GetCursorPos(&
pt);
1886 GetEnumInfo().SetInfo(LastStackTop);
1891void TWaitHook::FreeCursors()
1898void TWaitHook::SetCursor(TCursor*
cursor, TAutoDelete
del)
1905void TWaitHook::SetWaitCursor()
1907 ::SetCursor(*Cursor);
1940 (
msg >= WM_NCMOUSEFIRST &&
msg <= WM_NCMOUSELAST))
1950 if (Subclass.Wnds[
i] ==
wnd)
1964 TEnumInfoStr&
data = GetEnumInfo();
1975void TWaitCursor::Init()
1977 TEnumInfoStr&
data = GetEnumInfo();
1983 data.Hook =
new TWaitHook;
1989TWaitCursor::~TWaitCursor()
1991 TEnumInfoStr&
data = GetEnumInfo();
1994 const auto ok =
data.Top ==
this;
1995 WARN(!
ok,
_T(
"TWaitCursor::~TWaitCursor: Terminating due to failed precondition."));
2002 data.Hook =
nullptr;
2009void TWaitCursor::Restore()
2011 TEnumInfoStr&
data = GetEnumInfo();
2015 data.Hook =
nullptr;
2024 TEnumInfoStr&
data = GetEnumInfo();
2071 TModule*
module = new TModule(mname.c_str(),true, false, true);
2076 module = new TModule(locname.c_str(),true, false, true);
2081 module = Application;
Definition of class TAppDictionary.
Definition of class TApplication.
Legacy support for Borland Windows Custom Controls (BWCC)
#define WARNX(group, condition, level, message)
#define WARN(condition, message)
#define PRECONDITION(condition)
#define TRACEX(group, level, message)
#define DIAG_DEFINE_GROUP_INIT(f, g, e, l)
TAppDictionary implementation for DLLs only.
TApplication * GetApplication(uint pid=0)
Looks up and returns the application associated with a given process ID.
void Remove(TApplication *app)
Searches for the dictionary entry using the specified application (app).
void Add(TApplication *app, uint pid=0)
Adds an application object (app) and corresponding process ID to this dictionary.
Derived from TModule and TMsgThread and virtually derived from TEventHandler, TApplication acts as an...
virtual bool ProcessAppMsg(MSG &msg)
Called after each message is pulled from the queue, and before it is dispatched.
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)
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.
void SetTooltip(TTooltip *tooltip)
Assigns tooltip.
int MessageBox(HWND wnd, const tstring &text, const tstring &caption=tstring(), uint type=MB_OK) const
virtual void WaitOnObject(HANDLE handle, bool wait)
virtual void EnableTooltip(bool enable=true)
auto IdleAction(long idleCount) -> bool override
Called each time there are no messages in the queue.
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.
TWindow * GetWindowPtr(HWND hWnd) const
Get the TWindow pointer belonging to this app given an hWnd.
virtual void InitApplication()
Handle initialization for the first executing instance of the OWL application.
TFrameWindow * SetMainWindow(TFrameWindow *window)
Set (or reset) the main window.
auto Run() -> int override
Run this application, return when application terminates.
auto Find(TEventInfo &, TEqualOperator=nullptr) -> bool override
Overrides TEventHandler::Find.
virtual void InitMainWindow()
Initialize the application's main window.
auto ProcessMsg(MSG &) -> bool override
Called for each message that is pulled from the queue, to perform all translation & dispatching.
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().
virtual int Start() noexcept
Start this application and return immediately. Used for component DLLs.
void InitInstance() override
Performs each instance initialization necessary for the application.
~TApplication() override
~TApplication destroys the TApplication object.
TFrameWindow * GetMainWindow()
Return the current main window.
TDocManager * SetDocManager(TDocManager *docManager)
Set (or resets) the document manager, return the previous one if present.
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.
TDocManager creates a document manager object that manages the list of current documents and register...
A nested class, TEventInfo provides specific information about the type of message sent,...
virtual bool Find(TEventInfo &info, TEqualOperator op=0)
Searches the list of response table entries looking for a match.
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...
Derived from TWindow, TFrameWindow controls such window-specific behavior as keyboard navigation and ...
auto IdleAction(long idleCount) -> bool override
Overrides TWindow's virtual function.
void SetLanguage(const TLangId &langId)
TApplication * Application
Derived from TGadgetWindow, TMessageBar implements a message bar with one text gadget as wide as the ...
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TMsgThread implements basic behavior for threads that own message queues, including mutex locking for...
bool BreakMessageLoop
Message loop is broken via WM_QUIT.
virtual void InitInstance()
Handles initialization for each executing instance of the message thread.
virtual int TermInstance(int status)
Handles termination for each executing instance of the message thread.
bool LoopRunning
Track if the loop is running.
int MessageLoopResult
Return value from message loop.
void FlushQueue()
Flushes all real messages from the message queue.
bool PumpWaitingMessages()
The inner message loop.
TPoint is a support class, derived from tagPOINT.
A template class, TResponseTableEntry lets you define a pattern for entries into a response table.
static uint GetMajorVersion()
static void DestroyInstance()
static auto GetInstance(bool shouldCreateIfNeccessary=false) -> TTraceWindow *
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
void SetNext(TWindow *next)
Sets the next window in the sibling list.
virtual void SetParent(TWindow *newParent)
Sets the parent for the specified window by setting Parent to the specified new Parent window object.
virtual bool EnableWindow(bool enable)
Allows the given window to receive input from the keyboard of mouse.
void DrawMenuBar()
DrawMenuBar redraws the menu bar.
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
virtual bool Create()
Creates the window interface element to be associated with this ObjectWindows interface element.
void SetFlag(uint mask)
Sets the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
TWindow * GetParentO() const
Return the OWL's parent for this window.
uint32 SetExStyle(uint32 style)
Sets the extra style bits of the window.
bool IsWindow() const
Returns true if an HWND is being used.
bool IsChild(HWND hWnd) const
Returns true if the window is a child window or a descendant window of this window.
uint32 GetExStyle() const
Gets the extra style bits of the window.
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
virtual bool CanClose()
Use this function to determine if it is okay to close a window.
void ClearFlag(uint mask)
Clears the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
TWindow * Next()
Returns a pointer to the next sibling window in the window's sibling list.
virtual bool ShowWindow(int cmdShow)
Displays this TWindow in a given state.
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
HWND GetHandle() const
Returns the handle of the window.
auto ChildWithId(int id) const -> const TWindow *
Derived from xmsg, TXBase is the base class for ObjectWindows and ObjectComponents exception-handling...
A nested class, TXInvalidMainWindow describes an exception that results from an invalid Window.
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.
#define WM_OWLPREPROCMENU
Definition of class TDocManager.
Definition of class TFrameWindow.
#define IMPLEMENT_STREAMABLE_POINTER(cls)
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
#define IMPLEMENT_STREAMABLE_CLASS(cls)
#define IMPLEMENT_STREAMABLE1(cls, base1)
#define IMPLEMENT_STREAMER(cls)
virtual int Unhandled(TModule *appModule, uint promptResId)
Per-exception class unhandled-handler, will default to the per-module unhandled-handler.
#define LOCKAPPLDATA(l, s)
#define LOCKENUMINFO(l, s)
THandle GetHandle() const
Return the instance handle of the library module represented by the TModule obect.
LPCTSTR GetName() const
Returns the name of the module.
FARPROC GetProcAddress(TNarrowResId) const
Returns the entry-point address of the specified exported function if found, otherwise returns NULL.
virtual int Error(TXBase &x, uint captionResId, uint promptResId=0)
Replaceable exception handler; may be redefined to process OWL exceptions if canResume is false,...
@ wfMainWindow
This frame window is the main window.
Definition of class TMessageBar.
Object Windows Library (OWLNext Core)
UINT TMsgId
Message ID type.
bool FilterWindow(HWND hWnd)
int OWLMessageBox(HWND wnd, const tstring &text, const tstring &caption, uint type)
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
LPARAM TParam2
Second parameter type.
int(* TMessageBox)(HWND wnd, LPCTSTR text, const LPCTSTR caption, uint type)
WPARAM TParam1
First parameter type.
const TLangId LangNeutral
const TLangId LangUserDefault
TAppDictionary & OWLGetAppDictionary()
Global exported TAppDictionary in Owl.
LRESULT TResult
Result type.
auto to_tstring(const T &v) -> tstring
#define TYPESAFE_DOWNCAST(object, toClass)
Definition of private class TTraceWindow.
#define EV_COMMAND(id, method)
Response table entry for a menu/accelerator/push button message.