史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 程式語言討論區
忘記密碼?
論壇說明 標記討論區已讀

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


發文 回覆
 
主題工具 顯示模式
舊 2006-03-24, 12:31 PM   #1
不知道
長老會員
榮譽勳章
UID - 548
在線等級: 級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時級別:59 | 在線時長:3787小時 | 升級還需:53小時
註冊日期: 2002-12-06
住址: 桃園
文章: 8606
現金: 1491 金幣
資產: 1183995 金幣
Post 用C++Builder設計記事本

表單
http://home.pchome.com.tw/hot/quanhome/WinEditor/WinEditor.jpg
程式碼(Unit.cpp)
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include <Clipbrd.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TTabSheet* pts[128];
TRichEdit* rich[128];
int PageNo=0;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
ListBox1->Items->Add(Clipboard()->AsText);
pts[PageNo]=new TTabSheet(this);
pts[PageNo]->PageControl=PageControl1;
pts[PageNo]->Caption="NewText - "+IntToStr(PageNo)+".txt";
rich[PageNo]=new TRichEdit(this);
rich[PageNo]->Parent=pts[PageNo];
rich[PageNo]->Align=alClient;
rich[PageNo]->ScrollBars=ssBoth;
rich[PageNo]->Font->Name="Fixedsys";
rich[PageNo]->PlainText=true;
rich[PageNo]->OnKeyPress=rich_KeyPress;
PageControl1->ActivePage=pts[PageNo];
PageNo++;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton1->Caption;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton2->Caption;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton3->Caption;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton4Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton4->Caption;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton5Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton5->Caption;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton6Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton6->Caption;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton7Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton7->Caption;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton8Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText="「"+rich[PageControl1->ActivePageIndex]->SelText+"」";
rich[PageControl1->ActivePageIndex]->SelStart=rich[PageControl1->ActivePageIndex]->SelStart-2;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton9Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText="『"+rich[PageControl1->ActivePageIndex]->SelText+"』";
rich[PageControl1->ActivePageIndex]->SelStart=rich[PageControl1->ActivePageIndex]->SelStart-2;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton10Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText="("+rich[PageControl1->ActivePageIndex]->SelText+")";
rich[PageControl1->ActivePageIndex]->SelStart=rich[PageControl1->ActivePageIndex]->SelStart-2;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton11Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText="【"+rich[PageControl1->ActivePageIndex]->SelText+"】";
rich[PageControl1->ActivePageIndex]->SelStart=rich[PageControl1->ActivePageIndex]->SelStart-2;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton12Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=SpeedButton12->Caption;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
pts[PageNo]=new TTabSheet(this);
pts[PageNo]->PageControl=PageControl1;
pts[PageNo]->Caption="NewText - "+IntToStr(PageNo)+".txt";
rich[PageNo]=new TRichEdit(this);
rich[PageNo]->Parent=pts[PageNo];
rich[PageNo]->Align=alClient;
rich[PageNo]->ScrollBars=ssBoth;
rich[PageNo]->Font->Name="Fixedsys";
rich[PageNo]->PlainText=true;
rich[PageNo]->OnKeyPress=rich_KeyPress;
PageControl1->ActivePage=pts[PageNo];
PageNo++;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton2Click(TObject *Sender)
{
if(OpenDialog1->Execute()){
rich[PageControl1->ActivePageIndex]->Lines->LoadFromFile(OpenDialog1->FileName);
rich[PageControl1->ActivePageIndex]->Hint=OpenDialog1->FileName;
}

}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton3Click(TObject *Sender)
{
SaveDialog1->FileName=PageControl1->ActivePage->Caption;
SaveDialog1->InitialDir=rich[PageControl1->ActivePageIndex]->Hint;
if(SaveDialog1->Execute()){
rich[PageControl1->ActivePageIndex]->Lines->SaveToFile(SaveDialog1->FileName);
}

}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton5Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->CutToClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton6Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->CopyToClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton7Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->PasteFromClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N21231Click(TObject *Sender)
{
pts[PageNo]=new TTabSheet(this);
pts[PageNo]->PageControl=PageControl1;
rich[PageNo]=new TRichEdit(this);
rich[PageNo]->Parent=pts[PageNo];
rich[PageNo]->Align=alClient;
rich[PageNo]->ScrollBars=ssBoth;
rich[PageNo]->Font->Name="Fixedsys";
rich[PageNo]->PlainText=true;
rich[PageNo]->OnKeyPress=rich_KeyPress;
PageControl1->ActivePage=pts[PageNo];
rich[PageNo]->PasteFromClipboard();
pts[PageNo]->Caption=rich[PageNo]->Lines->Strings[0]+".txt";
PageNo++;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton8Click(TObject *Sender)
{
ListBox1->Items->Add(rich[PageControl1->ActivePageIndex]->SelText);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton9Click(TObject *Sender)
{
ListBox1->Items->Delete(ListBox1->ItemIndex);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
for(int i=0;i<PageNo;i++){
delete rich[i];
delete pts[i];
}

}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBox1Click(TObject *Sender)
{
rich[PageControl1->ActivePageIndex]->SelText=ListBox1->Items->Strings[ListBox1->ItemIndex];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::rich_KeyPress(TObject *Sender, char &Key)
{
if (Key == 13 && PageControl1->ActivePage->Caption == "NewText - "+IntToStr(PageControl1->ActivePageIndex)+".txt" && rich[PageControl1->ActivePageIndex]->Lines->Count > 0) {
PageControl1->ActivePage->Caption=rich[PageControl1->ActivePageIndex]->Lines->Strings[0]+".txt";
}

}
//---------------------------------------------------------------------------
原始檔(Password:slime)
http://home.pchome.com.tw/hot/quanho.../WinEditor.exe

<敬請批評指教>
__________________
地獄變現記
[人身得來不易,願大家能尊重生命--勿傷胎命][好淫者請好自為之吧--割鳥]
南泉禪師道:
道不屬知,不屬不知。知是妄覺,不知是無記。若真達不疑之道,猶如太虛,廓然蕩豁,豈可強是非邪?」
德山宣鑒禪師:
「如果明白無事,則勿妄求,妄求而得,亦非得也。汝但無事於心,無心於事,則虛而靈,空而妙。若毛端許,言之本末者,皆為自欺。何故?毫氂繫念,三塗業因。瞥爾情生,萬劫羈鎖。聖名凡號,盡是虛聲。殊相劣形,皆是幻色。汝欲求之,得無累乎?」
不知道 目前離線  
送花文章: 5469, 收花文章: 5341 篇, 收花: 24549 次
回覆時引用此帖
發文 回覆


主題工具
顯示模式

發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用


所有時間均為台北時間。現在的時間是 07:31 AM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1