【问题标题】:Setting Grid widths with Resize - Notification needed使用调整大小设置网格宽度 - 需要通知
【发布时间】:2014-09-10 04:25:42
【问题描述】:

我正在尝试使用 Form Resize 按比例调整列宽(开始时为 30、30、50、130、130、130),这很有效,有点...

问题 1:我想去掉 +50,但每个像素都调用了 Resize。

问题 2:如果我能收到关于宽度的拖动已停止且鼠标已释放且表单宽度稳定的通知,将解决问题 1。

问题 3:我需要帮助以减少表单宽度。我的数学不太好。

procedure TfrmMain.FormResize(Sender: TObject);
var
  i : Integer;
  aPcntR : Real;
  aPcntI : Integer;
  anInc : Integer;
begin
  if aClientWidth < 1 then Exit;
  if aClientWidth = ClientWidth then Exit;
  if aClientWidth+50 > ClientWidth then Exit; // Only adjust after an increase of at least 50
  aPcntR:=(((aClientWidth-ClientWidth) / ClientWidth)*100.0);
  aPcntI:=Abs(Round(aPcntR));
  for i:=0 to dbgridItems.Columns.Count-1 do
  begin
    anInc:=dbgridItems.Columns[i].Width*aPcntI div 100;
    dbgridItems.Columns[i].Width:=dbgridItems.columns[i].Width+anInc;
  end;
  aClientWidth:=ClientWidth;
  aClientHeight:=ClientHeight;
end;

【问题讨论】:

    标签: delphi delphi-5 column-width


    【解决方案1】:

    WM_EXITSIZEMOVE 消息添加一个处理程序,并在那里调整大小而不是使用OnResize

    interface
    
    type
      TfrmMain = class(TForm)
        // Other declarations by IDE
      private
        procedure WMExitSizeMove(var Msg: TMsg); message WM_EXITSIZEMOVE;
      // Other stuff
      end;
    

    WM_EXITSIZEMOVE 在调整大小或移动完成并且用户释放鼠标后发送一次。

    【讨论】:

      猜你喜欢
      • 2012-03-24
      • 2011-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-30
      • 1970-01-01
      • 2017-08-07
      相关资源
      最近更新 更多