13#if !defined(WS_EX_TOOLWINDOW)
14# define WS_EX_TOOLWINDOW 0x00000080L
48 CaptionFont =
nullptr;
87 if ((Attr.Style & WS_CAPTION) == WS_DLGFRAME) {
92 Attr.Style |= WS_BORDER;
93 Attr.Style &= ~WS_DLGFRAME;
94 if (Attr.Style & WS_THICKFRAME) {
108 Attr.Style |= WS_CAPTION;
111 Attr.Style |= WS_SYSMENU;
147 bool hasSysMenu, hasMaximize, hasMinimize;
148 hasSysMenu = hasMaximize = hasMinimize =
false;
149 if (style & WS_SYSMENU)
151 if (style & WS_MAXIMIZEBOX)
153 if (style & WS_MINIMIZEBOX)
160 if ((hasSysMenu || CloseBox) &&
GetSysBoxRect().Contains(winPt)) {
238 NCCALCSIZE_PARAMS & calcSize,
uint& )
284 sysBoxRect.right += 1;
286 wdc.
PatBlt(sysBoxRect, PATINVERT);
294 WaitingForSysCmd =
true;
302 if (WaitingForSysCmd) {
307 if (hitTest == HTSYSMENU)
311 wdc.
PatBlt(sysBoxRect, PATINVERT);
316 DownHit = HTMINBUTTON;
325 DownHit = HTMAXBUTTON;
354 if (TCEnabled && DownHit != HTNOWHERE) {
359 bool isNowPressed = hitTest == DownHit;
361 if (isNowPressed != IsPressed) {
362 IsPressed = isNowPressed;
408 if (TCEnabled && DownHit != HTNOWHERE) {
417 if (hitTest == DownHit) {
502 WaitingForSysCmd =
false;
540 if ((cmdType == SC_KEYMENU || cmdType == SC_MOUSEMENU) && !
IsIconic()) {
590 int glyphWidth = boxRect.
Width() > 7 ?
592 int glyphHeight = boxRect.
Height() > 7 ?
594 if (glyphWidth > 1 && glyphHeight > 1) {
595 TRect glyphRect(0, 0, glyphWidth, glyphHeight);
596 glyphRect.
Offset(boxRect.left + (boxRect.
Width()-glyphWidth-1)/2,
597 boxRect.top + (boxRect.
Height()-glyphHeight-1)/2);
629 dc.
TextRect(ventRect.left+1, ventRect.top+1,
639 dc.
TextRect(ventRect.left+1, ventRect.top+1,
642 dc.
TextRect(boxRect.right, boxRect.top,
659 int bh = boxRect.
Height();
660 int bw = boxRect.
Width();
664 while (begPt.x < endPt.x) {
687 int bh = boxRect.
Height();
688 int bw = boxRect.
Width();
693 while (begPt.x < endPt.x) {
706 while (begPt.x < endPt.x) {
744 int xOrg = captRect.right - captRect.left;
747 if (style & WS_MINIMIZEBOX)
750 if (style & WS_MAXIMIZEBOX)
753 if ((style & WS_SYSMENU) || CloseBox)
762 xOrg += captRect.left;
764 if ((style & WS_SYSMENU) || CloseBox)
786 else if (style & WS_SYSMENU){
793 if (style & WS_MINIMIZEBOX){
800 if (style & WS_MAXIMIZEBOX){
808 dc.
FrameRect(captRect.left, captRect.bottom-1, captRect.right, captRect.bottom,
822 captRect -= captRect.
TopLeft();
824 captRect.left += Frame.cx;
825 captRect.top += Frame.cy;
826 captRect.right -= Frame.cx;
827 captRect.bottom = captRect.top + CaptionHeight;
839 boxRect.right = boxRect.left + CaptionHeight;
855 boxRect.
Offset(-CaptionHeight, 0);
866 boxRect.left = boxRect.right - CaptionHeight;
882 EnableMenuItem(hSysMenu, SC_RESTORE, (
IsIconic() ||
IsZoomed()) ? MF_ENABLED : MF_GRAYED);
883 EnableMenuItem(hSysMenu, SC_MOVE, (1) ? MF_ENABLED : MF_GRAYED);
884 EnableMenuItem(hSysMenu, SC_SIZE, (style & WS_THICKFRAME) ? MF_ENABLED : MF_GRAYED);
885 EnableMenuItem(hSysMenu, SC_MINIMIZE, ((style&WS_MINIMIZEBOX) && !
IsIconic()) ? MF_ENABLED : MF_GRAYED);
886 EnableMenuItem(hSysMenu, SC_MAXIMIZE, ((style&WS_MAXIMIZEBOX) && !
IsZoomed()) ? MF_ENABLED : MF_GRAYED);
890 TrackPopupMenu(hSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
891 r.left-Frame.cx, r.top-Frame.cy, 0,
GetHandle(), &r);
896#if OWL_PERSISTENT_STREAMS
912 is >> captionHeight >> o->CloseBox;;
922TTinyCaption::Streamer::Write(
opstream& os)
const
928 int captionHeight = (100*o->CaptionHeight) /
930 os << captionHeight << o->CloseBox;
The GDI Brush class is derived from TGdiObject.
static const TColor SysBtnText
The symbolic system color value for the text on buttons.
static const TColor SysActiveCaption
The symbolic system color value for the caption of the active window.
static const TColor Sys3dHilight
The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the ...
static const TColor SysCaptionText
The symbolic system color value for text in captions and size boxes, and for the arrow boxes on scrol...
static const TColor SysInactiveCaption
The symbolic system color value for the caption background of every inactive window.
static const TColor SysInactiveCaptionText
The symbolic system color value for the caption text of every inactive window.
static const TColor SysWindowFrame
The symbolic system color value for the frame around each window.
static const TColor Sys3dShadow
The symbolic system color value for the shadow regions of 3-dimensional display elements (for edges f...
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
TDC is the root class for GDI DC wrappers.
bool FrameRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Draws a border on this DC around the given rectangle, rect, using the given brush,...
bool MoveTo(int x, int y)
Moves the current position of this DC to the given x- and y-coordinates or to the given point.
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
bool GetTextExtent(const tstring &str, int stringLen, TSize &size) const
Computes the extent (width and height) in logical units of the text line consisting of stringLen char...
virtual bool ExtTextOut(int x, int y, uint16 options, const TRect *r, const tstring &str, int count=-1, const int *dx=nullptr)
Draws up to count characters of the given null-terminated string in the current font on this DC.
bool TextRect(int x1, int y1, int x2, int y2)
Fills the given rectangle, clipping any text to the rectangle.
virtual void RestoreFont()
Restores the original GDI font object to this DC.
bool LineTo(int x, int y)
Draws a line on this DC using the current pen object.
virtual void SelectStockObject(int index)
Selects into the DC a predefined stock pen, brush, font, or palette.
virtual TColor SetTextColor(const TColor &color)
Sets the current text color of this DC to the given color value.
int SetBkMode(int mode)
Sets the background mode to the given mode argument, which can be either OPAQUE or TRANSPARENT.
bool PatBlt(int x, int y, int w, int h, uint32 rop=PATCOPY)
TPoint is a support class, derived from tagPOINT.
TPoint OffsetBy(int dx, int dy) const
Calculates an offset to this point using the given displacement arguments.
TPoint & Offset(int dx, int dy)
Offsets this point by the given delta arguments.
TRect is a mathematical class derived from tagRect.
int Height() const
Returns the height of this rectangle (bottom - top).
TRect & Offset(int dx, int dy)
Changes this rectangle so its corners are offset by the given delta values.
TRect InflatedBy(int dx, int dy) const
Returns a rectangle inflated by the given delta arguments.
TRect & Inflate(int dx, int dy)
Inflates a rectangle inflated by the given delta arguments.
const TPoint & BottomRight() const
Returns the TPoint object representing the bottom right corner of this rectangle.
const TPoint & TopLeft() const
Returns the upperleft point.
int Width() const
Returns the width of this rectangle (right - left).
TPoint BottomLeft() const
Returns the TPoint object representing the bottom left corner of this rectangle.
The tagSIZE struct is defined as.
TSize()
Default constructor that does nothing.
Derived from TWindow, TTinyCaption is a mix-in class that handles a set of non-client events to produ...
TEventStatus DoNCLButtonDown(uint hitTest, const TPoint &screenPt)
If the caption bar is not enabled, returns esPartial.
void PaintCaption(bool active)
Calls dc.SelectObject() to select the given rectangle and dc.PatBlt() to paint the tiny caption bar u...
TRect GetMinBoxRect()
Returns the size of the minimize box rectangle.
void EvLButtonUp(uint hitTest, const TPoint &screenPt)
Responds to a mouse button-up message by calling DoLButtonUp.
void PaintSysBox(TDC &dc, TRect &boxRect, bool pressed)
Paints the system box.
~TTinyCaption() override
Destroys a TTinyCaption object and deletes the caption font.
void EvSysCommand(uint cmdType, const TPoint &p)
Responds to a WM_SYSCOMMAND message by calling DoSysCommand.
TEventStatus DoSysCommand(uint cmdType, const TPoint &p)
Handle WM_SYSCOMMAND to make sure that SC_KEYMENU and SC_MOUSEMENU bring up our sys menu at the right...
TTinyCaption()
Constructs a TTinyCaption object attached to the given parent window.
void EvMouseMove(uint hitTest, const TPoint &screenPt)
Responds to a mouse-move message by calling DoMouseMove.
TEventStatus DoNCPaint()
If the caption bar is not enabled or is iconized, returns esPartial.
TEventStatus DoMouseMove(uint hitTest, const TPoint &screenPt)
Returns TEventStatus.
void EnableTinyCaption(int ch=0, bool closeBox=false)
Pass closeBox=true to replace SystemMenu box with a box that will close window when clicked Used for ...
void PaintMaxBox(TDC &dc, TRect &boxRect, bool pressed)
Paints a maximize box on the tiny caption bar.
TEventStatus DoLButtonUp(uint hitTest, const TPoint &screenPt)
Releases the mouse capture if the caption bar is enabled and a mouse button is pressed.
TEventStatus DoNCHitTest(const TPoint &screenPt, uint &evRes)
If the caption bar is not enabled, returns esPartial.
TRect GetCaptionRect()
Gets the area of the caption for changing or repainting.
uint EvNCHitTest(const TPoint &screenPt)
Return where in the non client area we are.
TEventStatus DoCommand(uint id, HWND hWndCtl, uint notifyCode, TResult &evRes)
Displays the system menu using TrackPopup so that TTinyCaption sends WM_COMMAND instead of WM_SYSCOMM...
void EvNCLButtonDown(uint hitTest, const TPoint &screenPt)
Responds to a press of the left mouse button while the cursor is within the nonclient area of the cap...
TRect GetSysBoxRect()
Returns the size of the system box rectangle.
TEventStatus DoNCActivate(bool active, bool &evRes)
If the tiny caption is not enabled or is iconic, returns esPartial.
void PaintCloseBox(TDC &dc, TRect &boxRect, bool pressed)
Paints a close box on the tiny caption bar.
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
EvCommand provides extra processing for commands, but lets the focus window and its parent windows ha...
void DoSysMenu()
Gets the system menu and sets up menu items.
void PaintMinBox(TDC &dc, TRect &boxRect, bool pressed)
Paints a minimize box on the tiny caption bar.
TEventStatus DoNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS &calcSize, uint &evRes)
Return the size of our client area, leaving room for caption bar.
TRect GetMaxBoxRect()
Returns the size of the maximize box rectangle.
void PaintButton(TDC &dc, TRect &boxRect, bool pressed)
Paints a blank button.
void EvNCPaint(HRGN)
Responds to a request to change a title bar or icon.
bool EvNCActivate(bool active)
Responds to a request to change a title bar or icon by calling DoNCActivate.
uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS &calcSize)
Calculates the size of the command window including the caption and border so that it can fit within ...
static const TUIMetric CyBorder
static const TUIMetric CyCaption
static const TUIMetric CyFixedFrame
static const TUIMetric CxBorder
static const TUIMetric CySizeFrame
static const TUIMetric CxFixedFrame
static const TUIMetric CySmCaption
static const TUIMetric CxSizeFrame
Derived from TDC, TWindowDC is a device context (DC) class that provides access to the entire area ow...
static void GetCursorPos(TPoint &pos)
Retrieves the cursor's current position (in window screen coordinates) and copies the values into the...
static HWND GetActiveWindow()
Retrieves the handle of the active window.
HWND SetCapture()
Sets the mouse capture to the current window.
void EvNCLButtonDown(uint codeHitTest, const TPoint &)
The default message handler for WM_NCLBUTTONDOWN.
void EvLButtonUp(uint modKeys, const TPoint &point)
The default message handler for WM_LBUTTONUP.
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
static void ReleaseCapture()
Releases the mouse capture from this window.
bool IsIconic() const
Returns true if window is iconic or minimized.
void ClientToScreen(TPoint &point) const
Converts the client coordinates specified in point to screen coordinates for the new window.
bool IsChild(HWND hWnd) const
Returns true if the window is a child window or a descendant window of this window.
void GetWindowRect(TRect &rect) const
Gets the screen coordinates of the window's rectangle and copies them into rect.
TResult HandleMessage(TMsgId, TParam1=0, TParam2=0)
Dispatches the given message using the response table.
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.
bool EvNCActivate(bool active)
The default message handler for WM_NCACTIVATE.
uint EvNCHitTest(const TPoint &)
The default message handler for WM_NCHITTEST.
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
void EvSysCommand(uint cmdType, const TPoint &point)
Responds to a user-selected command from the System menu or when the user selects the maximize or min...
virtual TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode)
WindowProc calls EvCommand to handle WM_COMMAND messages.
bool IsZoomed() const
Returns true if window is zoomed or maximized.
HMENU GetSystemMenu(bool revert=false) const
Returns a handle to the system menu so that an application can access the system menu.
bool PostMessage(TMsgId, TParam1=0, TParam2=0)
Posts a message (msg) to the window in the application's message queue.
void EvMouseMove(uint modKeys, const TPoint &point)
The default message handler for WM_MOUSEMOVE.
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
static HWND GetFocus()
Gets a handle to the window that has the focus.
uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS &)
The default message handler for WM_NCCALCSIZE.
HWND THandle
TWindow encapsulates an HWND.
HWND GetHandle() const
Returns the handle of the window.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Base class for writing streamable objects.
#define END_RESPONSE_TABLE
#define DEFINE_RESPONSE_TABLE(cls)
Macro to define a response table for a class with no base response tables.
Definition of abstract GDI object class and derived classes.
TEventStatus
Mixin window event implementation return status.
@ esPartial
Additional handlers may be invoked.
@ esComplete
No additional handlers are needed.
Object Windows Library (OWLNext Core).
TParam2 MkParam2(const T1 &lo, const T2 &hi)
IMPLEMENT_STREAMABLE(TDocManager)
LRESULT TResult
Result type.
Definition of TUIMetric, a UI metrics provider class.
#define EV_WM_NCLBUTTONDOWN