史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   程式語言討論區 (http://forum.slime.com.tw/f76.html)
-   -   [C++ Builder]"自製"記事本 (http://forum.slime.com.tw/thread156656.html)

魔術王子 2005-09-05 04:33 PM

[C++ Builder]"自製"記事本
 
表單很大喔(因為有圖示)
語法:

object Form1: TForm1
  Left = 192
  Top = 114
  Width = 824
  Height = 613
  Caption = '自製記事本'
  Color = clBtnFace
  DefaultMonitor = dmMainForm
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 661
    Top = 26
    Width = 3
    Height = 511
    Cursor = crHSplit
    Align = alRight
  end
  object ToolBar1: TToolBar
    Left = 0
    Top = 0
    Width = 816
    Height = 26
    AutoSize = True
    Caption = 'ToolBar1'
    Images = ImageList1
    TabOrder = 0
    object ToolButton1: TToolButton
      Left = 0
      Top = 2
      Caption = 'ToolButton1'
      ImageIndex = 0
      OnClick = ToolButton1Click
    end
    object ToolButton2: TToolButton
      Left = 23
      Top = 2
      Caption = 'ToolButton2'
      ImageIndex = 1
      OnClick = ToolButton2Click
    end
    object ToolButton3: TToolButton
      Left = 46
      Top = 2
      Caption = 'ToolButton3'
      ImageIndex = 2
      OnClick = ToolButton3Click
    end
    object ToolButton13: TToolButton
      Left = 69
      Top = 2
      Width = 8
      Caption = 'ToolButton13'
      ImageIndex = 3
      Style = tbsSeparator
    end
    object ToolButton14: TToolButton
      Left = 77
      Top = 2
      Caption = 'ToolButton14'
      ImageIndex = 3
      OnClick = ToolButton14Click
    end
    object ToolButton15: TToolButton
      Left = 100
      Top = 2
      Caption = 'ToolButton15'
      ImageIndex = 4
      OnClick = ToolButton15Click
    end
    object ToolButton16: TToolButton
      Left = 123
      Top = 2
      Caption = 'ToolButton16'
      ImageIndex = 5
      OnClick = ToolButton16Click
    end
  end
  object StatusBar1: TStatusBar
    Left = 0
    Top = 560
    Width = 816
    Height = 19
    Panels = <>
    SimplePanel = False
  end
  object Memo1: TMemo
    Left = 0
    Top = 26
    Width = 661
    Height = 511
    Align = alClient
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Fixedsys'
    Font.Style = []
    ParentFont = False
    ScrollBars = ssBoth
    TabOrder = 2
  end
  object ToolBar2: TToolBar
    Left = 0
    Top = 537
    Width = 816
    Height = 23
    Align = alBottom
    AutoSize = True
    ButtonHeight = 21
    ButtonWidth = 19
    Caption = 'ToolBar2'
    DragKind = dkDock
    DragMode = dmAutomatic
    Flat = True
    ShowCaptions = True
    TabOrder = 3
    object ToolButton4: TToolButton
      Left = 0
      Top = 0
      Caption = ','
      ImageIndex = 0
      OnClick = ToolButton4Click
    end
    object ToolButton5: TToolButton
      Left = 19
      Top = 0
      Caption = '。'
      ImageIndex = 1
      OnClick = ToolButton5Click
    end
    object ToolButton6: TToolButton
      Left = 38
      Top = 0
      Caption = '、'
      ImageIndex = 2
      OnClick = ToolButton6Click
    end
    object ToolButton7: TToolButton
      Left = 57
      Top = 0
      Caption = ';'
      ImageIndex = 3
      OnClick = ToolButton7Click
    end
    object ToolButton8: TToolButton
      Left = 76
      Top = 0
      Caption = ':'
      ImageIndex = 4
      OnClick = ToolButton8Click
    end
    object ToolButton9: TToolButton
      Left = 95
      Top = 0
      Caption = '!'
      ImageIndex = 5
      OnClick = ToolButton9Click
    end
    object ToolButton10: TToolButton
      Left = 114
      Top = 0
      Caption = '?'
      ImageIndex = 6
      OnClick = ToolButton10Click
    end
    object ToolButton11: TToolButton
      Left = 133
      Top = 0
      Caption = '「'
      ImageIndex = 7
      OnClick = ToolButton11Click
    end
    object ToolButton12: TToolButton
      Left = 152
      Top = 0
      Caption = '『'
      ImageIndex = 8
      OnClick = ToolButton12Click
    end
  end
  object Panel1: TPanel
    Left = 664
    Top = 26
    Width = 152
    Height = 511
    Align = alRight
    BevelOuter = bvLowered
    Caption = 'Panel1'
    TabOrder = 4
    object ListBox1: TListBox
      Left = 1
      Top = 27
      Width = 150
      Height = 483
      Align = alClient
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Fixedsys'
      Font.Style = []
      ItemHeight = 16
      ParentFont = False
      TabOrder = 0
      OnDblClick = ListBox1DblClick
    end
    object ToolBar3: TToolBar
      Left = 1
      Top = 1
      Width = 150
      Height = 26
      AutoSize = True
      Caption = 'ToolBar3'
      Images = ImageList2
      TabOrder = 1
      object ToolButton17: TToolButton
        Left = 0
        Top = 2
        Caption = 'ToolButton17'
        ImageIndex = 0
        OnClick = ToolButton17Click
      end
      object ToolButton18: TToolButton
        Left = 23
        Top = 2
        Caption = 'ToolButton18'
        ImageIndex = 1
        OnClick = ToolButton18Click
      end
    end
  end


魔術王子 2005-09-05 04:37 PM

由於圖是實在太大所以只好省略
請自行加入2個TImageList元件ImageList1,ImageList2
ImageList1放6個圖示(圖示分別為"新檔""開啟""儲存""剪下""複製""貼上")
ImageList2放2個圖示(圖示分別為"加入""移除")
語法:

  object ImageList1: TImageList
    Left = 64
    Top = 144
    Bitmap = {
  略(圖示分別為"新檔""開啟""儲存""剪下""複製""貼上")
    }
  end
  object OpenDialog1: TOpenDialog
    Left = 64
    Top = 176
  end
  object SaveDialog1: TSaveDialog
    Left = 64
    Top = 208
  end
  object ImageList2: TImageList
    Left = 96
    Top = 144
    Bitmap = {
  略(圖示分別為"加入""移除")
    }
  end
end


魔術王子 2005-09-05 04:44 PM

程式碼
語法:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
  Memo1->Clear(); 
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton2Click(TObject *Sender)
{
  if(OpenDialog1->Execute()) Memo1->Lines->LoadFromFile(OpenDialog1->FileName);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton3Click(TObject *Sender)
{
  if(SaveDialog1->Execute()) Memo1->Lines->SaveToFile(SaveDialog1->FileName);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton14Click(TObject *Sender)
{
  Memo1->CutToClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton15Click(TObject *Sender)
{
  Memo1->CopyToClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton16Click(TObject *Sender)
{
  Memo1->PasteFromClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton4Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert(",",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton5Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert("。",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton6Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert("、",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton7Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert(";",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton8Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert(":",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton9Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert("!",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton10Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert("?",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton11Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert("「」",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton12Click(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert("『』",i);
  Memo1->Text=s;
  Memo1->SelStart=i+1;

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

void __fastcall TForm1::ToolButton17Click(TObject *Sender)
{
  ListBox1->Items->Add(Memo1->SelText); 
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton18Click(TObject *Sender)
{
  if(ListBox1->ItemIndex>=0) ListBox1->Items->Delete(ListBox1->ItemIndex);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ListBox1DblClick(TObject *Sender)
{
  int i=Memo1->SelStart+1;
  String s=Memo1->Text;
  s.Insert(ListBox1->Items->Strings[ListBox1->ItemIndex],i);
  Memo1->Text=s;
  Memo1->SelStart=i+ListBox1->Items->Strings[ListBox1->ItemIndex].Length()-1;
  Memo1->SetFocus();

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


魔術王子 2005-09-07 08:15 AM

http://homepage3.seed.net.tw/web@1/a_quan/MyEditor.rar

小王子已經程式放置網站
有興趣網友可以下載研究(應該有這資格吧 :dcft689kj )

魔術王子 2005-09-08 03:45 PM

引用:

作者: 魔術王子
http://homepage3.seed.net.tw/web@1/a_quan/MyEditor.rar

小王子已經程式放置網站
有興趣網友可以下載研究(應該有這資格吧 :dcft689kj )

再次改良
這次用richedit元件

有興趣網友可以下載研究(同樣位置)

魔術王子 2005-09-08 04:12 PM

引用:

作者: 魔術王子
再次改良
這次用richedit元件

有興趣網友可以下載研究(同樣位置)

程式還有些問題

魔術王子 2005-09-15 11:00 AM

http://homepage3.seed.net.tw/web@1/a_quan/MyEditor.rar
已經修改完了(還不是很滿意啦^^a)

Star Dick 2005-09-16 01:11 PM

建議把TRichedit換成TCppWebBrowser會比較好用,
有疑問請上 http://delphi.ktop.com.tw


所有時間均為台北時間。現在的時間是 08:27 PM

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

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1