现在使用控件, 更喜欢继承
摘要:以前写代码, 总是把主单元弄得满满当当; 现在更喜欢把控件比较独立的功能写成一个单元, 改写属性、重载方法...哪怕只有一点点和默认不同, 也喜欢独立出来.刚刚用到 TListBox, 需要能拖动元素、双击删除.unit ListBox2;interfaceuses System.Classes, Vcl.Controls, Vcl.StdCtrls, System.Types;type TListBox2 = class(TCustomListBox) protected procedure DragOver(Source: TObject; X: Integer; Y: Int...
阅读全文
posted @
2013-07-24 13:20
万一
阅读(5224)
推荐(1) 编辑
唤醒控件曾经拥有的能力
摘要:控件的祖先 TControl 有很多功能, 但它的有些子孙确丧失了很多(为了专用).譬如 TBevel 就没有把一些常规的事件继承下来, 那些没有被继承的功能一般都隐藏在 protected 区, 如果重新继承是可以使用的.这里尝试了另外一种方法: 自己没有继承时, 问一问有继承的兄弟、叔伯获取其它亲戚; 当然应先确保自己的祖先有该功能且没被覆盖过.通过传统的继承法让 TBevel 相应双击事件:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
阅读全文
posted @
2011-05-12 10:46
万一
阅读(3578)
推荐(1) 编辑
Action 相关组件
摘要:TAction // TEditCut、TEditCopy、TEditPaste、TEditSelectAll、TEditUndo、TEditDelete、TEditSelectAll、TEditSelectAllTWindowAction // TWindowClose、TWindowCascade、TWindowTileHorizontal、TWindowTileVertical、TWindowMinimizeAll、TWindowArrangeTHelpAction // THelpContents、THelpTopicSearch、THelpOnHelp、THelpContextAct
阅读全文
posted @
2011-05-09 18:41
万一
阅读(3313)
推荐(0) 编辑
系统托盘组件 TTrayIcon 简介 - 回复 "三足乌" 的问题
摘要:问题来源: http://www.cnblogs.com/del/archive/2009/06/05/1496857.html#1549294TTrayIcon 的主要属性:TrayIcon.Icon指定托盘图标, 有几种用法:1、设计时选择;2、把一个 TIcon 对象给它;3、使用当前程序图标: TrayIcon1.Icon := Application.Icon;4、TrayIcon1.S...
阅读全文
posted @
2009-06-05 18:09
万一
阅读(7434)
推荐(0) 编辑
用一个 Byte 数表示 8 个复选框的选择状态
摘要:本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CheckLst; type TForm1 = class(TForm) CheckListBox1...
阅读全文
posted @
2009-04-16 17:38
万一
阅读(4802)
推荐(1) 编辑
学习 Message(15): 让窗体同时响应键盘事件的方法
摘要:KeyPreview := True; 即可, 它默认是 False; 这对一些快捷键会有用. 测试代码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = ...
阅读全文
posted @
2008-10-30 14:19
万一
阅读(4182)
推荐(0) 编辑
学习 Message(14): 区分左右 Shift、Ctrl、Alt
摘要:代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; procedure For...
阅读全文
posted @
2008-10-30 13:37
万一
阅读(3484)
推荐(0) 编辑
当前窗体
摘要:代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Panel1: TPanel; B...
阅读全文
posted @
2008-10-28 22:50
万一
阅读(2260)
推荐(0) 编辑
一句话为当前窗口客户区捉图: GetFormImage
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button...
阅读全文
posted @
2008-10-24 14:42
万一
阅读(2833)
推荐(0) 编辑
BringToFront、SendToBack - 控件置前与置后
摘要:本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Panel1: TPane...
阅读全文
posted @
2008-10-23 18:29
万一
阅读(11957)
推荐(1) 编辑
Controls 属性与继承 TShape 类的小练习
摘要:本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TMyShape = class(TShape) protected ...
阅读全文
posted @
2008-10-23 14:50
万一
阅读(3734)
推荐(0) 编辑
测试 Components 与 Controls 的区别
摘要:本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Panel1: TPane...
阅读全文
posted @
2008-10-23 13:32
万一
阅读(7211)
推荐(0) 编辑
给 TComboBox 添加图标 - 回复 "heyongan" 的问题
摘要:首先: 这有现成的控件: TComboBoxEx, 没必要使用 TComboBox; 非要在 TComboBox 基础上添加, 也可以. 本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialog...
阅读全文
posted @
2008-09-08 11:43
万一
阅读(4654)
推荐(0) 编辑
工具条按钮上的下拉菜单 - 没想到是这么容易实现的
摘要:制作步骤: 1、添加一个 TImageList: ImageList1, 然后载入些图标; 2、添加两个 TPopupMenu: PopupMenu1、PopupMenu2, 并分别添加些菜单项; 3、添加一个 TToolBar 控件: ToolBar1, 通过其右键菜单 New Button 添加两个按钮: ToolButton1、ToolButton2; 4、选择属性: To...
阅读全文
posted @
2008-09-03 14:43
万一
阅读(6005)
推荐(0) 编辑
模拟一个带背景的 TPanel
摘要:程序中用 TPanel 做了容器, 需要给它一个背景图片; 发现这竟是个难题! 发现我经常使用的滚动箱控件 TScrollBox, 是一个很好的替代品. 本例需要先添加两个图片资源, 添加方法可以参考: http://www.cnblogs.com/del/archive/2008/08/23/1274591.html 本例效果图: 代码文件: unit Unit1; interf...
阅读全文
posted @
2008-09-01 16:59
万一
阅读(8492)
推荐(0) 编辑
实现无标题栏但有边框的窗口
摘要:本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) CheckBox1: TCheckBox; ...
阅读全文
posted @
2008-08-29 14:45
万一
阅读(7224)
推荐(1) 编辑
给 Memo 排序的函数
摘要:本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Butto...
阅读全文
posted @
2008-07-04 16:50
万一
阅读(3891)
推荐(0) 编辑
获取窗口矩形的四种方法: GetClientRect、ClientRect、GetWindowRect、BoundsRect
摘要:其中 GetClientRect、ClientRect 获取的是窗口的客户区矩形; GetWindowRect、BoundsRect 是获取窗口矩形; 另外, 还有一个 Windows.GetClientRect(使用方法同 GetWindowRect, 它们都是 API 函数), 这里使用的 GetClientRect 是 Forms.GetClientRect. 本例效果图: unit...
阅读全文
posted @
2008-05-29 12:31
万一
阅读(18841)
推荐(0) 编辑
把窗体客户区图像保存到文件或剪切板
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton...
阅读全文
posted @
2008-05-15 11:20
万一
阅读(6802)
推荐(0) 编辑