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;
83 static LRESULT CALLBACK WaitWndProc(HWND, UINT, WPARAM, LPARAM);
88#if defined(BI_MULTI_THREAD_RTL)
93 TEnumInfoStr():Info(nullptr),Hook(nullptr),Top(nullptr)
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 {
121struct TApplicatData :
public TLocalObject {
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)
167OWLDefaultMsgBox(HWND wnd, LPCTSTR text, LPCTSTR caption,
uint type)
173TApplicatData::TApplicatData()
174: OwlMsgBox(OWLDefaultMsgBox)
178TApplicatData::~TApplicatData()
186TApplicatData& GetApplicatData()
191 static TApplicatData __ApplData;
197TEnumInfoStr& GetEnumInfo()
202 static TEnumInfoStr __EnumInfo;
211HINSTANCE TApplication::InitHInstance;
212HINSTANCE TApplication::InitHPrevInstance;
213int TApplication::InitCmdShow;
220 TApplicatData& data = GetApplicatData();
223 data.OwlMsgBox = newMsgBox;
230 return OWLMessageBox(wnd, text.c_str(), caption.c_str(), type);
239 if (!wnd && !(type & MB_SYSTEMMODAL))
240 type |= MB_TASKMODAL;
242 LPCTSTR _caption = caption;
243 if (_caption ==
nullptr)
245 return (GetApplicatData().OwlMsgBox)(wnd, text, _caption, type);
251 return OWLMessageBox(wnd, resId, caption.c_str(), type, module);
257 TModule& m =
module ? *module : wnd && wnd->GetModule() ? *wnd->GetModule() : GetGlobalModule();
259 LPCTSTR _caption = caption;
260 if (_caption ==
nullptr && wnd && wnd->GetApplication())
261 _caption = wnd->GetApplication()->GetName();
263 HWND h = wnd ? wnd->GetHandle() :
static_cast<HWND
>(
nullptr);
272TApplication::GetInitCmdLine()
274 static tstring InitCmdLine;
290 TModule(name, InitHInstance, GetInitCmdLine()),
295 hPrevInstance(InitHPrevInstance), nCmdShow(InitCmdShow),
296 DocManager(nullptr), MainWindow(nullptr),
299 CmdLine(GetInitCmdLine()),
301 WaitHandles(nullptr),
302#if defined(OWL_SUPPORT_BWCC)
303 BWCCOn(false),BWCCModule(0),
305#if defined(OWL_SUPPORT_CTL3D)
306 Ctl3dOn(false),Ctl3dModule(0),
310 CondemnedWindows(nullptr),
315 Dictionary->Add(
this);
326 TModule(name, InitHInstance, GetInitCmdLine()),
331 hPrevInstance(InitHPrevInstance), nCmdShow(InitCmdShow),
332 DocManager(nullptr), MainWindow(nullptr),
335 CmdLine(GetInitCmdLine()),
337 WaitHandles(nullptr),
338#if defined(OWL_SUPPORT_BWCC)
339 BWCCOn(false), BWCCModule(0),
341#if defined(OWL_SUPPORT_CTL3D)
342 Ctl3dOn(false), Ctl3dModule(0),
346 CondemnedWindows(nullptr),
351 Dictionary->Add(
this);
376 HINSTANCE prevInstance,
383 TModule(name, instance, cmdLine),
385 hPrevInstance(prevInstance), nCmdShow(cmdShow),
386 DocManager(nullptr), MainWindow(nullptr),
391 WaitHandles(nullptr),
392#if defined(OWL_SUPPORT_BWCC)
393 BWCCOn(false),BWCCModule(0),
395#if defined(OWL_SUPPORT_CTL3D)
396 Ctl3dOn(false),Ctl3dModule(0),
400 CondemnedWindows(nullptr),
405 Dictionary->Add(
this);
418 HINSTANCE prevInstance,
425 TModule(name, instance, cmdLine),
427 hPrevInstance(prevInstance), nCmdShow(cmdShow),
428 DocManager(nullptr), MainWindow(nullptr),
433 WaitHandles(nullptr),
434#if defined(OWL_SUPPORT_BWCC)
435 BWCCOn(false), BWCCModule(0),
437#if defined(OWL_SUPPORT_CTL3D)
438 Ctl3dOn(false), Ctl3dModule(0),
442 CondemnedWindows(nullptr),
447 Dictionary->Add(
this);
462#if defined(OWL_SUPPORT_CTL3D)
466 Ctl3dModule->Unregister(*
this);
470#if defined(OWL_SUPPORT_BWCC)
473 BWCCModule->IntlTerm();
492 Dictionary->Remove(
this);
522 const auto caption = caption_ ? caption_ :
GetName();
526 const auto needTaskModal = !(type & (MB_TASKMODAL | MB_SYSTEMMODAL)) && !wnd;
528 type |= MB_TASKMODAL;
530 WARNX(OwlApp, needTaskModal, 1, fun
531 <<
_T(
": NULL handle without either MB_TASKMODAL or MB_SYSTEMMODAL is not allowed;")
532 <<
_T(
"Applying MB_TASKMODAL."));
534 WARNX(OwlApp, wnd && (type & MB_TASKMODAL), 0, fun
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)
541 if (BWCCEnabled() && GetBWCCModule()) {
542 return GetBWCCModule()->MessageBox( wnd, text, caption, type);
548#if defined(OWL_SUPPORT_CTL3D)
550 EnableCtl3dAutosubclass(
true);
551 int retValue = (GetApplicatData().OwlMsgBox)(wnd, text, caption, type);
552 EnableCtl3dAutosubclass(
false);
556 return (GetApplicatData().OwlMsgBox)(wnd, text, caption, type);
585 TRACEX(OwlApp, 1,
_T(
"TApplication::InitApplication() called @") << (
void*)
this);
605 TRACEX(OwlApp, 1,
_T(
"TApplication::InitInstance() called @") << (
void*)
this);
611 MainWindow->Create();
613#if defined(__TRACE) || defined(__WARN)
624 MainWindow->ShowWindow(nCmdShow);
661 TRACEX(OwlApp, 1,
_T(
"TApplication::TermInstance() called @") << (
void*)
this);
663#if defined(__TRACE) || defined(__WARN)
685 uint32 style = MainWindow->GetExStyle();
688 if(Tooltip && Tooltip->GetParentO()==MainWindow)
689 Tooltip->SetParent(
nullptr);
697 uint32 style = MainWindow->GetExStyle();
701 if(Tooltip && Tooltip->GetParentO()==
nullptr && MainWindow->GetHandle())
702 Tooltip->SetParent(MainWindow);
704 return oldMainWindow;
712 auto old = std::unique_ptr<TFrameWindow>{
SetMainWindow(f.get())};
724 DocManager = docManager;
725 return oldDocManager;
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;}
832 DWORD r = MsgWaitForMultipleObjects(WaitCount, WaitHandles, FALSE, INFINITE, QS_ALLINPUT);
833 if (r >= WAIT_OBJECT_0 && r < WAIT_OBJECT_0 + WaitCount)
835 else if (r >= WAIT_ABANDONED_0 && r < WAIT_ABANDONED_0 + WaitCount)
865 TRACEX(OwlApp, 1,
_T(
"TApplication::IdleAction() called @") << (
void*)
this <<
866 _T(
" idleCount ") << idleCount);
869 more = MainWindow->IdleAction(idleCount);
871#if defined(__TRACE) || defined(__WARN)
876 const auto diagIdleAction = [](
long idleCount)
881 if (t && t->IdleAction(idleCount))
885 if (diagIdleAction(idleCount))
907 ::TranslateMessage(&msg);
909 TEventInfo cmdEventInfo(msg.message,
static_cast<uint>(msg.wParam));
910 if (
Find(cmdEventInfo)) {
911 Dispatch(cmdEventInfo, msg.wParam, msg.lParam);
916 if (
Find(eventInfo)) {
917 Dispatch(eventInfo, msg.wParam, msg.lParam);
922 ::DispatchMessage(&msg);
945 if (Tooltip && Tooltip->IsWindow()) {
946 if (msg.hwnd == *MainWindow || MainWindow->IsChild(msg.hwnd)) {
947 if (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST) {
948 Tooltip->RelayEvent(msg);
957 for (HWND hWnd = msg.hwnd; hWnd; hWnd = ::GetParent(hWnd)) {
964 static HWND deskTopHwnd = ::GetDesktopWindow();
965 if (hWnd == deskTopHwnd)
984 for (
int i = 0; i < static_cast<int>(WaitCount); i++)
985 if (WaitHandles[i] == handle)
996 LPHANDLE newHandles =
new HANDLE[WaitCount + 1];
997 for (
int i = 0; i < static_cast<int>(WaitCount); i++)
998 newHandles[i] = WaitHandles[i];
999 delete[] WaitHandles;
1000 WaitHandles = newHandles;
1001 WaitHandles[WaitCount] = handle;
1011 delete[] WaitHandles;
1012 WaitHandles =
nullptr;
1017 LPHANDLE newHandles =
new HANDLE[WaitCount - 1];
1020 for (i = 0; i < index; i++)
1021 newHandles[i] = WaitHandles[i];
1022 for (i = index + 1; i < static_cast<int>(WaitCount); 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;
1042 ::PostQuitMessage(-1);
1052 if (CurrentException ==
nullptr)
return;
1054 TRACEX(OwlApp, 0,
_T(
"TApplication::ResumeThrow: Rethrowing suspended exception."));
1055 exception_ptr e = CurrentException;
1056 CurrentException = exception_ptr();
1057 rethrow_exception(e);
1072 if (!::PeekMessage(&msg,
nullptr, 0, 0, PM_NOREMOVE))
1088 TWindow* tipParent = MainWindow;
1089 if(!MainWindow->GetHandle())
1090 tipParent =
nullptr;
1096 if (Tooltip->GetHandle())
1097 Tooltip->Activate(enable);
1110 if (Tooltip->GetHandle())
1111 Tooltip->SendMessage(WM_CLOSE);
1119 if (Tooltip && !Tooltip->GetHandle() &&
1120 MainWindow && MainWindow->GetHandle()) {
1121 if(!Tooltip->GetParentO())
1122 Tooltip->SetParent(MainWindow);
1124 Tooltip->ModifyStyle(0,WS_DISABLED);
1133void TApplication::EvSysCommand([[maybe_unused]]
uint cmd,
const TPoint&)
1136#if defined(__TRACE) || defined(__WARN)
1144 switch (cmd & 0xFFF0)
1155 t->ShowWindow(SW_SHOWNORMAL);
1163 if (cmd & (SC_KEYMENU | SC_MOUSEMENU))
1165 if (
const auto h = w->GetHandle())
1168 TSystemMenu{h}.CheckMenuItem(
ScmTrace, MF_BYCOMMAND | c);
1181TApplication::CmExit()
1185 frame->SendMessage(WM_CLOSE);
1201 const auto r = DocManager ? DocManager->Find(eventInfo, equal) :
false;
1204#if OWL_NEW_RESPONSE_TABLE
1216 static const TEntry entries[] =
1222 eventInfo.Object =
reinterpret_cast<TGeneric*
>(
this);
1243 return (!MainWindow || MainWindow->CanClose())
1244 && (!DocManager ||!DocManager->Find(eventInfo)
1245 || DocManager->Dispatch(eventInfo, 0, 0));
1257 if (DocManager && DocManager->Find(eventInfo)) {
1258 DocManager->Dispatch(eventInfo,
TParam1(hMenubar), 0);
1259 MainWindow->DrawMenuBar();
1284 TRACEX(OwlApp, 1,
_T(
"Condemning window @") << (
void*)win << *win);
1288 if (!CondemnedWindows)
1290 CondemnedWindows = win;
1297 for (
TWindow* w = CondemnedWindows; w; eol = w, w = w->
Next())
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);
1328 CondemnedWindows = win->
Next();
1343TApplication::DeleteCondemned()
1356 auto c = vector<TWindow*>{};
1357 while (CondemnedWindows)
1359 const auto next = CondemnedWindows->
Next();
1360 c.push_back(CondemnedWindows);
1361 CondemnedWindows = next;
1363 for (
const auto w : c)
1365 TRACEX(OwlApp, 1,
_T(
"Deleting condemned window @") << w << *w);
1369 while (CondemnedWindows);
1379 TXOwl(IDS_INVALIDMAINWINDOW)
1414disableWnds(HWND hWnd, TEnumInfo * ei)
1416 if (!(::GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)) {
1417 if (hWnd != ei->ModalWnd && ::IsWindowEnabled(hWnd)) {
1422 *(ei->Wnds++) = hWnd;
1423 ::EnableWindow(hWnd,
false);
1434static void termModal(TEnumInfo& ei)
1439 for (HWND* hWnd = ei.Wnds; *hWnd; hWnd++)
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};
1471 TEnumInfo* lastStackTop;
1473 TEnumInfoStr& data = GetEnumInfo();
1475 lastStackTop = data.GetInfo();
1484 if (flags & MB_SYSTEMMODAL) {
1485 flags &= ~MB_SYSTEMMODAL;
1486 flags |= MB_TASKMODAL;
1491 if (flags & MB_TASKMODAL) {
1500 if (!EnumThreadWindows(GetCurrentThreadId(), (WNDENUMPROC)disableWnds,
1501 TParam2(
static_cast<TEnumInfo *
>(&ei))))
1507 HWND* hWnds = ei.Wnds =
new HWND[ei.Count + 1];
1510 EnumThreadWindows(GetCurrentThreadId(),
reinterpret_cast<WNDENUMPROC
>(disableWnds),
1511 TParam2(
reinterpret_cast<TEnumInfo *
>(&ei)));
1533 TEnumInfoStr& data = GetEnumInfo();
1536 data.SetInfo(lastStackTop);
1541 TEnumInfoStr& data = GetEnumInfo();
1543 data.SetInfo(lastStackTop);
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
1582TApplication::EnableBWCC(
bool enable,
uint language)
1587 BWCCModule =
new TBwccDll();
1588 BWCCModule->IntlInit(language);
1591 WARNX(OwlApp, BWCCModule->GetVersion() < BWCCVERSION, 0, \
1592 _T(
"Old version of BWCC DLL found"));
1595 TRACEX(OwlApp, 0,
_T(
"Unable to create instance of TBwccDll"));
1605#if defined(OWL_SUPPORT_CTL3D)
1613TApplication::EnableCtl3d(
bool enable)
1628 Ctl3dModule =
new TCtl3dDll();
1629 Ctl3dModule->Register(*
this);
1632 TRACEX(OwlApp, 0,
_T(
"Unable to create instance of TCtl3dDll"));
1654TApplication::EnableCtl3dAutosubclass(
bool enable)
const
1656 if (Ctl3dEnabled()) {
1658 Ctl3dModule->Register(*
this);
1659 Ctl3dModule->AutoSubclass(*
this);
1662 Ctl3dModule->Unregister(*
this);
1669#if defined(OWL_SUPPORT_BWCC)
1674 const tchar BwccDllName[] =
_T(
"BWCC32.DLL");
1699 TModule(BwccDllName, true, true, false),
1701 IntlInit(*this,
"BWCCIntlInit"),
1702 Register(*this,
"BWCCRegister"),
1703 IntlTerm(*this,
"BWCCIntlTerm"),
1705 SpecialLoadDialog(*this,
"SpecialLoadDialog"),
1706 MangleDialog(*this,
"MangleDialog"),
1707 DefDlgProc(*this,
"BWCCDefDlgProc"),
1708 DefGrayDlgProc(*this,
"BWCCDefGrayDlgProc"),
1709 DefWindowProc(*this,
"BWCCDefWindowProc"),
1710 DefMDIChildProc(*this,
"BWCCDefMDIChildProc"),
1711 MessageBox(*this,
"BWCCMessageBox"),
1712 GetPattern(*this,
"BWCCGetPattern"),
1713 GetVersion(*this,
"BWCCGetVersion")
1719#if defined(OWL_SUPPORT_CTL3D)
1724 const tchar Ctl3dDllName[] =
_T(
"CTL3D32.DLL");
1730TCtl3dDll::TCtl3dDll()
1732 TModule(Ctl3dDllName, true, true, false),
1734 Register(*this,
"Ctl3dRegister"),
1735 Unregister(*this,
"Ctl3dUnregister"),
1736 AutoSubclass(*this,
"Ctl3dAutoSubclass"),
1737 CtlColorEx(*this,
"Ctl3dCtlColorEx"),
1738 SubclassDlg(*this,
"Ctl3dSubclassDlg"),
1739 SubclassDlgEx(*this,
"Ctl3dSubclassDlgEx"),
1740 GetVer(*this,
"Ctl3dGetVer"),
1741 Enabled(*this,
"Ctl3dEnabled"),
1742 ColorChange(*this,
"Ctl3dColorChange"),
1743 SubclassCtl(*this,
"Ctl3dSubclassCtl"),
1744 DlgFramePaint(*this,
"Ctl3dDlgFramePaint"),
1745 WinIniChange(*this,
"Ctl3dWinIniChange")
1752#if OWL_PERSISTENT_STREAMS
1787TApplication::Streamer::Write(
opstream& os)
const
1805 return !::IsWindowEnabled (hWnd) || !::IsWindowVisible (hWnd);
1812subclassWnds(HWND hWnd, TEnumInfo * ei)
1819 *(ei->Wnds++) = hWnd;
1820 *(ei->PrevWndProc++) =
reinterpret_cast<WNDPROC
>(::SetWindowLongPtr(hWnd, GWLP_WNDPROC,
reinterpret_cast<LONG_PTR
>(TWaitHook::WaitWndProc)));
1831TWaitHook::TWaitHook()
1833 LastStackTop(nullptr),
1836 DeleteOnClose(false)
1838 memset(&Subclass,0,
sizeof(Subclass));
1840 TEnumInfoStr& data = GetEnumInfo();
1841 LastStackTop = data.GetInfo();
1842 data.SetInfo(&Subclass);
1846 if (!::EnumThreadWindows(GetCurrentThreadId(),
reinterpret_cast<WNDENUMPROC
>(subclassWnds),
1847 TParam2(
reinterpret_cast<TEnumInfo *
>(&Subclass))))
1853 HWND* hWnds = Subclass.Wnds =
new HWND[Subclass.Count + 1];
1854 WNDPROC* fProc = Subclass.PrevWndProc =
new WNDPROC[Subclass.Count + 1];
1855 memset(Subclass.Wnds, 0,
sizeof(HWND)*(Subclass.Count + 1));
1856 memset(Subclass.PrevWndProc, 0,
sizeof(WNDPROC)*(Subclass.Count + 1));
1858 EnumThreadWindows(GetCurrentThreadId(),
reinterpret_cast<WNDENUMPROC
>(subclassWnds),
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++)
1874 ::SetWindowLongPtr(Subclass.Wnds[i], GWLP_WNDPROC,
reinterpret_cast<LONG_PTR
>(Subclass.PrevWndProc[i]));
1876 delete [] Subclass.Wnds;
1877 delete [] Subclass.PrevWndProc;
1879 while(HideCaretCount--)
1883 ::GetCursorPos(&pt);
1884 ::SetCursorPos(pt.x, pt.y);
1886 GetEnumInfo().SetInfo(LastStackTop);
1891void TWaitHook::FreeCursors()
1898void TWaitHook::SetCursor(TCursor* cursor, TAutoDelete del)
1905void TWaitHook::SetWaitCursor()
1907 ::SetCursor(*Cursor);
1910LRESULT CALLBACK TWaitHook::WaitWndProc(HWND wnd, UINT msg, WPARAM param1, LPARAM param2)
1912 return GetEnumInfo().Hook->WaitWndMethod(wnd, msg, param1, param2);
1915TResult TWaitHook::WaitWndMethod(HWND wnd, TMsgId msg, TParam1 param1, TParam2 param2)
1917 HWND hTopMostWindow;
1923 case WM_MOUSEACTIVATE:
1924 hTopMostWindow =
reinterpret_cast<HWND
>(param1);
1926 if (hTopMostWindow == wnd)
1927 return MA_ACTIVATEANDEAT;
1929 return ::DefWindowProc(wnd, msg, param1, param2);
1932 DefWndProc (wnd, msg, param1, param2);
1938 if ((msg >= WM_KEYFIRST && msg <= WM_KEYLAST) ||
1939 (msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST) ||
1940 (msg >= WM_NCMOUSEFIRST && msg <= WM_NCMOUSELAST))
1944 return DefWndProc (wnd, msg, param1, param2);
1947TResult TWaitHook::DefWndProc(HWND wnd, TMsgId msg, TParam1 param1, TParam2 param2)
1949 for(
int i = 0; i < static_cast<int>(Subclass.Count); i++){
1950 if (Subclass.Wnds[i] == wnd)
1951 return CallWindowProc(Subclass.PrevWndProc[i], wnd, msg, param1, param2);
1964 TEnumInfoStr& data = GetEnumInfo();
1967 data.Hook->SetCursor(cursor,del);
1975void TWaitCursor::Init()
1977 TEnumInfoStr& data = GetEnumInfo();
1983 data.Hook =
new TWaitHook;
1991 TEnumInfoStr& data = GetEnumInfo();
1994 const auto ok = data.Top ==
this;
1995 WARN(!ok,
_T(
"TWaitCursor::~TWaitCursor: Terminating due to failed precondition."));
1996 if (!ok) terminate();
2002 data.Hook =
nullptr;
2011 TEnumInfoStr& data = GetEnumInfo();
2015 data.Hook =
nullptr;
2024 TEnumInfoStr& data = GetEnumInfo();
2026 if(data.Top ==
this && data.Hook){
2049 LangId(static_cast<unsigned short>(-1))
2064 tchar szLocName[10];
2065 int retval = ::GetLocaleInfo(langId,LOCALE_SABBREVLANGNAME, szLocName, 10);
2070 mname +=
_T(
".DLL");
2072 if(module->
GetHandle() <= HINSTANCE(HINSTANCE_ERROR)){
2075 locname +=
_T(
"ENU.DLL");
2076 module = new TModule(locname.c_str(),true, false, true);
2077 if(module->
GetHandle() > HINSTANCE(HINSTANCE_ERROR))
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)
TAppDictionary implementation for DLLs only.
TApplication * GetApplication(uint pid=0)
Looks up and returns the application associated with a given process ID.
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 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.
TLangId GetLangId() const
Returns identifier of language used by application.
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.
TCursor(HCURSOR handle, TAutoDelete autoDelete=NoAutoDelete)
Creates a TCursor object and sets the Handle data member to the given borrowed handle.
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.
bool(*) TEqualOperator(const TGenericTableEntry &, const TEventInfo &)
bool SearchEntries(const TGenericTableEntry *entries, TEventInfo &info, TEqualOperator op)
Low-level response table search function.
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 ...
TFrameWindow()
< String-aware overload
void SetLanguage(const TLangId &langId)
TApplication * Application
TLangModule(const tstring &prefix, const TApplication &appl)
Derived from TGadgetWindow, TMessageBar implements a message bar with one text gadget as wide as the ...
virtual void SetHintText(LPCTSTR text)
Sets the hint text displayed on the messagebar.
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...
virtual int Run()
Runs this message thread, returns when the message queue quits.
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.
virtual int MessageLoop()
Retrieves and processes messages from the thread's message queue using PumpWaitingMessages() until Br...
int MessageLoopResult
Return value from message loop.
void FlushQueue()
Flushes all real messages from the message queue.
TMsgThread(TCurrent)
Attaches to the current running thread.
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.
void(T::*) PMF()
Type for a generic member function that responds to notification messages.
static uint GetMajorVersion()
static void DestroyInstance()
static auto GetInstance(bool shouldCreateIfNeccessary=false) -> TTraceWindow *
~TWaitCursor()
Restores the previous cursor.
void Restore()
Restores old state of cursor.
void Message(const tstring &text)
Sends text to the applications TMessageBar::SetHintText function if it has one.
void SetCursor(TCursor *cursor, TAutoDelete=AutoDelete)
Changes the cursor to cursor.
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.
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
virtual void Destroy(int retVal=0)
Destroys an MS-Windows element associated with the TWindow.
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
void UpdateWindow()
Updates the client area of the specified window by immediately sending a WM_PAINT message.
TWindow * Next()
Returns a pointer to the next sibling window in the window's sibling list.
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.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Base class for writing streamable objects.
#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)
TResponseTableEntry< TGeneric > TGenericTableEntry
#define IMPLEMENT_STREAMER(cls)
TXOwl(const tstring &msg, uint resId=0)
An OWL exception with a given message for displaying and an unsigned Id that can be used for identifi...
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.
int LoadString(uint id, TCHAR *buf, int maxChars) const
Loads a string resource identified by id into the buffer pointed to by buff.
TModule(const tstring &name, bool shouldLoad=true, bool mustLoad=true, bool addToList=true)
Constructs a TModule object that is used as an alias for a DLL.
HINSTANCE THandle
TModule encapsulates an HINSTANCE.
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).
TMessageBox SetDefMessageBox(TMessageBox)
UINT TMsgId
Message ID type.
bool FilterWindow(HWND hWnd)
int(*) TMessageBox(HWND wnd, LPCTSTR text, const LPCTSTR caption, uint type)
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.
WPARAM TParam1
First parameter type.
const TLangId LangNeutral
const TLangId LangUserDefault
TAppDictionary & OWLGetAppDictionary()
Global exported TAppDictionary in Owl.
LRESULT TResult
Result type.
DIAG_DEFINE_GROUP_INIT(OWL_INI, OwlApp, 1, 0)
auto to_tstring(const T &v) -> tstring
IMPLEMENT_STREAMABLE1(TApplication, TModule)
EV_COMMAND(IDOK, CmOkCancel)
#define TYPESAFE_DOWNCAST(object, toClass)
Definition of private class TTraceWindow.