发现 TSplitter 在嵌套时不好用, 索性写了个替代品
2011-05-12 17:50
274 查看
代替 TSplitter 的 TDirPanel 类:
调用测试:
unit DirPanel; interface uses Classes, Controls, Forms, ExtCtrls; type TDirPanel = class(TCustomPanel) private FLine: TPanel; B: Boolean; F: Integer; protected procedure LineMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); procedure LineMouseMove(Sender: TObject; Shift: TShiftState; X: Integer; Y: Integer); procedure LineMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); public constructor Create(AOwner: TComponent; aAlign: TAlign = alLeft); reintroduce; destructor Destroy; override; published end; implementation { TDirPanel } constructor TDirPanel.Create(AOwner: TComponent; aAlign: TAlign); begin inherited Create(AOwner); FLine := TPanel.Create(Self); FLine.Parent := Self; case aAlign of alTop: begin FLine.Align := alBottom; FLine.Height := 5; FLine.Cursor := crVSplit; Constraints.MaxHeight := Screen.Height div 4; Constraints.MinHeight := FLine.Height; end; alLeft: begin FLine.Align := alRight; FLine.Width := 5; FLine.Cursor := crHSplit; Constraints.MinWidth := FLine.Width; Constraints.MaxWidth := Screen.Width div 2; end; end; Align := aAlign; BevelOuter := bvNone; FLine.OnMouseDown := LineMouseDown; FLine.OnMouseMove := LineMouseMove; FLine.OnMouseUp := LineMouseUp; end; destructor TDirPanel.Destroy; begin FLine.Free; inherited; end; procedure TDirPanel.LineMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin B := True; case Align of alTop: F := Y; alLeft: F := X; end; end; procedure TDirPanel.LineMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if not B then Exit; case Align of alTop: Height := Height + Y - F; alLeft: Width := Width + X - F; end; end; procedure TDirPanel.LineMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin B := False; end; end.
调用测试:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, OleCtrls, SHDocVw, DirPanel; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} var dir1,dir2: TDirPanel; body: TPanel; web: TWebBrowser; memo: TMemo; procedure TForm1.FormCreate(Sender: TObject); begin body := TPanel.Create(Self); body.Parent := Self; body.Align := alClient; body.BevelOuter := bvNone; dir1 := TDirPanel.Create(Self); dir2 := TDirPanel.Create(Self, alTop); dir1.Parent := Self; dir2.Parent := body; web := TWebBrowser.Create(Self); TControl(web).Parent := dir1; web.Align := alClient; web.Navigate('http://del.cnblogs.com'); memo := TMemo.Create(Self); memo.Parent := dir2; memo.Align := alClient; memo.Text := 'memo'; end; end.
相关文章推荐
- 发现 TSplitter 在嵌套时不好用, 索性写了个替代品(处理MouseDown,MouseMove,MouseUp,然后设定控件的Left值就可以了)
- 最近发现Web前端、Php软件开发工程师以及UI设计的人才不好找
- 发现自己记性不好,以后学到东西都写在上面吧
- 农业银行U盾不好用,检查后发现系统光驱消失,解决方案
- ubuntu scim输入发太不好用了,有点想念 搜狗了,发现 fcitx 不错,网上有不错教程--Ubuntu 9.10 编译安装Fcitx-3.6.2 小企鹅输入法教程
- 突然发现asp.net2.0中的div不能嵌div,如果嵌了,backgroud-images: url()就不好用了,shit
- 今天早上起来写了一个smarty与函数相互结合的一个分页,上网搜了下发现他们写的太复杂,看不懂,自己写吧!写的不好,大家不要笑
- cordova测试发现回退键不好用
- hdu 1199想用线段树,结果发现不好处理,某天突然想起这方法。。易懂,不好写。。。
- CodeForces-787B(题目不好读懂,懂了题目就发现是水题,感觉自己棒棒哒)
- 密码发生器 在对银行账户等重要权限设置密码的时候,我们常常遇到这样的烦恼:如果为了好记用生日吧,容易被破解,不安全;如果设置不好记的密码,又担心自己也会忘记;如果写在纸上,担心纸张被别人发现或
- vux中scroller插件,不好发现的神技巧
- CSplitterWnd窗口分割之——动态静态嵌套分割(二)
- 发现了一个很高端的双层嵌套关键字用法
- thinkphp标签嵌套三层后就不好使了
- 今天微信小程序发现wx.request不好使了,调试报错: 小程序要求的 TLS 版本必须大于等于 1.2
- 支持嵌套的分裂器Obout ASP.NET Splitter 控件介绍
- 最近SLICKedit 挂了,就只能找替代品了,发现了VI+cscope+ctags!
- 密码发生器(在对银行账户等重要权限设置密码的时候,我们常常遇到这样的烦恼:如果为了好记用生日吧,容易被破解,不安全;如果设置不好记的密码,又担心自己也会忘记;如果写在纸上,担心纸张被别人发现或弄丢了)
- 自己发现的nodejs服务的问题--1查询语句的嵌套问题+接受的数据该怎么用