25#if !defined(WM_SETICON)
26# define WM_SETICON 0x0080
51 ::EnableMenuItem(HMenu, Position,
72 ::CheckMenuItem(HMenu, Position,
188 HWndRestoreFocus =
nullptr;
189 KeyboardHandling =
false;
195 MergeModule =
nullptr;
199 IconModule =
nullptr;
200 IconSmModule =
nullptr;
202 #if !defined( MAINWIN )
206 MinimizedPos =
TPoint(-1,-1);
240 for (
int i = 0;
i < count;
i++) {
242 if (state !=
static_cast<uint>(-1)) {
267 const int count = ::GetMenuItemCount(
hPopupMenu);
338 TRACEX(
OwlCmd, 1,
"TFrameWindow::GetCommandTarget - focus, "\
339 "child of client: " <<
static_cast<void*
>(
hFocus));
353 TRACEX(
OwlCmd, 1,
"TFrameWindow::GetCommandTarget - focus, "\
354 <<
static_cast<void*
>(
hFocus));
360 if (HWndRestoreFocus) {
361#if defined(__TRACE) || defined(__WARN)
364 TRACEX(
OwlCmd, 1,
"TFrameWindow::GetCommandTarget - HwndRestoreFocus, "\
365 <<
static_cast<void*
>(HWndRestoreFocus));
367 TRACEX(
OwlCmd, 1,
"TFrameWindow::GetCommandTarget - HwndRestoreFocus, "\
371 return HWndRestoreFocus;
376 TRACEX(
OwlCmd, 1,
"TFrameWindow::GetCommandTarget - self, " << *
this);
389 TRACEX(
OwlCmd, 1,
"TFrameWindow::EvCommand - id(" <<
id <<
"), ctl(" <<
396 if (
hCtl ==
nullptr) {
453 if (parent && ::IsDialogMessage(parent, &
msg))
495 if (Attr.Menu.IsString())
496 delete[] Attr.Menu.GetString();
535 if (CurIcon && IconModule) {
562 if (CurIconSm && IconSmModule) {
567 IconSmModule =
module;
571 if (IconSmResId != 0) {
609 if (HWndRestoreFocus ==
oldWnd)
610 HWndRestoreFocus =
nullptr;
622 ResizeClientWindow(
true);
631 HWndRestoreFocus = ClientWnd->
GetHandle();
656 if (
child == ClientWnd)
658 if (
child->GetHandle() == HWndRestoreFocus) {
659 HWndRestoreFocus =
nullptr;
722 wndClass.lpfnWndProc = ::DefWindowProc;
758 return hIcon ? hIcon : getAppIcon();
775 for (
auto&
child : win->GetChildren())
777 if (!
child.GetHandle())
continue;
803TFrameWindow::FirstChildWithTab()
810 { return w.GetHandle() && IsEnabledVisibleChild_(w.GetWindowLong(GWL_STYLE)); });
811 return (
i !=
c.end()) ? &(*i) :
nullptr;
844 if (!HWndRestoreFocus) {
847 HWndRestoreFocus =
cmdTgt;
853 if (HWndRestoreFocus) {
859 HWndRestoreFocus =
nullptr;
883 if (ClientWnd && ClientWnd->
GetHandle() ==
i.Child)
895 ResizeClientWindow(
true);
934TFrameWindow::ResizeClientWindow(
bool repaint)
1056 ResizeClientWindow(
true);
1058 if (MinimizedPos !=
TPoint(-1,-1)) {
1062 windata.ptMinPosition = MinimizedPos;
1081 if (!HWndRestoreFocus) {
1087 TWindow* win = FirstChildWithTab();
1092 HWndRestoreFocus =
cmdTgt;
1149 sizeSent = ResizeClientWindow(
true);
1243 MergeModule =
nullptr;
1255#if OWL_PERSISTENT_STREAMS
1270 is >>
o->KeyboardHandling;
1271 o->HWndRestoreFocus = 0;
1276 is >> *
o->MenuDescr;
1285 o->BarDescr =
new TBarDescr;
1292 is >>
o->IconModule;
1295 is >>
o->IconSmModule;
1296 is >>
o->IconSmResId;
1299 o->IconSmModule = 0;
1307 o->SetIcon(
o->IconModule,
o->IconResId);
1308 o->SetIconSm(
o->IconSmModule,
o->IconSmResId);
1310 is >>
o->MergeModule;
1311 is >>
o->MinimizedPos;
1320TFrameWindow::Streamer::Write(opstream&
os)
const
1322 TFrameWindow*
o = GetObject();
1328 os <<
o->KeyboardHandling;
1330 os.writeByte(
uint8(
o->MenuDescr ? 1 : 0));
1332 os << *
o->MenuDescr;
1335 os.writeByte(
uint8(
o->BarDescr ? 1 : 0));
1339 os <<
o->IconModule;
1341 os <<
o->IconSmModule;
1342 os <<
o->IconSmResId;
1344 os <<
o->MergeModule;
1345 auto windata =
o->GetWindowPlacement();
Definition of class TApplication.
Class definition for TBarDescr.
#define DIAG_DECLARE_GROUP(group)
#define TRACEX(group, level, message)
virtual void PreProcessMenu(HMENU hMenubar)
Called by the main window to provide an oportunity to preprocess the main window's menubar before it ...
void ClearMainWindow()
Called by the main window (TFrameWindow) destructor to zero the MainWindow member.
Descriptor of Bar Implementation.
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
virtual void Enable(bool enable=true)
Enables or disables the command sender.
@ Checked
Command is enabled.
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 Init(TWindow *clientWnd, bool shrinkToClient)
Normal initialization of a default constructed TFrameWindow.
~TFrameWindow() override
Destructor for a TFrameWindow.
virtual bool MergeMenu(const TMenuDescr &childMenuDescr)
Merges the given menu descriptor with this frame's own menu descriptor and displays the resulting men...
virtual TWindow * GetClientWindow()
Returns a pointer to the client window.
void EvSize(uint sizeType, const TSize &size)
Response method for an incoming WM_SIZE message.
auto SetDocTitle(LPCTSTR docname, int index) -> bool override
Overrides TWindow's virtual function.
void EvCommandEnable(TCommandEnabler &) override
Handle WM_COMMAND_ENABLE to provide command enable distribution and default support for windows witho...
virtual bool RestoreBar()
Do nothing in TFrameWindow. Overriden in TDecoratedFrame.
virtual bool SetMenu(HMENU newMenu)
Overrides TWindow's non-virtual SetMenu function, thus allowing derived classes the opportunity to im...
void SetMenuDescr(const TMenuDescr &menuDescr)
Sets the menu descriptor to the new menu descriptor.
void CleanupWindow() override
Cleans up any associated icons.
void EvPaletteChanged(HWND hWndPalChg)
Forwards the WM_PALETTECHANGED message to the client window.
virtual HWND GetCommandTarget()
Locates and returns the child window that is the target of the command and command enable messages.
auto HoldFocusHWnd(HWND hWndLose, HWND hWndGain) -> bool override
Overrides TWindow's virtual function.
auto PreProcessMsg(MSG &) -> bool override
Overrides TWindow's virtual function.
void BroadcastResizeToChildren(uint sizeType, const TSize &size)
Tell child windows frame has minimized/maximized/restored (They may want to change enabled state or r...
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
Handle WM_COMMAND to provide extra processing for commands: Extra processing for commands: starts wit...
bool EvQueryNewPalette()
Forwards the WM_QUERYNEWPALETTE message to the client window.
virtual TWindow * SetClientWindow(TWindow *clientWnd)
Sets the client window to the specified window.
void EvParentNotify(const TParentNotify &)
Responds to a message to notify the parent window that a given event has occurred.
bool SetIconSm(TModule *iconModule, TResId iconResIdSm)
Set the Small Icon (16 x 16)
bool SetIcon(TModule *iconModule, TResId iconResId)
Sets the icon in the module specified in iconModule to the resource ID specified in iconResId.
HICON EvQueryDragIcon()
Responds to a WM_QUERYDRAGICON message sent to a minimized (iconic) window that is going to be dragge...
virtual bool AssignMenu(TResId menuResId)
Perform a high-level menu assignment either before or after the HWND for the window has been created.
void SetBarDescr(TBarDescr *barDescr, TAutoDelete=AutoDelete)
Sets the control bar descriptor to the new bar descriptor.
void EvSetFocus(HWND hWndLostFocus)
Restores the focus to the active window.
void EvInitMenuPopup(HMENU hPopupMenu, uint index, bool isSysMenu)
Responds to WM_INITMENUPOPUP by performing a command enable run on each of the menu items in the popu...
TFrameWindow()
< String-aware overload
void SetupWindow() override
Calls TWindow::SetUpWindow to create windows in a child list.
void RemoveChild(TWindow *) override
If someone removes our client with a RemoveChild() call, update our client and restore focus ptrs.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TPoint is a support class, derived from tagPOINT.
TSize Size() const
Returns the size of rectangle.
TPointer GetPointerRepresentation() const
Returns the encapsulated pointer.
The tagSIZE struct is defined as.
static const TUIMetric CyBorder
static const TUIMetric CySmIcon
static const TUIMetric CxBorder
static const TUIMetric CxSmIcon
static BOOL DestroyIcon(HICON)
static HICON LoadIcon(HINSTANCE, LPCTSTR)
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
HWND SetFocus()
Sets the keyboard focus to current window and activates the window that receives the focus by sending...
void ShowScrollBar(int bar, bool show=true)
Displays or hides the scroll bar.
HMENU LoadMenu(TResId id) const
bool SetMenu(HMENU hMenu)
Sets the specified window's menu to the menu indicated by hMenu.
virtual void SetParent(TWindow *newParent)
Sets the parent for the specified window by setting Parent to the specified new Parent window object.
TApplication * GetApplication() const
Gets a pointer to the TApplication object associated with this.
void ChildBroadcastMessage(TMsgId, TParam1=0, TParam2=0)
Sends the specified message to all immediate children using SendMessage.
void SetBkgndColor(TColor color, bool shouldUpdate=true)
Sets the background color for the window.
TWindow()
Protected constructor for use by immediate virtually derived classes.
void DrawMenuBar()
DrawMenuBar redraws the menu bar.
bool SetWindowPos(HWND hWndInsertAfter, const TRect &rect, uint flags)
Changes the size of the window pointed to by rect.
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
auto GetChildren()
Returns a TWindow::TChildrenRange that can be iterated by standard means.
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.
TWindow * GetWindowPtr(HWND hWnd) const
Calls TApplication:GetWindowPtr on the application associated with this window.
virtual void RemoveChild(TWindow *child)
Removes a child window.
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
void SetWindowPlacement(const WINDOWPLACEMENT &place)
Wrapper for Windows API.
HICON EvQueryDragIcon()
The default message handler for WM_QUERYDRAGICON.
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,...
WINDOWPLACEMENT GetWindowPlacement() const
Wrapper for Windows API.
uint32 SetExStyle(uint32 style)
Sets the extra style bits of the window.
bool EvQueryNewPalette()
The default message handler for WM_QUERYNEWPALETTE.
void RouteCommandEnable(HWND hInitCmdTarget, TCommandEnabler &ce)
Walks the chain of windows from the initial target window to this window.
bool IsIconic() const
Returns true if window is iconic or minimized.
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.
virtual void CleanupWindow()
Always called immediately before the HWindow becomes invalid, CleanupWindow gives derived classes an ...
void GetWindowRect(TRect &rect) const
Gets the screen coordinates of the window's rectangle and copies them into rect.
HMENU GetMenu() const
Returns the handle to the menu of the indicated window.
TResult HandleMessage(TMsgId, TParam1=0, TParam2=0)
Dispatches the given message using the response table.
bool MoveWindow(int x, int y, int w, int h, bool repaint=false)
Repositions the specified window.
virtual bool IdleAction(long idleCount)
Called when no messages are waiting to be processed, IdleAction performs idle processing as long as t...
uint32 GetStyle() const
Gets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
LPCTSTR GetCaption() const
Returns the Title member of TWindow.
TResult ForwardMessage(HWND handle, bool send=true)
Forwards the window's current message.
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
TRect GetClientRect() const
Gets the coordinates of the window's client area (the area in a window you can use for drawing).
void SetWindowText(LPCTSTR str)
Sets the window's text to the given string (by copying).
virtual TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode)
WindowProc calls EvCommand to handle WM_COMMAND messages.
uint32 SetStyle(uint32 style)
Sets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
void EvSetFocus(HWND hWndLostFocus)
The default message handler for WM_SETFOCUS.
void ClearFlag(uint mask)
Clears the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
bool PostMessage(TMsgId, TParam1=0, TParam2=0)
Posts a message (msg) to the window in the application's message queue.
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.
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.
static HWND GetFocus()
Gets a handle to the window that has the focus.
void EvSize(uint sizeType, const TSize &size)
Response method for an incoming WM_SIZE message.
void EnableAutoCreate()
Ensures that an associated child window interface element is created and displayed along with its par...
void EvPaletteChanged(HWND hWndPalChg)
The default message handler for WM_PALETTECHANGED.
void GetClientRect(TRect &rect) const
Gets the coordinates of the window's client area and then copies them into the object referred to by ...
void EvInitMenuPopup(HMENU hPopupMenu, uint index, bool isSysMenu)
Handle WM_INITMENUPOPUP while embeded to generate command enable messages for our server menu items.
HWND GetHandle() const
Returns the handle of the window.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
#define WM_OWLFRAMESIZE
Notify children of frame resizing.
TDockable classes: TDockableGadgetWindow & TDockableControlBar TDockingSlip classes: TFloatingSlip & ...
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition of class TFrameWindow.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
#define IMPLEMENT_STREAMABLE1(cls, base1)
void ReadVirtualBase(Base *base, ipstream &in)
void WriteVirtualBase(Base *base, opstream &out)
THandle GetHandle() const
Return the instance handle of the library module represented by the TModule obect.
#define NoErase
don't erase, wait for Paint
#define NoColor
let DefWindowProc erase
@ wfMainWindow
This frame window is the main window.
@ wfFullyCreated
Window is fully created & not being destroyed.
@ wfShrinkToClient
Shrink a frame window to its client's size.
char * strnewdup(const char *s, size_t minAllocSize=0)
Object Windows Library (OWLNext Core)
WPARAM TParam1
First parameter type.
TDispatch< WM_PARENTNOTIFY >::TArgs TParentNotify
Alias for convenience.
LRESULT TResult
Result type.
TDispatch< WM_PARENTNOTIFY >::TChildInfoArgs TParentNotifyChildInfo
Alias for convenience.
TModule & GetGlobalModule()
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
#define TYPESAFE_DOWNCAST(object, toClass)
Definition of TUIMetric, a UI metrics provider class.