Литература
- 1. Методические указания по выполнению курсовых и дипломных проектов. Специальность: 2-40 02 01 «Программное обеспечение информационных технологий»;
- 2. Культин Н.Б. Самоучитель С++ Builder. - СПб.: БХВ-Петербург,2005. - 320с.: ил.
- 3. Культин Н.Б. С/С++ в задачах и примерах. - СПб.: БХВ-Петербург, 2006. - 288с.: ил.
- 4. Borland Builder C++. Освой самостоятельно. - СПб.: Питер, 2005. - 702с.: ил.
- 5. Холзнер С. Visual C++ 6. Учебный курс. - СПб.: Питер, 2006. - 570с.: ил.
- 6. Красиков И.В., Красикова И.Е. Алгоритмы. Просто как дважды два. - М.: Эксмо,2006. - 256с.: ил.
- 7. Карпов Б., Баранова Т. С++. Специальный справочник (2-е издание). - СПб.: Питер, 2005. - 381с.: ил.
- 8. Франка П. С++: Учебный курс. - СПб.: Питер, 2005. - 522с.: ил.
- 9. Википедия - свободная энциклопедия [Электронный ресурс]. - Электронные данные. - Режим доступа: http://ru.wikipedia.org/wiki/Веб-сайт;
- 10. Embarcadero Website [Электронный ресурс]. - Электронные данные. - Режим доступа: https://www.embarcadero.com/ru/products/cbuilder
Текст программы
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mshtml.h"
#include "home.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
using namespace std;
TForm1 *Form1;
IDispatch *Disp = NULL;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
this->WebBrowser1->Navigate("about:<html><body></body></html>");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
if (this->WebBrowser1->Document)
{
IHTMLDocument2 *html;
this->WebBrowser1->Document->QueryInterface<IHTMLDocument2>(&html);
BSTR bstrMode;
html->get_designMode(&bstrMode);
BSTR chek = L"On";
// Смена режима редактиования на режим просмотра )
if ( wcscmp(bstrMode , chek) ) {
html->put_designMode(L"On");
this->StatusBar1->Panels->operator [](1)->Text = "Редактирование";
this->BitBtn1->Caption = "Заблокировать";
}else{
html->put_designMode(L"Off");
this->StatusBar1->Panels->operator [](1)->Text = "Просмотр";
this->BitBtn1->Caption = "Редактировать";
}
html->Release();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonGroup1Items1Click(TObject *Sender)
{
if (this->WebBrowser1->Document)
{
IHTMLDocument2 *html;
TStringList *t = new TStringList;
this->WebBrowser1->Document->QueryInterface<IHTMLDocument2>(&html);
IHTMLElement *pElement;
html->get_body(&pElement);
pElement->get_parentElement(&pElement);
wchar_t *tmp;
pElement->get_outerHTML(&tmp);
t->Text = tmp;
if (this->SaveDialog1->Execute()){
t->SaveToFile( this->SaveDialog1->FileName);
}
pElement->Release();
html->Release();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonGroup1Items0Click(TObject *Sender)
{
if(this->OpenDialog1->Execute()){
Application->ProcessMessages();
TStringList *t = new TStringList;
t->LoadFromFile(this->OpenDialog1->FileName);
if (this->WebBrowser1->Document) {
this->WebBrowser1->Navigate("about:"+t->Text+"");
this->StatusBar1->Panels->operator [](1)->Text = "Просмотр";
this->BitBtn1->Caption = "Редактировать";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonGroup1Items3Click(TObject *Sender)
{
IHTMLDocument2 *html;
this->WebBrowser1->Document->QueryInterface<IHTMLDocument2>(&html);
html->put_designMode(L"Off");
this->StatusBar1->Panels->operator [](1)->Text = "Просмотр";
this->BitBtn1->Caption = "Редактировать";
this->WebBrowser1->Navigate("about:blank");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ButtonGroup1Items2Click(TObject *Sender)
{
if(this->WebBrowser1->Document){
IHTMLDocument2 *html;
this->WebBrowser1->Document->QueryInterface<IHTMLDocument2>(&html);
html->put_designMode(L"Off");
this->WebBrowser1->Navigate("about:blank");
this->StatusBar1->Panels->operator [](1)->Text = "Просмотр";
this->BitBtn1->Caption = "Редактировать";
html->Release();
}
}
//---------------------------------------------------------------------------
void ExecComd(BSTR cmd, VARIANT_BOOL showUI ){
if ( Form1->WebBrowser1->Document)
{
IHTMLDocument2 *html;
Form1->WebBrowser1->Document->QueryInterface<IHTMLDocument2>(&html);
VARIANT var;
VARIANT_BOOL receive;
html->execCommand(cmd,showUI,var, &receive);
html->Release();
}
}
void ExecComd2(BSTR cmd, VARIANT_BOOL showUI,VARIANT var ){
if ( Form1->WebBrowser1->Document)
{
IHTMLDocument2 *html;
Form1->WebBrowser1->Document->QueryInterface<IHTMLDocument2>(&html);
VARIANT_BOOL receive;
html->execCommand(cmd,showUI,var, &receive);
html->Release();
}
}
void __fastcall TForm1::Image5Click(TObject *Sender){ExecComd(L"Bold",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image8Click(TObject *Sender){ExecComd(L"Italic",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image6Click(TObject *Sender){ExecComd(L"underline",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image2Click(TObject *Sender){ExecComd(L"InsertImage",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image9Click(TObject *Sender){ExecComd(L"JustifyLeft",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image12Click(TObject *Sender){ExecComd(L"JustifyCenter",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image10Click(TObject *Sender){ExecComd(L"JustifyRight",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image11Click(TObject *Sender){ExecComd(L"justifyFull",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1Click(TObject *Sender){ExecComd(L"Indent",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image3Click(TObject *Sender){ExecComd(L"CreateLink",true);}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
if (RichEdit2->Text.Trim() == "" || RichEdit1->Text.Trim() == "") {
Beep();
return;
}
start = clock();
TStringList* tmpList = new TStringList;
tmpList->Assign(RichEdit2->Lines);
AnsiString procent = "";
for(int i=0; i < tmpList->Count ; i++){
AnsiString test = tmpList->operator [](i).Trim();
if (test.Length() < 3 ) {
continue;
}
TStringList* result = search(test, RichEdit1->Lines->Text);
if (result != NULL) {
AppendStr(procent,tmpList->operator [](i));
for(int i=0; i < result->Count ; i++){
// Form1->Memo1->Lines->Add(test);
RichEdit1->SelStart = StrToInt(result->operator [](i));
RichEdit1->SelLength = test.Length();
RichEdit1->SelAttributes->Color = clRed;
}
}
test = tmpList->operator [](i);
AnsiString noop = AnsiString::StringOfChar('ђ',test.Length());
tmpList->Text = StringReplace(tmpList->Text, test, noop, TReplaceFlags() << rfReplaceAll);
}
clock_t tmpl = clock();
Label4->Caption = "Текст уникален на " + FloatToStr(100.0 - (procent.Length() / (RichEdit1->Text.Length() / 100))) + "%";
log( "", "");
ADOTable1->Insert();
ADOTable1->Fields->operator [](2)->AsDateTime = Time();
ADOTable1->Fields->operator [](2)->AsString =FloatToStr((tmpl - start) / CLK_TCK)+" s.";
ADOTable1->Fields->operator [](3)->AsWideString = RichEdit2->Text.Trim();
ADOTable1->Fields->operator [](4)->AsWideString = RichEdit2->Text.Trim();
ADOTable1->Post();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
RichEdit1->Lines->Clear();
RichEdit2->Lines->Clear();
LabeledEdit1->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
if (!OpenTextFileDialog1->Execute()) return;
RichEdit1->Lines->LoadFromFile(OpenTextFileDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
if (!OpenTextFileDialog1->Execute()) return;
RichEdit2->Lines->LoadFromFile(OpenTextFileDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
if (!SaveTextFileDialog1->Execute()) return;
RichEdit1->Lines->SaveToFile(SaveTextFileDialog1->FileName);

}