zoukankan      html  css  js  c++  java
  • delphi ListView 设置固定列宽

    object Form1: TForm1
    Left = 0
    Top = 0
    Caption = 'Form1'
    ClientHeight = 772
    ClientWidth = 635
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    OldCreateOrder = False
    OnCreate = FormCreate
    OnDestroy = FormDestroy
    PixelsPerInch = 96
    TextHeight = 13
    object lvErrMsgs: TListView
    Left = 0
    Top = 0
    Width = 635
    Height = 415
    Align = alTop
    BevelInner = bvNone
    BevelOuter = bvNone
    BorderWidth = 1
    Columns = <
    item
    Caption = ' '
    Width = 30
    end
    item
    Caption = #26500#20214#21517#31216
    Width = 75
    end
    item
    Caption = #25152#23646#27004#23618
    Width = 75
    end
    item
    Caption = #38169#35823#25551#36848
    Width = 500
    end>
    ColumnClick = False
    DragCursor = crAppStart
    FlatScrollBars = True
    GridLines = True
    HideSelection = False
    Items.ItemData = {
    05450000000100000000000000FFFFFFFFFFFFFFFF03000000FFFFFFFF000000
    000003310031003100F85CC32603320032003200A85BC326057A007800630076
    006200B059C326FFFFFFFFFFFF}
    ReadOnly = True
    RowSelect = True
    ShowWorkAreas = True
    TabOrder = 0
    ViewStyle = vsReport
    ExplicitTop = -115
    ExplicitWidth = 524
    end
    end
    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls;
    
    type
      TForm1 = class(TForm)
        lvErrMsgs: TListView;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
      private
      FListViewOldWndProc: TWndMethod;
      procedure ListViewNewWndProc(var Msg: TMessage);
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    uses
    CommCtrl;
    
    {$R *.dfm}
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      FListViewOldWndProc := lvErrMsgs.WindowProc;
      lvErrMsgs.WindowProc := ListViewNewWndProc;
    end;
    
    procedure TForm1.FormDestroy(Sender: TObject);
    begin
      lvErrMsgs.WindowProc := FlistViewOldWndProc;
      FListViewOldWndProc := nil;
    end;
    
    procedure TForm1.ListViewNewWndProc(var Msg: TMessage);
    var
    hdn: ^THDNotify;
    begin
    if Msg.Msg = WM_NOTIFY then
    begin
    hdn := Pointer(Msg.lParam);
    if (hdn.hdr.code = HDN_BeginTrackW) or (hdn.hdr.code = HDN_BeginTrackA) then
    Msg.Result := 1
    else
    FListViewOldWndProc(Msg);
    end else
    FListViewOldWndProc(Msg);
    end;
    
    
    end.
  • 相关阅读:
    Django REST framework
    SQL的JOIN语法解析(inner join, left join, right join, full outer join的区别)
    zipfile 解压文件名乱码
    Django开发BUG汇总
    [Java 并发] AQS 是个啥?
    [碎碎念]来水一篇
    [Java 并发]深入浅出 synchronized 与锁
    [Java 并发]你确定你了解 volatile ?
    [Java 并发]为什么会有重排序?和 happens-before 有啥关系
    [Java 并发]带你从源码解读线程组( ThreadGroup )好不好
  • 原文地址:https://www.cnblogs.com/zhangzhifeng/p/9627389.html
Copyright © 2011-2022 走看看