【发布时间】:2015-12-30 17:33:19
【问题描述】:
我已经完成了我的工作,但我遇到了这个闪烁问题
当我想从左边距
或底部边距调整我的表单(BorderStyle 属性中有 bsNone)时,请先尝试这个示例(完整代码内):
My Example =>
最后是代码:
const
// frame Width
BORDER_WIDTH = 5;
// Key performance indicators (top-left, top-right ...)
EDGE_SIZE = 15;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
fRect: TRect;
fPos: TPoint;
fChangedCursor: Boolean;
begin
// Change cursor when the mouse pointer is located on the edge
fChangedCursor := False;
fPos := Point(X, Y);
// top margin
fRect := Rect(EDGE_SIZE, 0, Width - EDGE_SIZE, BORDER_WIDTH);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeNS;
if ssLeft in Shift then
begin
// here the bottom Margin flickering
ReleaseCapture;
PerForm(WM_SysCommand, $F003, 0);
end;
end;
// right margin
fRect := Rect(Width - BORDER_WIDTH, EDGE_SIZE, Width, Height - EDGE_SIZE);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeWE;
if ssLeft in Shift then
begin
ReleaseCapture;
PerForm(WM_SysCommand, $F002, 0);
end;
end;
// Bottom margin
fRect := Rect(EDGE_SIZE, Height - BORDER_WIDTH, Width - EDGE_SIZE, Height);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeNS;
if ssLeft in Shift then
begin
ReleaseCapture;
PerForm(WM_SysCommand, $F006, 0);
end;
end;
// left margin
fRect := Rect(0, EDGE_SIZE, BORDER_WIDTH, Height - EDGE_SIZE);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeWE;
if ssLeft in Shift then
begin
// here the Right Margin flickering
ReleaseCapture;
PerForm(WM_SysCommand, $F001, 0);
end;
end;
// Top left corner
fRect := Rect(0, 0, EDGE_SIZE, EDGE_SIZE);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeNWSE;
if ssLeft in Shift then
begin
// here the Both Margins flickering
ReleaseCapture;
PerForm(WM_SysCommand, $F004, 0);
end;
end;
// Top right corner
fRect := Rect(Width - EDGE_SIZE, 0, Width, EDGE_SIZE);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeNESW;
if ssLeft in Shift then
begin
// here the both Margins flickering
ReleaseCapture;
PerForm(WM_SysCommand, $F005, 0);
end;
end;
// Bottom right corner
fRect := Rect(Width - EDGE_SIZE, Height - EDGE_SIZE, Width, Height);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeNWSE;
if ssLeft in Shift then
begin
// here the both Margins flickering a Little
ReleaseCapture;
PerForm(WM_SysCommand, $F008, 0);
end;
end;
// Bottom left corner
fRect := Rect(0, Height - EDGE_SIZE, EDGE_SIZE, Height);
if PtInRect(fRect, fPos) then
begin
fChangedCursor := True;
Cursor := crSizeNESW;
if ssLeft in Shift then
begin
// here the Right Margin flickering
ReleaseCapture;
PerForm(WM_SysCommand, $F007, 0);
end;
end;
// Standardcursor
if not fChangedCursor then
Cursor := crDefault;
end;
【问题讨论】: