線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1831
推到 Plurk!
推到 Facebook!

尋找元件並Setfocus

答題得分者是:ccchen
cyl
中階會員


發表:163
回覆:171
積分:66
註冊:2002-07-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-01-23 16:37:50 IP:61.218.xxx.xxx 未訂閱
請問我在pagecontrol裡有三個page,這三個page上我都放個幾個dbedit,我想在切換page時去focus page上的第一個dbedit,寫一個procedure去做這件事,但是我想變動去focus,不想寫死程式碼為 dbedit1.setfocus,請問該如何做??
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-01-23 16:58:11 IP:61.221.xxx.xxx 未訂閱
cyl你好: 小弟有更好的建議,只要把dbedit1的Taborder設成0每次換頁focus就是dbedit1
------
======================
昏睡~
不昏睡~
不由昏睡~
banson1716
高階會員


發表:55
回覆:182
積分:167
註冊:2002-04-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-01-24 11:33:09 IP:61.223.xxx.xxx 未訂閱
在 FormCreate() 中不能放有 setfocus 的東西會產生錯誤訊息 setfocus 放在 FormShow 及 FormrResize 用 PageControl.ActivePageIndex:= 1; PageControl.ActivePageIndex:= 2; PageControl.ActivePageIndex:= 3; 決定開啟那一頁 pagecontrol 再去放 dbedit SetFocus
ccchen
版主


發表:61
回覆:940
積分:1394
註冊:2002-04-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-01-25 08:39:01 IP:203.217.xxx.xxx 未訂閱
引言: 請問我在pagecontrol裡有三個page,這三個page上我都放個幾個dbedit,我想在切換page時去focus page上的第一個dbedit,寫一個procedure去做這件事,但是我想變動去focus,不想寫死程式碼為 dbedit1.setfocus,請問該如何做??
只要每個page中taborder正確, 想第一個進入之edit其taborder值最小 在pagecontrol之onChange時如下
procedure TForm1.PageControl1Change(Sender: TObject);
begin
   pageControl1.ActivePage.SetFocus; //先focus在TabSheet上
   Perform(WM_NEXTDLGCTL, 0, 0); //跳至tabsheet內第一個control  
end;
cyl
中階會員


發表:163
回覆:171
積分:66
註冊:2002-07-11

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-01-28 13:58:54 IP:61.218.xxx.xxx 未訂閱
請問版主 Perform(WM_NEXTDLGCTL, 0, 0); 裡面的這三個參數是代表什麼??
ccchen
版主


發表:61
回覆:940
積分:1394
註冊:2002-04-15

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-01-28 18:25:56 IP:203.217.xxx.xxx 未訂閱
引言: 請問版主 Perform(WM_NEXTDLGCTL, 0, 0); 裡面的這三個參數是代表什麼??
perform是執行一個windowmessage 第一個參數WM_NEXTDLGCTL是window message 代號,後兩個參數則是WM_NEXTDLGCTL這個MESSAGE的WPARAM及LPARAM(所有WINDOW MESSAGE均藉由這樣的兩個參數來傳遞訊息) 當第3參數為0時, 第2個參數為0 表示下一個CONTROL, 為1表示至上一個CONTROL 以下是HELP內的原文 The WM_NEXTDLGCTL message is sent to a dialog box procedure to set the keyboard focus to a different control in the dialog box. WM_NEXTDLGCTL wCtlFocus = wParam; // identifies control for focus fHandle = (BOOL) LOWORD(lParam); // wParam handle flag Parameters wCtlFocus Value of wParam. If the fHandle parameter is TRUE, the wCtlFocus parameter identifies the control that receives the focus. If fHandle is FALSE, wCtlFocus is a flag that indicates whether the next or previous control with the WS_TABSTOP style receives the focus. If wCtlFocus is zero, the next control receives the focus; otherwise, the previous control with the WS_TABSTOP style receives the focus. fHandle Value of lParam. Contains a flag that indicates how Windows uses the wCtlFocus parameter. If the fHandle parameter is TRUE, wCtlFocus is a handle associated with the control that receives the focus; otherwise, wCtlFocus is a flag that indicates whether the next or previous control with the WS_TABSTOP style receives the focus. Return Values An application should return zero if it processes this message. Remarks The effect of this message differs from that of the SetFocus function because WM_NEXTDLGCTL modifies the border around the control. Do not use the SendMessage function to send a WM_NEXTDLGCTL message if your application will concurrently process other messages that set the focus. Use the PostMessage function instead.
系統時間:2024-05-13 5:26:44
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!