16#if defined(OWL_SUPPORT_BWCC)
20#include <owl/winres.rh>
57#define dfTmplMask 0x0f0000
58#define dfTmplDelMask 0x0a0000
107 Init(parent,
nullptr, module);
109 DialogAttr.Name = resId.
IsString() ?
strnewdup(resId) :
const_cast<LPTSTR
>(
static_cast<LPCTSTR
>(resId));
126 Init(parent,
nullptr, module);
128 DialogAttr.Name =
reinterpret_cast<LPTSTR
>(
const_cast<DLGTEMPLATE*
>(&dlgTemplate));
145 Init(parent,
nullptr, module);
147 DialogAttr.Name =
reinterpret_cast<LPTSTR
>(GlobalLock(hTemplate));
158#if defined(OWL5_COMPAT)
177 DialogAttr.Param = 0;
178 DialogAttr.Name =
nullptr;
190 if (
TResId(DialogAttr.Name).IsString())
191 delete[] DialogAttr.Name;
196 ::GlobalFree(::GlobalHandle(DialogAttr.Name));
198 ::GlobalUnlock(::GlobalHandle(DialogAttr.Name));
202 if (DlgCreationWindow ==
this)
204 DlgCreationWindow =
nullptr;
231 ::TranslateMDISysAccel(client, &msg))
237 return ::IsDialogMessage(
GetHandle(), &msg);
247#if defined(OWL_SUPPORT_BWCC)
274#if defined(OWL_SUPPORT_BWCC)
277 const auto b = a->BWCCEnabled();
279 a->GetBWCCModule()->Register(*
GetModule());
355 TRACEX(OwlMsg, 2, TMsgName(msg) <<
_T(
"(DlgFcn)=> ") << *
this);
384 ~TEventGuard() { Current =
Previous; }
399 auto wasHandled =
TResult{FALSE};
405 Dispatch(eventInfo, param1, param2);
412#if defined(OWL_SUPPORT_CTL3D)
421 DlgFramePaint(
GetHandle(), msg, param1, param2));
446 if (msg == GetWindowPtrMsgId)
return false;
448 if (DlgCreationWindow && !dlg && msg != WM_CANCELMODE && msg != WM_ENABLE)
450 dlg = DlgCreationWindow;
453 DlgCreationWindow =
nullptr;
455 if (!dlg)
return false;
463 TRACEX(OwlWin, 0,
_T(
"TDialog::StdDlgProc: Suspending unhandled exception for message: ") << msg);
479 throw TXWindow(
this, IDS_CLASSREGISTERFAIL);
494#if defined(OWL5_COMPAT)
502 DlgCreationWindow =
this;
536 typedef const DLGTEMPLATE* TTemplate;
538 ::CreateDialogParam (
545 ::CreateDialogIndirectParam(
547 reinterpret_cast<TTemplate
>(DialogAttr.Name),
599#if defined(OWL5_COMPAT)
607 DlgCreationWindow =
this;
639 LPCDLGTEMPLATE t =
reinterpret_cast<LPCDLGTEMPLATE
>(DialogAttr.Name);
641 ::DialogBoxIndirectParam(m, t, p,
StdDlgProc, DialogAttr.Param) :
642 ::DialogBoxParam(m, DialogAttr.Name, p,
StdDlgProc, DialogAttr.Param);
643 WARN(r > INT_MAX,
_T(
"TDialog::DoExecute: EndDialog 64-bit result truncated to 32 bits."));
644 return static_cast<int>(r);
661 if (!DialogAttr.Name)
return true;
667 res =
reinterpret_cast<char*
>(DialogAttr.Name);
675 if (!hDat)
return false;
676 res =
static_cast<char*
>(::LockResource(hDat));
677 if (!res)
return false;
680 if (!res)
return true;
689 WORD idc = *
reinterpret_cast<WORD*
>(res); res +=
sizeof(idc);
690 WORD msg = *
reinterpret_cast<WORD*
>(res); res +=
sizeof(msg);
691 DWORD len = *
reinterpret_cast<DWORD*
>(res); res +=
sizeof(len);
704 if (res[len - 1] !=
'\0')
return false;
705 LPCTSTR text =
_A2W(
static_cast<LPCSTR
>(data));
707 if (r == LB_ERR || r == LB_ERRSPACE)
return false;
713 if (res[len - 1] !=
'\0')
return false;
714 LPCTSTR text =
_A2W(
static_cast<LPCSTR
>(data));
716 if (r == CB_ERR || r == CB_ERRSPACE)
return false;
722 if (res[len - 1] !=
'\0')
return false;
724 item.mask = CBEIF_TEXT;
726 item.pszText =
_A2W(
static_cast<LPSTR
>(data));
728 if (r == -1)
return false;
731 case OWL_DLGINIT_COMMAND:
737 TRACE(
_T(
"Corrupt OWL_DLGINIT_COMMAND in DLGINIT. Expected data size 0, but size was ") << len <<
_T(
".\n"));
747 IFDIAG(
static const tchar error[] =
_T(
"Either correct the command in the control title, or remove the OWL_DLGINIT_COMMAND message in DLGINIT.");)
750 in.setf(ios::skipws);
753 in >> openingBrace >> cmd;
754 if (!in.good() || openingBrace !=
_T(
'{'))
756 TRACE(
_T(
"PerformDlgInit expected {<command>} in the title of control #") << idc
757 <<
_T(
", but found \"") << title <<
_T(
"\".\n") << error);
760 if (cmd ==
_T(
"LoadString"))
764 in >>
id >> closingBrace;
765 if (!in.good() || closingBrace !=
_T(
'}'))
767 TRACE(
_T(
"PerformDlgInit found a syntax error in the title of control #") << idc
768 <<
_T(
": \"") << title <<
_T(
"\".\n") << error);
775 TRACE(
_T(
"PerformDlgInit didn't recognize the command in the title of control #") << idc
776 <<
_T(
": \"") << cmd <<
_T(
"\".\n") << error);
783 WARNX(OwlMsg,
true, 1,
_T(
"Default DLGINIT item handler sent message #") << msg <<
_T(
" to control #") << idc <<
_T(
" with no error handling."));
791 res =
static_cast<char*
>(data) + len;
827#if defined(OWL_SUPPORT_CTL3D)
893 w.EnableAutoCreate();
985 if(::SendMessage(
GetReceiver(), BM_GETCHECK,0,0) != check)
986 ::SendMessage(
GetReceiver(), BM_SETCHECK, check, 0);
999 if (idleCount == 0) {
1018 auto rScreen = rDialog;
1020 if (!r)
throw TXOwl{
_T(
"TDialog::MapDialogRectToScreen failed")};
1049#if OWL_PERSISTENT_STREAMS
1059 is >> (
TResId&)GetObject()->DialogAttr.Name;
1063 isModal ? GetObject()->SetFlag(dfIsModal) : GetObject()->ClearFlag(dfIsModal);
1072TDialog::Streamer::Write(opstream& os)
const
1076 os <<
TResId(GetObject()->DialogAttr.Name);
1077 os << (bool)GetObject()->IsFlagSet(dfIsModal);
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)
TApplication * GetApplication(uint pid=0)
Looks up and returns the application associated with a given process ID.
void ResumeThrow()
Rethrows the suspended exception stored by a previous call to SuspendThrow.
void SuspendThrow(std::exception_ptr)
Stores the given exception so that it can be rethrown later by a call to ResumeThrow.
void Condemn(TWindow *win)
Condemns the given window to be deleted the at the next available safe time.
virtual void Enable(bool enable=true)
Enables or disables the command sender.
TCommandEnabler(uint id, HWND hWndReceiver=0)
Constructs the TCommandEnabler object with the specified command ID.
HWND GetReceiver() const
Returns the handle of the window that this enabler was destined for.
A TCommandEnabler for child controls in a dialog.
void SetCheck(int check)
Use with only buttons!
void Enable(bool enable=true)
Enables/disables the control.
void SetText(LPCTSTR text)
Set the text of the control.
TControlEnabler(uint id, HWND hWndReceiver=0)
Constructor. Initializes the base class.
Typically used to obtain information from a user, a dialog box is a window inside of which other cont...
void Init(TWindow *parent, LPCTSTR title, TModule *module)
Common initialization in constructor.
void SetControlFocus(HWND hwnd)
Sets focus within a dialog to a specific control.
void CloseWindow(int retValue=IDCANCEL) override
Overrides the virtual function defined by TWindow and conditionally shuts down the dialog box.
virtual bool EvInitDialog(HWND hWndFocus)
Virtual handler for WM_INITDIALOG message, called from DialogFunction().
void GetWindowClass(WNDCLASS &) override
Overrides the virtual function defined in TWindow.
auto PreProcessMsg(MSG &) -> bool override
Preprocess posted messages to provide various accelerator translations.
THow
Enumeration to be used when invoking the 'SetControlFocus' method.
@ Next
Set focus to the next sibling.
@ Previous
Set focus to the previous sibling.
bool PerformDlgInit()
Initialize dialog controls with contents of DLGINIT resources, if any.
bool SetMsgResult(TResult result)
Sets the dialog procedure message result (DWLP_MSGRESULT) and returns true.
void EvClose()
Message response function for WM_CLOSE by unconditionally closing the window.
void EvReposition()
Reposition the dialog so that it fits within the desktop area.
auto PerformCreate() -> THandle override
Called from Create to perform the final step in creating an Windows interface element to be associate...
bool MapDialogRect(TRect &rect) const
Converts the coordinates of the given rect from dialog units into screen units.
void CmOk()
Responds to a click on the dialog box's OK button with the identifier IDOK.
void SetupWindow() override
Overrides the virtual function defined in TWindow.
uint EvGetDefId()
Return the default Id.
~TDialog() override
Destructor for a TDialog.
void Destroy(int retValue=IDCANCEL) override
Destroys the interface element associated with the TDialog object.
virtual INT_PTR DialogFunction(TMsgId, TParam1, TParam2)
Override this to process messages within the dialog function.
bool EvSetDefId(int id)
Set the pushbutton with identifier id the default button for the dialog.
void RegisterChildObjects()
Registers WINDOW class(es) of Children.
auto GetWindowClassName() -> TWindowClassName override
Overrides the virtual function defined in TWindow and returns the name of the dialog box's default Wi...
void EvPaint()
Handler for WM_PAINT.
void CmCancel()
Responds to an incoming notification message from a button with an Id equal to IDCANCEL.
static INT_PTR CALLBACK StdDlgProc(HWND, UINT, WPARAM, LPARAM) noexcept
Callback procs for hooking TDialog to native window.
auto DoExecute() -> int override
Overriden TWindow virtual to modaly execute this dialog & return the result.
auto MapDialogRectToScreen(const TRect &) const -> TRect
Returns the rect, specified in screen coordinates, corresponding to the given rect,...
TDialog(TWindow *parent, TResId resId, TModule *module=nullptr)
Constructor for a TDialog object.
auto IdleAction(long idleCount) -> bool override
Handle enabling and disabling of child controls.
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...
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TRect is a mathematical class derived from tagRect.
bool IsString() const
Returns true if this resource identifier encodes a string pointer.
static BOOL GetClassInfo(HINSTANCE, LPCTSTR, LPWNDCLASS)
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
HWND GetParentH() const
Return the handle of the parent.
virtual THandle PerformCreate()
Called from Create to perform the final step in creating an Windows interface element to be associate...
TCurrentEvent & GetCurrentEvent()
Returns the current event to be processed in the message queue.
void SetDlgItemText(int childId, LPCTSTR text) const
Sets the title or text of a control in a dialog box.
TApplication * GetApplication() const
Gets a pointer to the TApplication object associated with this.
void GetHWndState(bool forceStyleSync=false)
Copies the style, coordinate, and the resource id (but not the title) from the existing HWnd into the...
TWindow(TWindow *parent, LPCTSTR title=nullptr, TModule *module=nullptr)
Adds this to the child list of parent if nonzero, and calls EnableAutoCreate so that this will be cre...
virtual int Execute()
Creates the underlying HWND and makes it modal with the help of TApplication's BeginModal support.
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
HWND GetWindow(uint cmd) const
Returns the handle of the window that has the indicated relationship to this window.
auto GetChildren()
Returns a TWindow::TChildrenRange that can be iterated by standard means.
virtual void Destroy(int retVal=0)
Destroys an MS-Windows element associated with the TWindow.
virtual bool Create()
Creates the window interface element to be associated with this ObjectWindows interface element.
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
virtual int DoExecute()
Do actual modal execution using the Begin/End Modal support of TApplication.
void GetWindowTextTitle()
Updates the TWindow internal caption (Title) from the current window's caption.
void DisableAutoCreate()
Disables the feature that allows an associated child window interface element to be created and displ...
void PerformSetupAndTransfer()
Ensures that the window is fully set up; then transfers data into the window.
void SetHandle(THandle)
Sets the window handle in a derived class.
virtual auto GetWindowClassName() -> TWindowClassName
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
void Init(TWindow *parent, LPCTSTR title, TModule *module)
Normal initialization of a default constructed TWindow.
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.
TModule * GetModule() const
Returns a pointer to the module object.
void LoadAcceleratorTable()
Loads a handle to the window's accelerator table specified in the TWindowAttr structure (Attr....
void RouteCommandEnable(HWND hInitCmdTarget, TCommandEnabler &ce)
Walks the chain of windows from the initial target window to this window.
bool IsWindow() const
Returns true if an HWND is being used.
void SetCaption(LPCTSTR title)
Copies title to an allocated string pointed to by title.
virtual bool IdleAction(long idleCount)
Called when no messages are waiting to be processed, IdleAction performs idle processing as long as t...
TResult SendDlgItemMessage(int childId, TMsgId, TParam1=0, TParam2=0)
Sends a message (msg) to the control specified in childId.
void SubclassWindowFunction()
Installs the instance thunk as the WindowProc and saves the old window function in DefaultProc.
LPCTSTR GetCaption() const
Returns the Title member of TWindow.
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
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,...
virtual void TransferData(TTransferDirection direction)
Transfers data between the TWindow's data buffer and the child windows in its ChildList (data is not ...
virtual bool Register()
Registers the Windows registration class of this window, if this window is not already registered.
int GetDlgItemText(int childId, TCHAR *text, int maxValue) const
Retrieves the text of a control specified by childId.
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
bool IsFlagSet(uint mask)
Returns the state of the bit flag in Attr.Flags whose mask is supplied.
HWND THandle
TWindow encapsulates an HWND.
HWND GetHandle() const
Returns the handle of the window.
virtual void CloseWindow(int retVal=0)
Determines if it is okay to close a window before actually closing the window.
TXOwl is root class of the ObjectWindows exception hierarchy.
static void Raise(TWindow *win=nullptr, uint resourceId=IDS_INVALIDWINDOW)
Creates the TXWindow exception and throws it.
TXWindow(TWindow *win=nullptr, uint resourceId=IDS_INVALIDWINDOW)
Constructs a TXWindow object with a default resource ID of IDS_INVALIDWINDOW.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of classes for CommonControl encapsulation.
Definition of TDialog class and TDialogAttr struct.
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
void ReadBaseObject(Base *base, ipstream &in)
void WriteBaseObject(Base *base, opstream &out)
THandle GetHandle() const
Return the instance handle of the library module represented by the TModule obect.
auto GetClassInfo(TWindowClassName, WNDCLASS *wndclass) const -> bool
Retrieves information about the given window class.
HGLOBAL LoadResource(HRSRC hRsrc) const
Wrapper for the Windows API.
HRSRC FindResource(TResId id, TResId type) const
Wrapper for the Windows API to find a particular resource.
HINSTANCE THandle
TModule encapsulates an HINSTANCE.
HRSRC FindResourceEx(TResId id, TResId type, TLangId langId=LangNeutral) const
Wrapper for the Windows API to find a particular resource.
@ wfDeleteOnClose
Window is condemned on EvClose.
@ wfAlias
TWindow is an alias to a preexisting HWND.
@ wfFromResource
Handle comes from HWND created from resource.
@ wfFullyCreated
Window is fully created & not being destroyed.
@ tdGetData
Get data from the window into the buffer.
char * strnewdup(const char *s, size_t minAllocSize=0)
Object Windows Library (OWLNext Core).
_OWLDATA(uint) GetWindowPtrMsgId
UINT TMsgId
Message ID type.
TWindow * GetWindowPtr(HWND, const TApplication *)
Raw function to retrieve a TWindow pointer given an HWND from the a given app, or any app (app==0).
LPARAM TParam2
Second parameter type.
WPARAM TParam1
First parameter type.
std::istringstream tistringstream
TAppDictionary & OWLGetAppDictionary()
Global exported TAppDictionary in Owl.
LRESULT TResult
Result type.
IMPLEMENT_STREAMABLE1(TApplication, TModule)
EV_COMMAND(IDOK, CmOkCancel)
DIAG_DECLARE_GROUP(OwlThread)
Definition of class TString, a flexible universal string envelope class.
Current event structure for windows events.
TMsgId Message
Message ID.
TWindow * Win
Window that message was sent/dispatched to.
TParam1 Param1
First parameter (WPARAM).
TParam2 Param2
Second parameter (LPARAM).