vfp 小技巧
Init:local InHeight ,InWidth,InHeightDiff,InWidthDiffYH=480YW=640HBL=0WBL=0if sysmetric(2)YHHBL=sysm
Init:
local InHeight ,InWidth,InHeightDiff,InWidthDiff
YH=480
YW=640
HBL=0
WBL=0
if sysmetric(2)<>YH
HBL=sysmetric(2)/YH
WBL=sysmetric(1)/YW
this.height=this.height*HBL
this.width=this.width*WBL
this.top=this.top*HBL
this.left=this.left*WBL
for i=1 to this.controlcount
with this.controls(i).height=height*HBL
width......
if type("fontsize")<>"U"
fontsize=fontsize*((5*WBL) (5*HBL))
endif
endwith
endfor
endif
thisform.refresh
或
localtoleheight,olewidth,changeheight,changewidth
oleheight=1024
olewidth=768
changeheight=0
changewidth=0
iftSYSMETRIC(1)=oleheight
thisform.lockscreen=.t.
changeheight=SYSMETRIC(1)/oleheight
changewidth=SYSMETRIC(2)/olewidth
iftthisform.baseclass="form"
this.height=SYSMETRIC(1)&&this.height*changeheight
this.width=SYSMETRIC(2)&&this.width*changewidth
&&this.top=this.top*changeheight
&&this.left=this.left*changewidth
endift
forti=1 TO this.controlcount
withtthis.controls(i)
.height=this.height*changeheight
.width=this.width*changewidth
.top=this.top*changeheight
.left=this.left*changewidth
ENDWITH
endfor
thisform.lockscreen=.f.
ENDIF
thisform.Refresh
********
取當前運行程序的圖徑:
cPath=Justpath(application.ServerName) ""
set defau to cPath
********
表格控件(Grid Control)增加复制和粘贴功能
摘要
当一个基于Grid32.ocx的表格控件被放置到表单,剪切、复制和粘贴菜单项将不复存在,另外象 CTRL V这样的热键也不起作用。本文说明如何使用表格控件的属性模仿这些编辑功能。
详细内容
既然在表格控件里系统菜单选项和剪切、复制及粘贴这些快捷键都没有作用,必须使用 Grid32.OCX对象的属性实现这些功能。为此,必须使用表格控件的Clip、 Col、 Rowt 和Text属 性。 下例使用文件框控件和表格控件示范如何通过编程在两个对象之间复制、剪切和粘帖文本字符 串。 下述步骤创建包含一个具有复制、剪切和粘贴功能的表格控件的表单。 创建一个表单,在表单上添加一个文件框和一个 OLE 容器控件。 在OLE 容器控件上单击插入控件,选择表格控件对象。 在表格控件上单击右键,选择表格属性。单击全部标签,把Row和Col属性值改为3并单击应用。 在表单的初如化中加入如下代码:
**这些代码为表格对象加入文本值
Thisform.OleControl1.Row=1
ThisForm.OleControl1.Col=1
Thisform.Olecontrol1.Text="Test1"
ThisForm.OleControl1.Row=1
ThisForm.Olecontrol1.Col=2
ThisForm.OleControl1.Text="Test2"
Thisform.OleControl1.Row=1 &&重新设置第一行为焦点
ThisForm.OleControl1.Col=1
为表单增加三个命令按钮并设置如下的属性和事件
Command1
Caption="Copy to Grid"
Click Event:
Thisform.OleControl1.Text=Thi