我正在尝试调整一个无边框窗体的大小,但当我使用右/下侧增加大小时,会在边框和旧客户区之间产生一个间隙,这取决于您移动鼠标的速度。当您从左边框甚至从左下角缩放时,效果更为明显,无论在哪里都很糟糕(我尝试过其他商业应用程序,也会发生这种情况)。当我改变为可调整大小的边框时,这种效果也会发生,但不像去掉窗体边框那样糟糕。
窗体布局由顶部面板执行标题栏功能(带有一些tImages和按钮),以及显示其他信息的其他面板(如备忘录、其他控件等)组成。
以下是我的代码片段,其中我捕获鼠标按钮并向Windows发送消息,但我也尝试手动操作,结果类似。
激活顶部面板的双缓冲可以避免闪烁,但调整面板的大小与调整窗体大小不同步,因此出现了间隙或部分面板消失的情况。
窗体布局由顶部面板执行标题栏功能(带有一些tImages和按钮),以及显示其他信息的其他面板(如备忘录、其他控件等)组成。
以下是我的代码片段,其中我捕获鼠标按钮并向Windows发送消息,但我也尝试手动操作,结果类似。
激活顶部面板的双缓冲可以避免闪烁,但调整面板的大小与调整窗体大小不同步,因此出现了间隙或部分面板消失的情况。
procedure TOutputForm.ApplicationEvents1Message( var Msg: tagMSG;
var Handled: Boolean );
const
BorderBuffer = 5;
var
X, Y: Integer;
ClientPoint: TPoint;
direction: integer;
begin
Handled := false;
case Msg.message of
WM_LBUTTONDOWN:
begin
if fResizable then
begin
if fSides = [sTop] then
direction := 3
else if fSides = [sLeft] then
direction := 1
else if fSides = [sBottom] then
direction := 6
else if fSides = [sRight] then
direction := 2
else if fSides = [sRight, sTop] then
direction := 5
else if fSides = [sLeft, sTop] then
direction := 4
else if fSides = [sLeft, sBottom] then
direction := 7
else if fSides = [sRight, sBottom] then
direction := 8;
ReleaseCapture;
SendMessage( Handle, WM_SYSCOMMAND, ( 61440 + direction ), 0 );
Handled := true;
end;
end;
WM_MOUSEMOVE:
begin
// Checks the borders and sets fResizable to true if it's in a "border"
// ...
end; // mousemove
end; // case
end;
我应该如何避免那个区域或强制窗口重新绘制?我正在使用Delphi,但通用的解决方案(或其他语言)甚至是前进的方向对我来说都可以。
提前感谢您。