iT邦幫忙

1

[BCB6] 新手的第一步

正式全名是:

Borland C++Builder 6

https://ithelp.ithome.com.tw/upload/images/20230609/201607587gWvQ1LncM.png
一個有點...古老的程式編譯器(在VisaulStudio2020這個時代)

若跟我一樣先有微軟的Winform經驗就很好理解
用C++,做個較為陽春、原始版的Winform
.
.
.
.
開啟編譯器後應該是直接像這樣顯示一個新專案的基本樣子
https://ithelp.ithome.com.tw/upload/images/20230609/20160758VAgdbuByYV.png
很特殊的是BCB6沒有把整個編譯器組成一個大視窗,所以平常會一直看到其他下層視窗或桌面
不過目前已經可以朝做個簡單基本的Form程式邁進了
.
.
.
從上方的物件工具箱內可找到許多常見的基本物件
https://ithelp.ithome.com.tw/upload/images/20230609/20160758dzYOdoaIx2.png

  • 按鈕
  • 文字框
  • 選擇紐

點擊選擇要建立的物件後,再在視窗(Form)內點擊便可產生一個物件(非拖曳)
https://ithelp.ithome.com.tw/upload/images/20230609/20160758ze6yDQ89uY.png
再來,取個基本的程式物件名稱(Name)
https://ithelp.ithome.com.tw/upload/images/20230609/20160758hZH8hMzGzC.png
通常,Caption會是物件顯示出的文字(文字框的話是Text)
https://ithelp.ithome.com.tw/upload/images/20230609/20160758NOEGI2ISgv.png
連點物件後視窗會跳至Cpp頁面
BCB會自動產生基本的功能函式(點擊、資料變更這些)
https://ithelp.ithome.com.tw/upload/images/20230609/20160758tE3LTVisUy.png
.
.
另外
常見的選擇功能CheckBox、RadioButton
可利用Group型物件直接建立來比較好管理多選項狀況
https://ithelp.ithome.com.tw/upload/images/20230609/20160758koEusMRpBm.png
直接點擊Items可編輯該Group型物件內容
https://ithelp.ithome.com.tw/upload/images/20230609/20160758nnhQvjP6sZ.png
一行一選項
https://ithelp.ithome.com.tw/upload/images/20230609/20160758CrrwLmL4DU.png
之後可在程式內以該物件的ItemIndex資料判別選擇項目為何

如此

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    if(RadioCheck->ItemIndex==0)
    {
    Number_03->Caption= StringToInt(Number_01->Text) + StringToInt(Number_02->Text);
    }
    if(RadioCheck->ItemIndex==1)
    {
    Number_03->Caption= StringToInt(Number_01->Text) - StringToInt(Number_02->Text);
    }
 }
                
        
 int StringToInt(String S )
 {
    if(S.IsEmpty() || S.Length()<=0)
    {
    return 0;
    }
    else return  S.ToInt();
 }

https://ithelp.ithome.com.tw/upload/images/20230609/20160758bXTo9NBcc0.png
可以弄出一個很簡單的判斷分歧程式


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
cpc0935
iT邦研究生 5 級 ‧ 2023-11-25 23:32:13

BCB6的確非常好用,然時至今日也已經超過20年了(2002/9/10發布的),不曾想要使用新一點的版本嗎?

我要留言

立即登入留言