|
VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
|
上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
tennis
註冊時間: 2007-10-15 文章: 27
第 1 樓
|
發表於: 星期一 二月 29, 2016 7:32 am 文章主題: 請問 如何知道 click時點到某物件? |
|
|
如題:
當mouse click 時,如何動態取得物件的caption,及相關屬性內容 |
|
回頂端 |
|
|
syntech
註冊時間: 2003-05-16 文章: 4212 來自: Taipei,Taiwan
第 2 樓
|
|
回頂端 |
|
|
tennis
註冊時間: 2007-10-15 文章: 27
第 3 樓
|
發表於: 星期二 三月 01, 2016 1:34 pm 文章主題: |
|
|
謝謝回答,我想要的是form 中有各式各樣的物件,我希望mouse 點到該物件時,能顯示該物件的類別及caption |
|
回頂端 |
|
|
syntech
註冊時間: 2003-05-16 文章: 4212 來自: Taipei,Taiwan
第 4 樓
|
發表於: 星期二 三月 01, 2016 2:19 pm 文章主題: |
|
|
沒錯呀,
在 MOUSExxxxx 事件中,把你要的屬性傳回來,
但是要每個物件都自己加進去.
----
得到奇怪答案的原因可能是問了不正確的問題 _________________ 如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問
請聯絡我們,也許我們幫得上忙 |
|
回頂端 |
|
|
oldbb
註冊時間: 2007-02-28 文章: 83
第 5 樓
|
發表於: 星期三 三月 02, 2016 8:53 am 文章主題: |
|
|
代碼: | ** Test.prg
of = CREATEOBJECT("_form")
of.show(1)
CLEAR ALL
DEFINE CLASS _form as Form
ADD OBJECT command1 as commandbutton WITH top=10,left=10
ADD OBJECT command2 as commandbutton WITH top=30,left=10
PROCEDURE Init
FOR EACH oObj IN this.Objects
IF PEMSTATUS(oObj, "Click", 5) AND PEMSTATUS(oObj, "Caption", 5)
BINDEVENT(oObj, "Click", this, "_FormClick")
ENDIF
ENDFOR
ENDPROC
PROCEDURE _FormClick
IF (AEVENTS(aObj, 0) > 0)
IF PEMSTATUS(aObj[1], "Caption", 5)
this.Caption = aObj[1].Caption
ENDIF
ENDIF
ENDPROC
ENDDEFINE |
|
|
回頂端 |
|
|
perry
註冊時間: 2014-07-20 文章: 203
第 6 樓
|
發表於: 星期三 三月 02, 2016 12:25 pm 文章主題: |
|
|
若不想每個物件寫,給一個不負責任及實際寫法的建議!!
1.讀取滑鼠全螢幕 x,y (Left,Top)
DECLARE INTEGER GetCursorPos IN user32 STRING @lpPoint
=GetCursorPos(@m.stru)
Mleft=asc(subs(m.stru,1,1))+asc(subs(m.stru,2,1))*256
Mtop=asc(subs(m.stru,5,1))+asc(subs(m.stru,6,1))*256
2.取得表單0,0相對於全螢幕的x,y
3.設 Timer 判讀滑鼠全螢幕 x,y是否在各物件的範圍中top,left,right,butt
thisform.controlcount &&物件數
thisform.controls(n).name &&物件名稱
thisform.controls(n).top... |
|
回頂端 |
|
|
oldbb
註冊時間: 2007-02-28 文章: 83
第 7 樓
|
發表於: 星期三 三月 02, 2016 2:13 pm 文章主題: |
|
|
代碼: | ** Test.prg
of = CREATEOBJECT("_form")
of.show(1)
CLEAR ALL
DEFINE CLASS _form as Form
ADD OBJECT command1 as commandbutton WITH top=10,left=10
ADD OBJECT command2 as commandbutton WITH top=30,left=10
PROCEDURE Init
DECLARE LONG SendMessage IN User32 LONG, LONG, LONG, LONG
BINDEVENT(this.hWnd, 0x0202, this, "_LButtonUp")
ENDPROC
PROCEDURE _LButtonUp(hWnd, nMsg, wParam, lParam)
IF (AMOUSEOBJ(aObj, 1) > 0)
IF PEMSTATUS(aObj[1], "Caption", 5)
this.Caption = aObj[1].Caption
ENDIF
ENDIF
SendMessage(hWnd, nMsg, wParam, lParam)
ENDPROC
ENDDEFINE
|
|
|
回頂端 |
|
|
perry
註冊時間: 2014-07-20 文章: 203
第 8 樓
|
發表於: 星期四 三月 03, 2016 2:43 pm 文章主題: |
|
|
tennis 寫到: | 我想要的是form 中有各式各樣的物件,我希望mouse 點到該物件時,能顯示該物件的類別及caption |
1.讀取滑鼠全螢幕 x,y (Left,Top)
DECLARE INTEGER GetCursorPos IN user32 STRING @lpPoint
m.stru=repl(chr(0),
=GetCursorPos(@m.stru)
Mleft=asc(subs(m.stru,1,1))+asc(subs(m.stru,2,1))*256
Mtop=asc(subs(m.stru,5,1))+asc(subs(m.stru,6,1))*256
2.取得表單0,0相對於全螢幕的x (s_left),y (s_top)
3.自行設定熱鍵來判讀滑鼠全螢幕 x,y是否在各物件的範圍中top,left,right,butt
thisform.controlcount &&物件數
thisform.controls(n).name &&物件名稱
******
on key label rightmouse do chkmobj
do form test
代碼: |
proc chkmobj
priv tform,old_err
old_err=on('error')
on error do merrpass
tform=_screen.activeform
on error &old_err
if vartype(tform)#'O'
retu
endi
DECLARE INTEGER GetCursorPos IN user32 STRING @lpPoint
m.stru=repl(chr(0),8)
=GetCursorPos(@m.stru)
Mleft=asc(subs(m.stru,1,1))+asc(subs(m.stru,2,1))*256
Mtop=asc(subs(m.stru,5,1))+asc(subs(m.stru,6,1))*256
s_top=_screen.top+12 &&自行想辦法
s_left=_screen.left+3 &&自行想辦法
for n=1 to tform.controlcount
oTop=tform.controls(n).top+s_top &&表單top=0相對全螢幕top
oButt=oTop+tform.controls(n).height
oLeft=tform.controls(n).left+s_left &&表單left=0相對全螢幕left
oRight=oLeft+tform.controls(n).width
if mleft>=oLeft and mleft<=oRight and mtop>=oTop and mtop<=oButt
wait wind tform.controls(n).name+chr(13)+tform.controls(n).baseclass timeout 5
exit
endi
next
endproc
proc merrpass
retu
endproc
|
|
|
回頂端 |
|
|
perry
註冊時間: 2014-07-20 文章: 203
第 9 樓
|
發表於: 星期四 三月 03, 2016 8:37 pm 文章主題: |
|
|
代碼: |
store 0 to s_top,s_left
s_top=tform.top+iif(tform.titlebar=1,sysm(34),0)+IIF(tform.BorderStyle>0,SYSM(13),SYSM(11))
s_left=tform.left+IIF(tform.BorderStyle>0,SYSM(12),SYSM(10))
if tform.ShowWindow#2
s_top=s_top+_screen.top+IIF(_Screen.titlebar=1,sysm(34),0)+IIF(_Screen.BorderStyle>0,SYSM(13),SYSM(11))
s_left=s_left+_screen.left+IIF(_Screen.BorderStyle>0,SYSM(12),SYSM(10))
endi
|
個人覺得畢竟程式是自己寫的,應該用不到這種功能= =''' |
|
回頂端 |
|
|
tennis
註冊時間: 2007-10-15 文章: 27
第 10 樓
|
發表於: 星期五 三月 04, 2016 10:51 pm 文章主題: |
|
|
3Q!! |
|
回頂端 |
|
|
55812296
註冊時間: 2012-09-19 文章: 49
第 11 樓
|
發表於: 星期一 三月 07, 2016 5:47 pm 文章主題: |
|
|
oForm.KeyPreview=.t. &&當物件有KeyPress事件 會先執行Form.KeyPress
oForm.KeyPress 事件
if oForm.ActiveControl.BaseClass='CommandButton'
if inlist(oForm.ActiveControl.name,'1','2','3')
messagebox('caption='+oForm.ActiveControl.caption)
endif
endif |
|
回頂端 |
|
|
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
|
|