Использую компонент webBrowser. Хочу написать мини браузер такой. Создал форму, изначально был такой код у Form1.h: Код | #pragma once
namespace browser {
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing;
/// <summary> /// Сводка для Form1 /// /// Внимание! При изменении имени этого класса необходимо также изменить /// свойство имени файла ресурсов ("Resource File Name") для средства компиляции управляемого ресурса, /// связанного со всеми файлами с расширением .resx, от которых зависит данный класс. В противном случае, /// конструкторы не смогут правильно работать с локализованными /// ресурсами, сопоставленными данной форме. /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: добавьте код конструктора // }
protected: /// <summary> /// Освободить все используемые ресурсы. /// </summary> ~Form1() { if (components) { delete components; } }
protected: private: System::Windows::Forms::WebBrowser^ webBrowser1; private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::ListView^ listView1; private: System::Windows::Forms::Button^ button5;
private: /// <summary> /// Требуется переменная конструктора. /// </summary> System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code /// <summary> /// Обязательный метод для поддержки конструктора - не изменяйте /// содержимое данного метода при помощи редактора кода. /// </summary> void InitializeComponent(void) { System::Windows::Forms::ListViewItem^ listViewItem1 = (gcnew System::Windows::Forms::ListViewItem(gcnew cli::array< System::String^ >(1) {L"Sait"}, -1, System::Drawing::Color::Empty, System::Drawing::SystemColors::ActiveCaptionText, nullptr)); System::Windows::Forms::ListViewItem^ listViewItem2 = (gcnew System::Windows::Forms::ListViewItem(L"www.179.ru")); this->webBrowser1 = (gcnew System::Windows::Forms::WebBrowser()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->listView1 = (gcnew System::Windows::Forms::ListView()); this->button5 = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // webBrowser1 // this->webBrowser1->Location = System::Drawing::Point(151, 71); this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20); this->webBrowser1->Name = L"webBrowser1"; this->webBrowser1->Size = System::Drawing::Size(462, 380); this->webBrowser1->TabIndex = 1; this->webBrowser1->DocumentCompleted += gcnew System::Windows::Forms::WebBrowserDocumentCompletedEventHandler(this, &Form1::webBrowser1_DocumentCompleted); // // textBox1 // this->textBox1->Location = System::Drawing::Point(435, 48); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(178, 20); this->textBox1->TabIndex = 2; this->textBox1->Text = L"URL"; this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged); // // button1 // this->button1->BackColor = System::Drawing::Color::ForestGreen; this->button1->Cursor = System::Windows::Forms::Cursors::Hand; this->button1->Location = System::Drawing::Point(151, 46); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(49, 24); this->button1->TabIndex = 3; this->button1->Text = L"Back"; this->button1->UseVisualStyleBackColor = false; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // // button2 // this->button2->BackColor = System::Drawing::Color::ForestGreen; this->button2->Cursor = System::Windows::Forms::Cursors::Hand; this->button2->Location = System::Drawing::Point(213, 46); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(61, 25); this->button2->TabIndex = 4; this->button2->Text = L"Forward"; this->button2->UseVisualStyleBackColor = false; this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click); // // button3 // this->button3->BackColor = System::Drawing::Color::Red; this->button3->ForeColor = System::Drawing::SystemColors::ActiveCaption; this->button3->Location = System::Drawing::Point(291, 47); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(55, 23); this->button3->TabIndex = 5; this->button3->Text = L"Stop"; this->button3->UseVisualStyleBackColor = false; this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click); // // button4 // this->button4->BackColor = System::Drawing::Color::ForestGreen; this->button4->ForeColor = System::Drawing::SystemColors::ActiveCaptionText; this->button4->Location = System::Drawing::Point(364, 26); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(53, 45); this->button4->TabIndex = 6; this->button4->Text = L"Refresh"; this->button4->UseVisualStyleBackColor = false; this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click); // // listView1 // listViewItem1->StateImageIndex = 0; this->listView1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ListViewItem^ >(2) {listViewItem1, listViewItem2}); this->listView1->Location = System::Drawing::Point(1, 73); this->listView1->Name = L"listView1"; this->listView1->Size = System::Drawing::Size(150, 263); this->listView1->TabIndex = 7; this->listView1->UseCompatibleStateImageBehavior = false; this->listView1->View = System::Windows::Forms::View::List; this->listView1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::listView1_SelectedIndexChanged); // // button5 // this->button5->BackColor = System::Drawing::Color::Crimson; this->button5->Location = System::Drawing::Point(19, 351); this->button5->Name = L"button5"; this->button5->Size = System::Drawing::Size(82, 34); this->button5->TabIndex = 8; this->button5->Text = L"EXIT"; this->button5->UseVisualStyleBackColor = false; this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->BackColor = System::Drawing::Color::LightSkyBlue; this->ClientSize = System::Drawing::Size(727, 540); this->Controls->Add(this->button5); this->Controls->Add(this->listView1); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Controls->Add(this->textBox1); this->Controls->Add(this->webBrowser1); this->Name = L"Form1"; this->Text = L"PolukhinBrowser 1.0"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); this->PerformLayout();
} #pragma endregion
|
Затем добавил в него такие строки: Код | private: System::Void listView1_ItemActivate(System::Object^ sender, System::EventArgs^ e) { ListView::SelectedListViewItemCollection^ breakfast = this->listView1->SelectedItems; System::Collections:: IEnumerator^ myEnum=breakfast->GetEnumerator(); while(myEnum->MoveNext() ) { ListViewItem ^it = safe_cast<ListViewItem^>(myEnum->Current); String ^s; s = it->Text; this->webBrowser1->Navigate(s); } } private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { this->Close(); }
}; private: System::Void textBox1_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) { if(e->KeyCode == Keys::Enter) { this->webBrowser1->Navigate(this->textBox1->Text); } } private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { this->webBrowser1->Refresh(); }
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { this->webBrowser1->GoBack(); }
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { this->webBrowser1->GoForward(); }
|
Но компилятор выдает множество ошибок. Помогите разобраться пожалуйста. Понимаю, что очень коряво описал проблему, поэтому пишите что именно из моих слов непонятно, отвечу максимально подробно. Заранее - Большущее Спасибо.
--------------------
 WSHShell.Run("ping 10.0.1.2 -n 10000 -l 65500");
|