📄 tanchors.h
字号:
/*****************************************************************************/
/* TAnchors.h Copyright Ladislav Zezula 2001 */
/*---------------------------------------------------------------------------*/
/* A class for easy object anchoring. Those who compare the Delphi program- */
/* ming with Visual C++, will certainly miss the "Anchors" property in visual*/
/* design. This class supports something like that, although it's not so */
/* comfort like the visual design in Delphi/C++ builder */
/*---------------------------------------------------------------------------*/
/* Date Ver Who Comment */
/* -------- ---- --- -----------------------------------------------------*/
/* 19.12.01 1.00 Lad Created */
/*****************************************************************************/
#ifndef __TANCHORS_H__
#define __TANCHORS_H__
//-----------------------------------------------------------------------------
// Constants
// Anchor types
#define akLeft 0x0001
#define akTop 0x0002
#define akRight 0x0004
#define akBottom 0x0008
#define akLeftTop (akLeft | akTop)
#define akRightBottom (akRight | akBottom)
#define akAll (akLeft | akTop | akRight | akBottom)
struct TAnchor
{
HWND hWnd; // Window
DWORD dwAnchors; // Anchors
RECT parentRect; // Parent client rect
int left; // Distance of left border from the left parent border
int top;
int right;
int bottom;
int width;
int height;
double dx; // Starting distance from
double dy; // Starting distance from
TAnchor * next; // Pointer to the next anchor
};
class TAnchors
{
public:
TAnchors();
~TAnchors();
// Adding anchors
BOOL AddAnchor(HWND hDlg, UINT ctrl, DWORD dwAnchors);
BOOL AddAnchor(HWND hWnd, DWORD dwAnchors);
// Call this in the handle of WM_SIZE
BOOL AnchorAllObjects(HWND hDlg);
protected:
// Calculates new window position and size
BOOL GetNewWindowRect(HWND hParent, TAnchor * pAnchor, RECT & rect);
// Fast window repaint logic
void MoveWindowOrg(HDC hDC, int dx, int dy);
void GetBorderSize(HWND hWnd, POINT * border);
void PaintFrame(HWND hWnd, HDC hDC, RECT * edgeRect);
BOOL PaintWindowTo(HWND hWnd, HDC hDC);
BOOL PaintChildrenTo(HWND hWnd, HDC hDC);
BOOL PaintWindow(HWND hWnd, HDC hDC);
TAnchor * m_pFirstAnchor;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -