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這樣的熱鍵也不起作用。本文說明如何使用表格控件的屬性模仿這些編輯功能。
詳細內(nèi)容
既然在表格控件里系統(tǒng)菜單選項和剪切、復制及粘貼這些快捷鍵都沒有作用,必須使用 Grid32.OCX對象的屬性實現(xiàn)這些功能。為此,必須使用表格控件的Clip、 Col、 Rowt 和Text屬 性。 下例使用文件框控件和表格控件示范如何通過編程在兩個對象之間復制、剪切和粘帖文本字符 串。 下述步驟創(chuàng)建包含一個具有復制、剪切和粘貼功能的表格控件的表單。 創(chuàng)建一個表單,在表單上添加一個文件框和一個 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