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

如何製造出一個C++ Builder 5 類比時鐘與數位時鐘??

尚未結案
ghosbrother
一般會員


發表:3
回覆:1
積分:0
註冊:2006-12-30

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-04-17 19:57:25 IP:218.175.xxx.xxx 訂閱
小弟最近自學了6個禮拜~打算寫一篇類比時鐘與數位時鐘同步顯示動作 (Timer) 
雖然數位時鐘會動~但類比時鐘就是不會動~我也不知道寫法~不知有經驗的前輩可否指教一下?? 看不懂 JAVA 沒學過^^""
附加檔案:48073b24d8d75_C++.rar
編輯記錄
ghosbrother 重新編輯於 2008-04-20 09:08:37, 註解 無‧
Roach
中階會員


發表:61
回覆:104
積分:98
註冊:2002-11-05

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-04-20 02:42:16 IP:218.168.xxx.xxx 訂閱
Hi 你好
看了一你的程式(我沒裝BC5 沒法run)
void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
Label1->Caption="現在:" Time();
}
這個timer事件只有在label秀出時間, 並沒有執行到畫圖(時針與分針的位置)的工作
應該是改成這樣就可以
void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
Label1->Caption="現在:" Time();
Image1->Canvas->Rectangle(-1,-1,299,299);
Image1->Canvas->Ellipse(0,0,199,199);
Image1->Canvas->MoveTo(100,100);
Image1->Canvas->LineTo(100,0);
Image1->Canvas->MoveTo(100,100);
Image1->Canvas->LineTo(150,100);
}
當然了
時針與分針的角度要用三角函數去算xy
這裡有個JavaSCRIPT 自己參考轉換嘿
function ClockAndAssign(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 Math.PI * mins/30;
hr = time.getHours();
hrs = -1.575 Math.PI * hr/6 Math.PI*parseInt(time.getMinutes())/360;
if (ie){
Od.style.top=window.document.body.scrollTop;
Of.style.top=window.document.body.scrollTop;
Oh.style.top=window.document.body.scrollTop;
Om.style.top=window.document.body.scrollTop;
Os.style.top=window.document.body.scrollTop;
}
for (i=0; i < n; i ){
var F=(ns)?document.layers['nsFace' i]:ieFace[i].style;
F.top=y[i] ClockHeight*Math.sin(-1.0471 i*Split*Math.PI/180) scrll;
F.left=x[i] ClockWidth*Math.cos(-1.0471 i*Split*Math.PI/180);
}
for (i=0; i < H.length; i ){
var HL=(ns)?document.layers['nsHours' i]:ieHours[i].style;
HL.top=y[i] HandY (i*HandHeight)*Math.sin(hrs) scrll;
HL.left=x[i] HandX (i*HandWidth)*Math.cos(hrs);
}
for (i=0; i < M.length; i ){
var ML=(ns)?document.layers['nsMinutes' i]:ieMinutes[i].style;
ML.top=y[i] HandY (i*HandHeight)*Math.sin(min) scrll;
ML.left=x[i] HandX (i*HandWidth)*Math.cos(min);
}
for (i=0; i < S.length; i ){
var SL=(ns)?document.layers['nsSeconds' i]:ieSeconds[i].style;
SL.top=y[i] HandY (i*HandHeight)*Math.sin(sec) scrll;
SL.left=x[i] HandX (i*HandWidth)*Math.cos(sec);
}
for (i=0; i < D.length; i ){
var DL=(ns)?document.layers['nsDate' i]:ieDate[i].style;
DL.top=Dy[i] ClockHeight*1.5*Math.sin(currStep i*Dsplit*Math.PI/180) scrll;
DL.left=Dx[i] ClockWidth*1.5*Math.cos(currStep i*Dsplit*Math.PI/180);
}
currStep-=step;
}
系統時間:2024-04-27 8:41:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!