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)
515#if defined(OWL_SUPPORT_BWCC)
525#if defined(OWL_SUPPORT_CTL3D)
562 TRACEX(
OwlApp, 1,
_T(
"TApplication::InitApplication() called @") << (
void*)
this);
582 TRACEX(
OwlApp, 1,
_T(
"TApplication::InitInstance() called @") << (
void*)
this);
590#if defined(__TRACE) || defined(__WARN)
638 TRACEX(
OwlApp, 1,
_T(
"TApplication::TermInstance() called @") << (
void*)
this);
640#if defined(__TRACE) || defined(__WARN)
665 if(Tooltip && Tooltip->
GetParentO()==MainWindow)
689 auto old = std::unique_ptr<TFrameWindow>{SetMainWindow(f.get())};
710 auto old = std::unique_ptr<TDocManager>{SetDocManager(
d.get())};
715#if defined(BI_MULTI_THREAD_RTL)
722 TApplication::TQueueLock
lock(*
this);
785 catch (...) {status = -1;}
842 TRACEX(
OwlApp, 1,
_T(
"TApplication::IdleAction() called @") << (
void*)
this <<
848#if defined(__TRACE) || defined(__WARN)
922 if (Tooltip && Tooltip->
IsWindow()) {
923 if (
msg.hwnd == *MainWindow || MainWindow->
IsChild(
msg.hwnd)) {
975 newHandles[
i] = WaitHandles[
i];
976 delete[] WaitHandles;
977 WaitHandles = newHandles;
978 WaitHandles[WaitCount] =
handle;
988 delete[] WaitHandles;
989 WaitHandles =
nullptr;
997 for (
i = 0;
i < index;
i++)
998 newHandles[
i] = WaitHandles[
i];
1000 newHandles[
i-1] = WaitHandles[
i];
1001 delete[] WaitHandles;
1002 WaitHandles = newHandles;
1017 TRACEX(
OwlApp, 0,
_T(
"TApplication::SuspendThrow: Suspending exception and posting quit-message."));
1018 CurrentException =
e;
1029 if (CurrentException ==
nullptr)
return;
1031 TRACEX(
OwlApp, 0,
_T(
"TApplication::ResumeThrow: Rethrowing suspended exception."));
1097 MainWindow && MainWindow->
GetHandle()) {
1113#if defined(__TRACE) || defined(__WARN)
1121 switch (
cmd & 0xFFF0)
1142 if (
const auto h =
w->GetHandle())
1151 m->DefaultProcessing();
1158TApplication::CmExit()
1178 const auto r = DocManager ? DocManager->Find(
eventInfo,
equal) :
false;
1181#if OWL_NEW_RESPONSE_TABLE
1193 static const TEntry
entries[] =
1220 return (!MainWindow || MainWindow->
CanClose())
1259 TRACEX(
OwlApp, 1,
_T(
"Condemning window @") << (
void*)win << *win);
1265 if (CondemnedWindows)
1268 for (
eol = CondemnedWindows;
eol->Next();
eol =
eol->Next())
1271 CHECK(!
"Double condemn is not nice!");
1277 CondemnedWindows = win;
1288 if (win && CondemnedWindows) {
1290 if (CondemnedWindows != win)
1291 for (
w = CondemnedWindows;
w->Next() != win;
w =
w->Next())
1295 TRACEX(
OwlApp, 1,
_T(
"Uncondemning window @") << (
void*)win << *win);
1297 w->SetNext(win->
Next());
1299 CondemnedWindows = win->
Next();
1314TApplication::DeleteCondemned()
1328 while (CondemnedWindows)
1330 const auto next = CondemnedWindows->
Next();
1331 c.push_back(CondemnedWindows);
1332 CondemnedWindows =
next;
1334 for (
const auto w :
c)
1340 while (CondemnedWindows);
1388 if (
hWnd !=
ei->ModalWnd && ::IsWindowEnabled(
hWnd)) {
1394 ::EnableWindow(
hWnd,
false);
1405static void termModal(TEnumInfo&
ei)
1411 ::EnableWindow(*
hWnd,
true);
1416 if (
ei.ModalWnd && IsWindow(
ei.ModalWnd)) {
1417 ::EnableWindow(
ei.ModalWnd,
true);
1418 ei.ModalWnd =
nullptr;
1441 TEnumInfo
ei = {
nullptr, 0,
nullptr,
nullptr};
1444 TEnumInfoStr&
data = GetEnumInfo();
1472 TParam2(
static_cast<TEnumInfo *
>(&
ei))))
1482 TParam2(
reinterpret_cast<TEnumInfo *
>(&
ei)));
1504 TEnumInfoStr&
data = GetEnumInfo();
1512 TEnumInfoStr&
data = GetEnumInfo();
1532 TEnumInfoStr&
data = GetEnumInfo();
1533 if (
data.GetInfo()){
1535 termModal(*
data.GetInfo());
1540#if defined(OWL_SUPPORT_BWCC)
1542#if !defined(BWCCVERSION)
1543#define BWCCVERSION 0x0200
1563 _T(
"Old version of BWCC DLL found"));
1576#if defined(OWL_SUPPORT_CTL3D)
1584TApplication::EnableCtl3d(
bool enable)
1625TApplication::EnableCtl3dAutosubclass(
bool enable)
const
1640#if defined(OWL_SUPPORT_BWCC)
1673 Register(*
this,
"BWCCRegister"),
1680 DefWindowProc(*
this,
"BWCCDefWindowProc"),
1682 MessageBox(*
this,
"BWCCMessageBox"),
1684 GetVersion(*
this,
"BWCCGetVersion")
1690#if defined(OWL_SUPPORT_CTL3D)
1701TCtl3dDll::TCtl3dDll()
1705 Register(*
this,
"Ctl3dRegister"),
1706 Unregister(*
this,
"Ctl3dUnregister"),
1712 Enabled(*
this,
"Ctl3dEnabled"),
1723#if OWL_PERSISTENT_STREAMS
1738 TMsgThread(TMsgThread::Current)
1746TApplication::Streamer::Read(ipstream&
is,
uint32 )
const
1748 TApplication*
o = GetObject();
1758TApplication::Streamer::Write(opstream&
os)
const
1760 TApplication*
o = GetObject();
1776 return !::IsWindowEnabled (
hWnd) || !::IsWindowVisible (
hWnd);
1802TWaitHook::TWaitHook()
1807 DeleteOnClose(
false)
1809 memset(&Subclass,0,
sizeof(Subclass));
1811 TEnumInfoStr&
data = GetEnumInfo();
1812 LastStackTop =
data.GetInfo();
1813 data.SetInfo(&Subclass);
1818 TParam2(
reinterpret_cast<TEnumInfo *
>(&Subclass))))
1826 memset(Subclass.Wnds, 0,
sizeof(
HWND)*(Subclass.Count + 1));
1827 memset(Subclass.PrevWndProc, 0,
sizeof(
WNDPROC)*(Subclass.Count + 1));
1830 TParam2(
reinterpret_cast<TEnumInfo *
>(&Subclass)));
1832 Subclass.Wnds =
hWnds;
1833 Subclass.PrevWndProc =
fProc;
1837 Cursor =
new TCursor(::LoadCursor(
nullptr,
IDC_WAIT));
1838 DeleteOnClose =
true;
1842TWaitHook::~TWaitHook()
1844 for (
int i = 0;
i < Subclass.Count;
i++)
1847 delete [] Subclass.Wnds;
1848 delete [] Subclass.PrevWndProc;
1850 while(HideCaretCount--)
1854 ::GetCursorPos(&
pt);
1857 GetEnumInfo().SetInfo(LastStackTop);
1862void TWaitHook::FreeCursors()
1869void TWaitHook::SetCursor(TCursor*
cursor, TAutoDelete
del)
1876void TWaitHook::SetWaitCursor()
1878 ::SetCursor(*Cursor);
1911 (
msg >= WM_NCMOUSEFIRST &&
msg <= WM_NCMOUSELAST))
1921 if (Subclass.Wnds[
i] ==
wnd)
1935 TEnumInfoStr&
data = GetEnumInfo();
1946void TWaitCursor::Init()
1948 TEnumInfoStr&
data = GetEnumInfo();
1954 data.Hook =
new TWaitHook;
1960TWaitCursor::~TWaitCursor()
1962 TEnumInfoStr&
data = GetEnumInfo();
1965 const auto ok =
data.Top ==
this;
1966 WARN(!
ok,
_T(
"TWaitCursor::~TWaitCursor: Terminating due to failed precondition."));
1973 data.Hook =
nullptr;
1980void TWaitCursor::Restore()
1982 TEnumInfoStr&
data = GetEnumInfo();
1986 data.Hook =
nullptr;
1995 TEnumInfoStr&
data = GetEnumInfo();
2042 TModule*
module = new TModule(mname.c_str(),true, false, true);
2047 module = new TModule(locname.c_str(),true, false, true);
2052 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.
#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.