CRect capPreview()

 

CRect
The CRect class is similar to a Windows RECT structure. CRect also includes member functions to manipulate CRect objects and Windows RECT structures.

A CRect object can be passed as a function parameter wherever a RECT structure, LPCRECT, or LPRECT can be passed.

Note   This class is derived from the tagRECT structure. (The name tagRECT is a less-commonly-used name for the RECT structure.) This means that the data members (left, top, right, and bottom) of the RECT structure are accessible data members of CRect.

A CRect contains member variables that define the top-left and bottom-right points of a rectangle.

When specifying a CRect, you must be careful to construct it so that it is normalized — in other words, such that the value of the left coordinate is less than the right and the top is less than the bottom. For example, a top left of (10,10) and bottom right of (20,20) defines a normalized rectangle but a top left of (20,20) and bottom right of (10,10) defines a non-normalized rectangle. If the rectangle is not normalized, many CRect member functions may return incorrect results. (See CRect::NormalizeRect for a list of these functions.) Before you call a function that requires normalized rectangles, you can normalize non-normalized rectangles by calling the NormalizeRect function.

Use caution when manipulating a CRect with the CDC::DPtoLP and CDC::LPtoDP member functions. If the mapping mode of a display context is such that the y-extent is negative, as in MM_LOENGLISH, then CDC::DPtoLP will transform the CRect so that its top is greater than the bottom. Functions such as Height and Size will then return negative values for the height of the transformed CRect, and the rectangle will be non-normalized.

When using overloaded CRect operators, the first operand must be a CRect; the second can be either a RECT structure or a CRect object.

 


CRect Class Members
Construction/Destruction
Operations
Operators

Construction

CRect Constructs a CRect object.


Operations

Width Calculates the width of CRect.
Height Calculates the height of CRect.
Size Calculates the size of CRect.
TopLeft Returns the top-left point of CRect.
BottomRight Returns the bottom-right point of CRect.
CenterPoint Returns the centerpoint of CRect.
IsRectEmpty Determines whether CRect is empty. CRect is empty if the width and/or height are 0.
IsRectNull Determines whether the top, bottom, left, and right member variables are all equal to 0.
PtInRect Determines whether the specified point lies within CRect.
SetRect Sets the dimensions of CRect.
SetRectEmpty Sets CRect to an empty rectangle (all coordinates equal to 0).
CopyRect Copies the dimensions of a source rectangle to CRect.
EqualRect Determines whether CRect is equal to the given rectangle.
InflateRect Increases the width and height of CRect.
DeflateRect Decreases the width and height of CRect.
NormalizeRect Standardizes the height and width of CRect.
OffsetRect Moves CRect by the specified offsets.
SubtractRect Subtracts one rectangle from another.
IntersectRect Sets CRect equal to the intersection of two rectangles.
UnionRect Sets CRect equal to the union of two rectangles.


Operators

operator LPCRECT Converts a CRect to an LPCRECT.
operator LPRECT Converts a CRect to an LPRECT.
operator = Copies the dimensions of a rectangle to CRect.
operator == Determines whether CRect is equal to a rectangle.
operator != Determines whether CRect is not equal to a rectangle.
operator += Adds the specified offsets to CRect or inflates CRect.
operator –= Subtracts the specified offsets from CRect or deflates CRect.
operator &= Sets CRect equal to the intersection of CRect and a rectangle.
operator |= Sets CRect equal to the union of CRect and a rectangle.
operator + Adds the given offsets to CRect or inflates CRect and returns the resulting CRect.
operator – Subtracts the given offsets from CRect or deflates CRect and returns the resulting CRect.
operator & Creates the intersection of CRect and a rectangle and returns the resulting CRect.
operator | Creates the union of CRect and a rectangle and returns the resulting CRect.

 

 

 

 

 

CRect::CRect
This constructor creates an instance of a CRect object. If no parameters are specified, left, top, right, and bottom members are not initialized.

The CRect( const RECT& ) and CRect( LPCRECT ) constructors perform a CopyRect. The other constructors initialize the member variables of the object directly.

CRect( );

CRect(
int l,
int t,
int r,
int b );

CRect(
const RECT& srcRect );

CRect(
LPCRECT lpSrcRect );

CRect(
POINT point,
SIZE size );

CRect(
POINT topLeft,
POINT bottomRight );
Parameters
l
Specifies the left position of CRect.
t
Specifies the top of CRect.
r
Specifies the right position of CRect.
b
Specifies the bottom of CRect.
srcRect
Refers to the RECT structure with the coordinates for CRect.
lpSrcRect
Points to the RECT structure with the coordinates for CRect.
point
Specifies the origin point for the rectangle to be constructed. Corresponds to the top-left corner.
size
Specifies the displacement from the top-left corner to the bottom-right corner of the rectangle to be constructed.
topLeft
Specifies the top-left position of CRect.
bottomRight
Specifies the bottom-right position of CRect.
Example
// Default constructor does not initialize!
CRect rectUnknown;

// Four-integers are left, top, right, and bottom.
CRect rect(0, 0, 100, 50);
ASSERT(rect.Width() == 100);
ASSERT(rect.Height() == 50);

// Initialize from RECT stucture.
RECT sdkRect;
sdkRect.left = 0;
sdkRect.top = 0;
sdkRect.right = 100;
sdkRect.bottom = 50;

CRect rect2(sdkRect);   // by reference
CRect rect3(&sdkRect);  // by address
ASSERT(rect2 == rect);
ASSERT(rect3 == rect);

// From a point and a size.
CPoint pt(0, 0);
CSize sz(100, 50);
CRect rect4(pt, sz);
ASSERT(rect4 == rect2);

// From two points.
CSize ptBottomRight(100, 50);
CRect rect5(pt, ptBottomRight);
ASSERT(rect5 == rect4);

Requirements
  Windows CE versions: 1.0 and later 
  Header file: Declared in Afxwin.h
  Platform: H/PC Pro, Palm-size PC, Pocket PC

 

 

 

 

 

 

 

 


CRect::CRect
CRect( );

CRect( int l, int t, int r, int b );

CRect( const RECT& srcRect );

CRect( LPCRECT lpSrcRect );

CRect( POINT point, SIZE size );

CRect( POINT topLeft, POINT bottomRight );

Parameters

l

Specifies the left position of CRect.

t

Specifies the top of CRect.

r

Specifies the right position of CRect.

b

Specifies the bottom of CRect.

srcRect

Refers to the RECT structure with the coordinates for CRect.

lpSrcRect

Points to the RECT structure with the coordinates for CRect.

point

Specifies the origin point for the rectangle to be constructed. Corresponds to the top-left corner.

size

Specifies the displacement from the top-left corner to the bottom-right corner of the rectangle to be constructed.

topLeft

Specifies the top-left position of CRect.

bottomRight

Specifies the bottom-right position of CRect.

Remarks

Constructs a CRect object. If no arguments are given, left, top, right, and bottom members are not initialized.

The CRect( const RECT& ) and CRect( LPCRECT ) constructors perform a CopyRect. The other constructors initialize the member variables of the object directly.

Example

// default constructor doesn't initialize!
CRect rectUnknown;

// four-integers are left, top, right, and bottom
CRect rect(0, 0, 100, 50);
ASSERT(rect.Width() == 100);
ASSERT(rect.Height() == 50);

// Initialize from RECT stucture
RECT sdkRect;
sdkRect.left = 0;
sdkRect.top = 0;
sdkRect.right = 100;
sdkRect.bottom = 50;

CRect rect2(sdkRect);   // by reference
CRect rect3(&sdkRect);  // by address
ASSERT(rect2 == rect);
ASSERT(rect3 == rect);

// from a point and a size
CPoint pt(0, 0);
CSize sz(100, 50);
CRect rect4(pt, sz);
ASSERT(rect4 == rect2);

// from two points
CSize szTopLeft(0, 0);
CRect rect5(szTopLeft, sz);
ASSERT(rect5 == rect4);

 

 

 

 

 

capPreview
The capPreview macro enables or disables preview mode. In preview mode, frames are transferred from the capture hardware to system memory and then displayed in the capture window using GDI functions. You can use this macro or explicitly call the WM_CAP_SET_PREVIEW message.

BOOL capPreview(
  hwnd, 
  f     
);
Parameters
hwnd
Handle to a capture window.
f
Preview flag. Specify TRUE for this parameter to enable preview mode or FALSE to disable it.
Return Values
Returns TRUE if successful or FALSE otherwise.

Remarks
The preview mode uses substantial CPU resources. Applications can disable preview or lower the preview rate when another application has the focus. The fLiveWindow member of the CAPSTATUS structure indicates if preview mode is currently enabled.

Enabling preview mode automatically disables overlay mode.

Requirements
  Windows NT/2000/XP: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Vfw.h.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值