Вы находитесь на странице: 1из 320

32.973.233-018.

2
004.658
59

59

. .
MS Visual C++ 2010 .NET. . .: ,
2012. 320 .: .
ISBN 978-5-459-00786-2
Visual Studio 2010
C++/CLI. ,
, .
.
.
. . . , .
WebBrowser ,
-. MS Excel, MS Word, AutoCAD MATLAB. PDF-.
SQL Server MS Access
ADO.NET. , .
, ,
, MS Visual C++/CLI.

32.973.233-018.2
004.658

. .
, , ,
. , ,

, .

ISBN 978-5-459-00786-2

, 2012

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
? . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2. . . . . . . . . . . . . . . . . . . . . . . 47
3. . . . . . . . . . . . . 57
4. , ,
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5. . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
6.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
7. . . . . . . . . . 149
8. WebBrowser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
9. MS Word, MS Excel, AutoCAD MATLAB,
PDF- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
10. ADO.NET . . . . . . . 229
11. LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
12. , Windows Application . . . . . . . . . . 280
. . . . . . . . . . . . . . . . . . . . . . . 303

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
? . . . . . . . . . . . . . . . . . . . . . . 12
1.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

1.
2.
3.
4.

5.
6.

7.
8.
9.
10.
11.

, , . . . . . . . . . . . . . . . . . . . . .
MouseHover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TextBox
TryParse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .

CheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
TabControl RadioButton . . . . . . . . . . . . . . .
Visible ToolTip Balloon . .
ComboBox . . . . . .
, .
Unicode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15
19
24
26
29
31
32
34
37
40
43

2. . . . . . . . . . . . . . . . . . . 47
12. . . . . . . . . . . . . . . . . . . . . .
13.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14. MessageBox::Show .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15. Visual Basic C++ . . . . . . . . . . . . . . . .
16. Dictionary . . . .

47
49
51
52
55

3. . . . . . . 57
17.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18. Button
. . . . . . . . . . . . . . . . . . . . . . . . . . .
19. . . . . . . . . . . . . . .
20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21. LinkLabel . . . . . . . . . . . . . . . . . . . . . . . . .
22. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23. . . . . . . . . . . . .
24. ,
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25. . . . . . . . . . . . .

57
59
61
63
67
69
71
73
75

4. , ,
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
26. / Unicode.
try...catch . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
27. / Windows 1251 . . . . . . 81
28. . .
Closing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
29. -
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
30. RTF- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
31. ( )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
33. /
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
5. . . . . . . . . . . . . . . . . . . . . . . . 110
34. . . .
35. PictureBox
. . . . . . . . . . . . . . . . . . . . . . . . .
36. () . . . . . . . . . .
37. ListBox . . . . . . . . . . . . . . . . . . . . . .
38. . . . . . . . . . . . . . . .
39. . . . . . . . . . . . . . . . . . . . . . . . . . .
40. BMP- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
41. JPG-
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42. . .
43. . . . . . . . . . . . . . . . . . . . . . .
44. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
45. Graphics . . . . . . . . . . . . . . .

110
113
115
116
120
121
122
123
125
127
130
133

6.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
46. . . . . . . . . . . . .
47. PictureBox.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
48. Alt+PrintScreen . . . . . .
49. BMP- . . . . . . . . . . .
50. Timer . . . . . . . . . . . . . . . . . . . . . . . . .
51.

. . . 138
.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

7. .

140
142
143
145
146
149

52. . String::Format . . . . . . . . . . . . . .
53. Double- .
. StringReader . . . . . . . . . . . . . . . .
54. Internet Explorer . . . . . . . . . . . . . . . . . . . . . . . . .
55.
DataGridView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
56. -
DataGridView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
57. . DataGridView. DataTable. DataSet.
XML . . . . . . . . . . . . . . . . . . . . . . .
58. .
DataGridView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59. . . . . . . . . . . . . . . . . . . . . . . . . . . .
60.
Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

149
152
155
158
159
162
165
170
174

8. WebBrowser . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

61.
62.
63.
64.
65.

HTML- WebBrowser . . . . . . . . . . . .
Flash- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- HTML- . . . . . . . . . . . . . . . . . .
- . . . . . . . . . . . . . . . . . . . . . . .
-
WebBrowser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

178
180
181
183
187

9. MS Word, MS Excel, AutoCAD


MATLAB, PDF- . . . . . . . . . . . . . . . . . . . . . . . . . . 190
66.
MS Word . . . . . . . . . . . . . . . . . . . . . . . . . . . .
67. MS Word . . . . . . . . . . . . . . . . .
68. MS Excel Visual C++ 2010 . . . . .
69. MS Excel . . . . . . . . . .
70. MS Excel
71. MS Excel . . . . . . . . . . .

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

190
194
197
199
202
205


72. AutoCAD
Visual C++ 2010 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
73. MATLAB Visual C++ 2010 . . . . . . . . .
74. MATLAB . . . . . . . .
75. PDF-
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
76. PDF- . . . . . . . . . . . . . . . . . . . . . . . . . . .
77. PDF- . . . . . . . . . . . . . . . . . .

208
211
213
215
219
224

10. ADO.NET 229


78. SQL Server . . . . . . . . . . . . . . . . . . . . . . . . .
79. SQL Server . . . . . .
80. MS Access
Visual Studio . . . . . . . . . . . . . . .
81. MS Access
Command DataReader . . . . . . . . . . .
82. MS Access . . . . . . . . . .
83. MS Access.
. . . . . . . . . . . . . . . . .
84. MS Access . . . . . . . . .
85. c
Command, DataReader
DataGridView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
86. DataGridView
Command, Adapter DataSet . .
87. MS Access . . . . . . . . .
88.
SQL- Command . . . . . . . . . . . . . . . . . . . .

229
231
234
235
237
239
241

243
245
247
250

11. LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . 252


89.
Linq::Enumerable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
90. () LINQ . . . . . . . . . . .
91. GroupBy . . . . . . . . . . . . . . . . . . . . . .
92. XML-
System::Xml::Linq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
93. XML- . . . . . . . . . . . . .
94. () XML- . . . . . . . . . . . . . . . . . . . . . . .
95. XML- XML- . . . . . . . . .
96. DataSet . . . . . . . . . . . . . . . .

252
255
259
263
266
271
274
276

12. , Windows Application . . . . 280


97. . . . 280
98. . . . . . . . . . . . . . . . . . . . . . . . . 283

99. . . . . . . . . . . . . . . . . 284
100. , ,
. . . . . . . . . . . . . . . . . . . . . . . . . . . 287
101. . . . . . . . . . . . 290
102. . . . . . . . . . . . . . . 292
103. Windows Media Player 11 . . . . . . . . . . . . . . . . . . . . 294
104. . . . . . . . . . . . . . . . . . . 298
105. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
. . . . . . . . 302

. . . . . . . . . . . . . . . . . . . 303


Microsoft Visual Studio 2010 .
, , ,
, - ( exe-), , .
Visual Studio 2010
.NET Framework Windows, -.
.NET Framework (CLR) .NET Framework, ADO.NET,
ASP.NET, Windows Forms Windows Presentation Foundation (WPF).
.NET Framework ,
,
.
Visual Studio 2010
Visual Basic, Visual C#, Visual C++ Visual F#. ,
.
C++ (Borland,
GNU, Intel), MS Visual C++ .NET.
C++ C++/CLI. , , ,
.

- . Visual Studio,
C#, Visual Basic C++, .NET , .
, , .
, .
, , , , . , .

,
. ,
, .

10

().
, . WebBrowser
, -.
()
MS Excel, MS Word, AutoCAD MATLAB. PDF-.
SQL Server MS Access ADO.NET.

LINQ, C++/CLI Microsoft
. , .
. ,
(...) . ,
,
.
. ( 100 ) .
, ,
, , , . (www.piter.com)
.
, , , , . -
, . . , .
. - .
, ,
, , goto . . , , , , ,
, . ,
, , ,

, , .
, (,
).
,
, ,
MS Visual C++/CLI. ? , ,

11

,
.
.
,
.
C# Visual Basic, , C#,
Visual Basic .NET, , , , ,
.
,
. ziborov@ukr.net,
.


, ,
comp@piter.com ( , ).
!
web- http://www.piter.com .


?
, , . ,
, , ,
, , ,
, ,
.
.
60- , .
,
, .
(
) . 1968
- ()
: , . goto. goto .
, : , . . goto,
( )
( ). goto .
(),
. (),
(if else), (switch case).
,
.
, , ,
( ), goto. ,
. , .
- . , ,

13

,
,
. , .
, IBM

- , .
goto .
.
,
, ,
,
. ,
, .
,
, . ,
, ()
. , , , ,
, . ,

, .

, , , .
-
.
;
, .
: ,
, . , ? , ,
, - , .
,
() !

, , ,
. -

14

, . , ,
.
,
, , .




1. , ,

Visual Studio 2010,


Visual C++ 2010, devenv.exe , ,
: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE.
,
. 1.1.

. 1.1. Visual Studio 2010

- , File
New Project. New Project (Installed Templates). , Visual Studio, Visual Basic,
Visual C#, Visual C++, Visual F# . Visual C++. Visual C++
CLR, (
) (Templates) Windows Forms Application Visual C++.

16

(Name) First OK, ,


. 1.2.

. 1.2.

Form1,
,
, . TextBox,
Button, Label,
, .
, ,
,
Toolbox,
, . .
,
- , Microsoft Visual C++ 2010,
.
!
23 .
-
. , ,
, .
: Form, Label,
Button MessageBox ! ( ).
.
Toolbox.
, , , Ctrl+Alt+x ViewToolbox. , Label Button
, Toolbox. , . 1.3.

1. , ,

17

. 1.3.

, . ,
Toolbox. ,
(properties). , (. 1.4):
(Name) button1, (Text), (Location)
X, Y, Size . . , ,
Properties, Properties
(. 1.4).

. 1.4. button1

,
: Form1 label1.

18

. label1 Text
Microsoft Visual C++ 2010 ( label1). button1 Text .
, ,
. , , ,
, (Load) .

. . , ,
.
button1 (. . 1.4) Events () button1
Click. Form1.h (. . 1.5).

1.5.

Form1.h , Visual C++ 2010 - .


, . , ,
Properties. , Text Button
:
this->button1->Text = L" ";

. 1.5. ,
,
button1_Click:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { }

2. MouseHover

19

, . , : Form1.h
Form1.h [Design], ( ).
Ctrl+Tab,
Windows,
F7.
,
, : !
:
MessageBox::Show(" !");

() Show MessageBox
! (::)
Show Messagebox. ,
, ,
, . ,
C- .
C- .
, (Click)
button1. F5 (. 1.6).

. 1.6.

, MS Visual C++!
, First.sln
First.

2. MouseHover
. MouseHover label1. MouseHover
, - ,

20

, ( .
hover , ). , MouseHover ,
. MouseEnter (),
(
label1), MouseHover.
,
Label Button.
Microsoft Visual C++ 2010; , ,
! , (
MouseHover),
Hover.
Visual Studio 2010,
New Project. New Project Visual C++ CLR, ( )
(Templates) Windows Forms Application Visual C++.
Hover OK.
Toolbox Label
Button, . . Properties
(Events)
Form_Load, button1_
Click label1_MouseHover.
Form1.h,
Visual Studio 2010 . , :
private:System::Void lab el1_MouseHover(System::Object^ sender,
System::EventArgs^ e){}

:
MessageBox::Show(" Hover!");

: F5,
label1, button1. !
.
, . , ,
. Properties.
! - , . ! () . ?
, .
, . , , .
, , ,

2. MouseHover

21

; , ,
. , , .
. , ,
.
( InitializeComponent),
Form1_Load,
.
, ,
, : Form1.h [Design].
. , ,
, Form1_Load,
Button Label
.
, button1_Click , Label.
, , :
private: System::Void Form1_Load(System::Object^
System::EventArgs^ e) { }

sender,


. Text
label1 Microsoft Visual C++ 2010:
label1->Text = "Microsoft

Visual

C++ 2010";

button1:
button1->Text = " ";

. , la,
,
. ,
IntelliSense ( ),
! Visual Studio 2010 , , . , Visual Studio 2010,
IntelliSense , :
Intellisense: Unavailable for C++/CLI ( IntelliSense C++/
CLI). Visual Assist X Microsoft
Visual Studio Whole Tomato; ,
: http://www.wholetomato.com.

22

IntelliSense, (::), - (.) - (->)


. Tab Enter ,
. , ,
, , , . .
, . . , ,

, , .
, ,
.
, (
) Form1, - . ,
. Text .
Form1
, , this
Form1:
this->Text = "";

Form1::Text = "";

, 1.1, .
1.1. Form1.h,

// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}
#pragma endregion
// .
// Form1_Load ,
// . button1_Click
// " !". ,
// ,
// " Hover".
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{ // :
this->Text = "";
// Form1::Text = "";

2. MouseHover
label1->Text = "Microsoft Visual
button1->Text = " ";

23

C++ 2010";

}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{ // :
MessageBox::Show(" !");
}
private: System::Void label1_MouseHover(System::Object^ sender,
System::EventArgs^ e)
{ // , :
MessageBox::Show(" Hover!");
}
};
}

, ,
, . C (//)
/* */. , ,
, . ,
. , .
, ,
,
. .
. 1.7 .

. 1.7.

,
, , . C++ 2010 Consolas.
Courier New, ,
ToolsOptionsEnvironmentFonts and Colors.
(FileClose Project).
, Hover. , Hover.sln, Hover.

24

3.
, , ,
( )
, .
,
.
Visual Studio 2010, New Project. New Project
Visual C++ CLR, ( )
(Templates) Windows Forms Application Visual C++.
OK.
Toolbox
Button, Label DateTimePicker. . DateTimePicker,
, . 1.8. ,
DateTimePicker Button.
Label.

, . 1.8.
Form1.h.
Visual Studio
Form_Load ( 1.2). , ,
. ValueChanged.
, Form1.h[Design]
, (Events), dateTimePicker1
ValueChanged. Form1.h.
(. 1.2).
1.2. Form1.h,

// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
private: System::Void Form1_Load(System::Object^
System::EventArgs^ e)

sender,

Visual

Studio

3.

25

{ // :
this->Text = " ";
dateTimePicker1->Format = DateTimePickerFormat::Custom;
dateTimePicker1->CustomFormat = "ddd, dd MMM, yyyy";
button1->Text = " :";
label1->Text = String::Format(": {0}",
dateTimePicker1->Text);
}
private: System::Void dateTimePicker1_ValueChanged(System::Object^ sender,
System::EventArgs^ e)
{ // :
label1->Text = String::Format(" : {0}",
dateTimePicker1->Text);
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{ // " "
// dateTimePicker1:
dateTimePicker1->Focus();
// <F4>:
SendKeys::Send("{F4}");
}
};
}

, : ( ddd)
; (dd MMM) ,
, , (yyyy).
ValueChanged label1 .
String::Format.
: {0} : , Text dataTimePicker1, .
dateTimePicker1. F4
. F4
Windows. , -,
( ) , F4
-,
. F4. Send
.
. 1.8.
,
Visual Studio Microsoft www.msdn.com.
.
, .
sln .

26

. 1.8.

4.
TextBox TryParse
TextBox. ,
, Label.
.
, Visual Studio,
FileNewProject. New Project Visual C++ CLR,
(Templates) Windows Forms Application
Visual C++. OK.
Toolbox ( , , ,
Ctrl+Alt+x ViewToolbox) TextBox, Label
Button. ,
Tools.
, .
, . 1.9.
.

Form1.h, InitializeComponent.
,
. ,
. Form1.h. (
this), button1 textBox1,
label1 :
this->Text = " ";
button1->Text = " ";
textBox1->Clear(); //
label1->Text = nullptr; // = String::Empty;

4. TextBox TryParse

27

F5 , .
button1_Click . ,
. ,
Single ( 1.3).
1.3.
TryParse
// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}
#pragma endregion
// ,
//
// label1.
// , label1.
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
button1->Text = " ";
label1->Text = String::Empty;
// label1->Text = nullptr;
this->Text = " ";
textBox1->Clear(); //
textBox1->TabIndex = 0; //
}
private: System:: // " ":
Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
Single X; // -
// Single:
bool _ = Single::TryParse(textBox1->Text,
System::Globalization::NumberStyles::Number,
System::Globalization::NumberFormatInfo::CurrentInfo, X);
// - (Integer,
// , ).
//
// -
// - ;
// X
if (_ == false)
{ // :
label1->Text = " ";


28

1.3 ()
label1->ForeColor = Color::Red; // -
return; // -
}
Single Y = (Single)Math::Sqrt(X); // -
label1->ForeColor = Color::Black; // -

label1->Text = String::Format(" {0} {1:F5}", X, Y);
}
};
}


, . TryParse. TryParse textBox1->Text. , (Integer),
(HexNumber), .
, ,
CurrentInfo,
. Windows
XP .
, ,

. ( ,
) TryParse ,
.
TryParse .
, TryParse true false,
, . ,
(, ), label1
: . ,
, button1_Click
return. . 1.9 .
, TryParse
2,3 ,

.
- ,
Math::Sqrt(X). Visual Studio 2010
Math. ,
Math (::).
: Abs, Sin, Cos, Min . .
1.9.
E = 2,718... (

5.

29

) PI = 3,14... ( , ). Math::Sqrt(X) double (


),
(Single) .
button1_Click
label1->Text String::Format.
{0} {1:F5} : ,
X, ;
, Y,
.
F5, , .
. 1.10.
,
F10 F11. ,
, .
( ),
, , F9 Stop,
.
. 1.10.
,

5.

,
, , . ,
TextBox, Label,
(, ), Button
.
Visual Studio CLR Windows
Forms Application Visual C++ . 1.4.
1.4. ,
// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}


30

1.4 ()
#pragma endregion
// ,
// , " ",
//
private: System:: // " ":
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " ";
textBox1->Text = nullptr; textBox1->TabIndex = 0;
textBox1->PasswordChar = *;
textBox1->Font = gcnew System::Drawing::Font("Courier New",
9.0F);
// textBox1->Font = gcnew System::Drawing::Font(FontFamily::
//
GenericMonospace,9.0F);
label1->Text = String::Empty;
label1->Font = gcnew System::Drawing::Font("Courier New", 9.0F);
button1->Text = " ";
}
private: System:: // " ":
Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
label1->Text = textBox1->Text;
}
};
}

,
c textBox1->PasswordChar;
(*). , . Courier New
, .
, , .
Consola. , Font
: textBox1 label1. 9.0 .
TabIndex = 0
.
button1_Click
.
. , F5. . 1.11 .
( F11
F10)
1.11.

.

6. CheckBox

31

, .
sln .

6.
CheckBox
CheckBox ()
Toolbox. ( ),
(). , , Label. CheckBox.
Visual Studio 2010 CLR Windows Forms Application Visual C++. Toolbox, Label CheckBox. 1.5
.
1.5. ,
// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}
#pragma endregion
// , Label,
// CheckBox
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " CheckBox";
checkBox1->Text = ""; checkBox1->Focus();
label1->Text = " ";
label1->TextAlign = ContentAlignment::MiddleCenter;
label1->Font = gcnew System::Drawing::Font("Courier New",
14.0F);
}
private: System::Void checkBox1_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)
{ //
if (checkBox1->Checked == true) label1->Font = gcnew System::
Drawing::Font("Courier New", 14.0F,
FontStyle::Bold);
if (checkBox1->Checked == false) label1->Font = gcnew System::
Drawing::Font("Courier New", 14.0F,
FontStyle::Regular);
}
};
}

32


Form1 ( this), label1 checkBox1. ,
, , .
, (checkBox1.
Focus();), .
, TextAlign (MiddleCenter) , . Courier New (
) 14 .
CheckedChanged.
CheckedChanged,
checkBox1 Form1.h [Design].
(. ): (
) Checked = true, label1 Courier
New, 14 , Bold, .
: , checkBox1.
Checked = false, Regular, .
, else (),
,
.
, F5. . ,
. 1.12.

. 1.12.

, 1.
sln 1.

7.


CheckedChanged ( ). if()
:
label1->Font = gcnew System::Drawing::Font(
"Courier New", 14.0F, label1->Font->Style ^ FontStyle::Bold);

7.

33

label1>Font->Style FontStyle::Bold.
(^) ( ), Bold, label1->Font->Style Bold.
label1->Font->Style Bold, (^)
Bold. XOR.
XOR :
A
0
1
0
1

Xor
Xor
Xor
Xor
Xor

B
0
0
1
1

=
=
=
=
=

C
0
1
1
0

B = 1 (FontStyle::Bold), A (label1->Font->Style)
Bold, Regular ( Bold). , (^)
, label1->Font->Style.
, .
.
, , F5.
CheckBox.
FontStyle . , ,
Bold Regular, Italic
Regular. 1.6.
1.6.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// "^" -
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " CheckBox";
checkBox1->Text = ""; checkBox2->Text = "";
label1->Text = " ";
label1->TextAlign = ContentAlignment::MiddleCenter;
label1->Font = gcnew System::Drawing::Font("Courier New",
14.0F);
}
private: System::Void checkBox1_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)


34

1.6 ()
{
label1->Font = gcnew System::Drawing::Font(
"Courier New", 14.0F, label1->Font->Style ^
FontStyle::Bold);
}
private: System::Void checkBox2_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)
{
label1->Font = gcnew System::Drawing::Font(
"Courier New", 14.0F, label1->Font->Style ^
FontStyle::Italic);
}
};
}

, ,
CheckedChanged CheckBox2.
. 1.13.

. 1.13.

, 2.
sln 2.

8. TabControl
RadioButton
.
Internet Explorer .
,
TabControl.
,
, TabControl
RadioButton. . 1.14.
, Visual Studio CLR Windows Forms Application Visual C++.
. Toolbox,

8. TabControl RadioButton

35

TabControl. , ,
, . 1.14, .
, .

. 1.14.

, .
( Properties) tabControl1 TabPages, TabPage Collection Edit, (
Add) ( ).
, TabPages(2).
.
, , ,
( 1.7).
, Toolbox
RadioButton, Label.

.
1.7. ,
// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}
#pragma endregion
// , ,
// TabControl
// RadioButton
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// "":
auto tabPage3 = gcnew System::Windows::Forms::TabPage();
tabPage3->UseVisualStyleBackColor = true;


36

1.7 ()
//
// tabControl1:
this->tabControl1->Controls->Add(tabPage3);
// 5 6 :
tabPage3->Controls->Add(this->radioButton5);
tabPage3->Controls->Add(this->radioButton6);
// 5 6:
this->radioButton5->Location = System::Drawing::Point(20, 15);
this->radioButton6->Location = System::Drawing::Point(20, 58);
this->Text = " ";
// :
tabControl1->TabPages[0]->Text = "";
tabControl1->TabPages[1]->Text = "";
tabControl1->TabPages[2]->Text = "";
// :
radioButton1->Text =
", ,\n-";
radioButton2->Text = " , , " +
",\n, ";
//
// radioButton2->Text = " , ," +
// Environment::NewLine + ", ";
// :
radioButton3->Text = "";
radioButton4->Text = "";
// :
radioButton5->Text = "11 ";
radioButton6->Text = "13 ";
label1->Text = radioButton1->Text;
}
private: System::Void radioButton1_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)
{ label1->Text = radioButton1->Text; }
private: System::Void radioButton2_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)
{ label1->Text = radioButton2->Text; }
private: System::Void radioButton3_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)
{ label1->ForeColor = Color::Red; }
private: System::Void radioButton4_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)
{ label1->ForeColor = Color::Blue; }
private: System::Void radioButton5_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)
{ label1->Font = gcnew System::Drawing::
Font(label1->Font->Name, 11); }
private: System::Void radioButton6_CheckedChanged(System::Object^ sender,
System::EventArgs^ e)

9. Visible ToolTip Balloon


{

label1->Font = gcnew System::Drawing::


Font(label1->Font->Name, 13);

37

};
}

, Form1_
Load (
InitializeComponent) . ,
auto, tabPage3 ( var C#)
Visual C++ 2010. tabPage3
tabControl1, . .
.
, , - ( ), ,
,
.
CheckChanged (. 1.7). ,

.
, .
sln .

9. Visible
ToolTip Balloon
Visible ().
Label , , . .
.
Visual Studio 2010, , FileNewProject, CLR
Windows Forms Application Visual C++. Visible.
Toolbox Label,
Button ToolTip.
( ) ToolTip on Tip.
, ( Properties) .
button1 ToolTip on Tip
.
. ,
!

38


View Code.
1.8.
1.8. Visible ToolTip
// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}
#pragma endregion
// Label ,
// ,
// . Visible.
// " " Balloon
private: System:: // " ":
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " ";
label1->Text = " ,\n" +
" , ";
label1->TextAlign = ContentAlignment::MiddleCenter;
button1->Text = "";
toolTip1->SetToolTip(button1, "\r\n");
//
// :
toolTip1->IsBalloon = true;
// IsBalloon = false,
//
}
private: System:: // " ":
Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
// :
// if (label1->Visible == true) label1->Visible = false;
// else label1->Visible = true;
// :
// label1->Visible = label1->Visible ^ true;
// "^" - ,
// :
label1->Visible = !label1->Visible;
}
};
}

Text , (+) .
\n ( \r\n)

9. Visible ToolTip Balloon

39

1 ( ).
Environment::NewLine. Environment
. TextAlign (MiddleCenter). ,
toolTip1, (Set) button1
(. . 1.14).
IsBalloon false, , IsBalloon = true
( Balloon) (. 1.15).

, () ( Form1.cs[Designer]) button1.
, , ,
. :
(Visible) (true), (false);
(else) .

. 1.15.

, . . !
, Enter .
.
.
^ ( ). , , ,
(true), , (false), .
:
label1->Visible

= ! label1->Visible;

label1>Visible . ,
- .

, "\n",
"\r" . ,
"\n".
"\r\n"
"\r" (
). . .

40

, .
Visual Studio 2010, ,
Ctrl+KC (Comment). ,
,
Ctrl+KU (Uncomment).
, Visible.sln Visible.

10.
ComboBox
ComboBox .
, .

ComboBox.
Visual Studio 2010, CLR Windows
Forms Application Visual C++. . Toolbox
TextBox, Button, Label
ComboBox.
1.9.
1.9.
// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}
#pragma endregion
// , .
//
// ComboBox
private: System:: // :
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = ""; label1->Text = ": ";
button1->Text = " ";
comboBox1->Text = " ";
// () :
array<String^>^ = {"", "",
"", "", ""};
// :
// auto = gcnew array<String^>{"", "",

10. ComboBox

41

//
"", "", ""};
comboBox1->Items->AddRange();
comboBox1->TabIndex = 2;
textBox1->Clear(); textBox1->TabIndex = 0;
textBox2->Clear(); textBox2->TabIndex = 1;
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender,
System::EventArgs^ e)
{ //
label1->Text = ": ";
// Single:
Single X, Y, Z = 0;
bool _1 = Single::TryParse(textBox1->Text,
System::Globalization::NumberStyles::Number,
System::Globalization::NumberFormatInfo::CurrentInfo, X);
bool _2 = Single::TryParse(textBox2->Text,
System::Globalization::NumberStyles::Number,
System::Globalization::NumberFormatInfo::CurrentInfo, Y);
if (_1 == false || _2 == false)
{
MessageBox::Show(" !", "",
MessageBoxButtons::OK, MessageBoxIcon::Error);
return;
}
// :
switch (comboBox1->SelectedIndex)
{ // :
case 0:
// "":
Z = X + Y; break;
case 1:
// "":
Z = X - Y; break;
case 2:
// "":
Z = X * Y; break;
case 3:
// "":
Z = X / Y; break;
case 4:
// "":
textBox1->Clear(); textBox2->Clear();
label1->Text = ": "; return;
}
label1->Text = String::Format(" {0:F5}", Z);
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{ // " ":
// "" :
comboBox1->DroppedDown = true;
}
};
}

42

,
: , . .
TabIndex
. . ,
, textBox1->TabIndex = 0. Tab

(. 1.16).

. 1.16.

omboBox1_
SelectedIndexChanged TryParse ,
. TryParse .
, Number, ,
. , , CurrentInfo,
.
Windows
. , ,

.
( , ) TryParse ,
.
TryParse .
, TryParse true false,
, . ,
,
!
return.
switch
SelectedIndex.
switch case. ,
, ++ (C#, Turbo C)
, Basic, ,

11. ,

43

case, break
switch.


String::Format label1. {0:F5} ,
Z
( ). , . Visual Studio
(. . 1.16).

,
ComboBox. DroppedDown
comboBox1.
, .sln
.

11. ,
.
Unicode
. - . . . . : ASCII,
ANSI Cyrillic ( Windows 1251), Unicode.
, 1 . 1 8 ,
28 = 256 ,
256 . ASCII 0 127
, , , . 128
255 , . IBM-
.
MS-DOS, .
-.
Windows ANSI
(Windows 1251). 0 127 ,
.
. - . ANSI . ANSI Cyrillic Windows 1251.
Unicode. . 216 = 65 536 .

44

Unicode .
MS Word ,
Unicode.
Unicode:  . , , , , , . , Unicode. .
, R,
. Label ,
= 3,14.
MessageBox .
Visual Studio 2010 CLR
Windows Forms Application C++ Label,
TextBox Button. . 1.17,
.

. 1.17. , Unicode

label1 MessageBox
, , : MS Word.
Visual Studio 2010 h- Unicode,
.
,
Convert::ToChar,
Unicode. ,
h- ANSI,
. Unicode , MS Word .
. , 0x. ,
n = 0x3B2 n 946.
Unicode .
( 1.10).

11. ,

45

1.10. Unicode
// ...............
// , ,
// ,
this->ResumeLayout(false);
this->PerformLayout();

Visual

Studio

}
#pragma endregion
// ,
// MessageBox .
// R,
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Font = gcnew System::Drawing::
Font("Times New Roman", 12.0F);
this->Text = " "; button1->Text = "";
// = 2 R
label1->Text = String::Format(
" :\n {0} = 2{1}{2}{1}R,\n {2} = {3}",
Convert::ToChar(0x3B2), Convert::ToChar(0x2219),
//
0=
1 -
Convert::ToChar(0x3C0), Math::PI);
//
2 -
3 -
label2->Text = " R:";
textBox1->Clear();
}
private: System::
Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
// - :
Single R; // -
bool _ = Single::TryParse(textBox1->Text,
System::Globalization::NumberStyles::Number,
System::Globalization::NumberFormatInfo::CurrentInfo, R);
if (_ == false)
{
MessageBox::Show(" !", "",
MessageBoxButtons::OK, MessageBoxIcon::Error); return;
}
Single beta = 2 * (Single)Math::PI * R;
// 0x3B2 -
MessageBox::Show(String::Format(" {0} = {1:F4}",
Convert::ToChar(0x3B2), beta), " ");
}
};
}

,
Times New Roman, 12 ,

46

, ,
. , String::Format, Text label1.
,
= 3,14.
Math::PI. Escape- "\n"
. NewLine
Environment.
button1_Click ( ), TryParse, .
(true), TryParse R.
beta Math::PI Double
Single .
beta Convert::ToChar(0x3B2) MessageBox.
String::Format. {0:F4} , beta
.
,
Form1.h
ANSI. , Unico.
sln Unico.

12.

, , -
, .
,
.
.
- ,
( . console ).
.
, , .
Visual C++ 2010, (New Project),
Visual C++ CLR Console Application CLR,
(Name) . OK
(. 2.1).
, Visual Studio 2010
. , , F10.
Windows- C++ Main()
. Main()
( 2.1).

48

. 2.1.
2.1.
// .cpp: .
// ,
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
// :
Console::Title = " :";
Console::BackgroundColor = ConsoleColor::Cyan; // -
Console::ForegroundColor = ConsoleColor::Black; // -
Console::Clear();
// :
Console::WriteLine(" :");
String^ = Console::ReadLine();
Single X, Y, Z;
// :
X = Single::Parse();
// :
Console::WriteLine(" :");
= Console::ReadLine();
Y = Single::Parse();
Z = X + Y;
Console::WriteLine(" = {0} + {1} = {2}", X, Y, Z);
// 1000 0.5 :
Console::Beep(1000, 500);
// - :
Console::ReadKey();
return 0;
}

, Main() ,
.

13.

49

. - ,
BackgroundColor - (Cyan), ,
, (Black).
WriteLine, , ,
ReadLine. Single
, . Single ,
, , .
Single 4 . ,
, Parse.
.
WriteLine Console:
Console::WriteLine(" = {0} + {1} = {2}", X, Y, Z)

Beep, .
Console::ReadKey();
- . ,
, . . F5, .
. 2.2.

. 2.2.

,
,
, . ,
, , (notepad.exe),
.
, .sln
.

13.

, ,
(, ) , ,

50

.
.
Visual Studio 2010, (New Project), Visual C++
CLR Console Application CLR,
, 2.2.
2.2.
// .cpp: .
// ,
//
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::BackgroundColor = ConsoleColor::Cyan;
Console::ForegroundColor = ConsoleColor::Black;
Console::Title = ""; Console::Clear();
Console::WriteLine(" ");
for (double i = 0; i <= 10; i++)
{
Console::WriteLine("{0,4} {1,8:F4}", i, Math::Sqrt(i));
}
Console::ReadKey();
return 0;
}

, for WriteLine, . ,
String::Format, . {0,4} {1,8:F4} : ,
i, ;
,
i, .

(. 2.3).

. 2.3.

14. MessageBox::Show

51


, String::Format.
, .
sln .

14. MessageBox::Show
.

1980- ,
. Visual C++
MessageBox::Show, , , . -
. , .
,
MessageBox ,
String::Format. Visual Studio 2010, ,
Visual C++ CLR Console Application CLR,
ConsoleMessageBox.
,
MessageBox. Project References
Add New Reference, .NET
System.Windows.Forms. Properties References ()
.
() System.Windows.Forms.dll, Program Files, .NET Framework.
,
:
using namespace System::Windows::Forms;

using ,
MessageBox ( 2.3).
2.3. MessageBox.Show
// ConsoleMessageBox.cpp: .
// MessageBox
// , String::Format
#include "stdafx.h"
using namespace System;
using namespace System::Windows::Forms;
int main(array<System::String ^> ^args)


52

2.3 ()
{
String^ = String::Format(
"(d) - \"\" : . . . . . . . . . {0:d}\n" +
"(D) - \"\" :. . . . . . . . . . .{0:D}\n" +
"(t) - \"\" : . . . . . . . {0:t}\n" +
"(T) - \"\" :. . . . . . . . {0:T}\n" +
"(f) - \"\" \"\" : {0:f}\n" +
"(F) - \"\" \"\" :. {0:F}\n" +
"(g) General - : . . {0:g}\n" +
"(G) General - \"\" : . . . . . . . . . . . . . {0:G}\n" +
" - , (G). . . . . . {0}\n" +
"(M) - : . . . . . . {0:M}\n" +
"(U) Universal full date/time - . . {0:U}\n" +
"(Y) - . . . . . . . {0:Y}\n",
DateTime::Now);
MessageBox::Show(, " ");
return 0;
}

, F5.
, MessageBox (. 2.4).

. 2.4.

,
ConsoleMessageBox.

15. Visual Basic


C++
, C++-
, Visual Basic.
: , ,
, , ,
.

15. Visual Basic C++

53

C++ CLR, InputBox,


MsgBox, IsNumeric, ,
. Visual Basic 6.0.
Visual Studio 2010, ,
Visual C++ CLR Console Application CLR,
VisualBasic.
Microsoft.VisualBasic.
dll. Project Properties
Add New Reference, .NET
Microsoft.VisualBasic. Properties References ()
. , 2.4.
2.4. Visual Basic
// VisualBasic.cpp: .
// Visual C++ Visual Basic.
// , ,
// , .
// Visual Basic: InputBox, IsNumeric ( ,
// ) MsgBox
#include "stdafx.h"
using namespace System;
// :
using namespace Microsoft::VisualBasic;
// Visual Basic .
// Project References
// Add Reference,
// .NET Microsoft.VisualBasic
int main(array<System::String ^> ^args)
{
String^ ;
// , :
for (; ; )
{
// Inputbox - , - ,
// , ,
// - :
= Interaction::
InputBox(" :", " ", "", 100,
100);
if (Information::IsNumeric() == true) break;
}
// - :
Single X = Single::Parse();
// :
for (; ; )


54

2.4 ()
{
= Interaction::
InputBox(" :", " ", "", 100,
100);
// , , ,
:
if (Information::IsNumeric() == true) break;
}
Single Y = Single::Parse();
Single Z = X + Y;
= String::Format(" = {0} + {1} = {2}", X, Y, Z);
// :
Interaction::MsgBox(, MsgBoxStyle::Information,
" ");
return 0;
}

for(;;){}.
InputBox , (. 2.5).

. 2.5.

IsNumeric, ,
break .
. , ,
Parse. ,
.NET Framework TryParse,

.
MsgBox.
String.Format. = {0} + {1} = {2} : , X, ,
,
Y, , .
. 2.6.
. 2.6.
,
VisualBasic.

16. Dictionary

55

16.
Dictionary
Dictionary ()
. (), ,
Value Key.
, Dictionary<Key, Value>
-. Dictionary<Key, Value> , , .
Dictionary . (null),
, Value .
, .
Dictionary ,
.
, , , Dictionary.
, ,
, .
-. , 30.
Visual Studio 2010,
, Visual C++ CLR Console Application CLR, Name . 2.5
.
2.5.
// ___.cpp: .
// Dictionary
// .
// , - .
// for each, ,
// 30
#include "stdafx.h"
using namespace System;
// :
using namespace System::Collections::Generic;
int main(array<System::String ^> ^args)
{
// :
Console::ForegroundColor = ConsoleColor::White;
Console::Title = " ";
// String^ int:
auto = gcnew Dictionary<String^, int>();


56

2.4 ()
// :
[""] = 31;
[""] = 31;
[""] = 28;
[""] = 31;
[""] = 31;
[""] = 30;
[""] = 30;
[""] = 31;
[""] = 31;
[""] = 30;
[""] = 30;
[""] = 31;
Console::WriteLine(" 30 : \n");
// , 30 :
for each(KeyValuePair<String^, int> in )
if ( .Value == 30 )
Console::WriteLine("{0} - {1} ", .Key, .Value);
// - :
Console::ReadKey();
return 0;
}

Dictionary,
String^ int
. , ,
: , .
, 30 ,
for each. KeyValuePair,
,
.
. 2.7.
. 2.7.
, ,
.sln .
30

17.

,
. , ListBox . , . 3.1.

. 3.1.

ListBox
. , ,
ListBox.
Visual Studio 2010
CLR Windows Forms Application Visual C++
Toolbox ListBox
.
,
, listBox1.
-

58

.
listBox1, (Properties)
listBox1 : MouseEnter, MouseLeave
MouseMove. ( 3.1).
3.1.

// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
// . ,
// ListBox . ListBox
// .
// ,
// ListBox
private: // :
System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " ";
}
// ,
// ListBox:
private: System::Void listBox1_MouseEnter(System::Object^ sender,
System::EventArgs^ e)
{
//
listBox1->Items->Add(" ListBox");
}
// ,
// ListBox:
private: System::Void listBox1_MouseLeave(System::Object^ sender,
System::EventArgs^ e)
{
listBox1->Items->Add(" ListBox");
}
// ,
// ListBox:
private: System::Void listBox1_MouseMove(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// Control MousePosition ,
//

18. Button

59

//
textBox1->Text = String::Format("X = {0} {1}",
this->MousePosition.X, e->X);
textBox2->Text = String::Format("Y = {0} {1}",
this->MousePosition.Y, e->Y);
}
};
}

, MouseEnter,
, ListBox1 (
Add) ListBox.
MouseLeave, ,
ListBox ListBox. ,
, ListBox1.
MouseMove, ListBox1, X Y
, Control MousePosition.
,
, ,
y .
, e , ,
listBox1. listBox1, , y . e->X e->Y ,
.
, , . ,
.sln .

18.
Button

, , ,
. ,
, ,
Toolbox. ,
, , .

60

,
, : , , ,
.
. , ,
Visual Studio 2010, New Project CLR Visual C++ Windows Forms Application Visual C++.
, . ,
3.2.
3.2.
// ...............
// , , Visual Studio
// ,
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
}
#pragma endregion
// ,
// .. ,
// Toolbox.
// : , , ,
// " "
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// :
Button^ button1 = gcnew Button();
// :
button1->Visible = true;
// :
button1->Size = Drawing::Size(100, 30);
// :
button1->Location = Drawing::Point(100, 80);
button1->Text = " ";
//
this->Controls->Add(button1);
// Click "".
// Click :
button1->Click += gcnew EventHandler(this,
&Form1::);
}
private: System::
Void (System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show(" ");
}
};
}

19.

61

,
button1 . : (Visible),
(Size), (Location) ,
.


.
,
.
(Events)
.
.

(->) button1
Click. , 3.2,
, EventHandler
Click . . ,
3.2.
. . 3.2 .

. 3.2.

,

InitializeComponent Form1.h .
, NewButton.sln NewButton.

19.


, , VB6,
.
Visual Studio (C++, C#, F# Visual Basic) .

62

.
,
, -.
, , , .
, sender, ,
.
, Visual Studio 2010, New Project CLR
Visual C++ Windows Forms Application Visual C++. .

( 3.3).
3.3.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ,
// .
//
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " "; label1->Text = nullptr;
// Click
:
button1->Click += gcnew EventHandler(this, &Form1::);
button2->Click += gcnew EventHandler(this, &Form1::);
//
//
EventHandler
}
private: System::Void (System::Object^ sender, System::EventArgs^ e)
{
// String S = Convert.ToString(sender);
// , , :
Button^ = (Button^)sender;
// String^ = ((Button^)sender)->Text;
label1->Text = " " + ->Text; //
->Name
}
};
}

,
,

20.

63


() EventHandler. ( )
button1->Click . , Click
.
, sender - , , .
C sender
Button , , ,
.
. 3.3 .

. 3.3. ,

, , ,
sender. , .

20.

.
-, , .
Visual Studio 2010, New Project CLR
Visual C++ Windows Forms Application Visual C++.
Toolbox 16 ,
, (=) , .
Form1.h [Design] , . 3.4.

. 3.4.

64

3.4 .
3.4.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// .
// .
//
// ~ ~ ~ ~ ~ ~ ~ ~
// , Form1:
String^ Znak;
// - ;
bool _; // - ;
Double 1, 2; // - ,
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = ""; _ = true;
Znak = nullptr;
button1->Text = "1"; button2->Text = "2"; button3->Text = "3";
button4->Text = "4"; button5->Text = "5"; button6->Text = "6";
button7->Text = "7"; button8->Text = "8"; button9->Text = "9";
button10->Text = "0"; button11->Text = "="; button12->Text =
"+";
button13->Text = "-"; button14->Text = "*"; button15->Text =
"/";
button16->Text = "";
textBox1->Text = "0";
textBox1->TextAlign = HorizontalAlignment::Right;
// " -"
// :
button1->Click += gcnew EventHandler(this, &Form1::);
button2->Click += gcnew EventHandler(this, &Form1::);
button3->Click += gcnew EventHandler(this, &Form1::);
button4->Click += gcnew EventHandler(this, &Form1::);
button5->Click += gcnew EventHandler(this, &Form1::);
button6->Click += gcnew EventHandler(this, &Form1::);
button7->Click += gcnew EventHandler(this, &Form1::);
button8->Click += gcnew EventHandler(this, &Form1::);
button9->Click += gcnew EventHandler(this, &Form1::);
button10->Click += gcnew EventHandler(this, &Form1::);
button12->Click += gcnew EventHandler(this, &Form1::);
button13->Click += gcnew EventHandler(this, &Form1::);
button14->Click += gcnew EventHandler(this, &Form1::);
button15->Click += gcnew EventHandler(this, &Form1::);

20.

65

button11->Click += gcnew EventHandler(this, &Form1::);


button16->Click += gcnew EventHandler(this, &Form1::);
}
private: System::Void (System::Object^ sender, System::EventArgs^ e)
{
// -.
// , , :
Button^ = (Button^)sender;
String^ Digit = ->Text;
if (_ == true)
{ // :
textBox1->Text = Digit;
_ = false; return;
}
// "" :
if (_ == false)
textBox1->Text = textBox1->Text + Digit;
}
private: System::Void (System::Object^ sender, System::EventArgs^ e)
{
// :
1 = Double::Parse(textBox1->Text);
// , , :
Button^ = (Button^)sender;
Znak = ->Text;
_ = true; //
}
private: System::Void (System::Object^ sender, System::EventArgs^ e)
{
// ""
double = 0;
2 = Double::Parse(textBox1->Text);
if (Znak == "+") = 1 + 2;
if (Znak == "-") = 1 - 2;
if (Znak == "*") = 1 * 2;
if (Znak == "/") = 1 / 2;
Znak = nullptr;
// :
textBox1->Text = .ToString();
1 = ; _ = true;
}
private: System::Void (System::Object^ sender, System::EventArgs^ e)
{
// ""
textBox1->Text = "0"; Znak = nullptr; _ = true;
}
};
}

66


Properties,
, , .
,
Form1_Load. ,
, : textBox1->
TextAlign = HorizontalAlignment::Right.
Click - . Click
.
-
Digit , Text , ,
. Digit
textBox1->Text, . , ,
, .
() _. -,
,
. ,
Form1,
.
_ = true,
, _ = false, . ,
- (_ = false), ,
textBox1.
+, -, *, /
value1 Double. Znak
. ,
, ,
_ true. ,
:
, _ true ( ).

Double. ,
, ,
. , result = value1 + value2, ,
- ,

21. LinkLabel

67

value1. , ,
Visual Studio 2010 (, )
.
, (. 3.5).

. 3.5.

, .
sln .

21. LinkLabel
LinkLabel -,
HTML-, - , , .
, LinkLabel www.mail.ru,
C:\Windows\ .
Visual Studio 2010, New
Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox
LinkLabel. . ,
, Properties.
( 3.5).
3.5.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}


68

3.5 ()
#pragma endregion
//
// www.mail.ru, C:\Windows\
//
// LinkLabel
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{ // :
this->Text = " :";
linkLabel1->Text = "www.mail.ru";
linkLabel2->Text = " C:\\Windows\\";
linkLabel3->Text = " \"\"";
this->Font = gcnew System::Drawing::Font("Consolas", 12.0F);
linkLabel1->LinkVisited = true;
linkLabel2->LinkVisited = true;
linkLabel3->LinkVisited = true;
// :
// :
linkLabel1->LinkClicked += gcnew
LinkLabelLinkClickedEventHandler(this, &Form1::);
linkLabel2->LinkClicked += gcnew
LinkLabelLinkClickedEventHandler(this, &Form1::);
linkLabel3->LinkClicked += gcnew
LinkLabelLinkClickedEventHandler(this, &Form1::);
}
private: System::Void (System::Object^ sender,
LinkLabelLinkClickedEventArgs^ e)
{ // :
LinkLabel^ = (LinkLabel^)sender;
String^ = ->Name;
// :
switch ([9])
{
case 1: //"linkLabel1":
Diagnostics::Process::Start(
"IExplore.exe", "http://www.mail.ru"); break;
case 2: // "linkLabel2":
Diagnostics::Process::Start("C:\\Windows\\"); break;
case 3: //"linkLabel3":
Diagnostics::Process::Start("Notepad", "text.txt");
break;
}
}
};
}

, Text LinkLabel , .
Text LinkLabel3 ,

22.

69

, escape- (\). Consolas, 12 . , ,


Visual Studio 2010 Consolas.
LinkVisited = true, ( ).
,
Click . ,
,
(), (linkLabel1, linkLabel2, linkLabel3), : Internet Explorer, Windows Explorer,
. , Click,
sender. (), . sender,
LinkLabel
sender LinkLabel. - , name,
.
name , Start Internet Explorer, Windows
Explorer, . Start
, .
-,
.

. 3.6. , . 3.6.

LinkLabel.

22.
( ) . KeyPress,
.
.
, ,
Alt, Shift Ctrl. ,
Alt, Shift Ctrl, KeyDown,
KeyUp. KeyDown ,
KeyUp .
, , . Visual Studio 2010, New Project
CLR Visual C++ Windows Forms Application
Visual C++. Toolbox Label.
, : KeyPress, KeyDown,

70

KeyUp, .
Properties (Events), .
3.6.
3.6.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ,
// ,
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// ():
Form1::Font = gcnew Drawing::
Font(FontFamily::GenericMonospace, 14.0F);
// ( 8
// 14),
Form1::Text = " :";
label1->Text = String::Empty; label2->Text = String::Empty;
}
private: System::Void Form1_KeyPress(System::Object^ sender,
System::Windows::Forms::KeyPressEventArgs^ e)
{
// :
//
label1->Text = " : " + e->KeyChar;
}
private: System::Void Form1_KeyDown(System::Object^ sender,
System::Windows::Forms::KeyEventArgs^ e)
{
//
//
label2->Text = String::Empty;
// Alt
if (e->Alt == true) label2->Text += "Alt: Yes\n";
else
label2->Text += "Alt: No\n";
// Shift
if (e->Shift == true) label2->Text += "Shift: Yes\n";
else
label2->Text += "Shift: No\n";
// Ctrl
if (e->Control == true) label2->Text += "Ctrl: Yes\n";

23.
else

71

label2->Text += "Ctrl: No\n";

label2->Text += String::Format(
" : {0} \nKeyData: {1} \nKeyValue: {2}",
e->KeyCode, e->KeyData, e->KeyValue);
}
private: System::Void Form1_KeyUp(System::Object^ sender,
System::Windows::Forms::KeyEventArgs^ e)
{
//
label1->Text = String::Empty; label2->Text = String::Empty;
}
};
}

label1 (
) KeyPress.
e (e->Alt, e->Shift e->Control)
, - ( ). KeyUp
.
. 3.7 .

. 3.7. ,

,
sln- .

23.


TryParse. true, ,
false . , -

. . ,
Windows,

72

.
.
, . ,
. ,
.
Visual Studio 2010, New Project CLR
Visual C++ Windows Forms Application Visual C++.
Toolbox TextBox .
3.7.
3.7. ( 1)
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ,
// . Backspace,
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " "; textBox1->Clear();
}
private: System::Void textBox1_KeyPress(System::Object^ sender,
System::Windows::Forms::KeyPressEventArgs^ e)
{
// Backspace:
if (Char::IsDigit(e->KeyChar) == true) return;
if (e->KeyChar == (char)Keys::Back) return;
// :
e->Handled = true;
}
};
}

,
TextBox1.
Clear().
textBox1_KeyPress.
, ,
Properties, (Events), KeyPress .
Visual Studio 2010
.

24.

73

, ,
e. , ,
e->KeyChar. IsDigital (
), , (true false). e Handled,
(true), (false).
textBox1_KeyPress e->Handled = false,
.
,
Backspace, return.
, .
. 3.8.

. 3.8.

,
.

24.
,

, , , , . ,

, , , Windows.
, . (
Windows ).
,

,
. ,
, .
Visual Studio 2010, New
Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox TextBox
. 3.8.

74

3.8. ( 2)
// ...............
// Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ,
// (
)
// ~ ~ ~ ~ ~ ~ ~ ~
//
// "." ","
//
// Windows:
String^ ;
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " ";
// ,
// :
= Globalization::
NumberFormatInfo::CurrentInfo->NumberDecimalSeparator;
}
private: System::Void textBox1_KeyPress(System::Object^ sender,
System::Windows::Forms::KeyPressEventArgs^ e)
{
bool = false;
// :
if (Char::IsDigit(e->KeyChar) == true) return;
// <Backspace>:
if (e->KeyChar == (char)Keys::Back) return;
// textBox, IndexOf() == -1,
:
if (textBox1->Text->IndexOf() != -1)
= true;
// textBox, ,
// :
if ( == true) { e->Handled = true; return; }
// textBox, :
if (e->KeyChar.ToString() == ) return;
// - :
e->Handled = true;
}
};
}

25.

75

, , .
,
, . ,
, KeyPress
Backspace return
e->Handled = true,
.
,
, ,
. :
,
, . ,
, . , .
. 3.8 .
. 3.9.

,
+

Or.

25.

,
. ,
.
. ,
. ,
.
Visual Studio 2010, New Project
CLR Visual C++ Windows Forms Application
Visual C++. Toolbox .
3.9.
3.9.
// ...............
// , , Visual Studio
// ,
this->Text = L"Form1";
this->ResumeLayout(false);
}


76

3.9 ()
#pragma endregion
// .
//
// . ,
//
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
MessageBox::Show(" \"
\"");
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// " ",
// :
button1->PerformClick();
// :
// button1_Click(nullptr, nullptr);
// :
// button1_Click(button1, EventArgs::Empty);
}
};
}

.
.
,
PerformClick.
. 3.10 .

. 3.10. ,

,
(sln-) -.

,

,

26. /
Unicode.
try...catch

( ). ,
, ,
. , , ,
, ; .
,
, , TextEdit.
.
, . ,
:
// StreamReader
IO::StreamReader^ Reader = gcnew IO::StreamReader("C:\\Text1.txt");
//
String^ Stroka = Reader->ReadToEnd();
Reader->Close();

. ,
.

Unicode.
.

78

4 , ,

Visual Studio 2010 New Project CLR


Visual C++ Windows Forms Application Visual C++.
Toolbox .
Properties Multiline True,
, , . ,
. 4.1
.
4.1. / Unicode
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// / Unicode
String ^ filename;
// filename , ""
// .
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
// :
textBox1->Multiline = true; textBox1->Clear();
textBox1->Size = Drawing::Size(268, 112);
button1->Text = ""; button1->TabIndex = 0;
button2->Text = "";
Form1::Text = " Unicode";
filename = "C:\\Text1.txt";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// .
// ,
// UNICODE:
try
{
// StreamReader :
auto = gcnew IO::StreamReader(filename);
// :
textBox1->Text = ->ReadToEnd();
->Close(); //
// UNICODE
// ( Open Close):
// array <String^>^ =

26. / Unicode

79

//
IO::File::ReadAllLines("C:\\Text1.txt");
}
catch (IO::FileNotFoundException^ )
{
// :
MessageBox::Show(->Message + \n ,
"", MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
}
catch (Exception^ )
{
// :
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
try
{
// StreamWriter :
auto = gcnew
IO::StreamWriter(filename, false);
->Write(textBox1->Text);
->Close();
//
// ( Close), , ,
// :
// IO::File::WriteAllText("C:\\tmp.tmp", textBox1->Text);
}
catch (Exception^ )
{
// :
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
};
}

try, , ,
. try : (try) , .
(, ), (catch)
(, Exception) . ,

.

80

4 , ,

C:\
Text1.txt. OpenFileDialog
. ,
, .
() . .
lename ReadToEnd() textBox1.
Text Close().

.
lename, false , (append) ( ),
(overwrite). Write()
Text textBox1. . 4.1 .

. 4.1. / Unicode

. () Unicode,
. , ,
, ()
Unicode.
ANSI.
ANSI Windows 1251. , RPad ( ), Unicode.
, Unicode
. , ,
Unicode,
.
ANSI,
,
. ? ,
Visual C++,
MSDN, , http://msdn.microsoft.com/library/rus/.
, . ,

27. / Windows 1251

81

Windows 1251, ASCII Unicode ,


.
.
. .
,
TxtUnicode.sln TxtUnicode.

27. /
Windows 1251

, , . Windows 1251 (ANSI).
, 4.2.
4.2. / Windows 1251
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// / Windows 1251
String^ filename;
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Multiline = true; textBox1->Clear();
textBox1->Size = Drawing::Size(268, 112);
button1->Text = ""; button1->TabIndex = 0;
button2->Text = "";
this->Text = " Windows 1251";
filename = "C:\\Text2.txt";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
try
{
// ,


82

4 , ,

4.2 ()
// :
System::Text::Encoding^ =
System::Text::Encoding::GetEncoding(1251);
// StreamReader
IO::StreamReader^ = gcnew
IO::StreamReader(filename, );
textBox1->Text = ->ReadToEnd();
->Close();
// Windows 1251
//
// ( Open Close):
// array <String^>^ =
//
IO::File::ReadAllLines("C:\\Text2.txt", );
}
catch (IO::FileNotFoundException^ )
{ // :
MessageBox::Show(->Message + \n ,
"", MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
}
catch (Exception^ )
{ //
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
try
{
auto =
System::Text::Encoding::GetEncoding(1251);
// StreamWriter :
auto = gcnew
IO::StreamWriter(filename, false, );
->Write(textBox1->Text);
->Close();
// (
// Close), ,
// :
// IO::File::WriteAllText("C:\\tmp.tmp",
//
textBox1->Text, );
}
catch (System::Exception^ )
{
// :

28. .

83

MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
};
}

,
. GetEncoding(1251) Windows 1251 . ,
->HeaderName.
:
lename , , (
) .
: filename, false ( ,
, ,
) , ,
.
,
auto,
( var C#)
Visual C++ 2010.
, TXT_1251.
sln TXT_1251.

28. .
.
Closing
, , /
. ,
.
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
Toolbox TextBox
MenuStrip. MenuStrip,
: , (. 4.2).
Toolbox OpenFileDialog
SaveFileDialog, , .
, Multiline True (
).

84

4 , ,

. 4.2.

4.3, , ! ,
, ,
Shift+Alt+Enter (Full Screen).
4.3.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Multiline = true; textBox1->Clear();
textBox1->Size = Drawing::Size(268, 160);
this->Text = " ";
openFileDialog1->FileName = "C:\\Text2.txt";
openFileDialog1->Filter =
" (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1->Filter =
" (*.txt)|*.txt|All files (*.*)|*.*";
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
openFileDialog1->ShowDialog();
if (openFileDialog1->FileName == nullptr) return;
// :
try
{ // StreamReader
auto = gcnew
IO::StreamReader(openFileDialog1->FileName,

28. .

85

System::Text::Encoding::GetEncoding(1251));
// - Win1251
textBox1->Text = ->ReadToEnd();
->Close();
}
catch (IO::FileNotFoundException^ )
{
MessageBox::Show(->Message + "\n ",
"", MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
}
catch (Exception^ )
{
//
MessageBox::Show(->Message, "",
MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
}
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
//
saveFileDialog1->FileName = openFileDialog1->FileName;
if (saveFileDialog1->ShowDialog() ==
Windows::Forms::DialogResult::OK) ();
}
void ()
{
try
{
// StreamWriter :
auto = gcnew
IO::StreamWriter(saveFileDialog1->FileName, false,
System::Text::Encoding::GetEncoding(1251));
// - Win1251
->Write(textBox1->Text);
->Close(); textBox1->Modified = false;
}
catch (Exception^ )
{
//
MessageBox::Show(->Message, "",
MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
}
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)


86

4 , ,

4.3 ()
{
this->Close();
}
private: System::Void Form1_FormClosing(System::Object^ sender,
System::Windows::Forms::FormClosingEventArgs^ e)
{ // :
if (textBox1->Modified == false) return;
// , , ?
auto MBox = MessageBox::Show(
" . \n ?",
" ", MessageBoxButtons::YesNoCancel,
MessageBoxIcon::Exclamation);
// YES ; NO ; CANCEL -
if (MBox == Windows::Forms::DialogResult::No) return;
if (MBox == Windows::Forms::DialogResult::Cancel) e->Cancel =
true;
if (MBox == Windows::Forms::DialogResult::Yes)
{
if (saveFileDialog1->ShowDialog() ==
Windows::Forms::DialogResult::OK)
{
(); return;
}
else e->Cancel = true; //
} // DialogResult::Yes
}
};
}

, . ,
(Open) (Save) (Filter) *.txt, *.*.
OpenFileDialog,
(nullptr), .
,
Windows 1251.

(. . 4.2). SaveFileDialog ,
OK ( ), (). , . ()
. , () (Try)
textBox1->Modied = false. Modied
. ,
false.

28. .

87

, . (.
, 3.3),
Windows, Alt+F4, ( ) (
FormClosing).
FormClosing,
. :
Application::Exit(), this->Close(). ?
Application::Exit() FormClosing.
(, ,
. .) :
1. textBox1->Modied.
2. ,
.
3. (textBox1->Modied =
true), ,
(. 4.3).

. 4.3.


, . 4.4.

. 4.4.

88

4 , ,

(Cancel).
,
. (. 4.3)
FormClosing e->Cancel,
true, (
), Form1_FormClosing .
, ,
, (
Alt+F4),
: e->Cancel = true.
, Form1_FormClosing, ,
.
,
.

29.
-



, ,
. . , ,
- ,
. , , , ,
, .
4.4.
4.4.


1/6. :
, , , , ;
, , ,
, , , ,
3
2/6. :


29. -

89

3
3/6. :
- - - - -
- - - - -
- - - - -
1
4/6. ,
1 = 1024 ; 1 = 1024
1 ; 1 = 8
1 ; 1 = 1024
3
5/6. -1,84E-04 :
-0,000184
-0,00184
-18400
1
6/6. :
FAT, NTFS .
Windows 1251, Unicode, ASCII .
SQL
2

:
, . .
.
-, ,
test_.txt, .
4.4, .
1, 2 3 .
, . ,
4/6, , ,
, ,
.
, , .
Visual Studio 2010 New Project CLR Visual C++
Windows Forms Application Visual C++. , RadioButton.
( 4.5).
4.5.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}


90

4 , ,

4.5 ()
#pragma endregion
// -
int ;
//
int ;
//
int ; //
// , :
array<String^>^ ;
int ; //
int ;
// ,
IO::StreamReader^ ;
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
button1->Text = " ";
button2->Text = "";
// "
// RadioButton:"
radioButton1->CheckedChanged +=
gcnew EventHandler(this, &Form1::);
radioButton2->CheckedChanged +=
gcnew EventHandler(this, &Form1::);
radioButton3->CheckedChanged +=
gcnew EventHandler(this, &Form1::);
();
}
void ()
{
System::Text::Encoding^ =
System::Text::Encoding::GetEncoding(1251);
try
{ // StreamReader
= gcnew IO::StreamReader(
IO::Directory::GetCurrentDirectory()
+ "\\test.txt", );
this->Text = ->ReadLine(); //
// :
= 0; = 0; = 0;
= gcnew array<String^>(100);
}
catch (Exception^ )
{ //
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
();
}
void ()
{
label1->Text = ->ReadLine();

29. -

91

// :
radioButton1->Text = ->ReadLine();
radioButton2->Text = ->ReadLine();
radioButton3->Text = ->ReadLine();
// , - :
= int::Parse(->ReadLine());
// "":
radioButton1->Checked = false; radioButton2->Checked = false;
radioButton3->Checked = false;
// ,
// :
button1->Enabled = false;
= + 1;
// , :
if (->EndOfStream == true) button1->Text = "";
}
private: Void (System::Object^ sender, System::EventArgs^ e)
{ // " "
// :
button1->Enabled = true; button1->Focus();
RadioButton^ = (RadioButton^)sender;
String^ tmp = ->Name;
// , :
= int::Parse(tmp->Substring(11));
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
// " // "
// :
if ( == )
= + 1;
if ( != )
{ // :
= + 1;
// :
[] = label1->Text;
}
if (button1->Text == " ")
{
button1->Text = " ";
// , :
radioButton1->Visible = true; radioButton2->Visible = true;
radioButton3->Visible = true;
// :
(); return;
}
if (button1->Text == "")


92

4 , ,

4.5 ()
{

// :
->Close();
// :
radioButton1->Visible = false; radioButton2->Visible =
false;
radioButton3->Visible = false;
// :
label1->Text = String::Format(" .\n" +
" : {0} {1}.\n" +
" : {2:F2}.", ,
, ( * 5.0F) / );
// 5F -
button1->Text = " ";
// ,
String^ Str = " , " +
" :\n\n";
for (int i = 1; i <= ; i++)
Str = Str + [i] + "\n";
// ,
// MessageBox :
if ( != 0)
MessageBox::Show(Str, " ");

}
if (button1->Text == " ") ();
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// ""
this->Close();
}
};
}

,
, Form1.

RadioButton .

.
test.txt,
, ,
.
, . , ,
. , . ,
.

29. -

93

, ,
.
,
, .
.
, , , ,
.
, , .
, , ( )
, MessageBox ,
.
. 4.5.

. 4.5.

. 4.6 ,
,
.

. 4.6.

, ,
Timer, .

94

4 , ,

,
, HTML. , .
, .sln .

30. RTF-
, , , Visual C++ 2010
RichTextBox ( ). -

RTF (
MS Word). RTF ,
, , ,
.
RTF-, RTF-,
Windows 1251,
RTF.
Toolbox RichTextBox, MenuStrip, SaveFileDialog
OpenFileDialog. ,
. 4.7: RTF, Win1251, RTF . 4.6.
4.6. RTF-
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// RTF-
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " RTF-"; richTextBox1->Clear();
openFileDialog1->FileName = "c:\\Text2.txt";
saveFileDialog1->Filter = " RTF (*.RTF)|*.RTF";
RTFToolStripMenuItem->Click += gcnew
EventHandler(this, &Form1::);
Win1251ToolStripMenuItem->Click += gcnew
EventHandler(this, &Form1::);
}
private: Void (System::Object^ sender, System::EventArgs^ e)
{ //
// .
// , :
ToolStripMenuItem^ t = (ToolStripMenuItem^)sender;

30. RTF-

95

// :
String^ = t->Text;
try
{ // - :
if ( == " RTF")
{
openFileDialog1->Filter =
" RTF (*.RTF)|*.RTF";
openFileDialog1->ShowDialog();
if (openFileDialog1->FileName == nullptr) return;
richTextBox1->LoadFile(openFileDialog1->FileName);
}
if ( == " Win1251")
{
openFileDialog1->Filter =
" (*.txt)|*.txt";
openFileDialog1->ShowDialog();
if (openFileDialog1->FileName == nullptr) return;
richTextBox1->LoadFile(openFileDialog1->FileName,
RichTextBoxStreamType::PlainText);
}
richTextBox1->Modified = false;
}
catch (IO::FileNotFoundException^ )
{
MessageBox::Show(->Message +
"\n ", "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
catch (Exception^ )
{
//
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
private: System::Void RTFToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
saveFileDialog1->FileName = openFileDialog1->FileName;
if (saveFileDialog1->ShowDialog() ==
Windows::Forms::DialogResult::OK) ();
}
Void ()
{
try
{
richTextBox1->SaveFile(saveFileDialog1->FileName);
richTextBox1->Modified = false;
}


96

4 , ,

4.6 ()
catch (Exception^ )
{ // :
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
this->Close();
}
private: System::Void Form1_FormClosing(System::Object^ sender,
System::Windows::Forms::FormClosingEventArgs^ e)
{ // :
if (richTextBox1->Modified == false) return;
// , , ?
auto MBox = MessageBox::Show(
" . \n ?",
" ", MessageBoxButtons::YesNoCancel,
MessageBoxIcon::Exclamation);
// YES ; NO ; CANCEL -
if (MBox==Windows::Forms::DialogResult::No) return;
if (MBox==Windows::Forms::DialogResult::Cancel) e->Cancel =
true;
if (MBox==Windows::Forms::DialogResult::Yes)
{
if (saveFileDialog1->ShowDialog() ==
Windows::Forms::DialogResult::OK)
{ (); return; }
else e->Cancel = true; //
} // - DialogResult::Yes
}
};
}

, .
(. ).
RTF Win1251.
18, 19 . (. 3). ,
, ,
sender. , , sender t ToolStripMenuItem. Text , .
,

30. RTF-

97

RTF, Win1251. LoadFile richTextBox1

RTF, .
catch ,
, , RTF
, .
(. 4.7)
SaveFileDialog. (), ,
richTextBox1->Modied = True.

. 4.7. RTF-

() try...catch:
(try) (SaveFile) (catch) MessageBox.
,
.
Windows. .
, Exit Application ( , ). . , Application::Exit() Closing.
Application::Exit ( F11). ,
Application::Exit , , .
MessageBox, , ,
Application::Exit.
Close Form ( Windows Application),
: this->Close(). , this->Close
Closing. .
this->Close
. , return.
, Rtf.
sln Rtf.

98

4 , ,

31.
( )
,
. , DataGridView ( ) Toolbox.
,
.
,
( ) X, Y, U V. , .
, ,
, ( , , . .).
/ ('\t').
,
.
.
4.7 .
4.7.
167.5 437,5 13.8
217.5 437.5 62,5

120,0
131.2

182.5
210
240
162,5
191.2
211.2
240
160
225
161.2
187.5
212.5
241.2

100
101.2
113.8
68.8
61.2
82.5
88.8
40
65
25
28.8
32.5
42.5

413.8
410
415
387.5
372.5
390
388.8
357,5
367.5
341.2
340
337.5
341.2

35.0
62.5
90
21.2
52.5
67.5
96.5
26.2
86.2
31.2
56.2
81.2
108.8

, ;
, ;
( Tab).
Visual Studio 2010 New
Project CLR Visual C++ Windows Forms

31.

99

Application Visual C++. Toolbox TextBox, ,


Multiline True,

(. . 4.8).
4.8.
4.8.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// , .
// ,
// ( ).
// / .
// /
// ('\t').
// / .
//
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// ,
// :
array<Double> ^X, ^Y, ^U, ^V;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
int i, n;
try
{
textBox1->Size = Drawing::Size(223, 205);
auto =
// String ^ =
IO::Directory::GetCurrentDirectory();
// :
String ^ = IO::File::ReadAllText(
+ "\\convert1.txt");
// ,
// , :
= ->Replace(".", ",");
// :
= ->Replace('\t', ' ');
// :
array<Char> ^ 1 = { '\r', '\n' };
auto = ->Split(1,
StringSplitOptions::RemoveEmptyEntries);


100

4 , ,

4.8 ()
// , (""), ,
// , .
n = ->Length; // -
// (
// ) :
for (i = 0; i <= n - 1; i++) [i] = [i]->Trim();
// ,
// , - (""):
= String::Empty;
for (i = 0; i <= n - 1; i++) += [i] +
"\r\n";
// Split ,
// , RemoveEmptyEntries:
= ->Split(1,
StringSplitOptions::RemoveEmptyEntries);
// .
// \t - ,
// .
// ,
// .
n = ->Length;
array<Char> ^ 2 = { ' ', '\t' };
// :
X = gcnew array<Double>(n + 1);
Y = gcnew array<Double>(n + 1);
U = gcnew array<Double>(n + 1);
V = gcnew array<Double>(n + 1);
// :
bool A, B, C, D;
for (i = 0; i <= n - 1; i++)
{ // :
array<String^> ^ = [i]->Split(2,
StringSplitOptions::RemoveEmptyEntries);
A = Double::TryParse([0], X[i + 1]);
B = Double::TryParse([1], Y[i + 1]);
C = Double::TryParse([2], U[i + 1]);
D = Double::TryParse([3], V[i + 1]);
//
// TryParse , :
if ((A && B && C && D) == false) MessageBox::Show(
String::Format(" {0} - !",
i + 1), "", MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
}
this->Text = String::Format(" = {0};", n);
textBox1->Multiline = true; textBox1->Clear();
// :
for (i = 1; i <= n; i++)

31.

//
//
//
//

101

textBox1->AppendText(String::Format("X = {0,5:F1}; " +


"Y = {1,5:F1}; U = {2,5:F1}; V = {3,5:F1};\r\n",
X[i], Y[i], U[i], V[i]));
"{0,5:F1}" :


.

}
catch (IO::FileNotFoundException^ )
{
MessageBox::Show(" \n" + ->Message,
"", MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
}
catch (Exception ^ )
{
// :
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
};
}

,
.
convert1.txt
, Replace.
(
Tab) . Split , ()
. RemoveEmptyEntries
, , ,
.
Length . ,
Visual Studio C# Visual Basic Count.
( Trim).
Split,
. ,
, ,
.
TryParse.
true .
(X, Y, U V), : A, B, C D.
() ,

102

4 , ,

TryParse .
.
. 4.8.

. 4.8.

, sln-
.

32.
( )
.
, , .
, ,
, .
.
, ,
. Windows
, ( ) (ReadOnly) .
, ,
: TextBox, MenuStrip : , , OpenFileDialog
PrintDocument. 4.9.
4.9.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ,
//

32.

103

// (ReadOnly)
IO::StreamReader ^ ;
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " ";
textBox1->Multiline = true; textBox1->Clear();
textBox1->Size = Drawing::Size(268, 112);
textBox1->ScrollBars = ScrollBars::Vertical;
textBox1->ReadOnly = true;
// ,
// "..."
ToolStripMenuItem->Visible = false;
openFileDialog1->FileName = nullptr;
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
// "":
openFileDialog1->Filter =
" (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->ShowDialog();
if (openFileDialog1->FileName == nullptr) return;
try
{ // StreamReader
= gcnew
IO::StreamReader(openFileDialog1->FileName,
System::Text::Encoding::GetEncoding(1251));
// - Win1251
textBox1->Text = ->ReadToEnd();
->Close();
ToolStripMenuItem->Visible = true;
}
catch (IO::FileNotFoundException^ )
{
MessageBox::Show(->Message +
"\n ", "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
catch (Exception^ )
{ // :
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{ // ""
try


104

4 , ,

4.9 ()
{
= gcnew
IO::StreamReader(openFileDialog1->FileName,
System::Text::Encoding::GetEncoding(1251));
// - Win1251
try { printDocument1->Print(); }
finally { ->Close(); }
}
catch (Exception^ )
{ MessageBox::Show(->Message); }
}
private: System::Void printDocument1_PrintPage(System::Object^ sender,
System::Drawing::Printing::PrintPageEventArgs^ e)
{ // (PrintPage):
Single = 0;
Single Y = 0;
Single = (Single)e->MarginBounds.Left;
Single = (Single)e->MarginBounds.Top;
String ^ = nullptr;
Drawing::Font ^ = gcnew Drawing::Font(
"Times New Roman", 12.0F);
//
= e->MarginBounds.Height /
->GetHeight(e->Graphics);
//
int i = 0; // -
while (i < )
{
= ->ReadLine();
if ( == nullptr) break; //
Y = + i *
->GetHeight(e->Graphics);
//
e->Graphics->DrawString(, , Brushes::Black,
, Y, gcnew StringFormat());
i = i + 1; // i += 1; -
}
// ,
if ( != nullptr) e->HasMorePages = true;
else e->HasMorePages = false;
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
this->Close();
}
};
}

32.

105

Form1_Load : ReadOnly = true.


ToolStripMenuItem->Visible = false ( ),
(
, ).
Form1_Load .
OpenFileDialog
StreamReader. , . ,
:
ToolStripMenuItem->Visible = true,
( ).
.
try...nally...catch
StreamReader, printDocument1->Print.
, printDocument1->Print,
. , PrintPage (. ),
PrintDocument. Print PrintPage.
PrintDocument1_PrintPage.
MSDN.
, e, . .
Times New Roman, 12 .
while line ->
ReadLine(), () DrawString. Graphics, e.
i .
, , ,
. , , . nullptr ( !=
nullptr), e.HasMorePages
true ,
PrintPage, PrintDocument1_PrintPage, . , e.HasMorePages = False
.
. 4.9 .
. 4.9.

, TxtPrint.sln TxtPrint.

106

4 , ,

33. /

- , . , () ,
(, ) . ,
, ,
. () , ,
, , .
,
.
.
.

. ,

.
. ,
.
, ,
,
. Toolbox
TextBox, Label : . ,
, . 4.10.
4.10.
4.10. /
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// /

private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " ";
label1->Text = " /";
label2->Text = " ..";
label3->Text = " ";
textBox1->Clear(); textBox2->Clear(); textBox3->Clear();

33. /

107

button1->Text = "";
button2->Text = "";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
//
if (IO::File::Exists("C:\\student.usp") == false) return;
//
IO::BinaryReader^ = gcnew IO::BinaryReader(
IO::File::OpenRead("C:\\student.usp"));
try
{
int _ = ->ReadInt32();
String ^ = ->ReadString();
Single = ->ReadSingle();
textBox1->Text = Convert::ToString(_);
textBox2->Text = Convert::ToString();
textBox3->Text = Convert::ToString();
}
finally { ->Close(); }
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
//
auto = gcnew IO::BinaryWriter(
IO::File::Open("C:\\student.usp", IO::FileMode::Create));
try
{
int _ = Convert::ToInt32(textBox1->Text);
String^ = Convert::ToString(textBox2->Text);
Single = Convert::ToSingle(textBox3->Text);
->Write(_);
->Write();
->Write();
}
finally { ->Close(); }
}
};
}

,
( ) :
, .
button2.Click,
(. . 4.10).

108

4 , ,

student.usp. ,
(Create), , . ,
OpenFileDialog
.

. 4.10. /


. _ int,
Convert::ToInt32 (
), ( )
Single,
Convert::ToSingle. . ->
Write . Finally
(Close) .

. , ,
, . C:\student.usp ,
(return) . ,
if, : , return.
if.
() .
student.usp,
.
ReadInt32 int, ReadString ReadSingle.
Convert::ToString. ,
,
. Finally (Close) . Finally
, return.

.

33. /

109

. :
catch (EndOfStreamException e)

.
, ReadWriteBin.
sln ReadWriteBin.

34.

- BMP, JPEG, PNG .
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
.
-. OnPaint.
OnPaint Form. , "this->" - ,
Form1. OnPaint ,
.
:
protected: virtual void

OnPaint. , .
poryv.png ( 5.1).
5.1. ( 1)
// ...............
// , , Visual Studio
// ,
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
//
protected: virtual void OnPaint( PaintEventArgs^ e ) override

34.

111

{
Form1::Text = "";
//
this->Width = 200; this->Height = 200;
//
Image ^ = gcnew Bitmap("C:\\poryv.png");
//
e->Graphics->DrawImage(, 5, 5);
// x=5, y=5 -
// : x - , y -
}
};
}

,
Width Height, .
.
DrawImage, Graphics e OnPaint.
. 5.1.
, .
OnPaint OnPaint.
5.2.
,

. 5.1.
Properties

Form1 Paint.
Graphics e Paint.

5.2. ( 2)
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
private: System::Void Form1_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)
{ //
// Form1 Paint.
// Paint - :
this->Text = "";
// :
Image^ = Image::FromFile("C:\\poryv.png");


112

5.2 ()
// Image^ = gcnew Bitmap("C:\\poryv.png");
// :
e->Graphics->DrawImage(, 5, 5);
}
};
}

.
Graphics. 5.3.
5.3. ( 3)
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^
{
// :
Form1::Text = "";
button1->Text = " ";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// " "
Image ^ = gcnew Bitmap("C:\\poryv.png");
// :
Graphics ^ = this->CreateGraphics();
// Graphics ^ = CreateGraphics();
->DrawImage(, 5, 5);
}
};
}

e)

, SimpleImage1, SimpleImage2 SimpleImage3. ,


,
, .

35. PictureBox

113

35.
PictureBox

, , ,
BMP, JPEG, GIF, PNG PictureBox ( ). PictureBox.
SizeMode, StretchImage.
,
PictureBox. ,
. (AutoScroll),
PictureBox . Panel. ,
PictureBox Panel AutoScroll = true
PictureBox SizeMode = AutoSize, .
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
Toolbox Panel,
PictureBox. , 5.4.
5.4. PictureBox
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// PictureBox,
// Panel,
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = "C";
// :
panel1->Size = Drawing::Size(200, 151);
// :
pictureBox1->Image = Image::FromFile("C:\\Ris.JPG");


114

5.4 ()
// Image ^ = gcnew Bitmap("C:\\Ris.JPG");
// pictureBox1->Image = ;
// PictureBox :
pictureBox1->SizeMode = PictureBoxSizeMode::AutoSize;
// :
panel1->AutoScroll = true;
}
};
}

, . :
, Form1.h[Design]
. .
. 5.2.

, .

. 5.2.

36.
()
: , , , . .
,
. Visual Studio
: , Ox
, Oy .
, , ,
, , , .
ListBox ().

.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Toolbox ListBox. ,
, ,
(Items) listBox1 ( 5.5).

36. ()

115

5.5.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// :
// , , , , ,
// .
// ListBox
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " ";
listBox1->Items->AddRange(gcnew array<Object^> {"",
"", "", "",
"", "", " "});
Font = gcnew System::Drawing::Font("Times New Roman", 14.F);
}
private: System::Void listBox1_SelectedIndexChanged(
System::Object^ sender, System::EventArgs^ e)
{
//
// listBox1_Click.
//
Graphics ^ = this->CreateGraphics();
//
Pen ^ = gcnew Pen(Color::Red);
// ""
Brush ^ = gcnew SolidBrush(Color::Red);
//
//
->Clear(SystemColors::Control);
// ->Clear(Color::FromName("Control"));
// ->Clear(ColorTranslator::FromHtml("#EFEBDE"));
switch (listBox1->SelectedIndex) // :
{
case 0:
// - :
->DrawEllipse(, 50, 50, 150, 150); break;
case 1:
// - :
->DrawLine(, 50, 50, 200, 200); break;
case 2:
// - :
->DrawRectangle(, 50, 30, 150, 180); break;
case 3:
// - :
->DrawPie(, 40, 50, 200, 200, 180, 225); break;
case 4:
// - :
->DrawString(" - , \n" +


116

5.5 ()
" .",
Font, , 10, 100); break;
case 5:
// - :
->DrawEllipse(, 30, 30, 150, 200); break;
case 6:
// - :
->FillPie(, 20, 50, 150, 150, 0, 45); break;
}
}
};
}

,
listBox1 (
), ,

, . Control
#EFEBDE ( ), Clear() :
->Clear(SystemColors::Control);


Control . , Microsoft: Windows

Explorer, Internet Explorer . .


, SelectIndex,
( 0 6),
. . 5.3 .

. 5.3.

, .
sln .

37.
ListBox
, BackColor, ,
Visual Studio 2010, ListBox.

37. ListBox

117

Visual Studio 2010 New Project


CLR Visual C++ Windows Forms Application
Visual C++. Toolbox
ListBox. Form1.cs , 5.6.
5.6. ListBox ( 1)
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// BackColor,
// , Visual Studio 2010,
// ListBox
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// KnownColor
array<String^>^ = Enum::GetNames(KnownColor::typeid);
// C#: string[] = Enum.GetNames(typeof(KnownColor));
listBox1->Items->Clear();
// listBox1:
listBox1->Items->AddRange();
//
listBox1->Sorted = true;
}
private: System::Void listBox1_SelectedIndexChanged(
System::Object^ sender, System::EventArgs^ e)
{
// Transparent "",
// :
if (listBox1->Text == "Transparent") return;
this->BackColor = Color::FromName(listBox1->Text);
this->Text = ": " + listBox1->Text;
}
};
}

, ,
Enum::GetNames, . () ListBox
AddRange. , (
F5). ListBox
KnownColor. ListBox,
(BackColor). KnownColor Control
( ), -

118

Microsoft, Windows Explorer, Internet Explorer, Visual Studio


2010 . , , ()
Color ( Color Control). Transparent
, . , (return),
.
. 5.4 . ,
Control, .

. 5.4.

for each
( 5.7).
5.7. ListBox ( 2)
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// KnownColor.
// Enum::GetNames
// :
array<String^>^ = Enum::GetNames(KnownColor::typeid);
// :
listBox1->Items->Clear();
// listBox1:
for each (String^ s in )
if (s != "Transparent") listBox1->Items->Add(s);
// Transparent "",
//
}

37. ListBox

119

private: System::Void listBox1_SelectedIndexChanged(


System::Object^ sender, System::EventArgs^ e)
{
//
// listBox1:
this->BackColor = Color::FromName(listBox1->Text);
// :
this->Text = ": " + listBox1->Text;
}
};
}

for each (,
Visual C# Visaul Basic foreach)
listBox1 , Transparent,
.
167 146 Color. , Visual Studio 2010
. Visual Studio RGB . (Red), (Green) (Blue) .
: 0 ,
(255) ,
. , Color::FromArgb(int red, int green, int
blue) , . () , 24 .
, 24 . ,
24 , 224 1 = 16 777 215 17 .
, , 24, 17
( ).

. , (
- - ).
, , . Pixie : http://natty.port5.com http://
www.nattyware.com. ,
HTML, #EFEBDE (
Control). ColorTranslator::FromHtml()
, () C++.
,
1 2.

120

38.

Visual Studio 2010, , .
, . ,
, ,
.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. .
Properties Form1.
, ,
Form1_Paint .
Form1.h Form1_Paint. ,
5.8.
5.8.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// ,
//
private: System::Void Form1_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)
{
// :
this->ClientSize = System::Drawing::Size(240, 200);
// :
Point p1 = Point(20, 20);
Point p2 = Point(225, 66);
Point p3 = Point(80, 185);
// :
array<Point>^ = { p1, p2, p3 };
// ControlDark :
e->Graphics->FillPolygon(gcnew SolidBrush(
SystemColors::ControlDark), );
// , :
this->TransparencyKey = SystemColors::ControlDark;
}
};
}

39.

121


,
. Graphics e. FillPolygon .
,

TransparencyKey.

. 5.5.
. 5.5.

,

MS Word.
,
.

39.
( ) . ,
: , , . . (. Graphics).
Visual Studio 2010 New
Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox
PrintDocument. 5.9.
5.9.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// ( ) . ,
//
// : , , .. (.
// Graphics)
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
printDocument1->Print();
}
private: System::Void printDocument1_PrintPage(System::Object^ sender,
System::Drawing::Printing::PrintPageEventArgs^ e)
{
//


122

5.9 ()
// (200, 250),
// 300 200
Pen ^ = gcnew Pen(Color::Red);
e->Graphics->DrawEllipse(, Rectangle(200, 250, 300, 200));
// e->Graphics->DrawEllipse(, 50, 50, 150, 150);
}
};
}

, PrintPage PrintDocument1->Print. PrintPage DrawEllipse


.
.
, .sln .

40. BMP-
, BMP. C: BMP C:\pic.bmp.
, .
, Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
Toolbox Button
PrintDocument. 5.10.
5.10. BMP-
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// bmp
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " C:\\pic.bmp";
button1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
//

41. JPG-

123

try
{
printDocument1->Print();
}
catch (Exception ^ )
{
MessageBox::Show(" \n",
->Message);
}
}
private: System::Void printDocument1_PrintPage(System::Object^ sender,
System::Drawing::Printing::PrintPageEventArgs^ e)
{
// , Print().
// BMP-
e->Graphics->DrawImage(Image::FromFile("C:\\pic.bmp"),
e->Graphics->VisibleClipBounds);
// ?
e->HasMorePages = false;
}
};
}

, printDocument1->Print. PrintPage,
printDocument1_PrintPage.
BMP- DrawImage.
, BMP.sln BMP.

41. JPG-

, - , -
, ,
.
, , ,
.
, , :
, Graphics
, .
Graphics ,
.

124

Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. _JPG. Toolbox
Button PictureBox. , 5.11.
5.11. , JPG

// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// Graphics,
// JPG-
//
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
button1->Text = " ";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
pictureBox1->Size = System::Drawing::Size(215, 35);
// 215 x 35
// 24
Bitmap ^ = gcnew Bitmap(215, 35, System::Drawing::
Imaging:: PixelFormat::Format24bppRgb);
// Graphics
Graphics ^ = Graphics::FromImage();
// Graphics!
// :
->Clear(Color::FromName("Control"));
// :
String ^ = String::Format(" {0:D}", DateTime::Now);
// 356 :
->RotateTransform(356.0F);
// ,
// x=5, y=15 -
->DrawString(, gcnew System::Drawing::
Font("Times New Roman", 14,
FontStyle::Regular), Brushes::Red, 5, 15);
// risunok.jpg:
->Save("risunok.jpg",
System::Drawing::Imaging::ImageFormat::Jpeg);
// :
pictureBox1->BorderStyle = BorderStyle::None; // FixedSingle;
// :

42.

125

pictureBox1->Image = Image::FromFile("risunok.jpg");
// :
delete ; delete ;
// C#: ->Dispose(); ->Dispose();
}
};
}

,
, Format24bppRgb
, 24 : 8 ,
. Graphics FromImage.
356 RotateTransform .
Save JPEG. pictureBox1 .
. 5.6 .
. 5.6.

,
,

_JPG.

42.


-
.

Invalidate.
: ;
.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. . Toolbox
Button Panel. , Panel
.
Panel .
.
Form.h1[]
. () , Form1, panel1 button1, -

126

Load, Paint Click.


.
, 5.12.
5.12. ,
Invalidate
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// .
//
//
// ~ ~ ~ ~ ~ ~ ~ ~
Graphics ^ ;
float ;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = " ";
button1->Text = "";
= 0.0F;
}
private: System::Void panel1_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)
{
// Paint
// :
panel1->BackColor = Color::AliceBlue;
panel1->Cursor = Cursors::Cross;
// e:
= e->Graphics;
// :
->TranslateTransform(100.0F, 70.0F);
// :
->RotateTransform();
//
// :
->DrawString(" !",
gcnew System::Drawing::Font("Comic Sans MS", 14,
FontStyle::BoldFontStyle::Italic), Brushes::Red, -70,
-15);
// -70, -15 -
//
}

43.
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
// :
= + 30.0F;
// :
panel1->Invalidate();
}
};

127

sender,

,
panel1_Paint. , .
.
,
. , Invalidate,

button1_Click.
,
X , Y .
, X Y,

.
. 5.7.
. 5.7.
,



.

43.
, .
, ,
.
, . , .
, .
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
Toolbox Button.
, 5.13.

128

5.13.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
//
// ~ ~ ~ ~ ~ ~ ~
// _ :
bool _;
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^
{
this->Text = " ";
button1->Text = "";
_ = false; // -
}
private: System::Void Form1_MouseDown(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// - MouseDown,
_ = true;
}
private: System::Void Form1_MouseUp(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// ,
_ = false;
}
private: System::Void Form1_MouseMove(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// ,
if (_ == true)
{ // (e.X, e.Y)
Graphics ^ = CreateGraphics();
->FillRectangle(gcnew SolidBrush(Color::Red),
e->X, e->Y, 10, 10);
// 10x10
// e->X, e->Y
delete ; // C#: ->Dispose();
}
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
Graphics ^ = CreateGraphics();

e)

43.

129

->Clear(this->BackColor);
// ->Clear(SystemColors::Control);
// ->Clear(Color::FromName("Control"));
// ->Clear(Color::FromKnownColor(KnownColor::Control));
// ->Clear(ColorTranslator::FromHtml("#EFEBDE"));
// this->Refresh(); //
}
};
}

, _
(bool) false. (_ = true) ( MouseMove),
(_ = false). _
Form1,
.
_ MouseUp ( , , _ = false), MouseDown
( , , _ = true).
Graphics System::Drawing, CreateGraphics(), FillRectangle(), , 10 10 .
e.X, e.Y ,
.
. 5.8 . , . Refresh(),
. ,
, CreateGraphics()
KnownColor::Control.

. 5.8.

,
Clear(Color::White), (White)

130

146 (::)
Color. 146 (BackColor). , Color::FromKnownColor.
Color::FromName(Control). ColorTranslator::FromHtml().
. #EFEBDE
.
, ,
. , .
, .
sln .

44.
Visual Studio 2010 . , DrawBezier ,
, .
, .
. 5.9 P0 P3 , P1 P2
.

. 5.9. P1 P2

P1 P2 ,
() . , , ,
, . www.msdn.com
, control points. control
. , ,
.
: , .
.

44.

131

Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Spline.
( 5.14). ,
Form1.h[Design] , (Events), ,
.
5.14.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// ,
// () .
//
// . ,
// ()
// ~ ~ ~ ~ ~ ~ ~ ~
array<PointF> ^ ;
// :
Boolean ;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
= false;
this->Text = " ";
= gcnew array<PointF>(4);
// :
[0] = PointF(50.0f, 50.0f);
// () , :
[1] = PointF(125.0f, 125.0f);
[2] = PointF(125.0f, 125.0f);
// :
[3] = PointF(200.0f, 200.0f);
}
private: System::Void Form1_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)
{
// e:
Graphics ^ = e->Graphics;
Pen ^ = gcnew Pen(Color::Blue, 3);
//
4 :
->DrawEllipse(,
[0].X - 2, [0].Y - 2, 4.0f, 4.0f);


132

5.14 ()
->DrawEllipse(,
[3].X - 2, [3].Y - 2, 4.0f, 4.0f);
// :
->Color = Color::Red;
->DrawRectangle(, [1].X - 2,
[1].Y - 2, 4.0f, 4.0f);
->Color = Color::Blue;
// :
->DrawBeziers(, );
delete ;
}
private: System::Void Form1_MouseMove(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// .
//
if (Math::Abs(e->X - [1].X) < 4.0f &&
Math::Abs(e->Y - [1].Y) < 4.0f &&
//
== true)
{ //
[1].X = (float)e->X;
[1].Y = (float)e->Y;
[2].X = (float)e->X;
[2].Y = (float)e->Y;
// () :
this->Invalidate();
}
}
private: System::Void Form1_MouseUp(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// ,
// :
= false;
}
private: System::Void Form1_MouseDown(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// ,
// :
= true;
}
};
}

( )
Form1,

45. Graphics

133

. .

,
, , .
, ,
true , ,
false.
, ,

( e) ( )
.
. 5.10.

. 5.10. ,

, Spline.sln
Spline.

45.
Graphics
, , ,
- , . ,
.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Toolbox
PictureBox ( ) Button. , 5.15.

134

5.15.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// . ,
//
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// ( ):
array<String^>^ Months;
array<int>^ Sales;
Graphics ^ ;
// , Bitmap,
// , PictureBox
Bitmap ^ ;
int , , , ;
int , , Y, Xmax, X;
// :
double ; int ;
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Months = gcnew array<String^> {"", "", "", "",
"",
"", "", "", "",
"", "", ""};
Sales = gcnew array<int> {335, 414, 572, 629, 750, 931,
753, 599, 422, 301, 245, 155};
= 35; = 15;
= 20; = 10;
this->Text = " ";
button1->Text = " ";
this->ClientSize = System::Drawing::Size(593, 342);
= gcnew Bitmap(pictureBox1->Width, pictureBox1->Height,
pictureBox1->CreateGraphics());
// pictureBox1->BorderStyle = BorderStyle::FixedSingle;
Y = pictureBox1->Height - ;
Xmax = pictureBox1->Width - ;
= pictureBox1->Width - ( +
);
= Y - ;
= (double)( / Sales->Length);
= (int)( / 10);
X = + 30;
} // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

45. Graphics

135

private: System::Void button1_Click(System::Object^ sender,


System::EventArgs^ e)
{ // :
= Graphics::FromImage();
();
();
();
();
pictureBox1->Image = ;
// , Graphics:
delete ; // - C#: .Dispose
} // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
private: void ()
{
//Pen = new Pen(Color.Black, 2);
Pen ^ = gcnew Pen(Color::Black, 2);
// :
->DrawLine(, , Y,
, );
// :
->DrawLine(, , Y,
Xmax, Y);
auto = gcnew Drawing::Font("Arial", 8);
for (int i = 1; i <= 10; i++)
{ // "" :
int Y = Y - i * ;
->DrawLine(, - 5, Y, , Y);
// 100 :
->DrawString((i * 100).ToString(), ,
Brushes::Black, 2, Y - 5.F);
}
// :
for (int i = 0; i <= Months->Length - 1; i++)
->DrawString(Months[i], , Brushes::Black,
+ 18.F + (int)(i * ), Y + 4.F);
} // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
private: void ()
{
Pen ^ = gcnew Pen(Color::LightGray, 1);
for (int i = 1; i <= 10; i++)
{ // "" :
int Y = Y - * i;
->DrawLine(, + 3, Y, Xmax, Y);
}
delete ; // - C#: .Dispose();
} // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
private: void ()
{ // ""
Pen ^ = gcnew Pen(Color::Bisque, 1);


136

5.15 ()
for (int i = 0; i <= Months->Length - 1; i++)
{
int X = X + (int)( * i);
->DrawLine(, X, ,
X, Y - 4);
}
delete ;
} // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
private: void ()
{
double = (double) / 1000;
// :
array<int>^ Y = gcnew array<int>(Sales->Length);
// :
array<int>^ X = gcnew array<int>(Sales->Length);
for (int i = 0; i <= Sales->Length - 1; i++)
{ // :
Y[i] = Y - (int)(Sales[i] * );
// , Y
//
X[i] = X + (int)( * i);
}
// :
Pen ^ = gcnew Pen(Color::Blue, 3);
->DrawEllipse(, X[0] - 2, Y[0] - 2, 4, 4);
for (int i = 0; i <= Sales->Length - 2; i++)
{ // :
->DrawLine(, X[i], Y[i], X[i + 1], Y[i + 1]);
// 2, () = 4:
->DrawEllipse(, X[i + 1] - 2, Y[i + 1] - 2,
4, 4);
}
} // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
};
}

,
, . Months
,
.

. Sales ,
.
, .
Button
Graphics, PictureBox ( ),
, , ,

45. Graphics

137

.
, ,
, .
. , , ,
, , .
Y, ( x
, y ) ,
. XMax
(. . 5.7), .
X . , ,
, .
. 5.11.

. 5.11.

, .sln
.

46.

. -
(), .
, .
, .
- , ,
( Shift),
. ,
Ctrl+C.
-
,
(. 6.1). 6.1.
6.1.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// -
// ,
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^

e)

46.

139

{
this->Text = " ";
textBox1->Clear(); textBox2->Clear();
textBox1->TabIndex = 0;
button1->Text = " ";
button2->Text = " ";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
if (textBox1->SelectedText != String::Empty)
{
Clipboard::SetDataObject(textBox1->SelectedText);
textBox2->Text = String::Empty;
}
else
textBox2->Text = " ";
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// -
IDataObject ^ = Clipboard::GetDataObject();
// ...
if (->GetDataPresent(DataFormats::Text) == true)
// Text
textBox2->Text = ->
GetData(DataFormats::Text)->ToString();
else
textBox2->Text = " - ";
}
};
}

,
, , (SelectedText) (Clipboard) () SetDataObject, (else)
textBox2 , .
, , ,
.
- .
- .
: (DataFormat::Text) . , TextBox2
, ToString.
.
. 6.1.

140

. 6.1.

, TXT.sln TXT.

47. PictureBox.

, , . PictureBox ( ),
, BMP, JPEG, PNG, GIF .
PictureBox GIF- ,
, .
GIF- , PictureBoxGif.sln
PictureBoxGif. PictureBox Flash SWF, ,
. , SWF
Microsoft WebBrowser, 8.
, PictureBox (, PNG).
. , , Paint Windows.
- ,
Paint, MS Office Picture Manager, ACDSee . ,
, .
Visual Studio 2010 New
Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox
PictureBox ( ) Button. 6.2.
6.2.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}

47. PictureBox.

141

#pragma endregion
// ,
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " :";
button1->Text = " ";
// :
pictureBox1->Size = Drawing::Size(184, 142);
// PictureBox :
try
{
pictureBox1->Image = Image::FromFile(
IO::Directory::GetCurrentDirectory() + "\\poryv.png");
}
catch (IO::FileNotFoundException^ )
{
// :
MessageBox::Show(->Message + "\n ",
"", MessageBoxButtons::OK,
MessageBoxIcon::Exclamation);
button1->Enabled = false;
return;
}
//
Clipboard::SetDataObject(pictureBox1->Image);
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// -
IDataObject ^ = Clipboard::GetDataObject();
Bitmap ^ ;
// Bitmap...
if (->GetDataPresent(DataFormats::Bitmap) == true)
{ //
// Bitmap:
= (Bitmap^)->GetData(DataFormats::Bitmap);
pictureBox1->Image = ;
}
}
};
}

, pictureBox1 - , poryv.png. GetCurrentDirectory() .


Clipboard::SetDataObject(pictureBox1->Image)

.
- , Paint. - ,

142

- .

, .
. 6.2.

. ,
, .
. 6.2.
-

. , ,

, Bitmap.

,
Bitmap ,
Bitmap. ,
pictureBox1 , Image
.
, Bitmap.sln Bitmap.

48.
Alt+PrintScreen
, PrintScreen , screen shot ( screen capture).
(,
Paint) .
Alt+PrintScreen
, .
Alt+PrintScreen Visual Studio
System::Windows::Forms SendKeys,
,
Alt+PrintScreen.
, . , .

Alt+PrintScreen Send SendKeys.
,
. :
Paint .
6.3.

49. BMP-

143

6.3. Alt+<PrintScreen>
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// Alt+<PrintScreen>
// Send SendKeys
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " Alt+<PrintScreen>";
button1->Text = " Send SendKeys";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// SendKeys::Send
// Alt+<PrintScreen>
SendKeys::Send("%{PRTSC}");
// :
// String ^ QQ = Keys::PrintScreen.ToString();
}
};
}


. Send SendKeys Alt+PrintScreen.
PrintScreen {PRTSC}.
Alt+PrintScreen, : %{PRTSC}. :
http://msdn.microsoft.com/ru-ru/library/system.windows.forms.sendkeys.aspx

, AltPrintScreen.sln AltPrintScreen.

49.
BMP-
, , , BMP-.
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.

144

Toolbox Button.
6.4.
6.4. BMP-
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// ,
// , BMP-
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " BMP-";
button1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// -
auto = Clipboard::GetDataObject();
Bitmap ^ ;
// Bitmap...
if (->GetDataPresent(DataFormats::Bitmap) == true)
{ // Bitmap
= (Bitmap^)->GetData(DataFormats::Bitmap);
// Clip.bmp
->Save("C:\\Clip.BMP");
//this->Text = " C:\\Clip.BMP";
//button1->Text = " ?";
MessageBox::Show
(" C:\\Clip.BMP",
"");
}
else
//
MessageBox::Show(
" Bitmap",
" - ");
}
};
}


-
. : ,
, Bitmap. ,

50. Timer

145

Bitmap
,
Bitmap. ,
Save(). ,
.
, SaveFileDialog.
. 6.3.

. 6.3.

, SaveBMP.sln SaveBMP.

50. Timer
(screen
shot) , . , (www.rentacoder.com).
100 . ,
, .
, :
ListBox,
, .
.
Visual Studio 2010 New Project
CLR Visual C++ Windows Forms Application
Visual C++. Toolbox
Timer ListBox. 6.5.
6.5.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}


146

6.5 ()
#pragma endregion
// Timer.
// ListBox.
// 2
// , 2
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = "Timer";
timer1->Interval = 2000; // - 2
//
timer1->Enabled = true; // -
}
private: System::Void timer1_Tick(System::Object^ sender,
System::EventArgs^ e)
{
listBox1->Items->Add(" ");
}
};
}

Timer
, Tick.

(Interval), 2000 ( ).
Tick, listBox1
. , . . 6.4

.
. 6.4.
,

Timer.sln Timer.

51.

, . :

Pic1.BMP, ..., Pic5.BMP.
, . ,

51.

147

Timer, Alt+PrintScreen
, ,
BMP.
Visual Studio 2010 New Project
CLR Visual C++ Windows Forms Application Visual C++.

Timer Button. 6.6.
6.6. 5
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
// Pic1.BMP, Pic2.BMP
// . .
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
int i; //
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
i = 0; //
this->Text = " 5 ";
button1->Text = "";
}
private: System::Void timer1_Tick(System::Object^ sender,
System::EventArgs^ e)
{
i = i + 1;
this->Text = String::Format(" {0} ", i);
if (i >= 28) { timer1->Enabled = false; this->Close(); }
if (i % 5 != 0) return;
// Alt+<PrintScreen>
SendKeys::Send("%{PRTSC}");
// -
auto = Clipboard::GetDataObject();
Bitmap ^ ;
// Bitmap,
//
if (->GetDataPresent(DataFormats::Bitmap) == true)
{ //
Bitmap
= (Bitmap^)->GetData(DataFormats::Bitmap);
//
// C:\Pic1, C:\Pic2, C:\Pic3, ...


148

6.6 ()
String ^ = String::Format("C:\\Pic{0}.BMP", i / 5);
->Save();
}
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = String::Format(" 0 ");
timer1->Interval = 1000; //
timer1->Enabled = true; //
}
};
}

, button1_Click Timer1_Tick.
i, ,
, .
Interval, 1000 ,
. timer1->Enabled = true,
timer1_Tick(), .
timer1_Tick i,
. i % 5 . ,
i , ,
Alt+PrintScreen .
,
Save5.


.

52. .
String::Format

,
, ( ),
.
: , .
,
. ,
. ,
: Imena Tel.
TextBox. ,
MenuStrip ,
(notepad.exe) ()
.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++.
: TextBox Multiline =
true MenuStrip , .
7.1.

150

7 .

7.1.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
// , String::Format. ,
// MenuStrip
// ,
//
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->textBox1->Multiline = true;
this->textBox1->Size = Drawing::Size(320, 216);
this->ClientSize = Drawing::Size(342, 266);
this->Text = " ";
array<String^>^ Imena = {" - ", "-X", "",
" ", " ",
" - ", " ",
" ", " "};
array<String^>^ Tel = {"274-88-17","+38(067)7030356",
"22-345-72", "009", "223-67-67 32-67",
"570-38-76", "201-72-23- ",
"001", "216-40-22"};
textBox1->ScrollBars = ScrollBars::Vertical;
textBox1->Font = gcnew Drawing::Font("Courier New", 9.0F);
textBox1->Text = " \r\n\r\n";
for (int i = 0; i <= 8; i++)
textBox1->Text += String::Format(
"{0, -21} {1, -21}", Imena[i], Tel[i]) + "\r\n";
textBox1->Text += "\r\n:" +
"\r\n " +
"\r\n Courier New";
// C:\Table.txt.
// StreamWriter
auto = gcnew IO::
StreamWriter("C:\\Table.txt", false,
System::Text::Encoding::GetEncoding(1251));
// - Win1251
->Write(textBox1->Text);
->Close();
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)

52. . String::Format

151

{
try
{
Diagnostics::Process::Start("Notepad", "C:\\Table.txt");
}
catch (Exception ^ )
{ //
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
this->Close();
}
};
}

TextBox,
Courier New. ,
(, , .) ,
. , Courier New,
. , ,
Consolas.
for +=, :
textBox1->Text , . String::Format ,
. . :
Imena[i], Tel[i]. 21 ,
21 (
), . \r\n , .
. 7.1.

. 7.1.

152

7 .

textBox1->Text
C:\Table.txt StreamWriter Windows 1251. 26 (. 4).

. 7.2.


, .
(notepad.exe)
C:\Table.txt (. 7.2).
, Txt.
sln Txt.

53. Double-
. .
StringReader
, ,
String,
Double. , X Y.
. . .
TextBox.
. ,
.
: , Visual Studio 2010 New
Project CLR Visual C++ Windows Forms
Application Visual C++.
Toolbox TextBox,
MenuStip PrintDocument. Design ,
. 7.3. ,
Multiline True ( ).
7.2.

53. Double-

153

7.2.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
// .
// TextBox.
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
IO::StringReader ^ ; // -
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " ";
Double X[] = {5342736.17653, 2345.3333, 234683.853749,
2438454.825368, 3425.72564, 5243.25,
537407.6236, 6354328.9876, 5342.243};
Double Y[] = {27488.17, 3806703.356, 22345.72,
54285.34, 2236767.3267, 57038.76,
201722.3, 26434.001, 2164.022};
// :
// array<Double> ^ Y = {27488.17, 3806703.356, 22345.72,
//
54285.34, 2236767.3267, 57038.76,
//
201722.3, 26434.001, 2164.022};
textBox1->Multiline = true;
textBox1->ScrollBars = ScrollBars::Vertical;
textBox1->Font = gcnew Drawing::Font("Courier New", 9.0F);
textBox1->Text = " \r\n";
textBox1->Text += "---------------------------------\r\n";
textBox1->Text += "||
X

Y
|\r\n";
textBox1->Text += "---------------------------------\r\n";
for (int i = 0; i <= 8; i++)
textBox1->Text += String::Format(
"| {0,3:D}{1,10:F2}{2,10:F2} |",
i, X[i], Y[i]) + "\r\n";
textBox1->Text += "---------------------------------\r\n";
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
// ""
try
{ // :
= gcnew IO::StringReader(textBox1->Text);
try


154

7 .

7.2 ()
{
printDocument1->Print();
}
finally
{
->Close();
}
}
catch (Exception ^ )
{
MessageBox::Show(->Message);
}
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^
{
//
this->Close();
}
};

e)

,
for String::Format. 0, 1 2
, i, X[i], Y[i].
3:D , i
D. 10:F2 , X(i)

.

. 7.3.

(. 7.3) try...
naly...catch , ,
textBox1->Text. , ,

54. Internet Explorer

155

().
, 31 (. 4).
, , (
),
.
,
TxtPrint.

54. Internet Explorer


. HTML,
() - Internet
Explorer. HTML (HyperText Markup Language, ) , . - HTML,
() HTML. , HTML
( ),
. HTML htm html. HTML
-. (<>).
, HTML ( 7.3).
7.3. HTML
<title> </title>
<table border>
<caption> </caption>
<tr><td> <td>274-88-17
<tr><td>-X<td>+38(067)7030356
<tr><td><td>22-345-72
<tr><td> <td>009
</table>

HTML,
<HTML>, <HEAD>, <TITLE> . .,
, 7.3.
<tr> (, )
<td> (, ).
, - htm
- Internet Explorer, Mozilla Firefox
. HTML

156

7 .

Microsoft Office SharePoint Designer ( Microsoft Office FrontPage )


, HTML- ,
.
, Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
, 44. : Imena Tel.
HTML, (
C:\Tabl_tel.htm),
Internet Explorer. 7.4.
7.4. Internet Explorer
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// Internet Explorer.
//
// .
// HTML.
// -
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^
{
this->Text = " HTML";
array<String^> ^ Imena = {" - ", "-X", "",
" ", " ", " - ",
" ", " ", " "};
array<String^> ^ Tel = {"274-88-17", "+38(067)7030356",
"22-345-72", "009", "223-67-67 32-67", "570-38-76",
"201-72-23- ", "001", "216-40-22"};
String ^ text = "<title> </title>" +
"<table border><caption>" +
" </caption>\r\n";
for (int i = 0; i <= 8; i++)
text += String::Format("<tr><td>{0}<td>{1}", Imena[i],
Tel[i]) + "\r\n";
text += "</table>";
// C:\Tabl_tel.htm.
// StreamWriter
auto = gcnew IO::
StreamWriter("C:\\Tabl_tel.htm", false,
System::Text::Encoding::GetEncoding(1251));
// - Win1251
->Write(text); ->Close();

e)

54. Internet Explorer

157

try
{
Diagnostics::Process::Start("Iexplore",
"C:\\Tabl_tel.htm");
// HTM MS_WORD:
// Diagnostics::Process::Start("WinWord",
//
"C:\\Tabl_tel.htm");
}
catch (Exception ^ )
{
//
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
};
}

HTML- text. <title> </title> . ,


.
<table> , <caption> </caption>
. for . String::Format,
{0} Imena[i], {1} Tel[i].
, , C:\Tabl_tel.
htm. try...catch Internet
Explorer.
. 7.4.

. 7.4.

158

7 .

HTM- -, MS Word, :
Diagnostics::Process::Start("WinWord", "C:\\Tabl_tel.htm")

. ,
_HTM.sln _HTM.

55.
DataGridView
,
, DataGridView ( ). DataGridView .
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++, . DataGridView
( ) Toolbox.
Imena[] Tel[] DataGridView.
. 7.5.
7.5. DataGridView
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
// , DataGridView
// ( ). DataGridView
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
Form1::Text = " ";
array<String^> ^ Imena = {" - ", "-X", "",
" ", " ", " - ",
" ", " ", " "};
array<String^> ^ Tel = {"274-88-17", "+38(067)7030356",
"22-345-72", "009", "223-67-67 32-67", "570-38-76",
"201-72-23- ", "001", "216-40-22"};
// " "
DataTable ^ = gcnew DataTable();

56. -

159

// ""
->Columns->Add("");
->Columns->Add(" ");
// ()
for (int i = 0; i <= 8; i++)
->Rows->Add( Imena[i], Tel[i] );
//
dataGridView1->DataSource = ;
}
};
}

, DataTable.
, Columns>Add, , Rows->Add.
DataGridView, DataSource DataTable.

. 7.5. DataGridView

. 7.5 . , , ,
.
, Grid.
sln Grid.

56. DataGridView
, -,
, , .
. -,
. - .
- , ,

160

7 .

. -,
, .
,
, - , .
-. , ,
(txt, jpg, mdb, xls) ,
,
(Notepad.exe, Pbrush.exe, MSAccess.exe, Excel.exe). , IP-. -
ViewState Session ASP.NET.
: -
, . ,
DataGridView, - .
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++, Name GridView .
DataGridView ( ) Toolbox. Form1.h
, 7.6.
7.6. -
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// ,
// -.
// .
// , - . ,
// DataGridView,
// -
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = " -";
// -:
System::Collections::Hashtable = gcnew
System::Collections::Hashtable();
// -.
// " - " :
[""] = "";
// :
.Add("", "");
// - , -

56. -

161

.Add("", "");
// ( ):
DataTable ^ = gcnew DataTable();
// , :
->Columns->Add("");
->Columns->Add("");
//
// - :
for each (System::Collections::DictionaryEntry in )
// DictionaryEntry
// " - "
->Rows->Add(.Key, .Value);
// DataGridView:
dataGridView1->DataSource = ;
}
};
}

Hashtable. , , , :
Add. DataTable,
-. -
DictionaryEntry,
-.
DataTable. , , dataGridView1 DataTable.
. 7.6.

. 7.6. -

, - ,
. -
,
, .
-: ,
, -
.
,
GridView.sln GridView.

162

7 .

57. .
DataGridView. DataTable. DataSet.
XML
, . , TextBox,
,
, . .
.

DataGridView ( ). ,
, ,
. , , DataGridView ,
DataGridView , , ,
.
, , , , , . .

XML.
C:\tabl.xml.
, . .
,
.
Visual Studio 2010 New Project
CLR Visual C++ Windows Forms Application
Visual C++. Toolbox : DataGridView Button.
7.7.
7.7.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
// , , , . .
//
// XML.
// C:\tabl.xml.
// ,

57. . DataGridView. DataTable. DataSet

163

//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
DataTable ^ ; // " "
DataSet ^ ; // " "
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " ";
button1->Text = "";
= gcnew DataTable();
= gcnew DataSet();
if (IO::File::Exists("C:\\tabl.xml") == false)
{
// XML- :
dataGridView1->DataSource = ;
// ""
->Columns->Add("");
->Columns->Add(" ");
// DataSet
->Tables->Add();
}
else // XML- C:
{
->ReadXml("C:\\tabl.xml");
// DataSet XML :
String ^ XML = ->GetXml();
dataGridView1->DataMember = " ";
dataGridView1->DataSource = ;
}
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// tabl.xml:
->TableName = " ";
->WriteXml("C:\\tabl.xml");
}
};
}

, .
ADO.NET.
: DataSet
DataTable. DataSet
ADO.NET. DataSet , . DataSet DataTable.
DataSet ,
WriteXml,

164

7 .

ReadXML. , : DataSet , DataTable


DataGridView .
. , ,
Exists(C:\\tabl.xml) == false, DataSource
DataGrid DataTable , : , DataTable DataSet.
. ( else),
DataSet XML- (ReadXML).
DataGrid DataSet.
(. 7.7) button1.Click XML- (WriteXml).

. 7.7.

, , XML-. (, Macintosh).
, .
XML MS Word,
. ,
UTF-8, , edit.com
Rpad32.exe ( ), . XML-
-, XML-editor ( Visual Studio 2010),
MS Office SharePoint Designer, MS Front Page .

. XML- MS Excel, .
. 7.8 XML- MS Word.
XML-
,
xml,
ReadXml XML-.

58.

165

. 7.8. XML- MS Word

. ,
() ,
DataTable: .Rows.Item(0).Item(0). ,
,
- , ADO.NET
. ,
DataSet.
, XML-. ,
.sln .

58.
.
DataGridView
, ().
,
. , , (
).
, DataGridView,
.
( -

166

7 .

,
). MessageBox.
, Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++. (. 7.9) Label, TextBox,
DataGridView Button.
. 7.8
.
7.8.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// .
// DataGridView
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// ,
// :
int n; // -
DataTable ^ ;
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " ";
// :
textBox1->TabIndex = 0;
dataGridView1->Visible = false; //
label1->Text = " :";
button1->Text = ""; // -
= gcnew DataTable();
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
array<double,2> ^ A = gcnew array<double,2>(n, n);
// :
array<double> ^ L = gcnew array<double>(n);
int i, j;
// :
bool _ = false;
String ^ tmp;
// -
if (button1->Text == "")

58.

167

{
for (; ; )
{ // ,
// :
_ = int::TryParse(textBox1->Text,
Globalization::NumberStyles::Integer,
Globalization::NumberFormatInfo::CurrentInfo, n);
if (_ == false) return;
// :
button1->Text = "";
// :
textBox1->Enabled = false;
// :
dataGridView1->Visible = true;
dataGridView1->DataSource = ;
// ""
for (i = 1; i <= n; i++)
{
tmp = "X" + Convert::ToString(i);
->Columns->Add(gcnew DataColumn(tmp));
}
// :
->Columns->Add(gcnew DataColumn("L"));
return;
}
}
else // button1->Text == "")
{
//
// ->Rows->Count -
if (->Rows->Count != n)
{
MessageBox::Show(
" ");
return;
}
// A[j, i]
for (j = 0; j <= n - 1; j++)
{
for (i = 0; i <= n - 1; i++)
{
A[j, i] = (j, i, _);
if (_ == false) return;
}
// B(j, 0)
L[j] = (j, i, _);
if (_ == false) return;
} // j
}
// A*x = L :


168

7 .

7.8 ()
gauss(n, A, L);
// L - ,
// x
String ^ s = " :\n";
for (j = 1; j <= n; j++)
{
tmp = L[j - 1].ToString();
s = s + "X" + j.ToString() + " = " + tmp + ";\n";
}
MessageBox::Show(s);
}
private: void gauss(int n, array<double,2> ^ A, array<double> ^ LL)
{
// n -
// A -
// LL - ,
int i, j, l = 0;
Double c1, c2, c3;
for (i = 0; i <= n - 1; i++) //
{
c1 = 0;
for (j = i; j <= n - 1; j++)
{
c2 = A[j, i];
if (Math::Abs(c2) > Math::Abs(c1))
{
l = j; c1 = c2;
}
}
for (j = i; j <= n - 1; j++)
{
c3 = A[l, j] / c1;
A[l, j] = A[i, j]; A[i, j] = c3;
} // j
c3 = LL[l] / c1; LL[l] = LL[i]; LL[i] = c3;
for (j = 0; j <= n - 1; j++)
{
if (j == i) continue;
for (l = i + 1; l <= n - 1; l++)
{
A[j, l] = A[j, l] - A[i, l] * A[j, i];
} // l
LL[j] = LL[j] - LL[i] * A[j, i];
} // j
} // i
}

58.

169

private: double (int j, int i, bool & _)


{ // j - , i -
// _ (bool & _)
double rab; // -
String ^ tmp = ->Rows[j][i]->ToString();
_ = Double::TryParse(tmp,
System::Globalization::NumberStyles::Number,
System::Globalization::NumberFormatInfo::CurrentInfo, rab);
if (_ == false)
{
tmp = String::Format(" {0}, " +
"{1},\n - ", j + 1, i + 1);
MessageBox::Show(tmp);
}
return rab;
}
};
}

, (Visible = false) , . , , ( ),

,
.

. 7.9.


. gauss, . gauss
for .
.
gauss s
. s MessageBox (. 7.10).
, -

. 7.10.

170

7 .

, NaN,
.

.
. . ,
.
, Grid.
sln Grid.

59.

. -.
(. 7.11),
.
, () , , -, ,
.
, - (. 7.12).
,
.
(),
. (. . 7.11), +,
(. 7.13).
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. .
DataGridView. , Visual Studio
2007 . 2007 DataGrid.
DataGridView , DataGrid. ,
DataGridView DataGrid.
DataGridView. , DataGrid
DataGridView, .
DataGridView.
DataGrid.

59.

171

, ToolBox DataGrid. ,
, DataGrid ,
.
. .NET Framework
DataGrid System.Windows.Forms.
OK ToolBox.
DataGrid . ,
Button ( ), .
7.9 .
7.9.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// ( ,
// ) ( , ,
// -).
// ( ).
// ,
// - .
// "". "" ,
//
// ~ ~ ~ ~ ~ ~ ~ ~
Boolean ;
System::Data::DataSet ^ ;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
button1->Text = " "; button1->TabIndex=0;
Form1::Text = " "; = true;
// " ":
System::Data::DataTable ^ = gcnew DataTable("");
// :
DataColumn ^ = gcnew DataColumn(" ");
->ReadOnly = true; // -
// :
->Unique = true;
// :
->Columns->Add();
// :
->Columns->Add(" ");
->Columns->Add("");
// :


172

7 .

7.9 ()
= gcnew DataSet();
// "" :
->Tables->Add();
// () :
->Rows->Add(
"", " ", "095 345 22 37");
->Rows->Add(
"", " ", "050 456 21 03");
->Rows->Add(
"", " ", "067 456 56 72");
// " ":
= gcnew DataTable("");
// "":
DataColumn ^ 1 = gcnew DataColumn(" ");
1->DataType = System::Type::GetType("System.Int32");
1->ReadOnly = true; 1->Unique = true;
->Columns->Add(1);
// :
->Columns->Add(" ");
->Columns->Add("-");
->Tables->Add();
// () :
->Rows->Add(1, "230000", "");
->Rows->Add(2, "178900", "");
->Rows->Add(3, "300000", "");
->Rows->Add(4, "345000", "");
->Rows->Add(5, "308000", "");
// :
// :
DataColumn ^ = ->
Tables[""]->Columns[" "];
DataColumn ^ = ->
Tables[""]->Columns["-"];
DataRelation ^ 1 = gcnew DataRelation(
" ", , );
//
// , - .
->Tables[""]->ParentRelations->Add(1);
// D A T A G R I D:
dataGrid1->SetDataBinding(, "");
dataGrid1->CaptionText = " \"\"";
dataGrid1->CaptionFont = gcnew
System::Drawing::Font("Consolas", 11);
}
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)

sender,

59.

173

{
// " ", "":
= !;
if ( == true)
{
dataGrid1->SetDataBinding(, "");
dataGrid1->CaptionText = " \"\"";
}
else
{
dataGrid1->SetDataBinding(, "");
dataGrid1->CaptionText = " \"\"";
}
}
};
}

, . DataTable, .
, , , .
.
.
( DataRelation), . DataSet
DataTable DataRelation.
DataSet - (SQL Server, MS Access,
Oracle) () , (), SQL-
.
Button,
.
. 7.117.13.

. 7.11.

174

7 .

. 7.12.

. 7.13.

, .sln .

60.
Chart
, Toolbox.
Chart.
().
, DataTable.
. .
.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Chart. ToolBox
: Chart
DataGridView. ,
, , . Chart. ,
Chart ,
. Properties

60. Chart

175

() Click.
,
. 7.10
.
7.10. Chart
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// , Chart DataGridView,
// () .
// DataTable
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
// :
Boolean ;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
= false;
this->Text = " ";
DataTable ^ = gcnew DataTable();
// "" "
":
->Columns->Add("", String::typeid);
// C#: .Columns.Add("", typeof(String));
// long:
->Columns->Add(" ", long::typeid);
// C#: .Columns.Add(" ", typeof(long));
// () :
DataRow ^ = ->NewRow();
[""] = ""; [" "] = 15;
->Rows->Add();
// :
= ->NewRow();
[""] = ""; [" "] = 35;
->Rows->Add();
// :
= ->NewRow();
[""] = ""; [" "] = 65;
->Rows->Add();
// :
= ->NewRow();
[""] = ""; [" "] = 85;
->Rows->Add();
// :


176

7 .

7.10 ()
= ->NewRow();
[""] = ""; [" "] = 71;
->Rows->Add();
// :
chart1->DataSource = ;
// .
// , -
// 2009 , -
// 2010 .
// ,
// "Series1"
// :
chart1->Series["Series1"]->XValueMember = "";
// :
chart1->Series["Series1"]->YValueMembers = " ";
// ():
chart1->Titles->Add(" ");
// - :
chart1->Series["Series1"]->ChartType = System::Windows::Forms::
DataVisualization::Charting::SeriesChartType::Column;
// , : Pie, Line .
chart1->Series["Series1"]->Color = Color::Aqua;
// :
chart1->Series["Series1"]->IsVisibleInLegend = false;
// :
chart1->DataBind();
//
dataGridView1->DataSource = ;
}
private: System::Void chart1_Click(System::Object^

sender,
System::EventArgs^

e)

{
// " "
= !;
// :
if ( == true)
chart1->Series["Series1"]["DrawingStyle"] = "Cylinder";
else
chart1->Series["Series1"]["DrawingStyle"] = "Default";
}
};
}


DataTable. . , DataGridView. DataTable
DataGridView, Chart.

60. Chart

177

DataTable ,
. (),
Add.
Chart DataGridView. , .
. 7.14.

. 7.14.

, Chart.
sln Chart.


WebBrowser

61. HTML-
WebBrowser
, ( Windows-),
(, exe-), -, .
Toolbox WebBrowser,
- Windows-.
WebBrowser , HTML :
<tr>, , <td>, .
, HTML-, ,
, WebBrowser
Navigate .
, , HTML -
, WebBrowser,
HTML-. .
. Visual Studio 2010 New Project CLR Visual C++
Windows Forms Application Visual C++. Toolbox
WebBrowser, .
8.1.
8.1. WebBrowser
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}

61. HTML- WebBrowser

179

#pragma endregion
//
// WebBrowser. HTML
// <tr> ( ) <td> ( )
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// ( ) :
webBrowser1->Dock = DockStyle::None;
// webBrowser1.Navigate("c:\\table.htm");
String ^ HTML = "- " +
"<table border> " +
"<caption> </caption> " +
"<tr><td> <td>274-88-17 " +
"<tr><td>-X<td>+38(067)7030356 " +
"<tr><td><td>22-345-72 " +
"<tr><td> <td>009 " +
"</table> " +
"- ";
webBrowser1->Navigate("about:" + HTML);
}
};
}

, . HTML
HTML- ,
. Navigate WebBrowser1, about:. ,
Navigate ,
table.htm.

WebBrowser, . 8.1.

. 8.1. WebBrowser

180

8 WebBrowser

, ,
.
, WebHTM.sln WebHTM.

62. Flash-
PictureBox,
. PictureBox
Flash- SWF.
,
, , SWF- .
,
WebBrowser SWF. Visual Studio 2010
New Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox WebBrowser
. , ,
,
. 8.2.
8.2. Flash-
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// WebBrowser
// Flash-
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// ( ) :
webBrowser1->Dock = DockStyle::None;
// webBrowser1.Navigate("www.mail.ru");
String ^ = IO::Directory::
GetCurrentDirectory() + "\\Shar.swf";
//
if (IO::File::Exists() == false)
{
MessageBox::Show(
" " + + " ", "");
return;
}

63. - HTML-

181

webBrowser1->Navigate();
}
};
}

, Navigate webBrowser1.
Flash- Shar.swf.
GetCurrentDirectory(). ,
- WebBrowser.
Shar.swf
(. 8.2).

. 8.2. Flash- WebBrowser

, , . , FlashWeb.sln FlashWeb.

63. -
HTML-
C++ , -,
, , HTML- .
WebBrowser.
, WebBrowser,
(. 8.3).
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
, WebBrowser ,
. textBox1 URL- - (, www.latino.
ho.ua), textBox2 , HTML .
, (Properties) Multiline =
True. 8.3.

182

8 WebBrowser

8.3. - HTML-
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// WebBrowser
// - HTML-
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^
{
this->Text = "- HTML-";
textBox1->Text = String::Empty;
textBox2->Text = String::Empty;
textBox2->Multiline = true;
textBox2->ScrollBars = ScrollBars::Vertical;
button1->Text = "";
webBrowser1->Dock = DockStyle::None;
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// " ":
webBrowser1->Navigate(textBox1->Text);
// webBrowser1->Navigate("www.latino.ho.ua")
// webBrowser1->GoBack()
//
// webBrowser1->GoForward() //
// webBrowser1->GoHome()
//
}
private: System::Void webBrowser1_DocumentCompleted(
System::Object^ sender, System::Windows::
Forms::WebBrowserDocumentCompletedEventArgs^ e)
{
// "- "
// HTML- WebBrowser:
textBox2->Text = webBrowser1->Document->Body->InnerHtml;
}
};
}

e)

,
. ScrollBars, , Vertical,
.
Navigate
webBrowser1 -
, textBox1.

64. -

183

. , GoBack -,
GoForward , GoHome
-.
, , ,
.
DocumentCompleted , , .
Body->innerHTML Text
textBox2 HTML-, -.
. 8.3 .

. 8.3. - HTML-

, Split.sln
Split.

64. -
, ,
WebBrowser, - -,
-. (,
, ,

.).
Submit ( -) -

184

8 WebBrowser

. WebBrowser , . ,
.
,
Yandex, Rambler, Google .
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Toolbox
WebBrowser. () HTML, -,
Microsoft.mshtml.dll.
, Microsoft , ,
, . , . , , : C:\Program Files\Microsoft Visual Studio 10.0\
Visual Studio Tools for Ofce\PIA\Common.
Project Add Reference, .NET Microsoft.mshtml.
Properties References ()
.
,
8.4.
8.4.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// WebBrowser
// http://yahoo.com. ,
// DomDocument ( WebBrowser),
// IHTMLDocument2.
// - .
// -,
// ""
// Submit. WebBrowser
// , ,
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
this->Text = " ";

64. -

185

// *** "http://google.com":
//String ^ = "http://google.com"
//String ^ = "f";
//String ^ = "q";
// "http://meta.ua":
//String ^ = "http://meta.ua";
//String ^ = "sForm";
//String ^ = "q";
// *** "http://yandex.ru":
//String ^ = "http://yandex.ru";
//String ^ = "form";
//String ^ = "text";
// *** "http://rambler.ru":
//String ^ = "http://rambler.ru";
//String ^ = "rSearch";
//String ^ = "query";
// *** "http://aport.ru":
//String ^ = "http://aport.ru";
//String ^ = "aport_search";
//String ^ = "r";
// *** "http://bing.com":
//String ^ = "http://bing.com";
//String ^ = "sb_form";
// - HTML- name , id = "sb_form"
//String ^ = "q";
// *** "http://yahoo.com":
String ^ = "http://yahoo.com";
String ^ = "sf1"; // "p_13838465-searchform"
String ^ = "p"; // "p_13838465-p"
// - WebBrowser:
webBrowser1->Navigate();
while (webBrowser1->ReadyState !=
WebBrowserReadyState::Complete)
{
Application::DoEvents();
System::Threading::Thread::Sleep(50);
}
if (webBrowser1->Document == nullptr)
{
MessageBox::Show(
", ", "");
return;
}
// DomDocument IHTMLDocument2:
mshtml::IHTMLDocument2 ^ = (mshtml::
IHTMLDocument2 ^)webBrowser1->Document->DomDocument;
// -
// :
mshtml::HTMLFormElement ^ = (mshtml::


186

8 WebBrowser

8.4 ()
HTMLFormElement ^)->forms->item(, nullptr);
if ( == nullptr)
{
MessageBox::Show(String::Format(" " +
" \"{0}\" ", ), "");
return;
}
// () :
mshtml::IHTMLInputElement ^ = (mshtml::
IHTMLInputElement ^)->namedItem();
if ( == nullptr)
{
MessageBox::Show(String::Format(" " +
" \"{0}\" ", ), "");
return;
}
// :
String ^ = " Visual";
->value = ;
// "" "Submit":
->submit();
}
};
}

, .
Yahoo! -, ,
.
: Google, Meta, Yandex, Rambler, Aport Bing.
?
, Internet Explorer,
Yahoo!,
HTML-. HTML- . , Yahoo! <form>.
name, id.
. <form> </form> <input>, .
(type) text, hidden ().
name, id.
.
- ,
.
- WebBrowser,
DomDocument (

65. -

187

WebBrowser), IHTMLDocument2.
- .

-,
Submit. WebBrowser
, ,
(. 8.4).

. 8.4.

,
_.

65. -
WebBrowser
- - (
), WebBrowser.
, -
, -,
. ,
,
. ?
, www.cbr.ru.
,
, ,
. ,
WebClient,
, . ,
WebBrowser .
Visual Studio 2010,
New Project. New Project Visual C++ CLR, ( )
(Templates) Windows Forms Application Visual C++.

188

8 WebBrowser

OK. Tollbox
Label PictureBox.
.
WebClient, System.Net.dll.
Project Add Reference, .NET
System.Net. Properties References ()
.
,
8.5.
8.5. HTML- -

// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// , WebClient, -
// www.cbr.ru,
// Label. ,
// " PictureBox" ,
// URL-
// ~ ~ ~ ~ ~ ~ ~ ~
// : ProjectProperties
// Add Reference, .NET System.Net
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = " ";
// -:
auto = gcnew System::Net::WebClient();
// - Win1251,
// ,
// :
// auto =
//
System::Text::Encoding::GetEncoding(1251);
System::IO::Stream ^ ;
String ^ ;
try
{ // -:
= ->OpenRead("http://www.cbr.ru/");
}
catch (Exception ^ )
{
= String::Format(
"www.cbr.ru\r\n{0}", ->Message);

65. -

189

label1->Text = ;
return;
}
// HTML- -
// Unicode ( ):
auto = gcnew
System::IO::StreamReader(); //, );
// HTML- :
= ->ReadToEnd();
// HTML- :
int i = ->IndexOf(" ");
= ->Substring(i, 300);
i = ->IndexOf("nowrap");
= ->Substring(i + 7);
i = ->IndexOf("&nbsp");
= ->Remove(i);
// :
= String::Format(" {0:D}: {1}",
DateTime::Now, );
->Close();
// :
label1->Text = ;
// :
pictureBox1->ImageLocation =
"http://www.cbr.ru/images/main_logo.gif";
}
};
}

, WebClient, -.
- Unicode. , , , -.
-, (
) .
, Windows1251, Encoding,
,
.
HTML- -,

.
. 8.5.
,
. 8.5.
.sln -

.

MS Word,
MS Excel, AutoCAD MATLAB,
PDF-

66.
MS Word
Microsoft Office OLE-,
.
. ,
- , . CheckSpelling
MS Word.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Toolbox .
, Multiline True ( ).
Button. ,
. 9.1.

. 9.1.

66.

191

MS Word ( ). Project Add Reference.


, MS Office 2003, COM
Microsoft Word 11.0 Object Libary.
MS Office 2007, Microsoft Word 12.0 Object
Library. , :
C:\Program Files\Microsoft Ofce\OFFICE11\MSWORD.OLB ( ...\OFFICE12\MSWORD.OLB
MS Ofce 2007).
, .
Properties References ()
Microsoft.Ofce.Interop.Word. , Interop
Interop.Microsoft.Ofce.Interop.Word.8.4.dll.
, MS Word.
, 9.1.
9.1. ( 1)
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// - ,
//
// .
// CheckSpelling MS Word
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// Project Add Reference.
// , MS Office 2007,
// COM
// Microsoft Word 12.0 Object Libary.
textBox1->Clear(); button1->Text = " ";
textBox1->TabIndex = 0; button1->TabIndex = 1;
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// Word::Application:
auto 1 =
gcnew Microsoft::Office::Interop::Word::Application();
// 1->Visible = false;
// "" :
Object ^ t = Type::Missing;
// MS Word:


192

9 MS Word, MS Excel, AutoCAD MATLAB

9.1 ()
auto = 1->Documents->Add(t, t, t, t);
// MS Word :
->Words->First->InsertBefore(textBox1->Text);
// :
->CheckSpelling(t, t, t, t, t, t, t, t, t, t, t, t);
// :
String ^ = ->Content->default;
// Visual Basic C#
// : = ->Content->Text;
// :
textBox1->Text = ->Replace("\r", "");
Object ^ tt = false;
// tt = Microsoft::Office::Interop::Word::
//
WdSaveOptions::wdDoNotSaveChanges;
1->Documents->Close(tt, t, t);
// Word :
1->Quit(tt, t, t);
1 = nullptr;
}
};
}

, .
Button1_Click
Word::Application, Documents->Add .
Type::Missing
. ( InsertBefore). CheckSpelling. ,
Word::Document,
Content->Text. Visual Basic C#,
: Content->Text.
Visual C++ , ,
default. .
MS Word wdDoNotSaveChanges, .
, . , F5, -
. ,
. 9.2.
,
,
.
9.2 ,
Selection.

66.

193

. 9.2.

9.2. ( 2)
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Clear(); button1->Text = " ";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
auto 1 =
gcnew Microsoft::Office::Interop::Word::Application();
1->Visible = false;
// "" :
auto t = Type::Missing;
// MS Word:
1->Documents->Add(t, t, t, t);
//
1->Selection->default = textBox1->Text;
// VB C# : 1->Selection->Text
// :
1->ActiveDocument->
CheckSpelling(t, t, t, t, t, t, t, t, t, t, t, t);
//
textBox1->Text = 1->Selection->default;


194

9 MS Word, MS Excel, AutoCAD MATLAB

9.2 ()
Object ^ tt = false;
1->Documents->Close(tt, t, t);
// Word :
1->Quit(tt, t, t);
1 = nullptr;
}
};
}


Word::Application , Add, MS Word. 1.Selection, -

, , MS Word
( TypeText). Text MS Word.
: 1->Selection->Text.
, VB C#. C++ , ,
default. .
,
1 2.

67. MS Word
.

MS Word. ,
Visual C++ 2010 (Word, Excel, Access,
PowerPoint . .), AutoCAD CorelDRAW ,
VBA (Visual Basic for Applications),
,
, Visual C++/CLI ( Visual C#).
, VBA-. , ,
MS Word. MS Word,
 ,
OK. MS Word
,  . .
.
Alt+F11 Microsoft Visual Basic,
VBA. ,
, , .

67. MS Word

195

Visual C++ 2010,


, MS Word, . ,
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application Visual C++.
MS Word. Project
Add Reference COM Microsoft Word 11.0 Object Library ( MS Word,
12.0 Object Library). Button,
.
MS Word .
, 9.3.
9.3. MS Word
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// MS Word:
// , ,
// MS Word
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
// Project Add Reference
// COM
// Microsoft Word 12.0 Object Library
button1->Text = ""; this->Text = "c ";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{ // :
array<String^> ^ Imena = {" - ", "-X", "",
" ", " ",
" - ", " ",
" ", " "};
array<String^> ^ Tel = {"274-88-17", "+38(067)7030356",
"22-345-72", "009", "223-67-67 32-67",
"570-38-76", "201-72-23- ",
"001", "216-40-22"};
// Word::_Application:
auto 1 =
gcnew Microsoft::Office::Interop::Word::Application();
1->Visible = true;
// "" :
auto t = Type::Missing;


196

9 MS Word, MS Excel, AutoCAD MATLAB

9.3 ()
// MS Word:
auto = 1->Documents->Add(t, t, t, t);
// MS WORD :
1->Selection->TypeText(" ");
// , , :
System::Object ^ t1 = Microsoft::Office::Interop::
Word::WdDefaultTableBehavior::wdWord9TableBehavior;
// , Word
// :
System::Object ^ t2 = Microsoft::Office::Interop::
Word::WdAutoFitBehavior::wdAutoFitContent;
// 9 2 :
1->ActiveDocument->Tables->Add(1->Selection->Range,
9, 2, t1, t2);
// :
for (int i = 1; i <= 9; i++)
{
1->ActiveDocument->Tables[1]->Cell(i, 1)->
default->InsertAfter(Imena[i - 1]);
1->ActiveDocument->Tables[1]->Cell(i, 2)->
default->InsertAfter(Tel[i - 1]);
// C#, :
// 1.ActiveDocument.Tables[1].Cell(i, 2).
//
Range.InsertAfter(Tel[i - 1]);
}
// MS Word:
Object ^ t3 = Microsoft::Office::Interop::Word::WdUnits::wdLine;
// , MS Word:
Object ^ 9 = 9;
// (Selection) ,
// ( ), - :
1->Selection->MoveDown(t3, 9, t);
// :
1->Selection->TypeText("- ");
// , :
// Object ^ = "C:\\a.doc";
// 1->ActiveDocument->SaveAs(, t, t, t, t, t,
//
t, t, t, t, t, t, t, t, t, t);
}
};
}

, , 44
(. 7). ,
. : Imena[] Tel[]. Word::Application Document::Add.
Type::Missing
. , - -

68. MS Excel Visual C++ 2010

197

C++-. ,
, Selection,
MS Word.
, () ,
(wdAutoFitContent).
(Selection) , - .
, MS Word (. 9.3),
, .

. 9.3. MS Word

, Word.sln Word.

68. MS Excel
Visual C++ 2010
- C++-
Microsoft Excel. MS Excel , , ,
, .
MS Excel, p = 3,14. p Math C++.
, , , MS Excel.

198

9 MS Word, MS Excel, AutoCAD MATLAB

,
MS Excel.
Visual Studio 2010 New Project
CLR Visual C++ Windows Forms Application Visual C++. ,
.
MS Excel,
MS Excel. Project
Add Reference. , MS Office 2003,
COM Microsoft Excel 11.0 Object
Library. MS Office 2007, Microsoft
Excel 12.0 Object Library.
, , MS Word,
,
Visual Studio.
Solution Explorer ( ;
, Ctrl+Alt+L), Add Reference.
, MS Excel. Object Browser ( ). , Ctrl+Alt+J. WorksheetFunction,
Members of 'WorksheetFunction' MS Excel
WorksheetFunction. ,
Pi().
Form1.h[Design]
.
Form1.h
. , 9.4.
9.4. MS Excel
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
// MS Excel = 3,14...
// ~ ~ ~ ~ ~ ~ ~ ~
// Excel,
// Project Add Reference. ,
// MS Office 2007, COM
// Microsoft Excel 12.0 Object Library
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)

69. MS Excel

199

{
// Excel::Application:
auto XL = gcnew Microsoft::Office::Interop::
Excel::Application();
double PI = XL->WorksheetFunction->Pi();
//
this->Text = "PI = " + PI;
XL->Quit();
}
};
}

, . Excel::Application,
MS Excel,
= 3,14.
. 9.4.

. 9.4.

, Excel.sln
Excel.
MS Excel C++-,
. , (
/ ),
MS Excel  .

69.
MS Excel
MS Excel
Visual C++ 2010. , 100 . 15 % , 10 . , . MS Excel
(),
( 0.15/12), (120 )
($100 .). () ()
Pmt() WorksheetFunction, . ,
C#- Pmt()
MS Excel. () WorksheetFunction : http://msdn.
microsoft.com/en-us/library/bb225774.aspx.

200

9 MS Word, MS Excel, AutoCAD MATLAB

,
Visual Studio 2010, MS Excel
WorksheetFunction .
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++. Toolbox ,
( Pmt()) .
MS Excel.
Project Add Reference, COM
Microsoft Excel 12.0 Object Library. ,
9.5.
9.5. MS Excel
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// Pmt()
// MS Excel
//
// ~ ~ ~ ~ ~ ~ ~ ~
// MS Excel Project
// Add Reference. ,
// MS Office 2007, COM
// Microsoft Excel 12.0 Object Library
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = " ";
label1->Text = ". %";
label2->Text = " ";
label3->Text = " ";
textBox1->Clear(); textBox2->Clear(); textBox3->Clear();
button1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
try
{
auto XL = gcnew Microsoft::Office::Interop::
Excel::Application();
// "" :
auto t = Type::Missing;
// :

69. MS Excel

201

double pay = XL->WorksheetFunction->Pmt(


(Convert::ToDouble(textBox1->Text)) / 1200,
Convert::ToDouble(textBox2->Text),
Convert::ToDouble(textBox3->Text), t, t);
// , Pmt()
// Microsoft.VisualBasic:
// double FV = 0;
// Microsoft::VisualBasic::DueDate dt =
//
Microsoft::VisualBasic::DueDate::EndOfPeriod;
// double pay = Microsoft::VisualBasic::Financial::Pmt(
//
(Convert::ToDouble(textBox1->Text)) / 1200,
//
Convert::ToDouble(textBox2->Text),
//
Convert::ToDouble(textBox3->Text), FV, dt);
auto = String::Format(
" {0:$#.##} ",
Math::Abs(pay));
MessageBox::Show();
XL->Quit();
}
catch (Exception ^ )
{
MessageBox::Show(->Message, "",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}
}
};
}

, (Clear) , label1label3 Button1.


Excel::Application. Excel::Application MS Excel, Pmt(). Pmt() ,
Double.
, 1200.
, .
Type::Missing .
Pmt() , ,
MessageBox::Show.
MS Excel try...catch
(Exception). ,
, ,
.
auto, ,

202

9 MS Word, MS Excel, AutoCAD MATLAB

( var C#), Visual C++ 2010.


. 9.5.

. 9.5.

, Excel.
sln Excel.

,
MS Excel .
Pmt() Visual Studio 2010 Microsoft::Visual
Basic::Financial . ( ,
Visual Basic 6.)
Visual Basic, 15 (. 2, ).
Microsoft.VisualBasic.dll.
Project Add Reference, .NET
Microsoft.VisualBasic. Pmt(), .
MS Excel
C++-.

70.
MS Excel
MS Excel, , Visual C++ 2010,
. , , :
X1 + X2 + X3 = 6
X1 + X2 = 3
X2 + X3 = 5
.
:
AX=L
A ; X
X1, X2, X3; L 6, 3, 5.

70. MS Excel

203

:
X = A1 L,
X1 .
MS Excel (), WorksheetFunction Microsoft
Excel MInverse().
() MMult(). Visual Studio 2010,
MS Excel.

Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application Visual C++.
Toolbox Label.
. , MS Excel.
Project Add Reference COM
Microsoft Excel 12.0 Object Library, OK.
( 9.6):
()

. label1.
9.6.
MS Excel
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
// MS Excel
// ~ ~ ~ ~ ~ ~ ~ ~
// MS Excel Project
// Add Reference. ,
// MS Office 2007, COM
// Microsoft Excel 12.0 Object Library
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
// AX = L
// : X = A(-1)L.
// (-1) - "" .
//
// X1 + X2 + X3 = 6


204

9 MS Word, MS Excel, AutoCAD MATLAB

9.6 ()
// X1 + X2
= 3
//
X2 + X3 = 5
// :
// array<double,2> ^ A = gcnew array<double,2>(n, n);
array<double,2> ^ A = { {1, 1, 1},
{1, 1, 0},
{0, 1, 1} };
// :
// array<double> ^ L = gcnew array<double>(n);
// :
array<double> ^ L = { 6, 3, 5 };
// Excel::Application:
auto XL1 = gcnew Microsoft::Office::Interop::
Excel::Application();
//
double det_A = XL1->Application->WorksheetFunction->MDeterm(A);
// det_A != 0, :
if (Math::Abs(det_A) < 0.01)
{
label1->Text = " , \n\n" +
" ";
return;
}
// oA:
Object ^ oA = XL1->Application->
WorksheetFunction->MInverse(A);
// Transpose
// :
Object ^ L = XL1->Application->
WorksheetFunction->Transpose(L);
// :
Object ^ X =
XL1->Application->WorksheetFunction->MMult(oA, L);
// ,
// :
array<Object^,2> ^ Xd = (array<Object^,2> ^)X;
// ,
// :
label1->Text = String::Format(
" :\n\nX1 = {0}; X2 = {1}; X3 = {2}.",
Xd[1, 1], Xd[2, 1], Xd[3, 1]);
}
};
}

, , . ( ) .
WorksheetFunction

71. MS Excel

205

. () , MS Excel Mdeterm().
,
0.01,
label1, .
0.01, MS Excel
MInverse() . ( ) , MS Excel
Transpose ( L).
MS Excel MMult() .
MMult() ,
( ).
label1.
. 9.6. , Excel.sln
Excel.
,

MS Excel. ,
. 9.6.
,

MS Excel.


dll-.

71.
MS Excel
- (, , )
(), , .
.
MS Excel , , , , .
, ()
Visual C++ 2010, ( ) MS Excel.
Visual Studio 2010 New Project CLR
Visual C++ Console Application CLR, .
MS Excel. Project Add Reference,
COM Microsoft Excel 12.0 Object Library
OK. ,
9.7.

206

9 MS Word, MS Excel, AutoCAD MATLAB

9.7. MS Excel
// Excel.cpp: .
// (),
// MS Excel
#include "stdafx.h"
using namespace System;
// :
using namespace Microsoft::Office::Interop::Excel;
// MS Excel Project
// Add Reference. COM
// Microsoft Excel 12.0 Object Library
int main(array<System::String ^> ^args)
{
// Excel::Application:
_Application ^ XL1 = gcnew Application();
XL1->Visible = true;
// " "
// :
Object ^ t = Type::Missing;
// MS Excel:
Workbook ^ = XL1->Workbooks->Add(t);
// :
Sheets ^ = ->Worksheets;
// :
_Worksheet ^ = (_Worksheet ^)->Item[1];
// () :
// _Worksheet ^ = safe_cast<_Worksheet^>(->Item[ (Object^)1 ]);
// :
->Range["A1", t]->Value2 = "";
->Range["A2", t]->Value2 = "";
->Range["A3", t]->Value2 = "";
->Range["A4", t]->Value2 = "";
->Range["A5", t]->Value2 = "";
->Range["A6", t]->Value2 = "";
->Range["B1", t]->Value2 = "";
->Range["B2", t]->Value2 = 138;
->Range["B3", t]->Value2 = 85;
->Range["B4", t]->Value2 = 107;
->Range["B5", t]->Value2 = 56;
->Range["B6", t]->Value2 = 34;
// () :
_Chart ^ = (_Chart ^)XL1->Charts->Add(t, t, t, t);
// :
->SetSourceData(->Range["A2", "B6"], XlRowCol::xlColumns);
// " " ():
->ChartType = XlChartType::xlColumnClustered;
// :
->HasLegend = false;
// :
->HasTitle = true;
->ChartTitle->Caption = " ";

71. MS Excel

207

// X:
Axis ^ = (Axis^)->Axes(
XlAxisType::xlCategory, XlAxisGroup::xlPrimary);
->HasTitle = true;
->AxisTitle->Text = "";
// Y:
Axis ^ = (Axis^)->Axes(
XlAxisType::xlValue, XlAxisGroup::xlPrimary);
->HasTitle = true;
->AxisTitle->Text = " ";
// :
// XL1->ActiveChart->Export("C:\\Excel.jpg", t, t);
return 0;
}

Excel::Application . : i , i .
_Chart. , ,
Chart. , ,
, ,
.
, .
xlColumnClustered,
( ).
.
jpg-
Export(). 9.7, Excel . 9.8.

. 9.7. jpg-

208

9 MS Word, MS Excel, AutoCAD MATLAB

. 9.8. MS Excel

, Excel.
sln Excel.

72. AutoCAD
Visual C++ 2010
-
( , ,
.),
AutoCAD C++-. AutoCAD (Computer-Aided
Design) -
. , Microsoft Office,
OLE-,
.
, ,
, , ,
, , . , , .
C++ 2010, AutoCAD,
dwg-.
AutoCAD, .
.
,
. Visual Studio 2010 New Project CLR Visual C++ Console Application CLR.
AutoCAD,
Project Add Reference, COM ,
AutoCAD 2008 Type Library, AutoCAD/ObjectDBX Common
17.0 Type Library..
, AutoCAD 2008. AutoCAD,
. , dwg- , ,

72. AutoCAD Visual C++ 2010

209

, 9.8.
9.8. AutoCAD
// ACAD.cpp: .
// AutoCAD
// .
// DWG. : AutoCAD 2008,
// , ,
// C:\.dwg AutoCAD
// ~ ~ ~ ~ ~ ~ ~ ~
// AutoCAD.
// ProjectAdd Reference COM AutoCAD 2008 Type Library,
// AutoCAD/ObjectDBX Common 17.0 Type Library
#include "stdafx.h"
using namespace System;
// AutoCAD 2008 Type Library COM:
using namespace AutoCAD;
// AutoCAD/ObjectDBX Common 17.0 Type Library:
using namespace AXDBLib;
int main(array<System::String ^> ^args)
{
// AutoCAD::AcadApplication:
AcadApplication ^ ACAD1 = gcnew AcadApplication();
// " "
// :
Object ^ t = Type::Missing;
AcadDocument ^ = ACAD1->Documents->Add(t);
// :
ACAD1->Visible = true;
// :
array<double> ^ T1 = { 10, 10, 0 };
array<double> ^ T2 = { 200, 200, 0 };
array<double> ^ T3 = { 200, 10, 0 };
array<double> ^ T4 = { 15, 200, 0 };
array<double> ^ T5 = { 100, 100, 0 };
// T1 T2:
->ModelSpace->AddLine(T1, T2);
// T2 T3:
AutoCAD::AcadLine ^ =
->ModelSpace->AddLine(T2, T3);
// T5, 80,
// , 180 :
AutoCAD::AcadArc ^ =
->ModelSpace->AddArc(T5, 80, 0, Math::PI);
// ->ModelSpace->AddArc(T5, 80, 0, Math->PI);
// ( 0 )
->ModelSpace->AddText("", T4, 22);


210

9 MS Word, MS Excel, AutoCAD MATLAB

9.8 ()
// 90 = /2:
AutoCAD::AcadText ^ =
->ModelSpace->AddText("", T1, 22);
// 90 :
->Rotation = Math::PI / 2;
// :
->SaveAs("C:\\.dwg", t, t);
ACAD1->Quit();
return 0;
}

, AcadApplication
AcadDocument.
AutoCAD Visible = True, AutoCAD .
(, , dwg-,
.) ,
. , ,
. ,
, AutoCAD .
AddLine 1, 2 2, 3.
, 90, /2. , SaveAs,
dwg- C.
AutoCAD,
. 9.9.

. 9.9. dwg- AutoCAD

, sln-
ACAD.

73. MATLAB Visual C++ 2010

211

73. MATLAB
Visual C++ 2010
MATLAB C++-.
MATLAB
.
MATLAB 6.5.
MATLAB,
MATLAB . y = sin(x) e x.
Visual Studio 2010 New
Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox
Button, MATLAB .
9.9.
9.9. MATLAB
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// Matlab
// ~ ~ ~ ~ ~ ~ ~ ~
//
// ProjectReference.
// MATLAB
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
button1->Text = " MATLAB";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// MATLAB:
Type ^ =
Type::GetTypeFromProgID("Matlab.Application");
// MATLAB:
Object ^ = Activator::CreateInstance();
// MATLAB:
array<Object^> ^ =
// { "surf(peaks)" };
{ "x = 0:0.1:6.28; y = sin(x).*exp(-x); plot(x,y)" };


212

9 MS Word, MS Excel, AutoCAD MATLAB

9.9 ()
// { "s = sin(0.5); c = cos(0.5); y = s*s+c*c; y" };
// MATLAB, :
Object ^ =
->InvokeMember("Execute", System::Reflection::
BindingFlags::InvokeMethod, nullptr, , );
MessageBox::Show(->ToString());
}
};
}

,
MATLAB.
. MATLAB,
. x = 0:0.1:6.28; x (
) 2 (6,28) 0,1. y = sin(x).*exp(-x); . plot
y x. Execute MATLAB
. MATLAB (. 9.10).

. 9.10. , MATLAB

, , MATLAB.
, Matlab.
sln Matlab.

74. MATLAB

213

74.
MATLAB
MATLAB
, ( . Think vectorized). , MATLAB
, MATLAB,
(matrix laboratory). ,
, , ,
MATLAB.
.
X1 + X2 + X3 = 6
X1 + X2 = 3
X2 + X3 = 5
.
Visual Studio 2010 New
Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox
Button. 9.10.
9.10. MATLAB
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// ,
// MATLAB, .
// , MessageBox
// ~ ~ ~ ~ ~ ~ ~ ~
//
// ProjectReference.
// MATLAB
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
button1->Text = " ";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// AX = L
// : X = A(-1)L.
// (-1) - "" .


214

9 MS Word, MS Excel, AutoCAD MATLAB

9.10 ()
//
// X1 + X2 + X3 = 6
// X1 + X2
= 3
//
X2 + X3 = 5
// MATLAB
:
// A = [1 1 1; 1 1 0; 0 1 1]; L = [6; 3; 5];
// % A L
// X = inv(A)*L % L" };
// % - MATLAB
// MATLAB:
Type ^ = Type::GetTypeFromProgID("Matlab.Application");
// MATLAB:
Object ^ = Activator::CreateInstance();
// MATLAB:
array<Object^> ^ =
{ "A = [1 1 1; 1 1 0; 0 1 1]; L = [6; 3; 5]; " +
"X = inv(A)*L % inv" };
// MATLAB, :
Object ^ = ->InvokeMember("Execute",
Reflection::BindingFlags::InvokeMethod,
nullptr, , );
// :
// MessageBox::Show(->ToString());
// ,
// double .
// GetFullMatrix
// MATLAB,
Reflection::ParameterModifier p =
Reflection::ParameterModifier(4);
p[0] = false; p[1] = false; p[2] = true; p[3] = true;
array<Reflection::ParameterModifier> ^ mods = { p };
array<double,2> ^ X = gcnew array<double,2>(3, 1);
array<Object^> ^ =
{ "X", "base", X, gcnew array<double>(0) };
// "X" - , .
// "base" MATLAB,
// "X".
= ->InvokeMember("GetFullMatrix",
Reflection::BindingFlags::InvokeMethod, nullptr, ,
, mods, nullptr, nullptr);
// X:
X = (array<double,2>^)[2];
String ^ = String::Format(
"X1 = {0}; X2 = {1}; X3 = {2};",
X[0, 0], X[1, 0], X[2, 0]);
MessageBox::Show();
}
};
}

75. PDF-

215

,
. MATLAB,
Execute, , , MessageBox.

Double, . ,
, Split, ,
.
( 9.10).
GetFullMatrix. .
. X, , MATLAB,
base (workspace) MATLAB,
X. , MATLAB
: base global.
X,
MATLAB, , ,
. . 9.11 . 9.11.
.

MATLAB
The MathWorks, MATLAB, www.

mathworks.com.
MATLAB
, Matlab.sln Matlab.

75. PDF-

, (, -
), , . , ,
, ,
.
- -,
, , , , ,
.
PDF-. PDF ,

216

9 MS Word, MS Excel, AutoCAD MATLAB

. PDF
. PDF- ,
.
, ,
,
. PDF- Adobe Reader, -, Internet Explorer
Mozilla Firefox ( PDF- ).
PDF-
(on the fly) -. , Microsoft
- C++ (
Visual Basic Visual C# Visual Studio
). PDF- Windows-.
,
. ,
.
, , . Visual Studio 2010 New Project
CLR Visual C++ Console Application CLR.
_PDF_1. Microsoft
PDF, itextsharp.dll, iText Software
www.itextsharp.com.
( ),
( www.piter.com).
.
ProjectProperties Add Reference,
Browse () . 9.11.
9.11. PDF-,
// _PDF_1.cpp: .
// " " PDF-
#include "stdafx.h"
// itextsharp.dll:
// ProjectPropertiesAdd References Browse ()
// itextsharp.dll.
using namespace System;
// :
using namespace iTextSharp::text;
using namespace iTextSharp::text::pdf;
int main(array<System::String ^> ^args)
{
// PDF-:
Document ^ = gcnew Document();

75. PDF-

217

PdfWriter::GetInstance(, gcnew System::IO::FileStream(


".pdf", System::IO::FileMode::Create));
->Open();
->Add(gcnew Paragraph("Hello ! \n Do you like C++ ?"));
->Close();
// PDF- Adobe Acrobat,
// :
System::Diagnostics::Process::Start(".pdf");
return 0;
}

, PDF- Document
itextsharp.dll. .
pdf (Close). (Paragraph) . PDF-
Adobe Acrobat, , ,
, PDF- -, Internet
Explorer. , .
, , PDF- .
Windows 1251. , . Visual Studio 2010 New Project CLR
Visual C++ Console Application CLR. _PDF_2. , ,
itextsharp.dll.
9.12.
9.12. PDF-
// _PDF.cpp: .
// " " PDF-
#include "stdafx.h"
// itextsharp.dll:
// ProjectPropertiesAdd References Browse ()
// itextsharp.dll.
using namespace System;
// :
using namespace iTextSharp::text;
using namespace iTextSharp::text::pdf;
int main(array<System::String ^> ^args)
{
// PDF-:
Document ^ = gcnew Document();
PdfWriter::GetInstance(, gcnew System::IO::FileStream(
".pdf", System::IO::FileMode::Create));
->Open();
// , Windows:
BaseFont ^ = BaseFont::CreateFont(
//"C:\\WINDOWS\\Fonts\\comic.ttf", "CP1251", BaseFont::EMBEDDED);


218

9 MS Word, MS Excel, AutoCAD MATLAB

9.12 ()
//"C:\\WINDOWS\\Fonts\\times.ttf", "CP1251", BaseFont::EMBEDDED);
"C:\\WINDOWS\\Fonts\\CONSOLA.TTF", "CP1251", BaseFont::EMBEDDED);
// 10 .
// Font::ITALIC () Font::BOLD ():
Font ^ = gcnew Font(, 10, Font::NORMAL);
->Add(gcnew Paragraph(
" !\n C++ ?", ));
->Close();
// PDF- -:
// System.Diagnostics.Process.Start("IExplore.exe", System.IO.
//
Directory.GetCurrentDirectory() + "\\.pdf");
// PDF- Adobe Acrobat,
// :
System::Diagnostics::Process::Start(".pdf");
return 0;
}

PDF-,
,
C:\Windows\Fonts. ,

, , . 14 , :
 Times (, , );
 Courier (, , );
 Helvetica (, , );
 Symbol;
 Zapf Dingbats.

. ,
, , ,
, ,
, .
- PDF Adobe Reader (. 9.12).

. 9.12. PDF-

76. PDF-

219

, _PDF_1 _PDF_2.

76. PDF-
PDF- - . itextsharp.dll iText Software (. )
. . A4.
. . 9.12. ,
.
,
, ,
- , - . , .
, :
PDF-. Visual Studio 2010
New Project CLR Visual C++ Console
Application CLR. _PDF__1. itextsharp.dll.
ProjectProperties Add Reference,
Browse () .
9.13.
9.13. PDF- ( 1)
// _PDF__1.cpp: .
// " " PDF-
// ""
#include "stdafx.h"
using namespace System;
// :
using namespace iTextSharp::text;
using namespace iTextSharp::text::pdf;
int main(array<System::String ^> ^args)
{
// :
array<String^> ^ __ = { "N /", "1", "2", "3" };
array<String^> ^ =
{ "", "", "", "" };
array<String^> ^ = { "", "", "", "" };
array<String^> ^ =
{ "", "2 760 000", "10 380 000", " 1 740 000" };
// PDF-:
Document ^ = gcnew Document();


220

9 MS Word, MS Excel, AutoCAD MATLAB

9.13 ()
PdfWriter ^ = PdfWriter::GetInstance(, gcnew System::
IO::FileStream("1.pdf", System::IO::FileMode::Create));
// System::IO::FileMode::Create - ,
// ,
->Open();
// Windows:
BaseFont ^ = BaseFont::CreateFont(
//"C:\\WINDOWS\\Fonts\\comic.ttf", "CP1251", BaseFont::EMBEDDED);
"C:\\WINDOWS\\Fonts\\times.ttf", "CP1251", BaseFont::EMBEDDED);
//"C:\\WINDOWS\\Fonts\\CONSOLA.TTF", "CP1251", BaseFont::EMBEDDED);
// 10 .
// Font::ITALIC () Font::BOLD ():
Font ^ = gcnew Font(, 12, Font::NORMAL);
// :
->Color = BaseColor::BLUE;
// :
->Add(gcnew Paragraph(" :\n\n", ));
// :
PdfPTable ^ = gcnew PdfPTable(4);
// :
->HorizontalAlignment = Element::ALIGN_CENTER; // ALIGN_LEFT;
PdfPCell ^ = gcnew PdfPCell(gcnew Phrase("", ));
// :
array<float> ^ = { 10.0f, 30.0f, 30.0f, 30.0f };
->SetTotalWidth();
// :
->GrayFill = 0.92f;
// :
->FixedHeight = 20.0f;
// :
->BorderColor = BaseColor::BLUE;
// :
->HorizontalAlignment = Element::ALIGN_LEFT; // ALIGN_CENTER;
->VerticalAlignment = Element::ALIGN_MIDDLE;
// :
for (int i = 0; i <= 3; i++)
{
->Phrase = gcnew Phrase(__[i], );
->AddCell();
->Phrase = gcnew Phrase([i], );
->AddCell();
->Phrase = gcnew Phrase([i], );
->AddCell();
->Phrase = gcnew Phrase([i], );
->AddCell();
}
->Add();
->Add(gcnew Paragraph(" ", ));

76. PDF-

221

->Close(); ->Close();
// PDF- -:
System::Diagnostics::Process::Start("IExplore.exe", System::IO::
Directory::GetCurrentDirectory() + "\\1.pdf");
// PDF- Adobe Acrobat,
// :
// System::Diagnostics::Process::Start(".pdf");
return 0;
}

,
PDF- ,
. , ,
PdfPTable. .
, , .
, PdfPCell.
. PDF-
Internet Explorer.
. 9.13.

. 9.13. Internet Explorer PDF-

, .
PDF- .
, ,
.
, ,
Visual Studio 2010 New Project CLR Visual C++ Console Application CLR. _PDF__2.

itextsharp.dll.
ProjectProperties Add Reference, Browse ()

222

9 MS Word, MS Excel, AutoCAD MATLAB

.
9.14.
9.14. PDF- ( 2)
// _PDF__2.cpp: .
// " " PDF-
// ""
#include "stdafx.h"
using namespace System;
// :
using namespace iTextSharp::text;
using namespace iTextSharp::text::pdf;
int main(array<System::String ^> ^args)
{
// :
array<String^> ^ = { "", "", "",
"" };
array<String^> ^ = { "", "", "", "" };
// PDF-:
Document ^ = gcnew Document();
PdfWriter ^ = PdfWriter::GetInstance(, gcnew System::
IO::FileStream(".pdf", System::IO::FileMode::Create));
// System::IO::FileMode::Create - ,
// ,
->Open();
// Windows:
BaseFont ^ = BaseFont::CreateFont(
//"C:\\WINDOWS\\Fonts\\comic.ttf", "CP1251", BaseFont::EMBEDDED);
"C:\\WINDOWS\\Fonts\\times.ttf", "CP1251", BaseFont::EMBEDDED);
//"C:\\WINDOWS\\Fonts\\CONSOLA.TTF", "CP1251", BaseFont::EMBEDDED);
// 10 .
// Font.ITALIC () Font.BOLD ():
Font ^ = gcnew Font(, 10, Font::NORMAL, BaseColor::BLUE);
// : ->Color = BaseColor::RED;
PdfPTable ^ = gcnew PdfPTable(2);
PdfPCell ^ = gcnew PdfPCell();
->HorizontalAlignment = Element::ALIGN_LEFT;//.ALIGN_CENTER;
// :
->Colspan = 2;
// :
->Border = 0;
// :
->FixedHeight = 16.0f;
->Phrase = gcnew Phrase("- ", );
->AddCell();
->BackgroundColor = BaseColor::LIGHT_GRAY;
// :
->Colspan = 1;
// :

76. PDF-

223

->Border = 15;
for (int i = 0; i <= 3; i++)
{
->Phrase = gcnew Phrase([i], );
->AddCell();
->Phrase = gcnew Phrase([i], );
->AddCell();
}
->Colspan = 2; //
->Border = 0; //
->Phrase = gcnew Phrase(" ", );
->BackgroundColor = BaseColor::WHITE;
->AddCell();
// :
->TotalWidth = ->PageSize->Width - 400;
// -
// :
->WriteSelectedRows(0, -1, 40, ->PageSize->Height - 30,
->DirectContent);
->Close(); ->Close();
// PDF- -:
System::Diagnostics::Process::Start("IExplore.exe", System::IO::
Directory::GetCurrentDirectory() + "\\.pdf");
return 0;
}


WriteSelectedRows,
. ,
HTML-. HTML-
, - ,
.
. 9.14.

. 9.14. Internet Explorer

224

9 MS Word, MS Excel, AutoCAD MATLAB

, _PDF__1 _PDF__2.

77.
PDF-
PDF-
, PDF-.
Visual Studio 2010 New Project CLR
Visual C++ Console Application CLR. _PDF__1. itextsharp.dll. ProjectProperties Add
Reference, Browse () .
9.15.
9.15. PDF-
// _PDF__1.cpp: .
// PDF- ,
// . ,
// . .
// .
//
#include "stdafx.h"
using namespace System;
// :
using namespace iTextSharp::text;
using namespace iTextSharp::text::pdf;
int main(array<System::String ^> ^args)
{
// PDF-:
Document ^ = gcnew Document();
PdfWriter ^ = PdfWriter::GetInstance(, gcnew System::
IO::FileStream(".pdf", System::IO::FileMode::Create));
// System::IO::FileMode::Create - ,
// ,
->Open();
// Windows:
BaseFont ^ = BaseFont::CreateFont(
"C:\\WINDOWS\\Fonts\\comic.ttf", "CP1251", BaseFont::EMBEDDED);
// 10 ::
// Font::ITALIC () Font::BOLD ():
Font ^ = gcnew Font(, 10, Font::NORMAL, BaseColor::BLUE);
// : ::Color = BaseColor::RED;
PdfPTable ^ = gcnew PdfPTable(2);
PdfPCell ^ = gcnew PdfPCell();
->HorizontalAlignment = Element::ALIGN_CENTER;

77. PDF-

225

// :
->Colspan = 2;
// :
->Border = 0;
// :
->FixedHeight = 16.0F;
->Phrase = gcnew Phrase(
" ?", );
->AddCell();
// :
->Colspan = 1;
// :
->Border = 15;
// :
->FixedHeight = 83.0F;
// :
->Image = Image::GetInstance("C:\\g.jpg");
->AddCell();
->Image = Image::GetInstance("C:\\m.jpg");
->AddCell();
->Colspan = 2; //
->Border = 0; //
->Phrase = gcnew Phrase(
", , ?", );
->BackgroundColor = BaseColor::WHITE;
->AddCell();
// :
->TotalWidth = ->PageSize->Width - 380;
// -
// :
->WriteSelectedRows(0, -1, 40,
->PageSize->Height - 30, ->DirectContent);
->Close(); ->Close();
// PDF- -:
System::Diagnostics::Process::Start("IExplore.exe", System::IO::
Directory::GetCurrentDirectory() + "\\.pdf");
return 0;
}

,

.
. 9.15.
, PDF-, . ,
. , , ,
Graphics, PDF. CLR,

226

9 MS Word, MS Excel, AutoCAD MATLAB

, Graphics,
(
). , , , PDF-.

. 9.15.

Visual Studio 2010 New Project


CLR Visual C++ Console Application CLR.
_PDF__2. , , System.Drawing.
dll. Project Properties Add Reference,
.NET System.Drawing. itextsharp.dll
PDF-. ProjectProperties
Add Reference, Browse () .
9.16.
9.16. , ,
PDF-
// _PDF__2.cpp: .
// Graphics.
// .
// , , ,
// .
//
// PDF-
#include "stdafx.h"
// :
// System.Drawing.dll itextsharp.dll
using namespace System;

77. PDF-

227

// :
using namespace iTextSharp::text;
using namespace iTextSharp::text::pdf;
int main(array<System::String ^> ^args)
{
// 215 x 35
// 24
auto = gcnew System::Drawing::
Bitmap(415, 35, System::Drawing::
Imaging::PixelFormat::Format24bppRgb);
// Graphics :
auto = System::Drawing::Graphics::FromImage();
auto 1 = System::Drawing::PointF(20.0f, 20.0f);
auto 2 = System::Drawing::PointF(360.0f, 20.0f);
auto = gcnew
System::Drawing::Drawing2D::LinearGradientBrush(1, 2,
System::Drawing::Color::Yellow, System::Drawing::Color::Red);
auto = gcnew System::Drawing::Font("Times gcnew Roman", 14.0F);
->Clear(System::Drawing::Color::White);
// 356 :
->RotateTransform(356.0F);
// 20.0f, 20.0f - :
->DrawString(" PDF-",
, , 20.0f, 20.0f);
// :
delete ; // C#: .Dispose();
// PDF-:
Document ^ = gcnew Document();
PdfWriter ^ = PdfWriter::GetInstance(, gcnew System::
IO::FileStream(".pdf", System::IO::FileMode::Create));
->Open();
auto = iTextSharp::text::Image::
GetInstance(, BaseColor::WHITE);
->Add();
->Close();
delete ; // C#: .Dispose();
System::Diagnostics::Process::Start(".pdf");
return 0;
}

, Graphics Image .
,
.
(. 9.16). GetInstance PDF-.
PDF- (. . 9.16).

228

9 MS Word, MS Excel, AutoCAD MATLAB

. 9.16. , Graphics

, _PDF__1 _PDF__2.

10


ADO.NET
78. SQL Server

, SQL Server
Visual Studio 2010. , ,
: , .
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++,
_SQL_Server. SQL Server.
Project Add Existing Item ( )
. sdf,
_SQL_Server.sdf. Visual Studio 2010
C++ sdf.
, _SQL_
Server.sdf. , ,
.
Server Explorer ( ).
_SQL_Server.sdf Tables ().
Tables, Create Table ( ). New Table. ( Name) .
, . 10.1.

230

10 ADO.NET

. 10.1.

OK, New Table.


( ),
( ). , (
) .
,
:
. ,
, ,
, . !
, Server Explorer
Tables. Edit Table Schema,
Allow Nulls ( ) No,
( ) .
Unique ( ?) No,
, . ,
(Primary KeyYes). OK
Edit Table .
. Server Explorer
Show Table Data
( ). ,
. 10.2, .

. 10.2.

79. SQL Server

231

,
. File Save All . ,
_SQL_Server.sdf. Microsoft
Visual Studio 2010 .
_SQL_Server.

79.
SQL Server
, SQL Server, _SQL_Server.
sdf, , ,
, , .
,
, C: Visual Studio 2010,
New Project CLR Visual C++
Console Application CLR. _SQL_Server_.
SQL Server System.Data.SqlServerCe.dll.
Project Properties Add Reference .NET
System.Data.SqlServerCe. .
10.1. SQL Server
// _SQL_Server_.cpp: .
// SQL Server ( *.sdf)
// Command DataReader
#include "stdafx.h"
using namespace System;
// System.Data.SqlServerCe.dll,
// : ProjectPropertiesAdd Reference
// .NET System.Data.SqlServerCe,
// :
using namespace System::Data::SqlServerCe;
int main(array<System::String ^> ^args)
{
// Connection:
SqlCeConnection ^ = gcnew SqlCeConnection();
// :
->ConnectionString = "Data Source=\"C:\\_SQL_Server.sdf\"";
->Open();
// Command: SQL-
SqlCeCommand ^ = gcnew SqlCeCommand();


232

10 ADO.NET

10.1 ()
->Connection = ;
// Command SQL-:
->CommandText = "Select * From [ ]";
// :
// "":
// .CommandText = "Select * From [ ] order by ";
// " ":
// .CommandText =
//
"Select * From [ ] ORDER BY [ ]";
// SQL- :
SqlCeDataReader ^ = ->
ExecuteReader(System::Data::CommandBehavior::CloseConnection);
// :
Console::Title = " :";
Console::BackgroundColor = ConsoleColor::Cyan; // -
Console::ForegroundColor = ConsoleColor::Black; // -
Console::Clear();
// () :
Console::WriteLine("{0,-11} {1,-11} {2,-15}\n", ->GetName(0),
->GetName(1), ->GetName(2));
while (->Read() == true)
// , .
// .FieldCount - .
// : 0, 1 2.
// :
Console::WriteLine("{0,-11} {1,-11} {2,-15}", ->GetValue(0),
->GetValue(1), ->GetValue(2));
->Close(); ->Close();
// - :
Console::ReadKey();
return 0;
}

, Connection .
sdf- (\"). ,
, .
Command SQL:
Select * From [ ]

[ ]. SQL - . ,
SQL-: (ORDER BY ) (ORDER BY [
]).
, DataReader, SQL-.
. DataReader

MS Access

233

() . DataReader Read, true,


, false, () .
DataReader .
. 10.3.

. 10.3. SQL Server

, sln- _SQL_Server_.

MS Access
() vic.mdb Access MS Office.
, - , ( ) 100 .
() .
.
,
. () : /,
. Microsoft
Access, (
Ctrl+N), vic.
mdb. vic: . (
): /, ;
, ; , .
, :
. ,
. ,
, .
. , .

. (. 10.4).

234

10 ADO.NET

. 10.4. MS Access

Access vic.mdb
Visual Studio 2010.

80.
MS Access Visual Studio

Visual Studio 2010, . Visual Studio.
ViewServer Explorer (
Ctrl+Alt+S). ,
Data Connections, Add Connection
(Data source) Microsoft Access Database File (OLE DB), Change.
Browse , C:\vic.mdb.
Test Connection.
, . 10.5.
, OK. Server
Explorer , , , .
Retrieve Data.
,
. 10.6. ,
(Update), (Insert), ,
. 10.5.
(Delete). ,

81. MS Access

235

PaneSQL, SQL- ,
Select.

. 10.6. Visual Studio

81.
MS Access
Command DataReader
,
( ) .
ADO.NET. . Connection .
Command SQL-
. DataSet DataReaders .
: Select (
), Insert ( ), Update (
), Delete ( ).
Visual Studio 2010 New Project CLR
Visual C++ Console Application CLR. DataReader. .
MessageBox::Show,
MessageBox::Show , ,
, .
Courier New Consolas, MessageBox
.
, DOS.
,
. , . ()

236

10 ADO.NET

, , .
10.2.
10.2. MS Access
// DataReader1.cpp: .
// MS Access
// Command DataReader
#include "stdafx.h"
using namespace System;
// :
using namespace System::Data::OleDb;
int main(array<System::String ^> ^args)
{
// :
Console::ForegroundColor = ConsoleColor::White;
// Connection
auto = gcnew OleDbConnection();
// :
->ConnectionString = "Data Source=\"C:\\vic.mdb\";User " +
"ID=Admin;Provider=\"Microsoft.Jet.OLEDB.4.0\";";
->Open();
// Command:
auto = gcnew OleDbCommand();
->Connection = ;
// SQL-:
->CommandText = "Select * From [ ]";
// "":
// ->CommandText = "Select * From [ ] order by ";
// " /":
// ->CommandText =
//
"Select * From [ ] ORDER BY ' /'";
// SQL-:
OleDbDataReader ^ = ->
ExecuteReader(System::Data::CommandBehavior::CloseConnection);
Console::WriteLine(" :\n");
while (->Read() == true)
// , .
// ->FieldCount - .
// : 0, 1 2.
// :
Console::WriteLine("{0,-3} {1,-15} {2,-15}", ->GetValue(0),
->GetValue(1), ->GetValue(2));
->Close(); ->Close();
// - :
Console::ReadKey();
return 0;
}

82. MS Access

237

, Connection .
mdb- . ,
, .
Command SQL:
Select * From [ ]

[ ]. SQL - . ,
SQL-: (ORDER BY ) / (ORDER BY ' /').
, DataReader, SQL-.
. DataReader
() . DataReader Read, true,
, false, () .
DataReader .
. 10.7.

. 10.7.

,
. ,
.
,
DataReader.

82. MS Access

, Access,
new_BD.mdb. , .
Visual C++ 2010, MS Access. ,
ADO.NET .

238

10 ADO.NET

Visual Studio 2010 New Project CLR


Visual C++ Console Application CLR. DLL- ADOX : Project
PropertiesAdd Reference, COM
Microsoft ADO Ext. 2.8 for DDL and Security, . , ,
Properties. , References, ADOX.
. , 10.3.
10.3.
// .cpp: .
// MS Access, new_BD.mdb.
// , .
//
// C++ 2010, MS Access.
// ADO.NET
#include "stdafx.h"
// ADOX: ProjectAdd Reference,
// COM Microsoft ADO Ext. 2.8 for DDL and Security
using namespace System;
// MessageBox :
// ProjectAdd Reference .NET
// System.Windows.Forms.dll, :
using namespace System::Windows::Forms;
int main(array<System::String ^> ^args)
{
ADOX::Catalog ^ = gcnew ADOX::Catalog();
try
{
->Create("Provider=Microsoft.Jet." +
"OLEDB.4.0;Data Source=C:\\new_BD.mdb");
MessageBox::Show(" C:\\new_BD.mdb ");
}
catch (System::Runtime::InteropServices::COMException ^ )
{ MessageBox::Show(->Message); }
finally
{ = nullptr; }
return 0;
}

MessageBox , dll-. , ,
ProjectPropertiesAdd Reference .NET
System.Windows.Forms.dll, :
Using namespace System::Windows::Forms;

using ,
MessageBox.

83.

239

: ADOX::catalog, Create ,
. ,
. Create try...catch, .
(. 10.8).
, ,
(. 10.9), new_BD.mdb
.

. 10.8.

. 10.9.

.
, .sln .

83.
MS Access.

ADO.NET. , ,
, .
, . ,
.
new_BD.mdb C:,
MS Access , . ,
. Visual Studio 2010 New Project
CLR Visual C++ Console Application CLR. , 10.4.
10.4. MS Access
//
//
//
//

.cpp: .
MS Access.
.
, .


240

10 ADO.NET

10.4 ()
// ,
#include "stdafx.h"
using namespace System;
// MessageBox :
// ProjectAdd Reference .NET
// System.Windows.Forms.dll, :
using namespace System::Windows::Forms;
//
// :
using namespace System::Data::OleDb;
int main(array<System::String ^> ^args)
{ // :
// Connection
// :
auto = gcnew OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\new_BD.mdb");
// :
->Open();
// Command
// SQL-:
auto = gcnew OleDbCommand("CREATE TABLE [" +
" ] ([ /] counter, [] ch" +
"ar(20), [ ] char(20))", );
try // SQL:
{
->ExecuteNonQuery();
MessageBox::Show(
" ' ' ");
}
catch (Exception ^ )
{ MessageBox::Show(->Message); }
->Close();
return 0;
}

MessageBox::Show DLL-. ProjectProperties


Add Reference .NET System.Windows.Forms.dll.
, Connection
, . Command SQL-.
(CREATE) :
/ (counter), . , .
SQL-, ExecuteNonQuery,
try...catch . SQL , :
' ' . , ,

84. MS Access

241

,
catch ( ),
, (. 10.10).
, . 10.10.
Connection

Open.

SQL- Command
ExecuteNonQuery. , , ,
, , ( ,
) .
, .sln .

84.
MS Access

, . ,

. Command SQL- (INSERT) .
, SQL- [
], , . ,
,
(case-sensitive search).
,
(case-insensitive search).
Connection Command
Connection:
->Connection = ;

, .
, 10.5.
10.5. MS Access
// .cpp: .
// MS Access.
// Command SQL-
// (Insert)
#include "stdafx.h"
using namespace System;


242

10 ADO.NET

10.5 ()
// MessageBox :
// ProjectAdd Reference .NET
// System.Windows.Forms.dll, :
using namespace System::Windows::Forms;
//
// :
using namespace System::Data::OleDb;
// :
int main(array<System::String ^> ^args)
{
// Connection
// :
auto = gcnew OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\new_BD.mdb");
// :
->Open();
// Command SQL-:
auto = gcnew OleDbCommand(
"INSERT INTO [ ] (" +
", [ ]) VALUES (-X, 521-61-41)");
// :
->Connection = ;
// SQL:
->ExecuteNonQuery();
MessageBox::Show(" ' ' ");
->Close();
return 0;
}

, Visual Studio C++,


, , , ,
SQL-. MS Access, SQL- . Visual Studio. View Other
WindowsServer Explorer ( Ctrl+Alt+S), . ,
, Retrieve Data.
(Toolbar) SQL, ( Ctrl+3) SQL-.
SQL-, , ,
, , .
, .sln .

85.

243

85.
c
Command, DataReader
DataGridView
,
DataGridView ( , ) Command DataReader .
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Toolbox
DataGridView . Form1.h , 10.6.
10.6.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
// Command, DataReader DataGridView ( )
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
// Connection :
auto = gcnew OleDb::OleDbConnection(
"Data Source=\"C:\\vic.mdb\";User " +
"ID=Admin;Provider=\"Microsoft.Jet.OLEDB.4.0\";");
->Open();
// Command, SQL-
auto = gcnew OleDb::
OleDbCommand("Select * From [ ]", );
// SQL-
auto = -> ExecuteReader();
// (CommandBehavior.CloseConnection)
auto = gcnew DataTable();
// ""
->Columns->Add(->GetName(0));
->Columns->Add(->GetName(1));
->Columns->Add(->GetName(2));
while (->Read() == true)


244

10 ADO.NET

10.6 ()
// ()
->Rows->Add(->GetValue(0),
->GetValue(1), ->GetValue(2));
// : 0, 1 2
->Close(); ->Close();
dataGridView1->DataSource = ;
}
};
}

, . SQL- DataTable,
(DataSource) dataGridView1.
, , Add.
, , While .
. 10.11.

. 10.11. DataGridView

,
. () , (
).
DataReader
.

.
, ReaderGridView.sln ReaderGridView.

86. DataGridView

245

86.
DataGridView
Command, Adapter DataSet
Adapter DataSet.
, DataSet,
DataGridView ( , ),
DataGridView DataSet.
DataGridView, . , , Visual Studio 2010
New Project CLR Visual C++ Windows Forms
Application Visual C++. Toolbox
DataGridView , . 10.12.

. 10.12.

, 10.7.
10.7. DataGridView
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// DataGridView
// Command, Adapter DataSet
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^
{
this->Text = " :";
auto = gcnew OleDb::OleDbConnection(
"Data Source=\"C:\\vic.mdb\";User " +

e)

246

10 ADO.NET

10.7 ()
"ID=Admin;Provider=\"Microsoft.Jet.OLEDB.4.0\";");
->Open();
auto = gcnew OleDb::OleDbCommand(
"Select * From [ ]", );
// ,
// "":
// auto =
//
gcnew OleDb::OleDbCommand("SELECT * FRO" +
//
"M [ ] WHERE ( LIKE %)", );
// Adapter SQL-
auto = gcnew OleDb::OleDbDataAdapter();
// DataSet
auto = gcnew DataSet();
// DataSet SQL-
->Fill(, " ");
// DataSet XML :
auto XML = ->GetXml();
// :
dataGridView1->DataSource = ;
// :
dataGridView1->DataMember = " ";
->Close();
}
};
}

, Connection,
. , Command,
SQL- .
SQL-. ,
SELECT LIKE,
, . LIKE
(pattern matching) () (*) (?).
. ,
% * LIKE-.
Adapter SQL-
Fill DataSet ,
SQL-.
dataGridView1 DataSet.
SQL- (. 10.13).
DataReader , .
() , ( ).

87. MS Access

247

. 10.13. SQL-

,
DataGridView, ,
.
, GridView.sln GridView.

87.
MS Access
(Select, Insert, Update
Delete) (Update, ) .

, () .
,
DataGridView,
. , , ,
, .
Visual Studio 2010 New Project
CLR Visual C++ Windows Forms Application
Visual C++. Toolbox DataGridView
. 10.8.
10.8. MS Access
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}


248

10 ADO.NET

10.8 ()
#pragma endregion
// (Update) MS Access
// ~ ~ ~ ~ ~ ~ ~ ~
// ,
// :
DataSet ^ ;
OleDb::OleDbDataAdapter ^ ;
OleDb::OleDbConnection ^ ;
OleDb::OleDbCommand ^ ;
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
= gcnew DataSet();
= gcnew OleDb::
OleDbConnection( // :
"Data Source=\"C:\\vic.mdb\";User " +
"ID=Admin;Provider=\"Microsoft.Jet.OLEDB.4.0\";");
= gcnew OleDb::OleDbCommand();
button1->Text = " "; button1->TabIndex = 0;
button2->Text = " ";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
if (->State ==
ConnectionState::Closed) ->Open();
= gcnew OleDb::OleDbDataAdapter(
"Select * From [ ]", );
// DataSet SQL-
->Fill(, " ");
// DataSet XML :
String ^ XML = ->GetXml();
// :
dataGridView1->DataSource = ;
// :
dataGridView1->DataMember = " ";
->Close();
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{ //
->CommandText = "UPDATE [ ] SET [" +
" ] = ?, = ? WHERE ([ /] = ?)";
// ,
->Parameters->Add(" ",
OleDb::OleDbType::VarWChar, 50, " ");
->Parameters->Add(
"", OleDb::OleDbType::VarWChar, 50, "");

87. MS Access

249

->Parameters->Add
(gcnew OleDb::OleDbParameter("Original___",
OleDb::OleDbType::Integer,
0, System::Data::ParameterDirection::
Input, false, (Byte)0, (Byte)0, " /",
System::Data::DataRowVersion::Original, nullptr));
->UpdateCommand = ;
->Connection = ;
try
{ // Update
int kol = ->Update(, );
MessageBox::Show(" " + kol + " ");
}
catch (Exception ^ )
{ MessageBox::Show(->Message, ""); }
}
};
}

, : , .
DataSet, DataAdapter, Connection Command
, Form1.
SQL-
(Select * From [ ]) Adapter DataSet. A DataSet (DataSource) dataGridView1. . 10.14.

. 10.14.


. . CommandText
SQL-. . SQL- .
,

250

10 ADO.NET

. Parameters->Add. (, ), ,
. , (
/) ,
, ,
.
try...catch Update, (kol) .
Exception: Exception
.
, Update.
sln Update.

88.
SQL-
Command
( ),
SQL-, Command. Command SQL-
. .
, , , .
Visual Studio 2010 New Project CLR Visual C++
Console Application CLR.
MessageBox::Show, Forms.
dll. ProjectPropertiesAdd Reference
.NET System.Windows.Forms.dll. ,
Referenses References
.
10.9.
10.9.
// .cpp: .
// SQL-
// Command
#include "stdafx.h"
using namespace System;
// MessageBox :
// ProjectAdd Reference .NET
// System.Windows.Forms.dll, :
using namespace System::Windows::Forms;
int main(array<System::String ^> ^args)

88.

251

{
// Connection
auto = gcnew Data::OleDb::
OleDbConnection( // :
"Data Source=\"C:\\vic.mdb\";User " +
"ID=Admin;Provider=\"Microsoft.Jet.OLEDB.4.0\";");
->Open();
// Command, SQL-
auto = gcnew Data::OleDb::OleDbCommand(
"Delete * From [ ] Where " +
" Like Vi%", );
// SQL
int i = ->ExecuteNonQuery();
// i -
if (i > 0) MessageBox::Show(
", 'Vi*', ");
if (i == 0) MessageBox::Show(
", 'Vi*', ");
->Close();
return 0;
}

Command SQL-
(Delete) , Vi*, , ,
Vi*, vi*, VI* . , (case-insensitive search).
, SQL ExecuteNonQuery. i .
i = 0, , , .
, .sln .


LINQ

11

LINQ (Language Integrated Query) (


) ,
, , , .NET Framework,
SQL Server, ADO.NET (DataSet) XML-.
LINQ , .
LINQ: , ,
, , (), .
LINQ SQL.
, LINQ- (from, where, select .), Visual Basic C#,
MS Visual C++ .NET . LINQ-
Visual Basic C#, Visual Studio 2008. , Microsoft C++/CLI 2010
. LINQ-
. , CLR .NET .
MS Visual C++ .NET LINQ. ,
LINQ-
LINQ-.

89.
Linq::Enumerable


Linq::Enumerable. :
, ,
(). ,
.

89. Linq::Enumerable

253

Visual Studio 2010,


, Visual C++ CLR Console Application CLR,
Name Linq. , System::Linq,
System.Core.dll.
ProjectPropertiesAdd Reference .NET
System.Core. 11.1
.
11.1.
// Linq.cpp: .
#include "stdafx.h"
// .NET System.Core
using namespace System;
// :
using namespace System::Linq;
bool (String ^ S)
{
// , true:
bool A = false;
if (S->Length == 6) A = true;
return A;
}
String ^ 2(String ^ S)
{
// :
S = S->ToUpper();
return S;
}
int main(array<System::String ^> ^args)
{
// ,
// . ,
//
// . LINQ- ( VB C#)
// LINQ-
Console::Title = " Linq::Enumerable";
Console::BackgroundColor = ConsoleColor::Cyan; // -
Console::ForegroundColor = ConsoleColor::Black; // -
Console::Clear();
auto =
" \n" +
" ";
// ,
// :
auto = ->Split(' ');
Console::WriteLine(" 1. :\n\n" + );
Console::WriteLine(
"\n \n" +


254

11 LINQ

11.1 ()
", ,
\n" +
" \n" +
" :
\n");
// , - :
auto = Enumerable::Where<String^>(, gcnew
Func<String ^,bool>());
// :
= Enumerable::OrderBy(, gcnew
Func<String ^,String ^>(2));
// :
= Enumerable::Select(, gcnew
Func<String ^,String ^>(2));
// :
= Enumerable::Distinct();
// :
for each (String ^ x in )
Console::WriteLine("{0} ", x);
Console::ReadKey();
return 0;
}

,
, LINQ- Where, , (Length) .
.
. LINQ- OrderBy,
Select.
Distinct. for each
.
. 11.1 .

. 11.1. LINQ

, Linq.
sln Linq.

90. () LINQ

255

90. ()
LINQ
(, List)
, . ,
,
.
,
. ,
. MSDN,
, ,
.
. :
, :
, , .
. , , 33 ( ). ,
.
Visual Studio 2010,
, Visual C++ CLR Console Application CLR,
Name Linq1. ,
System::Linq, System.Core.dll.
ProjectPropertiesAdd Reference .NET
System.Core. 11.2
.
11.2. ( 1)
// Linq1.cpp: .
//
//
#include "stdafx.h"
// .NET System.Core
using namespace System;
// :
using namespace System::Linq;
using namespace System::Collections::Generic;
// ( ):
value struct
// value class
{
public: String ^ ;
public: int ;


256

11 LINQ

11.2 ()
public: bool ;
};
bool ( S)
{
// , :
bool A = false;
if (S. == false) A = true;
return A;
// :
// return !S.;
//
}
bool 2( S)
{
// 33 , "":
bool A = false;
if (S. > 33) A = true;
return A;
// :
// return S. > 33;
//
}
int main(array<System::String ^> ^args)
{
Console::Title = " Linq::Enumerable";
Console::BackgroundColor = ConsoleColor::Cyan; // -
Console::ForegroundColor = ConsoleColor::Black; // -
Console::Clear();
// :
List<> ^ = gcnew List<>();
// ( ):
1 = {" ", 45, false};
->Add(1);
2 = {" ", 22, true};
->Add(2);
3 = {" ", 32, false};
->Add(3);
4 = {" ", 43, true};
->Add(4);
// :
auto = Enumerable::Where<>(, gcnew
Func< ,bool>());
// :
Console::WriteLine(" :\n");
for each ( x in )
Console::WriteLine("{0} ", x.);
// "" ,
// 33 :

90. () LINQ

257

auto = Enumerable::Where<>(, gcnew


Func< ,bool>(2));
// :
Console::WriteLine("\n\"\" :\n");
for each ( x in )
Console::WriteLine("{0} ", x.);
Console::ReadKey();
return 0;
}

, .
. .
, : ,
. ,
Where Enumerable. .
.
. 11.2.
, for each (. 11.2).

,

2.
LINQ
:
,
, .
,
, .
, Visual Studio 2010,
, Visual C++ CLR Console Application CLR, Name Linq2. ,
System::Linq, System.Core.dll.
ProjectPropertiesAdd Reference .NET
System.Core.
11.3 .
11.3. ( 2)
// Linq.cpp: .
// .
// ,
//
#include "stdafx.h"
// .NET System.Core
using namespace System;


258

11 LINQ

11.3 ()
// :
using namespace System::Linq;
using namespace System::Collections::Generic;
// :
value class
// : value struct
{
public: String ^ ;
public: array<int> ^ ;
};
bool ( S)
{
bool A = false;
// - , ,
// : A = true:
for each(int i in S.)
if (i <= 2) { A = true; break; }
return A;
}
String ^ 2( S)
{
// :
return S.;
}
int main(array<System::String ^> ^args)
{
// :
Console::ForegroundColor = ConsoleColor::White;
// :
array<> ^ =
{ "",
gcnew array<int>{5, 4, 4, 5},
"", gcnew array<int>{3, 3, 2, 4},
"", gcnew array<int>{3, 4, 4, 5},
"", gcnew array<int>{2, 4, 3, 2},
"",
gcnew array<int>{2, 3, 4, 3},
};
// :
List<> ^ = Enumerable::ToList<>();
// -:
auto = Enumerable::Where<>(, gcnew
Func< ,bool>());
// :
= Enumerable::OrderBy(, gcnew
Func<, String ^>(2));
// :
for each ( ^ x in )
Console::WriteLine("{0} ", x->);
Console::ReadKey();
return 0;
}

91. GroupBy

259

,
( ) , : . , .
LINQ
, . 11.3.

( Where),

( OrderBy).
. 11.3.
, Linq1 Linq2.

91.
GroupBy

GroupBy.
List. : .
, , 31, .
, Visual Studio 2010, , Visual C++ CLR Console Application CLR, Name Linq. ,
System::Linq,
System.Core.dll. ProjectPropertiesAdd
Reference .NET System.Core. 11.4
.
11.4. GroupBy
// Linq_.cpp: .
//
// .
// , ,
// 31 , , .
//
#include "stdafx.h"
// .NET System.Core
using namespace System;
// :
using namespace System::Linq;
using namespace System::Collections::Generic;
value struct


260

11 LINQ

11.4 ()
{
public: String ^ ;
public: int ;
};
bool ( t)
{
bool A = false;
if (t. == 31) A = true;
return A;
}
2( t)
{
return t;
}
int main(array<System::String ^> ^args)
{
// :
Console::ForegroundColor = ConsoleColor::White;
// - 12:
auto = gcnew List<>(12);
auto 1 = ();
// :
1. = "";
1. = 31; ->Add(1);
1. = ""; 1. = 28; ->Add(1);
1. = "";
1. = 31; ->Add(1);
1. = "";
1. = 30; ->Add(1);
1. = "";
1. = 31; ->Add(1);
1. = "";
1. = 30; ->Add(1);
1. = "";
1. = 31; ->Add(1);
1. = "";
1. = 31; ->Add(1);
1. = ""; 1. = 30; ->Add(1);
1. = ""; 1. = 31; ->Add(1);
1. = "";
1. = 30; ->Add(1);
1. = ""; 1. = 31; ->Add(1);
// , .
// : ,
// 31 , - :
auto = Enumerable::GroupBy<, bool, >(,
gcnew Func<, bool>(),
gcnew Func<, >(2));
// :
Console::WriteLine(" : \n");
// :
for each (IGrouping<bool,> ^ in )
{
if(->Key == true)
Console::WriteLine(", 31 : \n");
else Console::WriteLine("\n : \n");

91. GroupBy

261

// :
for each ( in )
Console::WriteLine("{0} - {1}", ., .);
}
// - :
Console::ReadKey();
return 0;
}

List.
, ,
.
GroupBy. . for each. ,

. . 11.4.

. 11.4.

, ,
Dictionary. .
, . .
, .
, , ,
90 . ,
LINQ-.
, Visual Studio 2010,
, Visual C++ CLR Console Application CLR, Name Linq. ,
System::Linq, System.Core.dll.
ProjectPropertiesAdd Reference .NET

262

11 LINQ

System.Core. 11.5
.
11.5. Dictionary GroupBy
// Linq.cpp: .
// Dictionary . // : . GroupBy
// : 90 .
//
#include "stdafx.h"
// .NET System.Core
using namespace System;
//
// :
using namespace System::Linq;
using namespace System::Collections::Generic;
bool (KeyValuePair<String^, float> t)
{
bool A = false;
if (t.Value > 90) A = true;
return A;
}
KeyValuePair<String^, float> 2(KeyValuePair<String^, float> t)
{
return t;
}
int main(array<System::String ^> ^args)
{
// :
Console::ForegroundColor = ConsoleColor::White;
// :
auto = gcnew Dictionary<String^, float>();
->Add("", 115.50F);
->Add("",
18.75F );
->Add("", 93.75F );
->Add("",
76.25F );
->Add("",
150.00F);
->Add("", 62.50F );
// , :
auto = Enumerable::GroupBy<
KeyValuePair<String^, float>,
bool, KeyValuePair<String^, float>>(,
gcnew Func<KeyValuePair<String^, float>, bool>(),
gcnew Func<KeyValuePair<String^, float>,
KeyValuePair<String^, float>>(2));
// :
Console::WriteLine(" : \n");
for each (IGrouping<bool,KeyValuePair<String^, float>> ^
in )

92. XML-

263

{
if(->Key == true)
Console::WriteLine(" 90 : \n");
else Console::WriteLine("\n 90 : \n");
for each (KeyValuePair<String^, float> in )
Console::WriteLine("{0} - {1}",.Key, .Value);
}
Console::ReadKey();
return 0;
}


. GroupBy.
-
KeyValuePair .
GroupBy
.
for each. , .
. 11.5.
, , , Linq Linq.

. 11.5.


GroupBy

92. XML-
System::Xml::Linq
, System::Xml , XML-, Visual Studio 2010
System::Xml::Linq, ,
XML, .
XML-, XDocument System::Xml::Linq.
: ,
. XML-
XML-, MS Excel , : , .
XML-.
, Visual Studio 2010, ,
Visual C++ CLR Console Application CLR ,
Name LinqXML-. ,
System::Xml::Linq, System.XML.

264

11 LINQ

Linq.dll. ProjectPropertiesAdd Reference


.NET System.XML.Linq. 11.6

.
11.6. XML-,
// LinqXML-.cpp: .
// XML-.
// XML-.
// XML-: , ,
// , , . XML-
// , ,
// , . XML-
// , .
// MS Excel,
#include "stdafx.h"
using namespace System;
// :
using namespace System::Xml::Linq;
int main(array<System::String ^> ^args)
{
Console::Title = " XML-";
// XML-:
XDocument ^ XML = gcnew XDocument(
// XML-:
gcnew XComment(
"_ - XML-:"),
gcnew XElement("_", // -
gcnew XComment(
" "),
gcnew XElement("", // - (Name)
gcnew XAttribute("", ""),
gcnew XElement("_", "236-23-67"), // -
//
gcnew XElement("_", "+7(495)625-31-43")),
gcnew XComment(" ' ':"),
gcnew XElement("",
gcnew XAttribute("", " "), // -
//
gcnew XElement("_", "001"),
gcnew XElement("_", "")), // -
// (Value)
gcnew XComment(
" =>"),
gcnew XElement("",
gcnew XAttribute("", " "),
// ""
gcnew XElement("_", "402-12-45"),

92. XML-

265

gcnew XElement("_", "+7(495)536-79-94")),


gcnew XComment(
"=> , MS Excel "),
gcnew XElement("",
gcnew XAttribute("", ""), // - -
gcnew XElement("_", ""),
gcnew XElement("_", "+7(495)615-24-41")))
);
// XML-:
XML->Save("C:\\.XML");
Console::WriteLine(XML);
Console::ReadKey();
return 0;
}

, XML, Internet Explorer (. 11.6).

. 11.6. XML-, Internet Explorer

XML-
<_> </_>.
.
MS Excel . ,
,
(Name) _ _.
MS Excel ( ):
, _ _.
( , ,
, _), ,
(Name) (Value) 001.
XML XML- ( ),
XML-. MS Excel,
(. 11.7).

266

11 LINQ

. 11.7. XML-, MS Excel

, LinqXML-.sln LinqXML-.

93.
XML-
, , , XML-, ,
-, .
XML- . XML-
.
XML- (. 11.8).

. 11.8. XML-

, XML- XML- (XML declaration),


(version information parameter).
XML- . , <>,
</>. , <>, (root element). ,
, , ,
. , XML- .

93. XML-

267

, , XML- , . Visual Studio 2010, New Project


CLR Visual C++ Windows Forms Application
Visual C++, Name Xml1.
System::Xml::Linq, System.XML.Linq.dll. ProjectPropertiesAdd
Reference .NET System.XML.Linq.
, Toolbox
TextBox XML
XML-.
, , textBox1 true Multiline.
, 11.7.
11.7. XML- (1 )
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// XML,
// .
// XML- ""
// ~ ~ ~ ~ ~ ~ ~ ~
// System.XML.Linq.dll.
// : ProjectPropertiesAdd Reference .NET
// System.XML.Linq
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = " XML-";
textBox1->Multiline = true;
textBox1->Font = gcnew
System::Drawing::Font("Consolas", 9.0F);
String ^ XML =
"<?xml version=\"1.0\"?>
\r\n" +
"
<>
\r\n" +
"
<></>
\r\n" +
"
<>2011.05.15 06:30 UTC</>
\r\n" +
"
<> 64 F (18 C)</> \r\n" +
"
<>- 8 /</>
\r\n" +
"
<>12 </>
\r\n" +
"
<> 72%</>
\r\n" +
"
<>760 </>
\r\n" +
"
</>";
// , XML:


268

11 LINQ

11.7 ()
auto =
System::Xml::Linq::XElement::Parse(XML);
// XML- :
// , XML, :
// System::IO::File::WriteAllText(
//
"C:\\.xml", XML);
// XML:
// =
//
System::Xml::Linq::XElement::Load(
//
"C:\\.xml");
//
// "" (Value)
// :
String ^ =
->Element("")->Value;
textBox1->Text =
" XML:\r\n\r\n" + XML + "\r\n\r\n";
textBox1->Text += " = " + ;
}
};
}

, XML-.
, Parse XElement Linq,
XML-. , / XML-.
Element (Value) , .
. 11.9.

. 11.9. XML-

, Xml1.sln Xml1.

,
XML- , <> </>;

93. XML-

269

( 11.8)
( ). : ?
, XML-
MS Excel, XML-
, XSLT ( XLS) (. 11.10).

. 11.10. XML- MS Excel

Visual Basic 2010 C# 2010, LINQ-.


, , MS Visual C++ .NET LINQ-. ,
System::Xml::Linq. ,
Where LINQ.
Visual Studio 2010, ,
Visual C++ CLR Console Application CLR.
Name Xml2.
System::Xml::Linq, System.XML.Linq.
dll. ProjectPropertiesAdd Reference
.NET System.XML.Linq.
, 11.8.
11.8. XML- (2 )
// Xml2.cpp: .
// XML,
// .
//
// <> </>.
// XML- MS Excel .
// XML-
// ""
#include "stdafx.h"
// .NET System.Xml.Linq
using namespace System;


270

11 LINQ

11.8 ()
// :
using namespace System::Xml::Linq;
using namespace System::Collections::Generic;
bool (XElement ^ t)
{
bool A = false;
if(t->Element("") != nullptr) A = true;
return A;
}
int main(array<System::String ^> ^args)
{
// :
Console::ForegroundColor = ConsoleColor::White;
Console::Title = " XML-";
// XML-:
String ^ XML =
"<?xml version=\"1.0\"?>"
+
"<>"
+
" <>"
+
"
<></>"
+
" </>"
+
" <>"
+
"
<>2010.05.15 06:30 UTC</>"
+
" </>"
+
" <>"
+
"
<> 64 F (18 C)</>" +
" </>"
+
" <>"
+
"
<>- 8 /</>"
+
" </>"
+
" <>"
+
"
<>12 </>"
+
" </>"
+
" <>"
+
"
<> 72%</>"
+
" </>"
+
" <>"
+
"
<>760 </>"
+
" </>"
+
"</>";
auto = XElement::Parse(XML);
//
auto = ->Elements();
// "":
auto = Linq::Enumerable::Where<XElement^>(,
gcnew Func<XElement^, bool>());
// :
for each (XElement ^ in )
Console::WriteLine(" = " + ->Value);

94. () XML-

271

// Where,
// :
// String ^ = String::Empty;
// for each (XElement ^ in )
// {
//
if (->Element("") != nullptr) =
//
->Element("")->Value;
// }
// Console::WriteLine(" = " + );
Console::ReadKey();
return 0;
}

, XML-
XML- Parse.
, Elements XElement.
Where . .
, XML-
Where.
. 11.11.

. 11.11. XML-

, , Xml1
Xml2.

94. () XML-
XML-,
, , , ,
.
, (
XML, . 11.9) . , , , ,
: , -
XML,
- .
, XML- MS Excel (. 11.12).

272

11 LINQ

. 11.12. XML- MS Excel

, MS Excel XML-
. , ,
, .
Visual Studio 2010,
, Visual C++ CLR Console Application CLR. Name Xml.
System::Xml::Linq, System.XML.Linq.
dll. ProjectPropertiesAdd Reference
.NET System.XML.Linq.
, 11.9.
11.9. XML-
// Xml.cpp: .
// XML-,
// , .
// ,
// ( XML) ""
// System::Xml::Linq
#include "stdafx.h"
// System.XML.Linq.dll
using namespace System;
// :
using namespace System::Xml::Linq;
int main(array<System::String ^> ^args)
{
// :
Console::ForegroundColor = ConsoleColor::White;
Console::Title = " XML- Linq";
// XML-:
String ^ XML =
"<?xml version=\"1.0\"?>
"
"
<>
"
"
<>
"
"
<></>
"
"
<_>274 28 44</_>
"
"
</>
"

+
+
+
+
+
+

94. () XML-

273

"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"

<>
" +
<></>
" +
<_>8-085-456-2378</_>" +
</>
" +
<>
" +
<> </>
" +
<_>445-56-47</_>
" +
</>
" +
<>
" +
<></>
" +
<_>099 72 161 52</_> " +
</>
" +
<>
" +
<></>
" +
<_>236-77-76</_>
" +
</>
" +
<>
" +
<></>
" +
<_>254 67 97</_>
" +
</>
" +
</>";
auto = XElement::Parse(XML);
// , XML, :
// IO::File::WriteAllText(C:\\.xml, XML);
// = XElement::Load(C:\\.xml);
//
auto = ->Elements();
Console::WriteLine(", \"\":");
for each (XElement ^ x in )
if (x->Element("")->Value == "")
Console::WriteLine(x->Element("_")->Value);
// -
Console::ReadKey();
return 0;
}

,
( ) XML-.
XML-, , , XML-
XML- ( ). , , XML- . . for each
. . 11.13.

. 11.13. XML- Linq

274

11 LINQ

, Xml.sln Xml.

95. XML-
XML-
XML-,
, .
,
. Internet Explorer . . 11.14,
MS Excel . . 11.15. XML-
. , XML-.

. 11.14. XML-

. 11.15. XML- MS Excel

Visual Studio 2010, Visual C++


CLR Console Application CLR, Name LinqPiter. ,
System::Xml::Linq,

95. XML- XML-

275

System.XML.Linq.dll.
Project Properties Add Reference .NET
System.XML.Linq. 11.10 .
11.10. XML- XML-
// LinqPiter.cpp: .
// XML- (),
// , . .
// () XML-
#include "stdafx.h"
// System.XML.Linq,
// Project | Properties | Add Reference .NET
// System.Xml.Linq
using namespace System;
// :
using namespace System::Xml;
using namespace System::Xml::Linq;
int main(array<System::String ^> ^args)
{
XmlWriterSettings ^ = gcnew XmlWriterSettings();
// :
->Indent = true;
// XML-:
XmlWriter ^ Xml =
XmlWriter::Create("C:\\.xml", );
// () :
Xml->WriteStartElement("__");
// :
Xml->WriteComment(" Piter.xml");
// XML- - :
XDocument ^ Xml = XDocument::Load("C:\\Piter.xml);
// :
XElement ^ =
Xml->Element("_");
// "":
auto = ->
Elements("__");
// "":
for each (XElement ^ in )
if (->Element("")->Value == " .")
// XML- . :
->WriteTo(Xml);
// XML-:
Xml->WriteEndElement();
Xml->Flush();
Xml->Close();
return 0;
}

276

11 LINQ

XML-,
- C:\Piter.xml. XML-
() ,
. for each
..
XML- (. 11.16
11.17).

. 11.16. XML-

. 11.17. XML- MS Excel

, LinqPiter.
sln LinqPiter.

96.
DataSet
DataSet, , , . DataSet (cache) (
, , ).

96. DataSet

277

.
DataTable, . , DataSet () DataTable.
LINQ , DataSet,
.
, ,
,
. :
, .
Visual Studio 2010 Windows Forms Application, Name DataSet. Toolbox
DataGridView,
Button TextBox.
, ,
.
, Multiline true.
DataSet
System.Data.DataSetExtensions.dll.
ProjectPropertiesAdd Reference .NET
System.Data.DataSetExtensions. ,
11.11.
11.11. DataSet
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
// DataGridView,
// . ,
// XML,
// DataGridView -
// . ""
// XML-. ""
// - DataSet
// .
// ~ ~ ~ ~ ~ ~ ~ ~
// System.Data.DataSetExtensions .NET
DataTable ^ ;
//
DataSet ^ ; //
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)


278

11 LINQ

11.11 ()
{
= gcnew DataTable();
= gcnew DataSet();
Form1::Text = " DataSet";
button1->Text = ""; button2->Text = "";
textBox1->Multiline = true; button2->TabIndex = 0;
if (System::IO::File::Exists("C:\\.xml") == false)
{
// XML- :
// ""
->Columns->Add("");
->Columns->Add("");
// DataSet
->Tables->Add();
dataGridView1->DataSource = ;
}
else // XML- C:
{
->ReadXml("C:\\.xml");
// DataSet XML :
// String ^ XML = ->GetXml();
= ->Tables[""];
dataGridView1->DataMember = "";
dataGridView1->DataSource = ;
}
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// "" // .xml:
->TableName = "";
->WriteXml("C:\\.xml");
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// "" - -:
textBox1->Clear(); // -
// () DataTable:
EnumerableRowCollection<DataRow^> ^ =
DataTableExtensions::AsEnumerable();
// :
Generic::Dictionary<String^, String^> =
gcnew Generic::Dictionary<String^, String^>();
// :
for each (DataRow ^ in )
{
// :

96. DataSet

279

String ^ = DataRowExtensions::
Field<String^>(, "");
String ^ = DataRowExtensions::
Field<String^>(, "");
// 1
:
if (Convert::ToInt32() >= 1000000)
.Add(, );
}
textBox1->Text = "-:\r\n";
// textBox1:
for each (String ^ in .Keys)
textBox1->Text +=
+ " - " + [] + "\r\n";
}
};
}

DataSet DataTable ,
Form1.
, .xml,
. , , , (): , (Add) ,
(DataSource)
dataGridView1. .xml ,
DataSet ,
.


.xml.

DataTable, DataSet.
,
. , for each.
. 11.18.
. 11.18.

-
, DataSet.sln

DataSet.

12


Windows Application

97.

, , . ,
.
: , . .
(,
pattern) ,
.
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Toolbox
TextBox, Label Button.
12.1 .
12.1.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// , , .

97.

281

//
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
label1->Text = " :";
button1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
textBox1->Text = textBox1->Text->Trim();
if (System::Text::RegularExpressions::Regex::Match(
textBox1->Text,
"^[---][--]*$")->Success != true)
MessageBox::Show (" ", "");
}
};
}

textBox1>Text Trim,
.

Regex::Match ( . match ):
Regex::Match(textBox1->Text, "^[---][--]*$")
Match . , ^
$. ^ $ .
, , .

. , , (
) , , , ,
, .
, , *
,
. . 12.1.

. 12.1.

282

12 , Windows Application

, ,
.
, 2010, 2.9, 5., .777,
( ).
,
, ( 12.2).
12.2.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// , , .
//
//
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
label1->Text = " :";
button1->Text = "";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
textBox1->Text = textBox1->Text->Trim();
if (System::Text::RegularExpressions::Regex::Match(
textBox1->Text,
"^(([0-9]+.[0-9]*)|([0-9]*.[0-9]+)|([0-9]+))$"
)->Success == false)
MessageBox::Show(" ", "");
}
};
}

,
"^(([0-9]+.[0-9]*)|([0-9]*.[0-9]+)|([0-9]+))$"

|, ,
.
0 9 . (+) ,
. *
, .
, , , 6.
( ). , -

98.

283

, , .777.
.
, ,
, .sln .sln .

98.
, Windows-,
. , ,
, . .
, . .
Visual Studio 2010 New Project
CLR Visual C++ Windows Forms Application
Visual C++.
Toolbox Timer (). Tick,
, .
timer1->Interval 100 ,
.
.
, .
, Timer
Form1.h[Design].
, Click.
Opacity, . 12.3.
12.3.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// .
// :
// , .
// . .
// ,


284

12 , Windows Application

12.3 ()
// . .
double s; // -
private: System::
Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
s = 0.1;
Form1::Text = " ";
// Timer1->Interval() = 400;
}
private: System::Void timer1_Tick(System::Object^ sender,
System::EventArgs^ e)
{
if (this->Opacity <= 0 || this->Opacity >= 1) s = -s;
this->Opacity += s;
}
private: System::Void Form1_Click(System::Object^ sender,
System::EventArgs^ e)
{
timer1->Enabled = !timer1->Enabled;
}
};
}

,
, .
100 timer1_Click. ,
Opacity 0.1,
s.
Visual Basic
http://subscribe.ru/archive/comp.soft.prog.visualbnet/200512/16181816.html,
C++. ,
Opacity.sln Opacity.

99.

, , ,
Windows. , , , , ,
(GMT Greenwich Meridian Time), , ,
, , , . ,
,
4 , 3 , , 3 , , .

99.

285

, ,
. , ,
Windows
.
www.
central-european-time.com, ,
( - , Central European Time (CET))
.
,
. , , ,
, .
Visual Studio 2010 New Project CLR Visual C++ Windows Forms Application
Visual C++. Toolbox Label Timer.
timer1_Tick .
Form1.h [Design]
, . 12.2.

. 12.2.

12.4.
12.4.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//
// . ,
//
// ~ ~ ~ ~ ~ ~ ~ ~
// t
// :
bool t;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)


286

12 , Windows Application

12.4 ()
{
t = false;
this->Text = " :";
Form1::Opacity = 0.75;
//
label1->Font = gcnew System::Drawing::Font("Courier New",
18.0F);
label1->Text = String::Empty;
timer1->Interval = 1000; // 1000 = 1
timer1->Start();
}
private: System::Void timer1_Tick(System::Object^ sender,
System::EventArgs^ e)
{
// ,
// : 1000 = 1
label1->Text = " : ";
String ^ ;
t = !t;
// , t = true ^ t;
if (t == true) = String::Format("{0:t}", DateTime::UtcNow);
else = String::Format("{0} {1:00}", DateTime::UtcNow.Hour,
DateTime::UtcNow.Minute);
label1->Text = label1->Text + ;
}
private: System::Void label1_MouseEnter(System::Object^ sender,
System::EventArgs^ e)
{
//
this->Opacity = 1;
}
private: System::Void Form1_MouseLeave(System::Object^ sender,
System::EventArgs^ e)
{
//
this->Opacity = 0.75;
}
};
}

:
( this->Text), Form1::Opacity = 0.75 ( this->Opacity = 0.75). Opacity = 0,
,
, , . Opacity = 1
.
timer1->Start() timer1>Interval = 1000 (1000 , 1 ). ,

100. ,

287


timer1_Tick.
,
. :
= String::Format("{0:t}", DateTime::Now)

.
Visual Studio 2010 UtcNow System::DateTime.

(Universal Coordinated Time, UTC), .
= String::Format("{0:t}", DateTime::UtcNow);

.
, ,
(:), . t,
( ) true false,
false true . ., : t = !t. , Tick (, Interval,
1000 = 1 ) timer1 label1
, .
,
, .
label1_MouseEnter
. (, ,
)
, ,
Form1_MouseLeave.
, .sln
.

100. ,
,

.
,
, .
, ,
, .

288

12 , Windows Application


. , , ,
. ,
, ,
.
, , . , , , ,
.
.
.
, ,
.
, . ,
.
Visual Studio 2010
New Project CLR Visual C++ Windows Forms
Application Visual C++. , , NotifyIcon
ContextMenuStrip. ContextMenuStrip, : .
, , 12.5.
12.5.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ,
// .
//
//
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = " ";
//
label1->Size = System::Drawing::Size(292, 90);
//
label1->AutoSize = false;

100. ,

289

label1->Text =
" " +
" . " +
" " +
" \"\"" +
" \" \"\"" +
". " +
" .";
button1->Text = " ";
//
SystemIcons - Windows
notifyIcon1->Icon = SystemIcons::Shield;
//
//
SystemIcons::Information -
notifyIcon1->Text = " ";
notifyIcon1->Visible = false;
// "" notifyIcon1
notifyIcon1->ContextMenuStrip = contextMenuStrip1;
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
//
this->Hide(); notifyIcon1->Visible = true;
}
private: System::Void notifyIcon1_MouseDoubleClick(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// , ,
// ,
// notifyIcon1
notifyIcon1->Visible = false; this->Show();
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
double ____ =
System::Environment::TickCount / 1000 / 60;
// "{0:F0} Double :
String ^ ss = String::Format(" {0:F0} ",
____);
MessageBox::Show(ss);
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
delete notifyIcon1; // C#: notifyIcon1.Dispose();
Application::Exit();
}
};
}

290

12 , Windows Application

, ,
notifyIcon1. Windows
(notifyIcon1->Icon = SystemIcons::Shield), (notifyIcon1->Visible = false).
. , , .
. . 12.3
12.4 .

. 12.3.

. 12.4.

, ___.

101. .

, Windows-
, , . , .
,
MouseEventArgs ,
, ,
. , Visual Basic,
Visual Basic .NET. 1.
, Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++, , -

., . Visual Basic .NET. . .: , 2002. . 591.

101. .

291

, . ,
12.6.
12.6.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// . ,
// "" ,
bool ;
// , = true
int MouseDownX;
int MouseDownY;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
= false;
}
private: System::Void Form1_MouseDown(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// " ".
//
//
if (e->Button == System::Windows::Forms::
MouseButtons::Left)
{
= true;
MouseDownX = e->X;
MouseDownY = e->Y;
}
}
private: System::Void Form1_MouseUp(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// ,
//
if (e->Button == System::Windows::Forms::
MouseButtons::Left) = false;
}
private: System::Void Form1_MouseMove(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
// ,
// .


292

12 , Windows Application

12.6 ()
// , = true
if ( == true)
{
auto = System::Drawing::Point();
.X = this->Location.X + (e->X - MouseDownX);
.Y = this->Location.Y + (e->Y - MouseDownY);
this->Location = ;
}
}
};
}

, Form1. Moving
, , .
( MouseDown, e->Button == Left),
Moving = true, .
( MouseUp), Moving = false,
. int (e->X e->Y) . ,
( MouseMove),
Moving = true.
, .sln .

102.

, , Windows
, , .
, , ,
.
,
,
.
Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
_. .
, 12.7.

102.

293

12.7.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
// Windows
System::Media::SoundPlayer ^ ;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
this->Text = " ";
= gcnew System::Media::SoundPlayer();
// :
button1->Text = " \"-\"";
button2->Text = " ";
button3->Text = " ";
button4->Text = " = 1000 ";
button5->Text = " Windows XP";
button6->Text = " Windows XP";
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// WAV-
->SoundLocation = "c:\\windows\\media\\tada.wav";
->Play();
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// SystemSounds ,
// Windows:
System::Media::SystemSounds::Asterisk->Play();
}
private: System::Void button3_Click(System::Object^ sender,
System::EventArgs^ e)
{
System::Media::SystemSounds::Beep->Play();
}
private: System::Void button4_Click(System::Object^ sender,
System::EventArgs^ e)
{
// 1000 0::5 :
Console::Beep(1000, 500);
}


294

12 , Windows Application

12.7 ()
private: System::Void button5_Click(System::Object^ sender,
System::EventArgs^ e)
{
->SoundLocation =
"c:\\windows\\media\\ Windows XP.wav";
->Play();
}
private: System::Void button6_Click(System::Object^ sender,
System::EventArgs^ e)
{
->SoundLocation =
"c:\\windows\\media\\ Windows XP.wav";
->Play();
}
};
}

,
( , ).
,
C:\Windows\Media, - .
. 12.5.
,
_.sln _.

. 12.5.


Windows

103. Windows Media


Player 11
,

AVI, MPEG, MP3, MP4, FLV, WMV .
, , Windows Media
Player 11. ,
: , ,
, ., .
, Visual Studio 2010 New Project CLR
Visual C++ Windows Forms Application Visual C++.
Player.
Windows Media Player. Toolbox . Toolbox Windows Media Player,
Windows Media Player. ,

103. Windows Media Player 11

295

,
Choose Items ( ). COM Components Windows Media Player OK.
Windows Media Player, - .
, . Debug Interop : AxInterop.WMPLib.1.0.dll Interop.
WMPLib.1.0.dll.
Windows Media Player.
Toolbox
MenuStrip. Type Here.
. . , . 12.6.

. 12.6.

12.8.
12.8. Windows Media Player 11
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// Windows Media Player 11
OpenFileDialog ^ openFileDialog1;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
openFileDialog1 = gcnew OpenFileDialog();
//
this->Text = "Windows Media Player, = " +
axWindowsMediaPlayer1->versionInfo;
}


296

12 , Windows Application

12.8 ()
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
// .
// :
openFileDialog1->ShowDialog();
//
axWindowsMediaPlayer1->URL = openFileDialog1->FileName;
// axWindowsMediaPlayer1->URL = "C:\\WINDOWS\\Media\\tada.wav";
//
axWindowsMediaPlayer1->Ctlcontrols->play();
// : PLAY
// axWindowsMediaPlayer1->openPlayer(openFileDialog1->FileName);
}
private: System::Void ToolStripMenuItem_Click(System::Object^ sender,
System::EventArgs^ e)
{
//
Application::Exit();
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
// .
// PLAY,
// :
if (axWindowsMediaPlayer1->playState ==
WMPLib::WMPPlayState::wmppsPlaying)
axWindowsMediaPlayer1->fullScreen = true;
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
//
axWindowsMediaPlayer1->Ctlcontrols->pause();
}
private: System::Void playToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
// Play
axWindowsMediaPlayer1->Ctlcontrols->play();
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
//
axWindowsMediaPlayer1->settings->mute = true;
}

103. Windows Media Player 11

297

private: System::Void ToolStripMenuItem_Click(


System::Object^ sender, System::EventArgs^ e)
{
//
axWindowsMediaPlayer1->settings->mute = false;
}
private: System::Void ToolStripMenuItem_Click(
System::Object^ sender, System::EventArgs^ e)
{
//
axWindowsMediaPlayer1->ShowPropertyPages();
}
};
}

,
OpenFileDialog.
, 25 (. 4),
, .

Windows Media Player, = .
versionInfo.

ShowDialog .
URL.
,
.
openPlayer.
: ( ,
wmppsPlaying), ,
Play, , , , .
. 12.7.

. 12.7.

298

12 , Windows Application

, Player.sln
Player.

104.

, ,
mp3, wma, mid . .
, , .
Visual Studio 2010 New
Project CLR Visual C++ Windows Forms
Application Visual C++. Player.
Toolbox
Button. ,
,
.
. ProjectProperties
()Add Reference ( ) Browse ()
C:\Windows\system32\wmp.dll. ,
Windows Media Player . , , ,
Widows Media Plaer,
. ,
12.9.
12.9.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
}
#pragma endregion
//
WMPLib::WindowsMediaPlayer ^ ;
OpenFileDialog ^ ;
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)
{
// .
// ProjectPropertiesAdd Reference
// Browse () C:\Windows\system32\wmp.dll

104.

299

= gcnew WMPLib::WindowsMediaPlayer();
= gcnew OpenFileDialog();
//
this->Text = "Windows Media Player " + ->versionInfo;
button1->Text = "";
button2->Text = " ";
button3->Text = " ";
// :
// ->URL = "C:\\VenSalvrme.wma";
->URL = "C:\\WINDOWS\\Media\\town.mid";
// ->URL = "C:\\juliana-best_of_best.mp3";
->settings->volume = 10;
//
->controls->play();
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
// :
->ShowDialog();
//
->URL = ->FileName;
//
->controls->play();
}
private: System::Void button2_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
->settings->volume = ->settings->volume + 10;
}
private: System::Void button3_Click(System::Object^ sender,
System::EventArgs^ e)
{
// :
->settings->volume = ->settings->volume - 10;
}
};
}


WindowsMediaPlayer. URL.
,
.

,
.

. 12.8.

300

12 , Windows Application


. 12.8
, Player.sln Player.

105.
.
,
. ,
( ) .

, .
Windows Forms
Application Visual C++, . Toolbox, , , . 12.9.

. 12.9.

,
, .
( 12.10).
12.10.
// ...............
// , , Visual Studio
// ,
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ,
// ( )
// . ,
//
// ,
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e)

105. .

301

{
MaximizeBox = false; // -
MinimizeBox = false; // -
// ,
//
HelpButton = true;
this->Text = " ";
button1->Text = ""; button2->Text = "";
textBox1->Clear(); textBox2->Clear(); textBox3->Clear();
label1->Text = " /"; label2->Text = "";
label3->Text = " ";
HelpProvider ^ helpProvider1 = gcnew HelpProvider();
helpProvider1->SetHelpString(textBox1,
" ");
helpProvider1->SetHelpString(textBox2,
" ");
helpProvider1->SetHelpString(textBox3,
" ");
helpProvider1->SetHelpString(button1,
" ");
helpProvider1->SetHelpString(button2,
" ");
// , help-
// <F1>
helpProvider1->HelpNamespace = "mspaint.chm";
}
};
}


. ,
( ), :
MaximizeBox = false;
MinimizeBox = false;

: HelpButton = true.
helpProvider1, , Toolbox.
.
, ToolTip (. 8 1).
HelpNamespace help-, F1. mspaint.chm,
MS Paint, Windows,
Windows. CHM
Microsoft . CHM-,
,
. , , CHM HLP- Windows.
, Help.sln
Help.

302

12 , Windows Application



, ( )
( ) ().
(setup.exe, *.msi, *.dll, *.tlb . .).
setup.exe, msi-,
. -, InstallShild, InnoSetup
. Visual Studio 2010. AutoCAD (. 60 9).
Visual Studio 2010, , New Project
Other Project Types Setup and Deployment ( ), Visual Studio Installer Setup Project.
Location , , C:\New, OK.
Project AddFile. exe- , msi- ,
ACADm.exe, Interop.AutoCAD.dll. Solution
Explorer ( ) exe- tlb-,
dll- msm-. Solution Explorer ACAD.
TLB. ,
- ocx- - . msi-.

BuildBuild Setup1. C:\New\Debug Setup.exe Setup1.msi. -
, - -. .
setup.exe,
, C:\Program Files\Acadm\,
.
, exe- dll- tlb-.
,
.
, ,
MS Visual C++, .
, .

1.

First


, ,
: !

Hover

,
,
, MouseHover

, 4

label1. -

label1

, 5

, ,

, 6
Label
CheckBox

.
^

,
,
TabControl
RadioButton

304

Visible

9
Label ,

, . Visible.

( ToolTip)

, .
ComboBox

10

Unico

,
MessageBox .
R,

11

12

- 13
,

ConsoleMessageBox

MessageBox
, String::Format

VisualBasic

Visual C++ 15
Visual Basic. , , ,
.
Visual Basic:
InputBox, IsNumeric ( ,
) MsgBox

16

Dictionary
.
,
.
for each,
,
30

14

305

17

. ,
ListBox .
ListBox

. ,

ListBox

NewButton

- 18
, ,
Toolbox. :
, , ,

,

.

.
20

.

LinkLabel

- 21
www.mail.ru,
C:\Windows\
LinkLabel

,
22
,

,

.
Backspace,

19

23

306

+Or
, (
)

24

. 25


.
,

TxtUnicode

/
Unicode

26

TXT_1251

/
Windows 1251

27

28

- 29

Rtf

RTF-

, 31
.

( ).

/ .

/
('\t').
/ .

TxtPrint


,

(ReadOnly)

ReadWriteBin

/ - 33

30

32

307

SimpleImage1,
SimpleImage2
SimpleImage3

,
34

PictureBox,
Panel,

36
: , ,
, , , .
ListBox

1
2

,
BackColor,
, Visual Studio 2010,
ListBox

37

38

39
( )
. ,
: , ,
. . (. Graphics)

BMP

bmp

_JPG

41
Graphics, JPG-

42

43

35

40

308

Spline


, () .

.
,
()


45
. ,

TXT


46
- ,

Bitmap

47

AltPrintScreen


Alt+PrintScreen Send SendKeys

48

SaveBMP

,
, BMP-

49

Timer

50
Timer.

ListBox.
,

Save
5



Pic1.BMP,
Pic2.BMP . .

Txt

52
,
String::Format. , MenuStrip
,


44

51

309

TxtPrint


. TextBox.

53

_HTM

Internet Explorer.


.
HTML.

- Internet Explorer

54

Grid

55

,
DataGridView ( ). DataGridView

GridView

56

, -. .
,
. ,
DataGridView,
-

57
,
, , . .

XML.
C:\tabl.xml.
,

Grid


. DataGridView

58

310


59
( , )
( ,
, -).

( ).

, .
.
,

Chart

,
Chart DataGridView, ()
.
DataTable

60

WebHTM

WebBrowser.
HTML
<tr> ( )
<td> ( )

61

62

FlashWeb

WebBrowser Flash-

Split

63
WebBrowser -
HTML-

64
WebBrowser

http://yahoo.com. ,
DomDocument
( WebBrowser), IHTMLDocument2.

- .

-,
Submit.
WebBrowser ,
,

, WebClient, 65
- www.
cbr.ru,

Label. ,
PictureBox
, URL-

1 - , 2
-
.
CheckSpelling
MS Word

66

Word


67
MS Word: , ,
MS Word

Excel


MS Excel
= 3,14...

68

69

Excel

311

Pmt() MS Excel -



Excel

- 70
MS Excel

Excel

(),
MS Excel

71

ACAD


AutoCAD
.
DWG. : AutoCAD 2008,
,
, C:\.
dwg AutoCAD

72

312

Matlab


Matlab

Matlab

, 74
MATLAB, . ,
MessageBox

_PDF_1
_PDF_2


PDF- ,

75

_PDF__1
_PDF__2

,
PDF-

76

_PDF__1
_PDF__2

,
PDF-

77

_SQL_Server

SQL Server
78
Visual Studio 2010.
,
,
:
,

_SQL_Server_
SQL Server ( *.sdf)
Command
DataReader

73

79

DataReader

81

MS Access
Command DataReader

MS Access,
new_BD.mdb.
,
.


C++ 2010, MS Access.
ADO.NET

82

313


MS Access. .
,
.
,

84

MS Access. Command SQL-
(Insert)

ReaderGridView


Command,
DataReader DataGridView
( )

85

GridView

DataGridView
Command, Adapter DataSet

86

Update

(Update)
MS Access

87


SQL-
Command

88

Linq

- 89
, .

,
.
LINQ-
( VB C#) LINQ

Linq1
Linq2

, ,
90
, ,
,

Linq
Linq

83

91

314

LinqXML

XML-. 92

XML-.
XML-:
, ,
,
, . XML-
,
,
. XML ,
. MS Excel,

Xml1
Xml2

XML,
93

.
XML-

Xml

94
XML-,
, .
, ( XML)

LinqPiter

XML- (),
95
, .

() XML-

DataSet

96
DataGridView,
.
,
XML,
DataGridView : .

XML-.

- DataSet
.

System::Xml::Linq

315

, ,

Opacity

- 98
.

: , .
. .

, . .

99
.
,

___

, 100

.

.
,
,

101


Windows

102

Player

103
Windows Media Player 11

Player

Help

105
,
( )
.


,

97

104

MS Visual C++ 2010 .NET.





.
.
.
.
.
.

, 198206, -, , 73, . 29.


005-93, 2; 95 3005 .
29.07.11. 70100/16. . . . 25,800. 1000. 0000.
CtP . . . .
197110, -, ., 15.

?
!
?
?
? ,

?
!


!

www.piter.com/ePartners

www.piter.com,
,

( www.piter.com)
!
.
10% ,
, - c
. ,
, 5%
.
, , 500 ,
. Web.Money.
:
http://www.piter.com/book.phtml?978538800282
http://www.piter.com/book.phtml?978538800282&refer=0000
, 0000


WWW.PITER.COM


, ,
,

/ . , . ., . 29
./: (812) 7037373, 7037372; email: sales@piter.com
. , ., . 2/1, . 1, 6
./: (495) 23438-15, 97434-50; e-mail: sales@msk.piter.com

., . 169; ./: (4732) 396170


email: piterctr@omch.ru
. , . 11; ./: (343) 3789841, 3789842
mail: office@ekat.piter.com

. , . 13; .: (8312) 412731


email: office@nnov.piter.com
. , . 36; .: (383) 363-01-14
: (383) 3501979; email: sib@nsk.piter.com
//

. , . 26; .: (863) 2699122, 2699130


mail: piterug@rostov.piter.com

. , . 33; 223; .: (846) 2778979


e-mail: pitvolga@samtel.ru

. , . 12, 10; .: (1038057) 751-10-02


758-41-45; : (1038057) 712-27-05; -mail: piter@kharkov.piter.com

., . 6, . 1, 33; .: (1038044) 4903569


: (1038044) 4903568; mail: office@kiev.piter.com

. , . 34, 2; ./: (1037517) 201-48-79, 201-48-81


mail: gv@minsk.piter.com

, .
: (812) 703/73/73. E/mail: fuganov@piter.com
.
: / (812) 703/73/72, (495) 974/34/50
.: (812) 7037373.
mail: kozin@piter.com
: www.piter.com; .: (812) 703-73-74
ICQ 413763617

!



.


./: (4232) 238212
email: bookbase@mail.primorye.ru

,
.: (3952) 200917, 241777
email: prodalit@irk.ru
http://www.prodalit.irk.ru

, , . , . 1
.: (4212) 360665, 339531
email: dkniga@mail.kht.ru

,
./: (3952) 252590
email: kkcbooks@bk.ru
http://www.kkcbooks.ru

,
.: (4212) 328551, : (4212) 328250
email: postmaster@worldbooks.kht.ru
,
.: (4212) 394960
email: zakaz@booksmirs.ru

, , . , . 3
.: (8182) 654134, 653879
email: marketing@avfkniga.ru

, , . , . 4
.: (4732) 267777
http://www.amital.ru
, ,

./: (4012) 215628, 6 56568
email: nshibkova@vester.ru
http://www.vester.ru
, ,
, .15
.: (846) 3312233
email: chaconne@chaccone.ru
,
. , . 58
.: (4732) 512893, 470081
email: manager@kmsvrn.ru

, , . , 424
./: (87934) 69309
email: rossy@kmw.ru

,
. , . 86
./: (3912) 273971
email: bookworld@public.krasnet.ru
, 
.: (383) 3361026
: (383) 3361027
email: office@topkniga.ru
http://www.topkniga.ru

, ,

.: (843) 2723455
email: tais@bancorp.ru

,
. , . 12
./: (343) 3581898, 3581484
email: domknigi@k66.ru

,
. , . 1
./: (343) 228-10-70
e-mail: igm@lumna.ru
http://www.lumna.ru
,
. , . 124
.: (351) 2477403, 2477409,
2477416
email: zakup@intser.ru
http://www.fkniga.ru, www.intser.ru


:
: www.piter.com
: postbook@piter.com
: (812) 703/73/74
: 197198, /, / 127,
ICQ: 413763617

:

.
.
,
.
. : . Web-money USD
E-Gold, MoneyMail, INOCard, RBK Money (RuPay), USD Bets, Mobile Wallet
.
, ,
.
.
.
e-mail.

:
, , , , , email;
, , , , , ,
, ;
, , .

Вам также может понравиться