Home Units Hierarchy Routines All identifiers

Class unaWinWindow

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type unaWinWindow = class(unaObject)

Description

This class encapsulates Windows window object.

Hierarchy

Overview

Fields

Protected f_isCommonDC: bool;

Methods

Public constructor create(const params: unaWinCreateParams); overload;
Public constructor create(wndClass: unaWinClass = nil; font: unaWinFont = nil; const caption: string = ''; parent: hWnd = 0; style: unsigned = WS_OVERLAPPEDWINDOW or WS_VISIBLE; exStyle: unsigned = 0; x: int = int(CW_USEDEFAULT); y: int = int(CW_USEDEFAULT); w: int = int(CW_USEDEFAULT); h: int = int(CW_USEDEFAULT); menu: hMenu = 0; instance: hModule = 0; icon: hIcon = 0); overload;
Public constructor createStdWnd(const className: string; const caption: string = ''; parent: unaWinWindow = nil; style: unsigned = 0; exStyle: unsigned = 0; x: int = 2; y: int = 2; w: int = 20; h: int = 20; id: unsigned = 0);
Public destructor Destroy(); override;
Public function createWindow(): hWnd;
Public function enable(doEnable: bool = true): unaWinWindow;
Public function endModal(modalResult: int = -1): unaWinWindow;
Public function enter(timeout: tTimeout = 10000): bool;
Public function getCreateParams(): punaWinCreateParams;
Public function getDC(clipRgn: hRGN = 0; flags: unsigned = DCX_WINDOW; wnd: int = -1): hDC;
Public function getHandle(): hWnd;
Public function getText(): string;
Public function getTextLength(): int;
Public function messageBox(const text: string; const caption: string = ''; flags: unsigned = MB_OK): unsigned;
Public function postMessage(message: unsigned; wParam: int = 0; lParam: int = 0): bool;
Public function processMessages(): unaWinWindow;
Public function redraw(): unaWinWindow;
Public function releaseDC(dc: hDC = 0): int;
Public function sendMessage(message: unsigned; wParam: int = 0; lParam: int = 0): int;
Public function setAnchors(anchors: unsigned = unawinAnchor_LEFT or unawinAnchor_TOP): unaWinWindow;
Public function setFocus(firstChild: bool = false): unaWinWindow;
Public function setFont(font: unaWinFont): unaWinWindow;
Public function setText(const text: string): unaWinWindow;
Public function show(cmd: unsigned = SW_SHOW): unaWinWindow;
Public function showModal(cmd: unsigned = SW_SHOW): int;
Public function textOut(const text: string; x: int = 0; y: int = 0; dc: hDC = 0): bool;
Public function update(): unaWinWindow;
Protected function doCreateWindow(): hWnd; virtual;
Protected function initWindow(): bool; virtual;
Protected function notifyActivate(isActivate: bool): bool; virtual;
Protected function notifyCreate(cs: pCREATESTRUCT): bool; virtual;
Protected function notifyDestroy(): bool; virtual;
Protected function onActivate(wayOfActivate: unsigned; window: hWnd): bool; virtual;
Protected function onActivateApp(isActivate: bool; activeThreadId: unsigned): bool; virtual;
Protected function onClick(button: Word; x, y: word): bool; virtual;
Protected function onClose(): bool; virtual;
Protected function onCommand(cmd: int; wnd: int): bool; virtual;
Protected function onCreate(cs: pCREATESTRUCT): int; virtual;
Protected function onDestroy(): bool; virtual;
Protected function onEnterSizeMove(): bool; virtual;
Protected function onGetDlgCode(): LRESULT; virtual;
Protected function onGetMinMaxInfo(infO: pMINMAXINFO): bool;
Protected function onGetText(buf: paChar; maxSize: unsigned): int; virtual;
Protected function onKeyDown(vkCode: unsigned; keyData: int): bool; virtual;
Protected function onMove(x, y: int): bool; virtual;
Protected function onPaint(param: int): bool; virtual;
Protected function onPosChange(pos: pWINDOWPOS): bool; virtual;
Protected function onShow(isShow: bool; reason: unsigned): bool; virtual;
Protected function onSize(action: unsigned; height, width: unsigned): bool; virtual;
Protected function parentResize(dw, dh: int): unaWinWindow; virtual;
Protected function wndProc(message, wParam, lParam: int): int; virtual;
Public procedure addChild(child: unaWinWindow);
Public procedure destroyWindow();
Public procedure leave();
Protected procedure idle(); virtual;

Properties

Public property anchors: unsigned read f_anchors write setFAnchors;
Public property deviceContext: hDC read f_dc;
Public property font: unaWinFont read getFont write setFFont;
Public property height: int read getHeight write setHeight;
Public property isCommonDC: bool read f_isCommonDC;
Public property isDisabled: bool index WS_DISABLED read hasStyle;
Public property isMaximized: bool index WS_MAXIMIZE read hasStyle;
Public property isMinimized: bool index WS_MINIMIZE read hasStyle;
Public property isOverlapped: bool index WS_OVERLAPPED read hasStyle;
Public property isVisible: bool index WS_VISIBLE read hasStyle;
Public property left: int read getLeft write setLeft;
Public property minHeight: int read f_minHeight write setMinHeight;
Public property minWidth: int read f_minWidth write setMinWidth;
Public property rect: tRECT read f_rect;
Public property top: int read getTop write setTop;
Public property unaParent: unaWinWindow read getUnaParent;
Public property width: int read getWidth write setWidth;
Public property winClass: unaWinClass read getWndClass;
Public property wmCommand: tmessageEvent read f_wmCommand write f_wmCommand;
Public property wnd: hWnd read f_handle;

Description

Fields

Protected f_isCommonDC: bool;
 

Methods

Public constructor create(const params: unaWinCreateParams); overload;

Creates new Windows window.

Public constructor create(wndClass: unaWinClass = nil; font: unaWinFont = nil; const caption: string = ''; parent: hWnd = 0; style: unsigned = WS_OVERLAPPEDWINDOW or WS_VISIBLE; exStyle: unsigned = 0; x: int = int(CW_USEDEFAULT); y: int = int(CW_USEDEFAULT); w: int = int(CW_USEDEFAULT); h: int = int(CW_USEDEFAULT); menu: hMenu = 0; instance: hModule = 0; icon: hIcon = 0); overload;

Creates new Windows window.

Public constructor createStdWnd(const className: string; const caption: string = ''; parent: unaWinWindow = nil; style: unsigned = 0; exStyle: unsigned = 0; x: int = 2; y: int = 2; w: int = 20; h: int = 20; id: unsigned = 0);

Creates new "standard" Windows window (such as BUTTON, EDIT and so on).

Public destructor Destroy(); override;

Destroys Windows window. If this window has child windows, they will be also destroyed.

Public function createWindow(): hWnd;

Creates Windows window. Returns handle on new created window. If window is already created does nothing and returns handle on previously created window.

Public function enable(doEnable: bool = true): unaWinWindow;

Enables or disables the window.

Public function endModal(modalResult: int = -1): unaWinWindow;
 
Public function enter(timeout: tTimeout = 10000): bool;

Enters TM-safe lock state, if possible. Returns False if locking was impossible during given time interval.

Public function getCreateParams(): punaWinCreateParams;

Returns pointer on unaWinCreateParams structure.

Public function getDC(clipRgn: hRGN = 0; flags: unsigned = DCX_WINDOW; wnd: int = -1): hDC;

Default value -1 for wnd means window handle will be used instead.

You can specify 0 as wnd to retrieve the entire screen DC.

Make sure you call releaseDC() as soon as possible.

Public function getHandle(): hWnd;

Returns handle on window. Creates window if necessary.

Public function getText(): string;

Returns text associated with window.

Public function getTextLength(): int;

Returns length of text associated with window.

Public function messageBox(const text: string; const caption: string = ''; flags: unsigned = MB_OK): unsigned;

Displays message box with specified text.

Public function postMessage(message: unsigned; wParam: int = 0; lParam: int = 0): bool;

Posts a message for window.

Public function processMessages(): unaWinWindow;

Process all messages waiting in window message queue.

Public function redraw(): unaWinWindow;

Redraws the window contents.

Public function releaseDC(dc: hDC = 0): int;

Default value 0 means last DC returned by getDC() method will be used

Class and private DCs (i.e. when isCommonDC property is false) will not be released, and it is safe to call this function for that class styles.

Public function sendMessage(message: unsigned; wParam: int = 0; lParam: int = 0): int;

Sends a message to window.

Public function setAnchors(anchors: unsigned = unawinAnchor_LEFT or unawinAnchor_TOP): unaWinWindow;

Sets anchors for window. Default anchors are [unawinAnchor_LEFT or unawinAnchor_TOP].

Public function setFocus(firstChild: bool = false): unaWinWindow;

Sets the focus on window. If firstChild = true sets the focus on first child window.

Public function setFont(font: unaWinFont): unaWinWindow;

Sets new font for window.

Public function setText(const text: string): unaWinWindow;

Sets text to be associated with window.

Public function show(cmd: unsigned = SW_SHOW): unaWinWindow;

Show (SW_SHOW) or hides (SW_HIDE) the window.

Public function showModal(cmd: unsigned = SW_SHOW): int;
 
Public function textOut(const text: string; x: int = 0; y: int = 0; dc: hDC = 0): bool;

For non-common DCs if dc = 0, it will create and release a DC, so use this method carefully (performance issue)

Public function update(): unaWinWindow;

Updates the window contents.

Protected function doCreateWindow(): hWnd; virtual;
 
Protected function initWindow(): bool; virtual;
 
Protected function notifyActivate(isActivate: bool): bool; virtual;

WM_NCACTIVATE message handler.

Protected function notifyCreate(cs: pCREATESTRUCT): bool; virtual;

WM_NCCREATE message handler.

Protected function notifyDestroy(): bool; virtual;

WM_NCDESTROY message handler.

Protected function onActivate(wayOfActivate: unsigned; window: hWnd): bool; virtual;

WM_ACTIVATE message handler.

Protected function onActivateApp(isActivate: bool; activeThreadId: unsigned): bool; virtual;

WM_ACTIVATEAPP message handler.

Protected function onClick(button: Word; x, y: word): bool; virtual;
 
Protected function onClose(): bool; virtual;

WM_CLOSE message handler. Returns true, if window should be closed and destroyed. Our handler simply hides the window, not destroying it.

Protected function onCommand(cmd: int; wnd: int): bool; virtual;

WM_COMMAND message handler.

Protected function onCreate(cs: pCREATESTRUCT): int; virtual;

WM_CREATE message handler.

Protected function onDestroy(): bool; virtual;

WM_DESTROY message handler.

Protected function onEnterSizeMove(): bool; virtual;

WM_ENTERSIZEMOVE message handler.

Protected function onGetDlgCode(): LRESULT; virtual;
 
Protected function onGetMinMaxInfo(infO: pMINMAXINFO): bool;

WM_GETMINMAXINFO message handler.

Protected function onGetText(buf: paChar; maxSize: unsigned): int; virtual;

WM_GETTEXT message handler.

Protected function onKeyDown(vkCode: unsigned; keyData: int): bool; virtual;
 
Protected function onMove(x, y: int): bool; virtual;

WM_MOVE message handler.

Protected function onPaint(param: int): bool; virtual;

WM_PAINT message handler.

Protected function onPosChange(pos: pWINDOWPOS): bool; virtual;

WM_WINDOWPOSCHANGING message handler.

Protected function onShow(isShow: bool; reason: unsigned): bool; virtual;

WM_SHOW message handler.

Protected function onSize(action: unsigned; height, width: unsigned): bool; virtual;

WM_SIZE message handler.

Protected function parentResize(dw, dh: int): unaWinWindow; virtual;
 
Protected function wndProc(message, wParam, lParam: int): int; virtual;

This is Windows WndProc routine.

Public procedure addChild(child: unaWinWindow);

creates window if necessary

Public procedure destroyWindow();

Destroys Windows window. Child windows (if any) will NOT be destroyed.

Public procedure leave();

Frees the window from TM-safe lock state.

Protected procedure idle(); virtual;

This method is called periodically when there are no pending messages in window queue and window is application or is in modal state.

Properties

Public property anchors: unsigned read f_anchors write setFAnchors;

Window anchors.

Public property deviceContext: hDC read f_dc;

This property is valid only if isCommonDC is false.

Use getDC()/releaseDC() methods otherwise.

Public property font: unaWinFont read getFont write setFFont;

Window font.

Public property height: int read getHeight write setHeight;

Height of the window.

Public property isCommonDC: bool read f_isCommonDC;

false if this window belongs to class with CS_CLASSDC, CS_OWNDC or CS_PARENTDC style set. true otherwise

Public property isDisabled: bool index WS_DISABLED read hasStyle;

Returns true if window has WS_DISABLED style.

Public property isMaximized: bool index WS_MAXIMIZE read hasStyle;

Returns true if window has WS_MAXIMIZE style.

Public property isMinimized: bool index WS_MINIMIZE read hasStyle;

Returns true if window has WS_MINIMIZE style.

Public property isOverlapped: bool index WS_OVERLAPPED read hasStyle;

Returns true if window has WS_OVERLAPPED style.

Public property isVisible: bool index WS_VISIBLE read hasStyle;

Returns true if window has WS_VISIBLE style.

Public property left: int read getLeft write setLeft;

X coordinate of top-left window corner (in relative coordinates).

Public property minHeight: int read f_minHeight write setMinHeight;

Minimum value for window height.

Public property minWidth: int read f_minWidth write setMinWidth;

Minimum value for window width.

Public property rect: tRECT read f_rect;
 
Public property top: int read getTop write setTop;

Y coordinate of top-left window corner (in relative coordinates).

Public property unaParent: unaWinWindow read getUnaParent;
 
Public property width: int read getWidth write setWidth;

Width of the window.

Public property winClass: unaWinClass read getWndClass;

Window class.

Public property wmCommand: tmessageEvent read f_wmCommand write f_wmCommand;

Command event. (Handles WM_COMMAND messages).

Public property wnd: hWnd read f_handle;

Window handle.

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09