diff --git a/4238.pdf b/4238.pdf new file mode 100644 index 0000000..3dd6e9f Binary files /dev/null and b/4238.pdf differ diff --git a/4239.pdf b/4239.pdf new file mode 100644 index 0000000..c23626e Binary files /dev/null and b/4239.pdf differ diff --git a/9781430210535.jpg b/9781430210535.jpg new file mode 100644 index 0000000..790a042 Binary files /dev/null and b/9781430210535.jpg differ diff --git a/Chapter02/Arrays.cpp b/Chapter02/Arrays.cpp new file mode 100644 index 0000000..1f0fd2e --- /dev/null +++ b/Chapter02/Arrays.cpp @@ -0,0 +1,76 @@ +using namespace System; + +// Arrays in Action +void main() +{ + // Single dimension + array^ a = gcnew array(4); + array^ b = gcnew array(4); + + for (int i = 0; i < a->Length; i++) + { + a[i] = i; + } + + for (int i = 0; i < b->Length; i++) + { + b[i] = a[i].ToString(); + } + + for (int i = 0; i < b->Length; i++) + { + Console::WriteLine(b[i]); + } + + Console::WriteLine(); + Array::Reverse(b); + for (int i = 0; i < b->Length; i++) + { + Console::WriteLine(b[i]); + } + + // Multi dimension uniform + array^ c = gcnew array(4,3); + array^ d = gcnew array(4,3); + + for (int x = 0; x < c->GetLength(0); x++) + { + for (int y = 0; y < c->GetLength(1); y++) + { + c[x,y] = (x*10)+y; + } + } + + Console::WriteLine(); + for (int x = 0; x < d->GetLength(0); x++) + { + for (int y = 0; y < d->GetLength(1); y++) + { + Console::Write("{0,-5:00}", c[x,y]); + } + Console::WriteLine(); + } + + // Multi dimension jagged + array< array^ >^ e = gcnew array^>(4); + + for (int x = 0; x < e->Length; x++) + { + e[x] = gcnew array(4+(x*2)); // each row 2 bigger + for(int y = 0; y < e[x]->Length; y++) + { + e[x][y] = (x*10)+y; + } + } + + Console::WriteLine(); + + for (int x = 0; x < e->Length; x++) + { + for (int y = 0; y < e[x]->Length; y++) + { + Console::Write("{0,-5:00}", e[x][y]); + } + Console::WriteLine(); + } +} diff --git a/Chapter02/Boolean.cpp b/Chapter02/Boolean.cpp new file mode 100644 index 0000000..9e59c3a --- /dev/null +++ b/Chapter02/Boolean.cpp @@ -0,0 +1,15 @@ +using namespace System; + +// Boolean Fundamental Type in Action +void main() +{ + bool a = 18757; // will give a warning but set to true + bool b = 0; // false + bool c = true; // obviously true + bool d = false; // obviously false + + Console::WriteLine( a ); + Console::WriteLine( b ); + Console::WriteLine( c ); + Console::WriteLine( d ); +} diff --git a/Chapter02/BooleanLiteral.cpp b/Chapter02/BooleanLiteral.cpp new file mode 100644 index 0000000..e9d8cea --- /dev/null +++ b/Chapter02/BooleanLiteral.cpp @@ -0,0 +1,15 @@ +using namespace System; + +// Boolean Literals in Action +void main() +{ + bool isTrue = true; + bool isFalse = false; + + Console::WriteLine ( isTrue ); + Console::WriteLine ( isFalse ); + + // This is kind of neat. Boolean literals are objects too! + Console::WriteLine ( true.ToString () ); + Console::WriteLine ( false.ToString () ); +} diff --git a/Chapter02/Boxing.cpp b/Chapter02/Boxing.cpp new file mode 100644 index 0000000..dd5ef5d --- /dev/null +++ b/Chapter02/Boxing.cpp @@ -0,0 +1,20 @@ +using namespace System; + +// Boxing in Action +value class POINT +{ +public: + int x, y; + POINT(int x, int y) : x(x) , y(y) {} +}; + +void main() +{ + POINT p1(1,2); + Object ^o = p1; + POINT ^p2 = (POINT)o; + + Console::WriteLine("p1 x={0} y={1}\n", p1.x, p1.y); + Console::WriteLine("o x={0} y={1}\n", ((POINT)o).x, ((POINT)o).y); + Console::WriteLine("p2 x={0} y={1}\n", p2->x, p2->y); +} \ No newline at end of file diff --git a/Chapter02/BuildAll.bat b/Chapter02/BuildAll.bat new file mode 100644 index 0000000..3bb4314 --- /dev/null +++ b/Chapter02/BuildAll.bat @@ -0,0 +1,18 @@ +cl Arrays.cpp /clr:safe +cl Boolean.cpp /clr:safe +cl BooleanLiteral.cpp /clr:safe +cl Boxing.cpp /clr:safe +cl CharLiteral.cpp /clr:safe +cl Chars.cpp /clr:safe +cl Decimal.cpp /clr:safe +cl Enums.cpp /clr:safe +cl FloatingPoint.cpp /clr:safe +cl Hello.cpp /clr:safe +cl IntegerLiteral.cpp /clr:safe +cl IntegerTypes.cpp /clr:safe +cl MainArgsNew.cpp /clr:safe +cl MainArgsTrad.cpp /clr:pure +cl ReferenceIndirect.cpp /clr:pure +cl StringFun.cpp /clr:safe +cl StringLiteral.cpp /clr:safe +cl ValueClass.cpp /clr:safe diff --git a/Chapter02/CharLiteral.cpp b/Chapter02/CharLiteral.cpp new file mode 100644 index 0000000..31a2ef4 --- /dev/null +++ b/Chapter02/CharLiteral.cpp @@ -0,0 +1,21 @@ +using namespace System; + +// Character Literals in Action +void main() +{ + char a = 'a'; // character 'a' + Char b = L'b'; // Unicode 'b' + + char t = '\t'; // tab escape + Char s = L'\\'; // Unicode backslash escape + + char d = '\45'; // octal escape + Char e = L'\x0045'; // Unicode hexadecimal escape + + Console::WriteLine ( a ); // displays numeric equiv of 'A' + Console::WriteLine ( b ); // displays the letter 'b' + Console::WriteLine ( t ); // displays numeric equiv of tab + Console::WriteLine ( s ); // displays backslash + Console::WriteLine ( d ); // displays decimal equiv of octal 45 + Console::WriteLine ( e ); // displays the letter 'e' +} diff --git a/Chapter02/Chars.cpp b/Chapter02/Chars.cpp new file mode 100644 index 0000000..7beba5e --- /dev/null +++ b/Chapter02/Chars.cpp @@ -0,0 +1,12 @@ +using namespace System; + +// Character Fundamental Type in Action +void main() +{ + Char a = L'A'; // character literal 'A' + Char b = L'\x0041'; // hex notation for hex 41 which happens to be 'A' + + Console::WriteLine ( a ); + Console::WriteLine ( b ); //Even though I put hex 41 in b, the ASCII 'A' + //is printed due to b being a Char +} diff --git a/Chapter02/Decimal.cpp b/Chapter02/Decimal.cpp new file mode 100644 index 0000000..38212e0 --- /dev/null +++ b/Chapter02/Decimal.cpp @@ -0,0 +1,39 @@ +using namespace System; + +// Decimal Fundamental Type in Action +void main() +{ + Decimal w = System::Convert::ToDecimal("123456789012345678901.2345678"); + Console::WriteLine( w ); + + Decimal x = (Decimal)0.1234567890123456789012345678; // will get truncated + Decimal y = (Decimal)0.0000000000000000789012345678; // works fine + + Console::WriteLine( x ); + Console::WriteLine( y ); + + // Decimal constructor + Decimal z(0xeb1f0ad2, 0xab54a98c, 0, false, 0); // = 12345678901234567890 + Console::WriteLine( z ); + + // Create a 28 significate digit number + Decimal a = (Decimal)123456789012345000000.00000000; + Decimal b = (Decimal)678901.23456780; + Decimal c = -(a + b); + + Console::WriteLine( c ); // display pre broken Decimal + + // Break it up into 4 parts + array^ d = Decimal::GetBits(c); + + // Reassemble using Decimal constructor + Decimal e(d[0], d[1], d[2], // digits + ((d[3] & 0x80000000) == 0x80000000), // sign + ((d[3] >> 16) & 0xff) ); // decimal location + + Console::WriteLine( d[0] ); // display part 1 + Console::WriteLine( d[1] ); // display part 2 + Console::WriteLine( d[2] ); // display part 3 + Console::WriteLine( d[3].ToString("X") ); // display part 4 + Console::WriteLine( e ); // display reassembled Decimal +} diff --git a/Chapter02/Enums.cpp b/Chapter02/Enums.cpp new file mode 100644 index 0000000..5746626 --- /dev/null +++ b/Chapter02/Enums.cpp @@ -0,0 +1,26 @@ +using namespace System; + +enum class PrimeColors { Red, Blue, Yellow }; + +// Enum Type in Action +void main() +{ + PrimeColors color; + + color = PrimeColors::Blue; + + switch (color) + { + case PrimeColors::Red : + Console::WriteLine("Red"); + break; + case PrimeColors::Blue : + Console::WriteLine("Blue"); + break; + case PrimeColors::Yellow : + Console::WriteLine("Yellow"); + break; + } + + Console::WriteLine(color.ToString()); +} diff --git a/Chapter02/FloatingPoint.cpp b/Chapter02/FloatingPoint.cpp new file mode 100644 index 0000000..da553d2 --- /dev/null +++ b/Chapter02/FloatingPoint.cpp @@ -0,0 +1,15 @@ +using namespace System; + +// Floating-point Fundamental Types in Action +void main() +{ + float w = 123.456f; // standard decimal notation + float x = 7890e3f; // exponent notation + double y = 34525425432525764765.76476476547654; // too big will truncate + double z = 123456789012345e-300; // exponent will be reset + + Console::WriteLine( w ); // Write out Single + Console::WriteLine( x ); // Write out Single with more zeros + Console::WriteLine( y ); // Write out Double truncated + Console::WriteLine( z ); // Write out Double shift back decimal +} diff --git a/Chapter02/Hello.cpp b/Chapter02/Hello.cpp new file mode 100644 index 0000000..1251f0e --- /dev/null +++ b/Chapter02/Hello.cpp @@ -0,0 +1,7 @@ +using namespace System; + +// The Obligatory Hello World! +void main(void) +{ + Console::WriteLine("Hello C++/CLI World"); +} \ No newline at end of file diff --git a/Chapter02/IntegerLiteral.cpp b/Chapter02/IntegerLiteral.cpp new file mode 100644 index 0000000..69daeba --- /dev/null +++ b/Chapter02/IntegerLiteral.cpp @@ -0,0 +1,15 @@ +using namespace System; + +// Integer Literals in Action +void main() +{ + Console::WriteLine ( 010 ); // An Octal 10 is a base-10 8 + Console::WriteLine ( -010 ); // Negative Octal 10 is a base-10 -8 + + Console::WriteLine ( 0x10 ); // A Hex 10 is a base-10 16 + Console::WriteLine ( -0x10 ); // Negative Hex 10 is a base-10 -16 + + // This is kind of neat. Number literals are objects too! + Console::WriteLine ( (1234567890).ToString() ); + Console::WriteLine ( (0xABCDEF).ToString("X") ); +} diff --git a/Chapter02/IntegerTypes.cpp b/Chapter02/IntegerTypes.cpp new file mode 100644 index 0000000..524b090 --- /dev/null +++ b/Chapter02/IntegerTypes.cpp @@ -0,0 +1,18 @@ +using namespace System; + +// Integer Fundamental Types in Action +void main() +{ + char v = 'F'; // Intialize using charater literal + short w(123); // Intializing using Functional Notation + int x = 456789; // Decimal literal assigned + long y = 987654321l; // long integer literal assigned + Int64 z = 0xFEDCBA9876543210; // Hex literal assigned + + Console::WriteLine( v ); // Write out a char + Console::WriteLine( w ); // Write out a short + Console::WriteLine( x ); // Write out a int + Console::WriteLine( y ); // Write out a long + Console::WriteLine( z ); // Write out a Int64 + Console::WriteLine( z.ToString("x") ); // Write out a Int64 in Hex +} diff --git a/Chapter02/MainArgsNew.cpp b/Chapter02/MainArgsNew.cpp new file mode 100644 index 0000000..806569d --- /dev/null +++ b/Chapter02/MainArgsNew.cpp @@ -0,0 +1,14 @@ +using namespace System; + +// Passing parameters to main() new method +int main(array ^args) +{ + Console::WriteLine(args->Length); + + for each (String^ s in args) + { + Console::WriteLine(s); + } + return 0; +} + diff --git a/Chapter02/MainArgsTrad.cpp b/Chapter02/MainArgsTrad.cpp new file mode 100644 index 0000000..7e1a476 --- /dev/null +++ b/Chapter02/MainArgsTrad.cpp @@ -0,0 +1,12 @@ +using namespace System; + +// Passing parameters to main() +int main ( int argc, char *argv[] ) +{ + Console::WriteLine ( argc.ToString() ); + for (int i = 0; i < argc; i++) + { + Console::WriteLine ( gcnew String(argv[i]) ); + } + return 0; +} diff --git a/Chapter02/ReferenceIndirect.cpp b/Chapter02/ReferenceIndirect.cpp new file mode 100644 index 0000000..f5395f1 --- /dev/null +++ b/Chapter02/ReferenceIndirect.cpp @@ -0,0 +1,38 @@ +using namespace System; + +ref class RefClass +{ +public: + int X; + + RefClass(int x) + { + X = x; + } +}; + +// Reference and Indirection in Action +void main() +{ + RefClass rc(10); + RefClass ^o; + + o = %rc; // place a reference of rc in the handle o + Console::WriteLine(o->X); // print out object. This should contain 10. + + rc.X = 20; // place 50 at the address y points to + Console::WriteLine(o->X); // print out object. This should contain 20. + + int %i = rc.X; // assign rc.X to a reference + + i = 30; // change value of reference + Console::WriteLine(o->X); // print out object. This should contain 30. + + Console::WriteLine(); + + int ^y = gcnew int(100); // create a handle to an int + Console::WriteLine(y); // print out int. + + *y = 110; // Assign new value to dereferenced int + Console::WriteLine(*y); // print out dereferenced int. +} diff --git a/Chapter02/StringFun.cpp b/Chapter02/StringFun.cpp new file mode 100644 index 0000000..e84755f --- /dev/null +++ b/Chapter02/StringFun.cpp @@ -0,0 +1,29 @@ +using namespace System; + +// String Type in Action +void main() +{ + // Create some strings + String^ s1 = "This will "; + String^ s2 = "be a "; + String^ s3 = "String"; + Console::WriteLine(String::Concat(s1, s2, s3)); + + // Create a copy, then concatenate new text + String^ s4 = s2; + s4 = String::Concat(s4, "new "); + Console::WriteLine(String::Concat(s1, s4, s3)); + + // Replace stuff in a concatenated string + String^ s5 = String::Concat(s1, s2, s3)->Replace("i", "*"); + Console::WriteLine(s5); + + // Insert into a string + String^ s6 = s3->Insert(3, "ange Str"); + Console::WriteLine(String::Concat(s1, s2, s6)); + + // Remove text from strings + s1 = s1->Remove(4, 5); // remove ' will' from middle + s2 = s2->Remove(0, 3); // remove 'be ' from start + Console::WriteLine(String::Concat(s1, "is ", s2, s3)); +} diff --git a/Chapter02/StringLiteral.cpp b/Chapter02/StringLiteral.cpp new file mode 100644 index 0000000..8f54540 --- /dev/null +++ b/Chapter02/StringLiteral.cpp @@ -0,0 +1,11 @@ +using namespace System; + +// String Literals in Action +void main() +{ + String^ a = "Managed String"; + String^ b = L"Unicode String"; + + Console::WriteLine(a); + Console::WriteLine(b); +} diff --git a/Chapter02/ValueClass.cpp b/Chapter02/ValueClass.cpp new file mode 100644 index 0000000..240d9f2 --- /dev/null +++ b/Chapter02/ValueClass.cpp @@ -0,0 +1,39 @@ +using namespace System; + +// Value class in Action +value class Coord3D +{ +public: + double x; + double y; + double z; + + Coord3D (double x, double y, double z) + { + this->x = x; + this->y = y; + this->z = z; + } + + String^ Write() + { + return String::Format("{0},{1},{2}", x, y, z); + } +}; + +void main() +{ + Coord3D coordA; + Coord3D coordB(1,2,3); + + coordA = coordB; // Assign is simply an = + + coordA.x += 5.5; // Operations work just like usual + coordA.y *= 2.7; + coordA.z /= 1.3; + + Console::WriteLine(coordB.Write()); + Console::WriteLine(coordA.x); + Console::WriteLine(coordA.y); + Console::WriteLine(coordA.z); +} diff --git a/Chapter03/AbstractEx.cpp b/Chapter03/AbstractEx.cpp new file mode 100644 index 0000000..674d051 --- /dev/null +++ b/Chapter03/AbstractEx.cpp @@ -0,0 +1,57 @@ +using namespace System; + + ref class AbstractExClass abstract +{ +protected: + int AbstractVar; + AbstractExClass(int val): AbstractVar(val) {} +public: + virtual void Method1() = 0; // unimplemented method + virtual void Method2() = 0; // unimplemented method + void Method3() + { + Console::WriteLine(AbstractVar.ToString()); + } +}; + +ref class MidAbstractExClass abstract : public AbstractExClass +{ +public: + virtual void Method1() override sealed + { + Console::WriteLine((AbstractVar * 3).ToString()); + } +protected: + MidAbstractExClass(int val) : AbstractExClass(val) {} +}; + +ref class DerivedExClass : public MidAbstractExClass +{ +public: + DerivedExClass(int val) : MidAbstractExClass(val) {} + virtual void Method2() override + { + Console::WriteLine((AbstractVar * 2).ToString()); + } +}; + +void testMethod(AbstractExClass ^aec) +{ + aec->Method1(); + aec->Method2(); + aec->Method3(); +} + +void main() +{ + AbstractExClass ^Ab1 = gcnew DerivedExClass(5); + Ab1->Method1(); + Ab1->Method2(); + Ab1->Method3(); + + AbstractExClass ^Ab2 = gcnew DerivedExClass(6); + testMethod(Ab2); + + DerivedExClass ^dc = gcnew DerivedExClass(7); + testMethod(dc); +} diff --git a/Chapter03/ArrayProp.cpp b/Chapter03/ArrayProp.cpp new file mode 100644 index 0000000..4788d17 --- /dev/null +++ b/Chapter03/ArrayProp.cpp @@ -0,0 +1,36 @@ +using namespace System; + +ref class ArrayProp +{ +public: + ArrayProp(int size) + { + numArray = gcnew array(size); + } + + property array^ NumArray + { + array^ get() + { + return numArray; + } + + void set ( array^ value ) + { + numArray = value; + } + } +private: + array^ numArray; +}; + +void main() +{ + ArrayProp aprop(5); + + for ( int i = 0 ; i < aprop.NumArray->Length ; ++i ) + aprop.NumArray[i] = i; + + for each (int i in aprop.NumArray) + Console::WriteLine(i); +} diff --git a/Chapter03/BuildAll.bat b/Chapter03/BuildAll.bat new file mode 100644 index 0000000..62cb412 --- /dev/null +++ b/Chapter03/BuildAll.bat @@ -0,0 +1,17 @@ +cl AbstractEx.cpp /clr:safe +cl ArrayProp.cpp /clr:safe +cl Casting.cpp /clr +cl Constructors.cpp /clr:safe +cl DefIndexProps.cpp /clr:safe +cl IndexProps.cpp /clr:safe +cl Inherit.cpp /clr:safe +cl InterfaceEx.cpp /clr:safe +cl MethodEx.cpp /clr:safe +cl NestedClass.cpp /clr:safe +cl OperatorOverload.cpp /clr:safe +cl OperatorOverloadMixed.cpp /clr:safe +cl ScalarProp.cpp /clr:safe +cl StackReferences.cpp /clr:safe +cl StaticMethodEx.cpp /clr:safe +cl StaticProp.cpp /clr:safe +cl VirtualAnimals.cpp /clr:safe diff --git a/Chapter03/Casting.cpp b/Chapter03/Casting.cpp new file mode 100644 index 0000000..800b1b8 --- /dev/null +++ b/Chapter03/Casting.cpp @@ -0,0 +1,33 @@ +using namespace System; + +ref class A {}; +ref class B : public A {}; +ref class C {}; + +void main() +{ + Object ^v1 = gcnew A(); + Object ^v2 = gcnew B(); + Object ^v3 = gcnew C(); + + A ^a1 = gcnew A(); + A ^a2 = gcnew B(); + A ^a3 = dynamic_cast(v1); // downcast + A ^a4 = dynamic_cast(v2); // downcast + A ^a5 = static_cast(v3); // a5 has invalid value of type C class + + B ^b1 = gcnew B(); + B ^b2 = dynamic_cast(v2); // downcast + B ^b3 = dynamic_cast(v3); // Fails b3 = null. Miss match classes + B ^b4 = dynamic_cast(a2); // downcast + + C ^c1 = gcnew C(); + C ^c2 = dynamic_cast(v1); // Fails c2 = null. Miss match classes + C ^c3 = static_cast(v2); // c3 has invalid value of type B class + C ^c4 = safe_cast(v3); // downcast + + C ^c5 = (C^)(v3); // downcast + +// B ^e1 = safe_cast(c1); // does not compile as compiler knows these + // are unrelated handles. +} \ No newline at end of file diff --git a/Chapter03/Constructors.cpp b/Chapter03/Constructors.cpp new file mode 100644 index 0000000..95285c6 --- /dev/null +++ b/Chapter03/Constructors.cpp @@ -0,0 +1,53 @@ +using namespace System; + +// Parent Class +ref class ParentClass +{ +public: + // Default constructor that initializes ParentVal to a default value + ParentClass() : PVal(10) {} + + // A constructor that initializes ParentVal to a passed value + ParentClass(int inVal) : PVal(inVal) {} + + // Copy Constructor + ParentClass(const ParentClass %p) : PVal(p.PVal) {} + + int PVal; +}; + +// --------------------------------------------------------------- + +// Child class that inherits form ParentClass +ref class ChildClass : public ParentClass +{ +public: + // Default constructor that initializes ChildVal to a default value + ChildClass () : CVal(20) {}; // default constructor + + // A constructor that initialized the parent class with a passed value + // and initializes ChildVal to a another passed value + ChildClass (int inVal1, int inVal2) : ParentClass(inVal1), CVal(inVal2) {} + + ChildClass(const ChildClass %vals) : ParentClass(vals.PVal), CVal(vals.CVal) {} + + int CVal; +}; + +void main() +{ + ParentClass p1(4); // Constructor + ParentClass p2 = p1; // Copy Constructor + + p1.PVal = 2; // Change original, new unchanged + + Console::WriteLine("p1.PVal=[{0}] p2.PVal=[{1}]", p1.PVal, p2.PVal); + + ChildClass ^c1 = gcnew ChildClass(5,6); // Constructor + ChildClass c2 = *c1; // Copy Constructor + + c1->CVal = 12; // Change original, new unchanged + + Console::WriteLine("c1=[{0}/{1}] c2=[{2}/{3}]", + c1->PVal, c1->CVal, c2.PVal, c2.CVal); +} diff --git a/Chapter03/DefIndexProps.cpp b/Chapter03/DefIndexProps.cpp new file mode 100644 index 0000000..bf608f2 --- /dev/null +++ b/Chapter03/DefIndexProps.cpp @@ -0,0 +1,37 @@ +using namespace System; + +ref class Numbers +{ +public: + Numbers() + { + defaultArray = gcnew array + { + "zero", "one", "two", "three", "four", "five" + }; + } + + property String^ default [int] + { + String^ get(int index) + { + if (index < 0) + index = 0; + else if (index > defaultArray->Length) + index = defaultArray->Length - 1; + + return defaultArray[index]; + } + } +private: + array^ defaultArray; +}; + +void main() +{ + Numbers numbers; + + Console::WriteLine(numbers[-1]); + Console::WriteLine(numbers[3]); + Console::WriteLine(numbers[10]); +} \ No newline at end of file diff --git a/Chapter03/IndexProps.cpp b/Chapter03/IndexProps.cpp new file mode 100644 index 0000000..e983a44 --- /dev/null +++ b/Chapter03/IndexProps.cpp @@ -0,0 +1,65 @@ +using namespace System; + +ref class Student +{ +public: + Student(String^ s, int g) + { + Name = s; + Grade = g; + } + + property String^ Name; + property int Grade; +}; + +ref class Course +{ + ref struct StuList + { + Student ^stu; + StuList ^next; + }; + StuList ^Stu; + static StuList ^ReportCards = nullptr; + +public: + property Student^ ReportCard [String^] + { + Student^ get(String^ n) + { + for(Stu = ReportCards; Stu && (Stu->stu->Name != n); Stu = Stu->next) + ; + if (Stu != nullptr) + return Stu->stu; + else + return gcnew Student("",0); // empty student + } + + void set(String^ n, Student^ s) + { + for(Stu = ReportCards; Stu && (Stu->stu->Name != n); Stu = Stu->next) + ; + if (Stu == nullptr) + { + StuList ^stuList = gcnew StuList; + stuList->stu = s; + stuList->next = ReportCards; + ReportCards = stuList; + } + } + } +}; + +void main() +{ + Course EnglishLit; + Student Stephen("Stephen", 95); // student as stack variable + Student ^Sarah = gcnew Student("Sarah", 98); // student as heap variable + + EnglishLit.ReportCard[ "Stephen" ] = %Stephen; // index as String literal + EnglishLit.ReportCard[ Sarah->Name ] = Sarah; // index as String^ + + Console::WriteLine(EnglishLit.ReportCard[ Stephen.Name ]->Grade); + Console::WriteLine(EnglishLit.ReportCard[ "Sarah" ]->Grade); +} \ No newline at end of file diff --git a/Chapter03/Inherit.cpp b/Chapter03/Inherit.cpp new file mode 100644 index 0000000..0b63c53 --- /dev/null +++ b/Chapter03/Inherit.cpp @@ -0,0 +1,34 @@ +using namespace System; + +/// Base class +ref class Square +{ +public: + int Area() + { + return Dims * Dims; + } + + int Dims; +}; + +/// Child class +ref class Cube : public Square +{ +public: + int Volume() + { + return Area() * Dims; + } +}; + +/// Inheritance in action +void main() +{ + Cube ^cube = gcnew Cube(); + cube->Dims = 3; + + Console::WriteLine(cube->Dims); + Console::WriteLine(cube->Area()); + Console::WriteLine(cube->Volume()); +} diff --git a/Chapter03/InterfaceEx.cpp b/Chapter03/InterfaceEx.cpp new file mode 100644 index 0000000..899941e --- /dev/null +++ b/Chapter03/InterfaceEx.cpp @@ -0,0 +1,75 @@ +using namespace System; + +interface class Interface1 +{ + void Method1(); + void Method2(); +}; + +interface class Interface2 +{ + void Method3(); + property String^ X; +}; + +ref class Base +{ +public: + void MethodBase() + { + Console::WriteLine("MethodBase()"); + } +}; + +ref class DerivedClass : public Base, public Interface1, public Interface2 +{ +public: + virtual property String^ X + { + String^ get() + { + return x; + } + + void set(String^ value) + { + x = value; + } + } + + virtual void Method1() + { + Console::WriteLine("Method1()"); + } + + virtual void Method2() + { + Console::WriteLine("Method2()"); + } + + virtual void Method3() + { + Console::WriteLine("Method3()"); + } + + virtual void Print() + { + MethodBase(); + Method1(); + Method2(); + Method3(); + } + +private: + String^ x; +}; + +void main() +{ + DerivedClass dc; + + dc.X = "Start'n Up"; + Console::WriteLine(dc.X); + + dc.Print(); +} diff --git a/Chapter03/MethodEx.cpp b/Chapter03/MethodEx.cpp new file mode 100644 index 0000000..e630d9c --- /dev/null +++ b/Chapter03/MethodEx.cpp @@ -0,0 +1,40 @@ +using namespace System; + +ref class MethodEx +{ +public: + void printPublic(int num) + { + for (int i = 0; i < num; i++) + { + Console::WriteLine( "Public" ); + } + printProtected(num/2); + } +protected: + void printProtected(int num) + { + for (int i = 0; i < num; i++) + { + Console::WriteLine( "Protected" ); + } + printPrivate(num/2); + } +private: + void printPrivate(int num) + { + for (int i = 0; i < num; i++) + { + Console::WriteLine( "Private" ); + } + } +}; + +int main() +{ + MethodEx ex; + + ex.printPublic(4); + // ex.printProtected(4); // Error can not access + // ex.printPrivate(4); // Error can not access +} diff --git a/Chapter03/NestedClass.cpp b/Chapter03/NestedClass.cpp new file mode 100644 index 0000000..e1a7bd6 --- /dev/null +++ b/Chapter03/NestedClass.cpp @@ -0,0 +1,74 @@ +using namespace System; + +ref class SurroundClass +{ +public: + ref class NestedClass // Declaration of the nested class + { + public: + int publicMember; + protected: + int protectedMember; + private: + int privateMember; + }; + + NestedClass^ protectedNC; // protected variable reference to NestedClass + +private: + NestedClass^ privateNC; // private variable reference to NestedClass + +public: + NestedClass^ publicNC; // public variable reference to NestedClass + + // Constructor for SurroundClass + // Notice the initializer list declaration of the reference member variable + SurroundClass() : publicNC(gcnew NestedClass), + protectedNC(gcnew NestedClass), + privateNC(gcnew NestedClass) + {} + + // A member showing how to access NestedClass within SurroundClass + // Notice only public member varibles of the nested class are accessed + // The private and protected are hidden + void method() + { + int x; + + NestedClass nc1; // Declared another reference NestedClass + + x = nc1.publicMember; // Accessing new NestedClass variable + + x = publicNC->publicMember; // Accessing public NestedClass variable + x = protectedNC->publicMember;// Accessing protected NestedClass variable + x = privateNC->publicMember; // Accessing private NestedClass variable + } +}; + +// A inhertied class showing how to access NestedClass within a member method +// Notice only public and protected NestedClass are accessed +// The private is hidden +ref class inheritSurroundClass : public SurroundClass +{ +public: + void method() + { + int x; + + NestedClass nc1; // can access because NestedClass + // declaration protected + x = nc1.publicMember; + + x = publicNC->publicMember; + x = protectedNC->publicMember; + } +}; + +// The main function shows how to access NestedClass from outside SurroundClass +// inhertance tree +// Notice only the public NestedClass reference is accessible +void main() +{ + SurroundClass sc; + int x = sc.publicNC->publicMember; +} diff --git a/Chapter03/OperatorOverload.cpp b/Chapter03/OperatorOverload.cpp new file mode 100644 index 0000000..f69f524 --- /dev/null +++ b/Chapter03/OperatorOverload.cpp @@ -0,0 +1,76 @@ +using namespace System; + +ref class OpClass +{ +public: + OpClass() : i(0) {} + OpClass(int x) : i(x) {} + + // x != y + static bool operator !=(const OpClass ^lhs, const OpClass ^rhs) + { + return lhs->i != rhs->i; + } + + // x * y + static OpClass^ operator *(const OpClass ^lhs, const OpClass ^rhs) + { + OpClass^ ret = gcnew OpClass(); + ret->i = lhs->i * rhs->i; + + return ret; + } + + // x *= y + static void operator *=(OpClass ^lhs, const OpClass ^rhs) + { + lhs->i *= rhs->i; + } + + // -x + static OpClass^ operator -(const OpClass ^lhs) + { + OpClass^ ret = gcnew OpClass(); + ret->i = -(lhs->i); + + return ret; + } + + // ++x and x++ + static OpClass^ operator ++(const OpClass ^lhs) + { + OpClass^ ret = gcnew OpClass(); + ret->i = (lhs->i) + 1; + + return ret; + } + + virtual String ^ ToString() override + { + return i.ToString(); + } + +private: + int i; +}; + +void main() +{ + OpClass ^op1 = gcnew OpClass(3); + OpClass ^op2 = gcnew OpClass(5); + OpClass ^op3 = gcnew OpClass(15); + + if ( op1 * op2 != op3) + Console::WriteLine("Don't Equal"); + else + Console::WriteLine("Equal"); + + op1 *= op2; + Console::WriteLine(op1); + + Console::WriteLine(++op1); // prints 15 then increments to 16 + Console::WriteLine(op1++); // increOpClassents to 17 then prints + + Console::WriteLine(-op1); // Negation of OpClass1 + Console::WriteLine(op1); // prior Negation op left OpClass1 unchanged +} diff --git a/Chapter03/OperatorOverloadMixed.cpp b/Chapter03/OperatorOverloadMixed.cpp new file mode 100644 index 0000000..68563ca --- /dev/null +++ b/Chapter03/OperatorOverloadMixed.cpp @@ -0,0 +1,38 @@ +using namespace System; + +ref class Number +{ +public: + Number(int x) : i(x) {} + + static bool operator >(Number^ n, int v) // maps to operator > + { + return n->i > v; + } + static bool operator >(int v, Number^ n) // maps to operator > + { + return v > n->i; + } + + virtual String ^ ToString() override + { + return i.ToString(); + } +private: + int i; +}; + +int main() +{ + Number^ n = gcnew Number(5); + + if ( n > 6 ) + Console::WriteLine("{0} Greater than 6", n); + else + Console::WriteLine("{0} Less than or Equal 6", n); + + if ( 6 > n ) + Console::WriteLine("6 Greater than {0}", n); + else + Console::WriteLine("6 Less than or Equal {0}", n); +} diff --git a/Chapter03/ScalarProp.cpp b/Chapter03/ScalarProp.cpp new file mode 100644 index 0000000..0e3131f --- /dev/null +++ b/Chapter03/ScalarProp.cpp @@ -0,0 +1,81 @@ +using namespace System; + +ref class ScalarProp +{ +public: + // Constructor + ScalarProp() + { + Cost = 0.0; + number = 0; + name = "Blank Name"; + description = "Scalar Property"; + } + + // trivial property + property double Cost; + + // Read & write with validated parameter + property int Number + { + void set(int value) + { + if (value < 1) + value = 1; + else if (value > 10) + value = 10; + + number = value; + } + + int get() + { + return number; + } + } + + // Write only property + property String^ Name + { + void set(String^ value) + { + name = value; + } + } + + // Ready only property + property String ^Description + { + String^ get() + { + return String::Concat(name, " ", description); + } + } + +private: + String ^name; + String ^description; + int number; +}; + + +void main() +{ + ScalarProp sp; + + sp.Name = "The Ref Class"; + + Console::WriteLine(sp.Description); + + sp.Cost = 123.45; + Console::WriteLine(sp.Cost); + + sp.Number = 20; // Will be changed to 10 + Console::WriteLine(sp.Number); + + sp.Number = -5; // Will be changed to 1 + Console::WriteLine(sp.Number); + + sp.Number = 6; // Will not change + Console::WriteLine(sp.Number); +} \ No newline at end of file diff --git a/Chapter03/StackReferences.cpp b/Chapter03/StackReferences.cpp new file mode 100644 index 0000000..32117f2 --- /dev/null +++ b/Chapter03/StackReferences.cpp @@ -0,0 +1,23 @@ +using namespace System; + +ref class Square +{ +public: + int Area() + { + return Dims * Dims; + } + + int Dims; +}; + +void main() +{ + Square ^sqr1 = gcnew Square(); // Handle + sqr1->Dims = 2; + Console::WriteLine( sqr1->Area() ); + + Square sqr2; // local stack instance + sqr2.Dims = 3; + Console::WriteLine( sqr2.Area() ); +} diff --git a/Chapter03/StaticMethodEx.cpp b/Chapter03/StaticMethodEx.cpp new file mode 100644 index 0000000..1bd52e1 --- /dev/null +++ b/Chapter03/StaticMethodEx.cpp @@ -0,0 +1,17 @@ +using namespace System; + +ref class StaticTest +{ +private: + static int x = 42; +public: + static int get_x() + { + return x; + } +}; + +void main() +{ + Console::WriteLine ( StaticTest::get_x() ); +} \ No newline at end of file diff --git a/Chapter03/StaticProp.cpp b/Chapter03/StaticProp.cpp new file mode 100644 index 0000000..8c0234f --- /dev/null +++ b/Chapter03/StaticProp.cpp @@ -0,0 +1,25 @@ +using namespace System; + +ref class StaticProp +{ + static String^ name; + +public: + property static String^ Name + { + void set(String^ value) + { + name = value; + } + String^ get() + { + return name; + } + } +}; + +int main() +{ + StaticProp::Name = "Static Property"; + Console::WriteLine(StaticProp::Name); +} \ No newline at end of file diff --git a/Chapter03/VirtualAnimals.cpp b/Chapter03/VirtualAnimals.cpp new file mode 100644 index 0000000..5a0c9a0 --- /dev/null +++ b/Chapter03/VirtualAnimals.cpp @@ -0,0 +1,83 @@ +using namespace System; + +ref class Animal +{ +public: + virtual void Speak () + { + Console::WriteLine("Animal is Mysteriously Silent"); + } +}; + +ref class Dog : public Animal +{ +public: + // Standard explicit virtual override + virtual void Speak() override + { + Console::WriteLine("Dog says Woof"); + } +}; + +ref class Puppy : public Dog +{ +public: + // Yip name overrides dog's virtual speak + virtual void Yip() = Dog::Speak // should be just: = Speak + { + Console::WriteLine("Puppy says Yip Yip"); + } +}; + +ref class Cat : public Animal +{ +public: + // Start a new speak virtual sequence so animal's virtual speak fails + virtual void Speak() new + { + Console::WriteLine("Cat says Meow"); + } +}; + +ref class Tiger : public Cat +{ +public: + // Though inherited from cat, Tiger name overrides Animal's speak + // thus, can speak though animal virtual sequence + // also this method overrides Cat’s virtual Speak method as well + virtual void Growl() = Animal::Speak, Cat::Speak + { + Console::WriteLine("Tiger says Grrrr"); + } +}; + +void main() +{ + // Array of Animal handles + array^ animals = gcnew array + { + gcnew Animal(), + gcnew Dog(), + gcnew Puppy(), + gcnew Cat(), + gcnew Tiger() + }; + + for each ( Animal ^a in animals) + { + a->Speak(); + } + + Console::WriteLine(); + + Animal^ cat1 = gcnew Cat(); + Cat^ cat2 = gcnew Cat(); + Cat^ tiger = gcnew Tiger(); + + // new cancels virtual sequence of Animal + cat1->Speak(); + + // new speak sequence established for cat + cat2->Speak(); + tiger->Speak(); +} diff --git a/Chapter04/BuildAll.bat b/Chapter04/BuildAll.bat new file mode 100644 index 0000000..70715f4 --- /dev/null +++ b/Chapter04/BuildAll.bat @@ -0,0 +1,18 @@ +cd Cards +call BuildAll.bat + +cd ../PlayCards +call BuildAll.bat + +cd .. +cl CatchAll.cpp /clr +cl CatchException.cpp /clr:safe +cl Defined.cpp /clr:safe +cl Delegates.cpp /clr:safe +cl Events.cpp /clr:safe +cl Finally.cpp /clr:safe +cl Generics.cpp /clr:safe +cl MultiException.cpp /clr:safe +cl RethrowException.cpp /clr:safe +cl Templates.cpp /clr:safe +cl ThrowDerived.cpp /clr:safe diff --git a/Chapter04/Cards/BuildAll.bat b/Chapter04/Cards/BuildAll.bat new file mode 100644 index 0000000..97497fa --- /dev/null +++ b/Chapter04/Cards/BuildAll.bat @@ -0,0 +1 @@ +cl card.cpp deck.cpp /clr:safe /LD /FeCards.dll diff --git a/Chapter04/Cards/Card.cpp b/Chapter04/Cards/Card.cpp new file mode 100644 index 0000000..aae70a9 --- /dev/null +++ b/Chapter04/Cards/Card.cpp @@ -0,0 +1,58 @@ +using namespace System; + +#include "card.h" +using namespace Cards; + +Card::Card(int type, Suits suit) +{ + Type = type; + Suit = suit; +} + +int Card::Type::get() +{ + return type; +} + +void Card::Type::set(int value) +{ + type = value; +} + +Suits Card::Suit::get() +{ + return suit; +} + +void Card::Suit::set(Suits value) +{ + suit = value; +} + +String^ Card::ToString() +{ + String ^t; + + if (Type > 1 && Type < 11) + t = Type.ToString(); + else if (Type == 1) + t = "A"; + else if (Type == 11) + t = "J"; + else if (Type == 12) + t = "Q"; + else + t = "K"; + + switch (Suit) + { + case Suits::Heart: + return String::Concat(t, gcnew String((Char)3, 1)); + case Suits::Diamond: + return String::Concat(t, gcnew String((Char)4, 1)); + case Suits::Club: + return String::Concat(t, gcnew String((Char)5, 1)); + default: //Spade + return String::Concat(t, gcnew String((Char)6, 1)); + } +} diff --git a/Chapter04/Cards/Card.h b/Chapter04/Cards/Card.h new file mode 100644 index 0000000..2322471 --- /dev/null +++ b/Chapter04/Cards/Card.h @@ -0,0 +1,26 @@ +namespace Cards +{ + public enum class Suits { Heart, Diamond, Spade, Club }; + + public ref class Card + { + int type; + Suits suit; + + public: + Card(int type, Suits suit); + + property int Type + { + int get(); + void set(int value); + } + property Suits Suit + { + Suits get(); + void set(Suits value); + } + + virtual String^ ToString() override; + }; +} diff --git a/Chapter04/Cards/Deck.cpp b/Chapter04/Cards/Deck.cpp new file mode 100644 index 0000000..e81e4a0 --- /dev/null +++ b/Chapter04/Cards/Deck.cpp @@ -0,0 +1,44 @@ +using namespace System; + +#include "card.h" +#include "deck.h" +using namespace Cards; + +Deck::Deck(void) +{ + deck = gcnew array(52); + + for (int i = 0; i < 13; i++) + { + deck[i] = gcnew Card(i+1, Suits::Heart); + deck[i+13] = gcnew Card(i+1, Suits::Club); + deck[i+26] = gcnew Card(i+1, Suits::Diamond); + deck[i+39] = gcnew Card(i+1, Suits::Spade); + } + curCard = 0; +} + +Card^ Deck::Deal() +{ + if (curCard < deck->Length) + return deck[curCard++]; + else + return nullptr; +} + +void Deck::Shuffle() +{ + Random ^r = gcnew Random(); + Card ^tmp; + int j; + + for( int i = 0; i < deck->Length; i++ ) + { + j = r->Next(deck->Length); + tmp = deck[j]; + deck[j] = deck[i]; + deck[i] = tmp; + } + + curCard = 0; +} diff --git a/Chapter04/Cards/Deck.h b/Chapter04/Cards/Deck.h new file mode 100644 index 0000000..c733532 --- /dev/null +++ b/Chapter04/Cards/Deck.h @@ -0,0 +1,14 @@ +namespace Cards +{ + public ref class Deck + { + array^ deck; + int curCard; + + public: + Deck(void); + + Card ^Deal(); + void Shuffle(); + }; +} diff --git a/Chapter04/CatchAll.cpp b/Chapter04/CatchAll.cpp new file mode 100644 index 0000000..340526f --- /dev/null +++ b/Chapter04/CatchAll.cpp @@ -0,0 +1,45 @@ +using namespace System; + +ref class MyDerivedException : public ApplicationException +{ +public: + MyDerivedException( String ^err ); +}; + +MyDerivedException::MyDerivedException(String ^err) : ApplicationException(err) +{ +} + + +ref class MyException // Not derived from Exception class +{ +}; + + +void main() +{ + for (int i = 0; i < 4; i++) + { + Console::WriteLine("Start Loop"); + try + { + if (i == 1) + throw gcnew ApplicationException("\tBase Exception"); + else if (i == 2) + throw gcnew MyDerivedException("\tMy Derived Exception"); + else if (i == 3) + throw gcnew MyException(); + + Console::WriteLine("\tNo Exception"); + } + catch (ApplicationException ^e) + { + Console::WriteLine(e->Message); + } + catch (...) + { + Console::WriteLine("\tMy Exception"); + } + Console::WriteLine("End Loop"); + } +} \ No newline at end of file diff --git a/Chapter04/CatchException.cpp b/Chapter04/CatchException.cpp new file mode 100644 index 0000000..c210440 --- /dev/null +++ b/Chapter04/CatchException.cpp @@ -0,0 +1,20 @@ +using namespace System; + +ref class X {}; +ref class Y {}; + +void main() +{ + X ^x = gcnew X; + + try + { + Y ^y = (Y^)x; + Console::WriteLine("No Exception"); // Should not execute + } + catch (InvalidCastException ^e) + { + Console::WriteLine("Invalid Cast Exception"); + Console::WriteLine(e->StackTrace); + } +} \ No newline at end of file diff --git a/Chapter04/Defined.cpp b/Chapter04/Defined.cpp new file mode 100644 index 0000000..b81d174 --- /dev/null +++ b/Chapter04/Defined.cpp @@ -0,0 +1,17 @@ +using namespace System; + +#define DISAPPEARS +#define ONE 1 +#define TWO 2 +#define POW2(x) (x)*(x) + +void main() +{ + Console::Write("The follow symbol disappears->" DISAPPEARS); + Console::WriteLine("<-"); + + Int32 x = TWO; + Int32 y = POW2(x + ONE); + + Console::WriteLine(y); +} \ No newline at end of file diff --git a/Chapter04/Delegates.cpp b/Chapter04/Delegates.cpp new file mode 100644 index 0000000..44e8c56 --- /dev/null +++ b/Chapter04/Delegates.cpp @@ -0,0 +1,69 @@ +using namespace System; + +/// A Delegate that talks a lot +delegate void SayDelegate(String ^name); + +/// A friendly function +void SayHello(String ^name) +{ + Console::Write("Hello there "); + Console::WriteLine(name); +} + +/// A talkative class +ref class Talkative +{ +public: + static void SayHi(String ^name); + void SayStuff(String ^name); + void SayBye(String ^name); +}; + +void Talkative::SayHi(System::String ^name) +{ + Console::Write("Hi there "); + Console::WriteLine(name); +} + +void Talkative::SayStuff(System::String ^name) +{ + Console::Write("Nice weather we are having. Right, "); + Console::Write(name); + Console::WriteLine("?"); +} + +void Talkative::SayBye(System::String ^name) +{ + Console::Write("Good-bye "); + Console::WriteLine(name); +} + +/// Delegates in action +void main() +{ + SayDelegate^ say; + + // Global Function + say = gcnew SayDelegate(&SayHello); + + // add Static member function + say += gcnew SayDelegate(&Talkative::SayHi); + + Talkative ^computer = gcnew Talkative(); + + // add instance member functions + say = say + gcnew SayDelegate(computer, &Talkative::SayStuff); + say += gcnew SayDelegate(computer, &Talkative::SayBye); + + // invoke delegate + say->Invoke("Stephen"); + + Console::WriteLine("-------------------------------"); + + // remove a couple of methods + say = say - gcnew SayDelegate(&Talkative::SayHi); + say -= gcnew SayDelegate(computer, &Talkative::SayBye); + + // invoke delegate again with two fewer methods + say("Stephen"); +} \ No newline at end of file diff --git a/Chapter04/Events.cpp b/Chapter04/Events.cpp new file mode 100644 index 0000000..26511cc --- /dev/null +++ b/Chapter04/Events.cpp @@ -0,0 +1,87 @@ +using namespace System; + +delegate void SayHandler(String ^name); + +ref class EventSource +{ +public: + event SayHandler^ OnSay; + + void Say(String ^name) + { + OnSay(name); + } +}; + +ref class EventReceiver1 +{ + EventSource ^source; +public: + + EventReceiver1(EventSource ^src) + { + if (src == nullptr) + throw gcnew ArgumentNullException("Must pass an Event Source"); + + source = src; + + source->OnSay += gcnew SayHandler(this, &EventReceiver1::SayHello); + source->OnSay += gcnew SayHandler(this, &EventReceiver1::SayStuff); + } + + void RemoveStuff() + { + source->OnSay -= gcnew SayHandler(this, &EventReceiver1::SayStuff); + } + + void SayHello(String ^name) + { + Console::Write("Hello there "); + Console::WriteLine(name); + } + + void SayStuff(String ^name) + { + Console::Write("Nice weather we are having. Right, "); + Console::Write(name); + Console::WriteLine("?"); + } +}; + +ref class EventReceiver2 +{ + EventSource ^source; +public: + + EventReceiver2(EventSource ^src) + { + if (src == nullptr) + throw gcnew ArgumentNullException("Must pass an Event Source"); + + source = src; + + source->OnSay += gcnew SayHandler(this, &EventReceiver2::SayBye); + } + + void SayBye(String ^name) + { + Console::Write("Good-bye "); + Console::WriteLine(name); + } +}; + +void main() +{ + EventSource ^source = gcnew EventSource(); + + EventReceiver1 ^receiver1 = gcnew EventReceiver1(source); + EventReceiver2 ^receiver2 = gcnew EventReceiver2(source); + + source->Say("Mr Fraser"); + + Console::WriteLine("-------------------------------"); + + receiver1->RemoveStuff(); + + source->Say("Stephen"); +} \ No newline at end of file diff --git a/Chapter04/Finally.cpp b/Chapter04/Finally.cpp new file mode 100644 index 0000000..9027cac --- /dev/null +++ b/Chapter04/Finally.cpp @@ -0,0 +1,33 @@ +using namespace System; + +void main() +{ + for (int i = 0; i < 3; i++) + { + Console::WriteLine("Start Loop"); + try + { + if (i == 0) + { + Console::WriteLine("\tCounter = 0"); + } + else if (i == 1) + { + throw gcnew ApplicationException("\t*Exception* Counter = 1"); + } + else + { + Console::WriteLine("\tCounter > 1"); + } + } + catch (ApplicationException ^e) + { + Console::WriteLine(e->Message); + } + finally + { + Console::WriteLine("\tDone every time"); + } + Console::WriteLine("End Loop"); + } +} \ No newline at end of file diff --git a/Chapter04/Generics.cpp b/Chapter04/Generics.cpp new file mode 100644 index 0000000..b6250bd --- /dev/null +++ b/Chapter04/Generics.cpp @@ -0,0 +1,49 @@ +using namespace System; + +// Generic Class ---------------------------------------- + +generic + where K : IComparable +ref class KVClass +{ +public: + property K Key; + property V Value; + KVClass(K key, V value); + + V isGreater(KVClass ^in); +}; + +generic +KVClass::KVClass(K key, V value) +{ + Key = key; + Value = value; +} + + +generic + where K : IComparable +V KVClass::isGreater(KVClass ^in) +{ + if (Key->CompareTo(in->Key) > 0) + return Value; + else + return in->Value; +} + + +// main function ---------------------------------------- + +void main() +{ + KVClass ^a = gcnew KVClass(5, "Five"); + KVClass ^b = gcnew KVClass(6, "Six"); + + Console::WriteLine(a->isGreater(b)); + + KVClass ^t = gcnew KVClass("Tomato", 1); + KVClass ^c = gcnew KVClass("Carrot", 2); + + Console::WriteLine(t->isGreater(c)); +} \ No newline at end of file diff --git a/Chapter04/MultiException.cpp b/Chapter04/MultiException.cpp new file mode 100644 index 0000000..ceb7b99 --- /dev/null +++ b/Chapter04/MultiException.cpp @@ -0,0 +1,59 @@ +using namespace System; + +/// Base Class +ref class LevelOneException : public ApplicationException +{ +public: + LevelOneException( String ^err ); +}; + +LevelOneException::LevelOneException(String ^err) : ApplicationException(err) +{ +} + +/// Inherited Class +ref class LevelTwoException : public LevelOneException +{ +public: + LevelTwoException( String ^err ); +}; + +LevelTwoException::LevelTwoException(String ^err) : LevelOneException(err) +{ +} + +/// Catching multiple exceptions +void main() +{ + for (int i = 0; i < 4; i++) + { + Console::WriteLine("Start Loop"); + try + { + if (i == 1) + throw gcnew ApplicationException("\tBase Exception Thrown"); + else if (i == 2) + throw gcnew LevelOneException("\tLevel 1 Exception Thrown"); + else if (i == 3) + throw gcnew LevelTwoException("\tLevel 2 Exception Thrown"); + + Console::WriteLine("\tNo Exception"); + } + catch (LevelTwoException ^e2) + { + Console::WriteLine(e2->Message); + Console::WriteLine("\tLevel 2 Exception Caught"); + } + catch (LevelOneException ^e1) + { + Console::WriteLine(e1->Message); + Console::WriteLine("\tLevel 1 Exception Caught"); + } + catch (ApplicationException ^e) + { + Console::WriteLine(e->Message); + Console::WriteLine("\tBase Exception Caught"); + } + Console::WriteLine("End Loop"); + } +} \ No newline at end of file diff --git a/Chapter04/PlayCards/BuildAll.bat b/Chapter04/PlayCards/BuildAll.bat new file mode 100644 index 0000000..a190b46 --- /dev/null +++ b/Chapter04/PlayCards/BuildAll.bat @@ -0,0 +1,2 @@ +cl card.cpp deck.cpp /clr:safe /LD /FeCards.dll +cl playcards.cpp /CLR:safe diff --git a/Chapter04/PlayCards/Card.cpp b/Chapter04/PlayCards/Card.cpp new file mode 100644 index 0000000..aae70a9 --- /dev/null +++ b/Chapter04/PlayCards/Card.cpp @@ -0,0 +1,58 @@ +using namespace System; + +#include "card.h" +using namespace Cards; + +Card::Card(int type, Suits suit) +{ + Type = type; + Suit = suit; +} + +int Card::Type::get() +{ + return type; +} + +void Card::Type::set(int value) +{ + type = value; +} + +Suits Card::Suit::get() +{ + return suit; +} + +void Card::Suit::set(Suits value) +{ + suit = value; +} + +String^ Card::ToString() +{ + String ^t; + + if (Type > 1 && Type < 11) + t = Type.ToString(); + else if (Type == 1) + t = "A"; + else if (Type == 11) + t = "J"; + else if (Type == 12) + t = "Q"; + else + t = "K"; + + switch (Suit) + { + case Suits::Heart: + return String::Concat(t, gcnew String((Char)3, 1)); + case Suits::Diamond: + return String::Concat(t, gcnew String((Char)4, 1)); + case Suits::Club: + return String::Concat(t, gcnew String((Char)5, 1)); + default: //Spade + return String::Concat(t, gcnew String((Char)6, 1)); + } +} diff --git a/Chapter04/PlayCards/Card.h b/Chapter04/PlayCards/Card.h new file mode 100644 index 0000000..2c662eb --- /dev/null +++ b/Chapter04/PlayCards/Card.h @@ -0,0 +1,26 @@ +namespace Cards +{ + public enum class Suits { Heart, Diamond, Spade, Club }; + + public ref class Card + { + int type; + Suits suit; + + public: + Card(int type, Suits suit); + + property int Type + { + int get(); + void set(int value); + } + property Suits Suit + { + Suits get(); + void set(Suits value); + } + + virtual String^ ToString() override; + }; +} diff --git a/Chapter04/PlayCards/Deck.cpp b/Chapter04/PlayCards/Deck.cpp new file mode 100644 index 0000000..e81e4a0 --- /dev/null +++ b/Chapter04/PlayCards/Deck.cpp @@ -0,0 +1,44 @@ +using namespace System; + +#include "card.h" +#include "deck.h" +using namespace Cards; + +Deck::Deck(void) +{ + deck = gcnew array(52); + + for (int i = 0; i < 13; i++) + { + deck[i] = gcnew Card(i+1, Suits::Heart); + deck[i+13] = gcnew Card(i+1, Suits::Club); + deck[i+26] = gcnew Card(i+1, Suits::Diamond); + deck[i+39] = gcnew Card(i+1, Suits::Spade); + } + curCard = 0; +} + +Card^ Deck::Deal() +{ + if (curCard < deck->Length) + return deck[curCard++]; + else + return nullptr; +} + +void Deck::Shuffle() +{ + Random ^r = gcnew Random(); + Card ^tmp; + int j; + + for( int i = 0; i < deck->Length; i++ ) + { + j = r->Next(deck->Length); + tmp = deck[j]; + deck[j] = deck[i]; + deck[i] = tmp; + } + + curCard = 0; +} diff --git a/Chapter04/PlayCards/Deck.h b/Chapter04/PlayCards/Deck.h new file mode 100644 index 0000000..c733532 --- /dev/null +++ b/Chapter04/PlayCards/Deck.h @@ -0,0 +1,14 @@ +namespace Cards +{ + public ref class Deck + { + array^ deck; + int curCard; + + public: + Deck(void); + + Card ^Deal(); + void Shuffle(); + }; +} diff --git a/Chapter04/PlayCards/PlayCards.cpp b/Chapter04/PlayCards/PlayCards.cpp new file mode 100644 index 0000000..7368e3c --- /dev/null +++ b/Chapter04/PlayCards/PlayCards.cpp @@ -0,0 +1,27 @@ +#using + +using namespace System; +using namespace Cards; + +void main() +{ + Deck deck; + + deck.Shuffle(); + + Card ^card; + int cnt = 0; + while ((card = deck.Deal()) != nullptr) + { + Console::Write(card->ToString()); + Console::Write("\t"); + cnt++; + + if (cnt > 4) + { + Console::WriteLine(""); + cnt = 0; + } + } + Console::WriteLine(""); +} \ No newline at end of file diff --git a/Chapter04/RethrowException.cpp b/Chapter04/RethrowException.cpp new file mode 100644 index 0000000..d57fc5b --- /dev/null +++ b/Chapter04/RethrowException.cpp @@ -0,0 +1,25 @@ +using namespace System; + +void main() +{ + try + { + try + { + throw gcnew ApplicationException("\t***Boom***"); + Console::WriteLine("Imbedded Try End"); + } + catch (ApplicationException ^ie) + { + Console::WriteLine("Caught Exception "); + Console::WriteLine(ie->Message); + throw; + } + Console::WriteLine("Outer Try End"); + } + catch (ApplicationException ^oe) + { + Console::WriteLine("Recaught Exception "); + Console::WriteLine(oe->Message); + } +} \ No newline at end of file diff --git a/Chapter04/Templates.cpp b/Chapter04/Templates.cpp new file mode 100644 index 0000000..83cd207 --- /dev/null +++ b/Chapter04/Templates.cpp @@ -0,0 +1,116 @@ +using namespace System; + +// Function Template -------------------------------------- + +template +T min ( T a, T b) +{ + return (a < b) ? a : b; +} + +// Class Template ----------------------------------------- + +template +ref class Point2D +{ +public: + Point2D(); + Point2D(T x, T y); + + T X; + T Y; + + static Point2D^ operator-(const Point2D^ lhs, const Point2D^ rhs); + static Point2D^ operator*(const Point2D^ lhs, const T rhs); + + virtual String^ ToString() override; +}; + +template +Point2D::Point2D() : X((T)0), Y((T)0) {} + +template +Point2D::Point2D(T x, T y) : X(x), Y(y) {} + +template +Point2D^ Point2D::operator-(const Point2D^ lhs, const Point2D^ rhs) +{ + Point2D^ ret = gcnew Point2D(); + + ret->X = lhs->X - rhs->X; + ret->Y = lhs->Y - rhs->Y; + + return ret; +} + +template +Point2D^ Point2D::operator*(const Point2D^ lhs, const T rhs) +{ + Point2D^ ret = gcnew Point2D(); + + ret->X = lhs->X * rhs; + ret->Y = lhs->Y * rhs; + + return ret; +} + +template +String^ Point2D::ToString() +{ + return String::Format("X={0} Y={1}", X, Y); +} + +// Class Template Specialization ---------------------------- + +template <> +ref class Point2D +{ +public: + Point2D() { throw gcnew Exception("Data Type is too small"); } + Point2D(char x, char y) { throw gcnew Exception("Data Type is too small"); } +}; + +// main function -------------------------------------------- + +void main() +{ + int a = 5; + int b = 6; + double c = 5.1; + + Console::WriteLine("The min of {0} and {1} is {2}", a, b, min(a,b)); + Console::WriteLine("The min of {0} and {1} is {2}", a, c, min(a,c)); + + Console::WriteLine("----------------------------"); + + Point2D^ TopLeftI = gcnew Point2D(10, 10); + Point2D^ BottomRightI = gcnew Point2D(15, 20); + + Point2D^ SizeI = BottomRightI - TopLeftI; + Console::WriteLine(SizeI); + + SizeI = SizeI * 2; + Console::WriteLine(SizeI); + + Console::WriteLine("----------------------------"); + + Point2D^ TopLeft = gcnew Point2D(10.5, 10.9); + Point2D^ BottomRight = gcnew Point2D(15.2, 20.3); + + Point2D^ SizeD = BottomRight - TopLeft; + Console::WriteLine(SizeD); + + SizeD = SizeD * 0.5; + Console::WriteLine(SizeD); + + Console::WriteLine("----------------------------"); + + try + { + Point2D^ TopLeft = gcnew Point2D(10, 10); + } + catch (Exception^ ex) + { + Console::WriteLine(ex->Message); + } +} \ No newline at end of file diff --git a/Chapter04/ThrowDerived.cpp b/Chapter04/ThrowDerived.cpp new file mode 100644 index 0000000..86b3292 --- /dev/null +++ b/Chapter04/ThrowDerived.cpp @@ -0,0 +1,39 @@ +using namespace System; + +ref class MyException : public ApplicationException +{ +public: + MyException( String ^err ); +}; + +MyException::MyException(System::String ^err) : ApplicationException(err) +{ +} + +void main() +{ + for (int i = 0; i < 3; i++) + { + Console::WriteLine("Start Loop"); + try + { + if (i == 0) + { + Console::WriteLine("\tCounter equal to 0"); + } + else if (i == 1) + { + throw gcnew MyException("\t**Exception** Counter equal to 1"); + } + else + { + Console::WriteLine("\tCounter greater than 1"); + } + } + catch (MyException ^e) + { + Console::WriteLine(e->Message); + } + Console::WriteLine("End Loop"); + } +} \ No newline at end of file diff --git a/Chapter06/AllTags/AllTags.cpp b/Chapter06/AllTags/AllTags.cpp new file mode 100644 index 0000000..8c61385 --- /dev/null +++ b/Chapter06/AllTags/AllTags.cpp @@ -0,0 +1,2 @@ +#include "AllTags.h" + diff --git a/Chapter06/AllTags/AllTags.h b/Chapter06/AllTags/AllTags.h new file mode 100644 index 0000000..4fd4008 --- /dev/null +++ b/Chapter06/AllTags/AllTags.h @@ -0,0 +1,152 @@ +#pragma once + +using namespace System; +using namespace System::IO; + +namespace AllTags +{ + public ref class AClass + { + public: + + /// + /// This is a summary tag for the summaryTag() method + /// + void summaryTag() {} + + /// The first int parameter + /// The second String^ parameter + void paramTag(int param1, String ^param2) {} + + /// returnsTag returns an int + int returnsTag() {return 0;} + + /// valueTag property has a value of double + property double valueTag + { + double get() {return 0.0;} + void set(double val) {} + } + + /// + /// This is a remarks tag for the remarksTag() method + /// + void remarksTag() {} + + /// + /// Example summary + /// + /// Visual Basic .NET code example + /// + /// + /// C# code example + /// + /// + /// C++ code example + /// + /// + void exampleTag() {} + + /// + /// This method might throw this exception (NOT) + /// + void exceptionTag() {} + + /// + /// Go ahead anyone can access me. + /// + void permissionTag() {} + + /// + /// Some Program code in a summary + /// + void cTag() {} + + /// + /// Some code in an example tag + /// + /// A code statement; + /// Another code statement; + /// + /// + void codeTag() {} + + /// + /// This is the first paragraph which spans more than one line + /// when the document window is small enough.This is the + /// next paragraph which started in a new line. + /// + void paraTag() {} + + /// + /// A bullet list + /// + /// bullet + /// bullet + /// + /// A numbered list + /// + /// entry 1 + /// entry 2 + /// entry n + /// + /// A table + /// + /// + /// row 1 -- column a + /// row 1 -- column b + /// row 1 -- column c + /// + /// + /// row 2 -- column a + /// row 2 -- column b + /// row 2 -- column c + /// + /// + /// A definition of terms + /// + /// + /// Properties + /// Initial Value + /// + /// + /// term1 name + /// term1 description + /// + /// + /// term2 name + /// term2 description + /// + /// + /// termN name + /// termN description + /// + /// + /// + void listTag() {} + + /// This is a summary with an <include> tag containing + /// a <list type="bullet"> + /// + /// + /// + void includeTag() {} + + /// This summary reference the + /// parameter of the method + /// + void paramrefTag(int param1) {} + + /// + /// The basic see tag + /// The enhanced see tag System::IO:FileInfo + /// + void seeTag() {} + + /// + /// The basic see tag . + /// The enhanced see tag System::IO::FileInfo + /// + void seealsoTag() {} + }; +} diff --git a/Chapter06/AllTags/AllTags.vcproj b/Chapter06/AllTags/AllTags.vcproj new file mode 100644 index 0000000..280814e --- /dev/null +++ b/Chapter06/AllTags/AllTags.vcproj @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter06/AllTags/document.xml b/Chapter06/AllTags/document.xml new file mode 100644 index 0000000..83c4db8 --- /dev/null +++ b/Chapter06/AllTags/document.xml @@ -0,0 +1,20 @@ + + + + + These are repeating bullets: + + bullet + bullet + bullet + + + + + + This is a complete <remark> entry from an include + file called documentation.xml. + + + + diff --git a/Chapter06/Chapter06.sln b/Chapter06/Chapter06.sln new file mode 100644 index 0000000..918afe1 --- /dev/null +++ b/Chapter06/Chapter06.sln @@ -0,0 +1,54 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleTripleSlash", "SimpleTripleSlash\SimpleTripleSlash.vcproj", "{7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ViewSimple", "ViewSimple\ViewSimple.vcproj", "{C64C6183-FD33-42CF-8A27-2774E22CFC82}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllTags", "AllTags\AllTags.vcproj", "{E42DA001-0DAA-4ED9-AEF6-6220777D40BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Debug|Win32.ActiveCfg = Debug|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Debug|Win32.Build.0 = Debug|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Release|Any CPU.ActiveCfg = Release|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Release|Mixed Platforms.Build.0 = Release|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Release|Win32.ActiveCfg = Release|Win32 + {7D891CBC-A936-4BD5-9697-C9B3DB8D9B98}.Release|Win32.Build.0 = Release|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Debug|Win32.ActiveCfg = Debug|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Debug|Win32.Build.0 = Debug|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Release|Any CPU.ActiveCfg = Release|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Release|Mixed Platforms.Build.0 = Release|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Release|Win32.ActiveCfg = Release|Win32 + {C64C6183-FD33-42CF-8A27-2774E22CFC82}.Release|Win32.Build.0 = Release|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Debug|Win32.ActiveCfg = Debug|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Debug|Win32.Build.0 = Debug|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Release|Any CPU.ActiveCfg = Release|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Release|Mixed Platforms.Build.0 = Release|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Release|Win32.ActiveCfg = Release|Win32 + {E42DA001-0DAA-4ED9-AEF6-6220777D40BC}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter06/Chapter06.suo b/Chapter06/Chapter06.suo new file mode 100644 index 0000000..5bbc107 Binary files /dev/null and b/Chapter06/Chapter06.suo differ diff --git a/Chapter06/Documentation.chm b/Chapter06/Documentation.chm new file mode 100644 index 0000000..8710152 Binary files /dev/null and b/Chapter06/Documentation.chm differ diff --git a/Chapter06/SimpleTripleSlash/SimpleTripleSlash.cpp b/Chapter06/SimpleTripleSlash/SimpleTripleSlash.cpp new file mode 100644 index 0000000..0b2acd1 --- /dev/null +++ b/Chapter06/SimpleTripleSlash/SimpleTripleSlash.cpp @@ -0,0 +1,4 @@ +// This is the main DLL file. + +#include "SimpleTripleSlash.h" + diff --git a/Chapter06/SimpleTripleSlash/SimpleTripleSlash.h b/Chapter06/SimpleTripleSlash/SimpleTripleSlash.h new file mode 100644 index 0000000..49738a9 --- /dev/null +++ b/Chapter06/SimpleTripleSlash/SimpleTripleSlash.h @@ -0,0 +1,21 @@ +// SimpleTripleSlash.h + +#pragma once + +using namespace System; + +namespace SimpleTripleSlash +{ + /// + /// This is a summary comment for Class1 + /// + public ref class Class1 + { + public: + /// This is a summary comment for Method1 + void Method1() {} + + /// This is a summary comment for Variable1 + int Variable1; + }; +} diff --git a/Chapter06/SimpleTripleSlash/SimpleTripleSlash.vcproj b/Chapter06/SimpleTripleSlash/SimpleTripleSlash.vcproj new file mode 100644 index 0000000..08e9467 --- /dev/null +++ b/Chapter06/SimpleTripleSlash/SimpleTripleSlash.vcproj @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter06/ViewSimple/AssemblyInfo.cpp b/Chapter06/ViewSimple/AssemblyInfo.cpp new file mode 100644 index 0000000..4bb4f93 --- /dev/null +++ b/Chapter06/ViewSimple/AssemblyInfo.cpp @@ -0,0 +1,61 @@ +#include "stdafx.h" + +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ViewSimple")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ViewSimple")]; +[assembly:AssemblyCopyrightAttribute("Copyright @ 2005")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project directory. +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly:AssemblyDelaySignAttribute(false)]; +[assembly:AssemblyKeyFileAttribute("")]; +[assembly:AssemblyKeyNameAttribute("")]; + +[assembly:ComVisible(false)]; + diff --git a/Chapter06/ViewSimple/ViewSimple.cpp b/Chapter06/ViewSimple/ViewSimple.cpp new file mode 100644 index 0000000..2c40667 --- /dev/null +++ b/Chapter06/ViewSimple/ViewSimple.cpp @@ -0,0 +1,14 @@ +// This is the main project file for VC++ application project +// generated using an Application Wizard. + +using namespace System; +using namespace SimpleTripleSlash; + +void main() +{ + Class1 ^class1 = gcnew Class1(); + + class1->Method1(); + + int x = class1->Variable1; +} diff --git a/Chapter06/ViewSimple/ViewSimple.vcproj b/Chapter06/ViewSimple/ViewSimple.vcproj new file mode 100644 index 0000000..98c6d4c --- /dev/null +++ b/Chapter06/ViewSimple/ViewSimple.vcproj @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter06/ViewSimple/resource.h b/Chapter06/ViewSimple/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter06/ViewSimple/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter06/ViewSimple/stdafx.cpp b/Chapter06/ViewSimple/stdafx.cpp new file mode 100644 index 0000000..38c5ac0 --- /dev/null +++ b/Chapter06/ViewSimple/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ViewSimple.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter06/ViewSimple/stdafx.h b/Chapter06/ViewSimple/stdafx.h new file mode 100644 index 0000000..5acdcf6 --- /dev/null +++ b/Chapter06/ViewSimple/stdafx.h @@ -0,0 +1,10 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include + +// TODO: reference additional headers your program requires here diff --git a/Chapter07/AlgorithmEx.cpp b/Chapter07/AlgorithmEx.cpp new file mode 100644 index 0000000..10b68a8 --- /dev/null +++ b/Chapter07/AlgorithmEx.cpp @@ -0,0 +1,110 @@ +#include +#include +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // comparison operator. + bool operator>(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) > 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + +bool BeforeCaesar(Pet^ value) +{ + Pet^ Caesar = gcnew Pet("Caesar"); + return value > Caesar; // Note sorted in decending order +} + +int main(array ^args) +{ + vector pets; + pets.push_back(gcnew Pet("King")); + pets.push_back(gcnew Pet("Buster")); + pets.push_back(gcnew Pet("Caesar")); + pets.push_back(gcnew Pet("Daisy")); + + Console::Write("initial -- vector:\n "); + for each (Pet^ pet in pets) + Console::Write("{0} ", pet->Name); + + Console::Write("\n\nreverse(F,L):\n "); + reverse(pets.begin(), pets.end()); + for each (Pet^ pet in pets) + Console::Write("{0} ", pet->Name); + + Console::Write("\n\nsort(F,L):\n "); + sort(pets.begin(), pets.end()); + for each (Pet^ pet in pets) + Console::Write("{0} ", pet->Name); + + Console::Write("\n\nrandom_shuffle(F,L):\n "); + random_shuffle(pets.begin(), pets.end()); + for each (Pet^ pet in pets) + Console::Write("{0} ", pet->Name); + + Console::Write("\n\nsort(F,L, functor):\n "); + sort(pets.begin(), pets.end(), greater()); + for each (Pet^ pet in pets) + Console::Write("{0} ", pet->Name); + + Console::Write("\n\nmax_element(F,L):\n "); + vector::iterator maxPet = max_element(pets.begin(), pets.end()); + Console::Write("{0}", maxPet->Name); + + Console::Write("\n\nbinary_search(F,L, v, functor):\n "); + Console::Write("Caesar was {0}.", + binary_search(pets.begin(), pets.end(), + gcnew Pet("Caesar"), greater()) + ? "found" : "not found"); + + Console::Write("\n\ncount_if(F,L, BeforeCaesar()) is:\n "); + Console::Write(count_if(pets.begin(), pets.end(), BeforeCaesar).ToString()); + + System::Console::WriteLine("\n\n"); + + return 0; +} diff --git a/Chapter07/DequeEx.cpp b/Chapter07/DequeEx.cpp new file mode 100644 index 0000000..51a70d1 --- /dev/null +++ b/Chapter07/DequeEx.cpp @@ -0,0 +1,102 @@ +#include +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + + +int main(array ^args) +{ + deque pets; + pets.push_front(gcnew Pet("King")); + pets.push_front(gcnew Pet("Buster")); + pets.push_front(gcnew Pet("Caesar")); + pets.push_front(gcnew Pet("Daisy")); + + System::Console::WriteLine("for loop -- Using subscript:"); + for(int i=0; i < pets.size(); i++) + System::Console::Write("{0} ", pets[i]->Name); + + System::Console::WriteLine("\n\nfor loop -- Using const_iterator" + + " with insert: "); + pets.insert(pets.begin() + 1, gcnew Pet("Jack")); + deque::const_iterator pet_i; + for(pet_i = pets.begin(); pet_i != pets.end(); pet_i++) + System::Console::Write("{0} ", pet_i->Name); + + System::Console::WriteLine("\n\nfor each loop -- From typecast to IList<>" + + " with Add():"); + IList^ genericIList = %pets; + genericIList->Add(gcnew Pet("Queen")); + for each (Pet^ pet in genericIList) + System::Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nfor each loop --" + + " using built in IEnumerator<> interface:"); + for each (Pet^ pet in pets) + System::Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nfor each loop --" + + " subset ICollection<>" + + " created by make_collection<>():"); + ICollection^ icPets = make_collection(pets.begin() + 1, + pets.end() - 1); + for each (Pet^ pet in icPets) + System::Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nfor loop --" + + " Using reverse_iterator from ICollection" + + " with pop_back():"); + deque^ dPets = gcnew deque(icPets); + dPets->pop_front(); + deque::reverse_iterator pet_ri; + + for(pet_ri = dPets->rbegin(); pet_ri != dPets->rend(); pet_ri++) + System::Console::Write("{0} ", pet_ri->Name); + + System::Console::WriteLine("\n\n"); + + return (0); +} diff --git a/Chapter07/DictionaryGeneric.cpp b/Chapter07/DictionaryGeneric.cpp new file mode 100644 index 0000000..df04f7a --- /dev/null +++ b/Chapter07/DictionaryGeneric.cpp @@ -0,0 +1,113 @@ +#using + +using namespace System; +using namespace System::Collections::Generic; + +// Make the dictionary sort in reverse +ref class Reverse : public IComparer +{ +public: + virtual int Compare(int x, int y) { return y - x; } + virtual bool Equals(int x, int y) { return x == y; } + virtual int GetHashCode(int obj) { return obj.GetHashCode(); } +}; + +Dictionary^ DictionaryExample() +{ + Dictionary^ dict = gcnew Dictionary(); + + dict->Add(1, "One"); + dict->Add(6, "Six"); + dict->Add(5, "Five"); + + dict->Add(3, "3"); +// dict->Add(3, "3"); // throws an exception + dict[3] = "Three"; + + dict[7] = "Seven"; + + String^ t = dict[3]; + Console::WriteLine("dict[3] = {0}\n", t); + + for each (KeyValuePair^ pair in dict) + { + Console::WriteLine("Key = [{0}]\tValue = [{1}]", + pair->Key, pair->Value); + } + + Console::WriteLine("\nDictionary contains 6? [{0}]", + dict->ContainsKey(6)); + + dict->Remove(6); + + Console::WriteLine("\nDictionary had 6 removed? [{0}]\n", + !dict->ContainsKey(6)); + + Dictionary::KeyCollection::Enumerator ^key = + dict->Keys->GetEnumerator(); + Dictionary::ValueCollection::Enumerator ^value = + dict->Values->GetEnumerator(); + + while ( key->MoveNext() && value->MoveNext()) + { + Console::WriteLine("Key = [{0}]\tValue = [{1}]", + key->Current, value->Current); + } + + return dict; +} + +void SortedDictionaryExample(Dictionary^ inDict) +{ + SortedDictionary^ dict = + gcnew SortedDictionary(inDict, gcnew Reverse()); + + dict->Add(6, "Six"); + + String^ t = dict[3]; + Console::WriteLine("dict[3] = {0}\n", t); + + Console::WriteLine("Sorted Values:"); + for each (String ^s in dict->Values) + Console::WriteLine("\t{0}",s); + + Console::WriteLine(); + + for each (KeyValuePair^ pair in dict) + { + Console::WriteLine("Key = [{0}]\tValue = [{1}]", + pair->Key, pair->Value); + } + + Console::WriteLine("\nSortedDictionary contains 'Six'? [{0}]", + dict->ContainsValue("Six")); + + dict->Remove(6); + + Console::WriteLine("\nSortedDictionary had 'Six' removed? [{0}]\n", + !dict->ContainsValue("Six")); + + SortedDictionary::KeyCollection::Enumerator ^key = + dict->Keys->GetEnumerator(); + SortedDictionary::ValueCollection::Enumerator ^value = + dict->Values->GetEnumerator(); + + while ( key->MoveNext() && value->MoveNext()) + { + Console::WriteLine("Key = [{0}]\tValue = [{1}]", + key->Current, value->Current); + } +} + +void main() +{ + Console::WriteLine("Dictionary\n----------"); + Dictionary^ dict = DictionaryExample(); + + Console::WriteLine(); + + Console::WriteLine("\nReverse SortedDictionary\n----------------"); + SortedDictionaryExample(dict); + + Console::WriteLine(); +} diff --git a/Chapter07/HashSortList.cpp b/Chapter07/HashSortList.cpp new file mode 100644 index 0000000..8245e79 --- /dev/null +++ b/Chapter07/HashSortList.cpp @@ -0,0 +1,80 @@ +using namespace System; +using namespace System::Collections; + +void main() +{ + Hashtable ^hash = gcnew Hashtable(); + SortedList ^sort = gcnew SortedList(); + + array^ keys = gcnew array { "B", "A", "C", "D" }; + array^ skeys = gcnew array { "A", "B", "C", "D" }; + array^ values = gcnew array { "moose", "zebra", "horse", "frog" }; + + for (int i = 0; i < keys->Length; i++) + { + hash->Add(keys[i], values[i]); + sort->Add(keys[i], values[i]); + } + + Console::WriteLine("Hashtable\tSortedList"); + + Console::WriteLine("By indexed property"); + for (int i = 0; i < hash->Count; i++) + { + Console::WriteLine("{0} {1}\t\t{2} {3}", skeys[i], + hash[skeys[i]], skeys[i], sort[skeys[i]]); + } + + Console::WriteLine("\nBy index"); + for (int i = 0; i < sort->Count; i++) + { + Console::WriteLine("N/A\t\t{0} {1}", i, sort->GetByIndex(i)); + } + + Console::WriteLine("\nBy enumerator"); + IDictionaryEnumerator ^enum1 = hash->GetEnumerator(); + IDictionaryEnumerator ^enum2 = sort->GetEnumerator(); + while ( enum1->MoveNext() && enum2->MoveNext()) + { + Console::Write("{0} {1}\t\t", enum1->Key, enum1->Value); + Console::WriteLine("{0} {1}", enum2->Key, enum2->Value); + } + + Console::WriteLine("\nEnumerate Key"); + IEnumerator ^keys1 = hash->Keys->GetEnumerator(); + IEnumerator ^keys2 = sort->Keys->GetEnumerator(); + while ( keys1->MoveNext() && keys2->MoveNext()) + { + Console::Write("{0}\t\t", keys1->Current); + Console::WriteLine("{0}", keys2->Current); + } + + Console::WriteLine("\nEnumerate Value"); + IEnumerator ^vals1 = hash->Values->GetEnumerator(); + IEnumerator ^vals2 = sort->Values->GetEnumerator(); + while ( vals1->MoveNext() && vals2->MoveNext()) + { + Console::Write("{0}\t\t", vals1->Current); + Console::WriteLine("{0}", vals2->Current); + } + + Console::WriteLine("\nContains a Key 'A' and 'Z'"); + Console::WriteLine("{0}\t\t{1}", hash->Contains("A"), + sort->Contains("A")); + Console::WriteLine("{0}\t\t{1}", hash->ContainsKey("Z"), + sort->ContainsKey("Z")); + + Console::WriteLine("\nContains a Value 'frog' and 'cow'"); + Console::WriteLine("{0}\t\t{1}", hash->ContainsValue("frog"), + sort->ContainsValue("frog")); + Console::WriteLine("{0}\t\t{1}", hash->ContainsValue("cow"), + sort->ContainsValue("cow")); + + Console::WriteLine("\n\t\t'B' key index: {0}", + sort->IndexOfKey("B")); + + Console::WriteLine("\t\t'frog' value index: {0}", + sort->IndexOfValue("frog")); + + Console::WriteLine(); +} diff --git a/Chapter07/IEnum_foreach.cpp b/Chapter07/IEnum_foreach.cpp new file mode 100644 index 0000000..4008d5d --- /dev/null +++ b/Chapter07/IEnum_foreach.cpp @@ -0,0 +1,26 @@ +using namespace System; +using namespace System::Collections; + +void main() +{ + array^ IntList = gcnew array { 1, 2, 3, 4, 5 }; + + + IEnumerable ^collection = (IEnumerable^)IntList; //Not really needed + IEnumerator ^enumerator = collection->GetEnumerator(); + + Console::WriteLine("IEnumerator\n-----------"); + + while (enumerator->MoveNext()) + { + int i = (int)enumerator->Current; + Console::WriteLine(i); + } + + Console::WriteLine("\nfor each\n--------"); + + for each (int i in IntList) + Console::WriteLine(i); + + Console::WriteLine(); +} diff --git a/Chapter07/LinkedListGeneric.cpp b/Chapter07/LinkedListGeneric.cpp new file mode 100644 index 0000000..0f15750 --- /dev/null +++ b/Chapter07/LinkedListGeneric.cpp @@ -0,0 +1,44 @@ +#using + +using namespace System; +using namespace System::Collections::Generic; + +int main() +{ + array^ arrList = gcnew array {"Two", "Three", "Four"}; + + LinkedList^ list = gcnew LinkedList((IEnumerable^)arrList); + + list->AddLast("Six"); + list->AddFirst("Zero"); + list->AddAfter(list->First, "One"); + list->AddBefore(list->Last, "5"); + + Console::WriteLine("Write with error"); + + LinkedListNode^ current = list->Last; + while (current != nullptr) + { + Console::WriteLine(current->Value); + current = current->Previous; + } + + Console::WriteLine("\nNumber of elements = {0}", list->Count); + + LinkedListNode^ node = list->Find("5"); + + list->AddBefore(node, "Five"); + list->Remove(node); + + list->RemoveFirst(); + + Console::WriteLine("\nWrite with corrections"); + for each (String^ str in list) + Console::WriteLine(str); + + Console::WriteLine("\nNumber of elements = {0}", list->Count); + + Console::WriteLine(); + +// list->Add(4); // Compile time error +} \ No newline at end of file diff --git a/Chapter07/ListDict.cpp b/Chapter07/ListDict.cpp new file mode 100644 index 0000000..551a1bb --- /dev/null +++ b/Chapter07/ListDict.cpp @@ -0,0 +1,35 @@ +#using + +using namespace System; +using namespace System::Collections; +using namespace System::Collections::Specialized; + +void main() +{ + ListDictionary ^ldict = gcnew ListDictionary(); + + ldict->Add("A", "First"); + ldict->Add("B", "Second"); + ldict->Add("C", "Third"); + ldict["D"] = "Fourth"; + + try { + ldict->Add("C", "Third Replaced"); + } + catch (ArgumentException ^e) + { + Console::WriteLine("ldict->Add(\"C\", \"Third Replaced\");"); + Console::WriteLine("Throws exception: {0}", e->Message); + } + ldict["B"] = "Second Replaced"; + + Console::WriteLine("\nEnumerate"); + IEnumerator ^keys = ldict->Keys->GetEnumerator(); + IEnumerator ^vals = ldict->Values->GetEnumerator(); + while ( keys->MoveNext() && vals->MoveNext()) + { + Console::WriteLine("{0}\t\t{1}", keys->Current, vals->Current); + } + + Console::WriteLine(); +} \ No newline at end of file diff --git a/Chapter07/ListEx.cpp b/Chapter07/ListEx.cpp new file mode 100644 index 0000000..632cfd3 --- /dev/null +++ b/Chapter07/ListEx.cpp @@ -0,0 +1,133 @@ +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // comparison operator. + bool operator>(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) > 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + +ref class MyGreaterThanFunctor +{ +public: + bool operator()(Pet^ a, Pet^ b) + { + return a > b; + } +}; + +int main(array ^args) +{ + list pets; + pets.push_front(gcnew Pet("King")); + pets.push_front(gcnew Pet("Buster")); + pets.push_front(gcnew Pet("Caesar")); + pets.push_front(gcnew Pet("Daisy")); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\nfor loop -- Using iterator" + + " with insert: "); + + list::iterator pet_i = pets.begin(); + pets.insert(++pet_i, gcnew Pet("Jack")); + + for(pet_i = pets.begin(); pet_i != pets.end(); pet_i++) + System::Console::Write("{0} ", pet_i->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nfor each loop --" + + " From typecast to ICollection<>" + + " with Add() and sort():"); + + ICollection^ genericIList = %pets; + + genericIList->Add(gcnew Pet("Queen")); + + pets.sort(); + + for each (Pet^ pet in genericIList) + System::Console::Write("{0} ", pet->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nfor each loop --" + + " merging puppies with reverse sorted pets" + " display by built in IEnumerator<> interface:"); + list puppies; + + puppies.push_front(gcnew Pet("Lady")); + puppies.push_front(gcnew Pet("Chalk")); + + pets.sort(gcnew MyGreaterThanFunctor()); + puppies.sort(greater()); + pets.merge(puppies, greater()); + + for each (Pet^ pet in pets) + System::Console::Write("{0} ", pet->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nfor each loop --" + + " spliced a random pet" + " display by built in IEnumerator<> interface:"); + list RanPet; + + list::iterator pet_ir = pets.begin(); + int randPetNo = (gcnew Random())->Next(pets.size()); + for (int i = 0; i < randPetNo; i++) + pet_ir++; + + RanPet.splice(RanPet.begin(), pets, pet_ir); + + for each (Pet^ pet in pets) + System::Console::Write("{0} ", pet->Name); + Console::Write("<- Splice -> "); + for each (Pet^ pet in RanPet) + System::Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\n"); + + return (0); +} diff --git a/Chapter07/ListGeneric.cpp b/Chapter07/ListGeneric.cpp new file mode 100644 index 0000000..9c7aa95 --- /dev/null +++ b/Chapter07/ListGeneric.cpp @@ -0,0 +1,75 @@ +using namespace System; +using namespace System::Collections::Generic; + +// -------- StringEx class --------------------------------------- + +ref class StringEx +{ +public: + String^ Value; + + StringEx(String^ in); + virtual String^ ToString() override; + + static bool With_e_Predicate(StringEx^ val); + static void SurroundInStars(StringEx^ val); +}; + +StringEx::StringEx(String^ in) : Value(in) {} + +String^ StringEx::ToString() { return Value; } + +bool StringEx::With_e_Predicate(StringEx^ val) +{ + return val->Value->ToUpper()->IndexOf("E") > 0; +} + +void StringEx::SurroundInStars(StringEx^ val) +{ + val->Value = String::Format("** {0} **", val->Value); +} + +// ---------- Main function --------------------------------------- + +void main() +{ + List^ alist = gcnew List(); + + alist->Add(gcnew StringEx("One")); + alist->Add(gcnew StringEx("-")); + alist[1] = gcnew StringEx("Three"); + + alist->Insert(1, gcnew StringEx("Two")); + + List^ morenums = gcnew List(); + morenums->Add(gcnew StringEx("Four")); + morenums->Add(gcnew StringEx("Five")); + + alist->AddRange(morenums); + +// alist[0] = "Six"; // Compile time error not a StringEx +// alist->Add("Six"); // Compile time error not a StringEx + + Console::WriteLine("*** The List ***"); + for (int i = 0; i < alist->Count; i++) + Console::WriteLine("{0} ", alist[i]); + + // Find all words in list that contain an 'e' + List^ With_e = + alist->FindAll(gcnew Predicate(StringEx::With_e_Predicate)); + + Console::WriteLine("\n\n*** The List containing an 'e' ***"); + + for each(StringEx^ str in With_e) + Console::WriteLine("{0} ", str); + + // Surround all elements with stars + alist->ForEach(gcnew Action(StringEx::SurroundInStars)); + + Console::WriteLine("\n\n*** The List surrounded by stars ***"); + + for each(StringEx^ str in alist) + Console::WriteLine("{0} ", str); + + Console::WriteLine("\n"); +} \ No newline at end of file diff --git a/Chapter07/MapEx.cpp b/Chapter07/MapEx.cpp new file mode 100644 index 0000000..05c92d0 --- /dev/null +++ b/Chapter07/MapEx.cpp @@ -0,0 +1,198 @@ +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + +int main(array ^args) +{ + System::Console::WriteLine("****************"); + System::Console::WriteLine("* map Examples *"); + System::Console::WriteLine("****************"); + + map pets; + Pet^ King = gcnew Pet("King"); // Use later in find method + + pets.insert(pets.end(), map::make_value(gcnew Pet("Zipper"), 3.0)); + pets.insert(map::make_value(King, 10.0)); + pets.insert(map::make_value(gcnew Pet("Buster"),9.0)); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\nInserting duplicate elements to map" + + " display by for loop using reverse_iterator:"); + +// pair::iterator, bool> success; /** Does not work **/ + map::pair_iter_bool success; + + success = pets.insert(map::make_value(gcnew Pet("New_Puppy"),0.1)); + Console::WriteLine("First Time {0} age {1} is added {2}", + success.first->first->Name, + success.first->second, + success.second ? "successfully" : "unsuccessfully"); + + success = pets.insert(map::make_value(gcnew Pet("New_Puppy"),0.2)); + Console::WriteLine("Second Time {0} age {1} is added {2}", + success.first->first->Name, + success.first->second, + success.second ? "successfully" : "unsuccessfully"); + + map::reverse_iterator pet_ri; + for(pet_ri = pets.rbegin(); pet_ri != pets.rend(); pet_ri++) + System::Console::Write("{0} [{1}] ", pet_ri->first->Name, pet_ri->second); + + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nInsert pets from .NET Dictionary" + + " display by IDictionary<> interface:"); + + Dictionary^ morepets = gcnew Dictionary(); + morepets->Add(gcnew Pet("Daisy"), 5); + morepets->Add(gcnew Pet("Lady"), 7); + + for each (KeyValuePair ^kvp in morepets) //Yuck!! + pets.insert(map::make_value(kvp->Key, kvp->Value)); + + List::value_type>^ evenmorepets = gcnew List::value_type>(); + evenmorepets->Add(map::make_value(gcnew Pet("Toby"), 1)); + evenmorepets->Add(map::make_value(gcnew Pet("Spot"), 2)); + + pets.insert(evenmorepets); + + IDictionary^ pets_IDict = %pets; + + for each (KeyValuePair ^kvp in pets_IDict) + System::Console::Write("{0} [{1}] ", kvp->Key->Name, kvp->Value); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nInsert pets into copy map" + + " less 2nd, last & 'Lady'" + + " display by IEnumerator<> interface:"); + + map copy; + map::iterator pets_e = pets.end(); + copy.insert(pets.begin(), --pets_e); + + map::iterator pets_cb = copy.begin(); + copy.erase(++pets_cb); + + copy.erase(gcnew Pet("Lady")); + + for each (KeyValuePair ^kvp in (IDictionary^)%copy) + System::Console::Write("{0} [{1}] ", kvp->Key->Name, kvp->Value); + + // -------------------------------------------------------------------- + Console::WriteLine("\n\nFound = {0}", copy.find(King)->first->Name); + + map::iterator Lady = copy.find(gcnew Pet("Lady")); + Console::WriteLine("Did {0}Find = Lady", (Lady == copy.end()) ? "not " : ""); + + + // ******************************************************************** + System::Console::WriteLine("\n*********************"); + System::Console::WriteLine("* multimap Examples *"); + System::Console::WriteLine("*********************"); + + multimap mpets; + mpets.insert(multimap::make_value(gcnew Pet("King"), 10.0)); + mpets.insert(multimap::make_value(gcnew Pet("Buster"), 9.0)); + mpets.insert(mpets.end(), + multimap::make_value(gcnew Pet("Zipper"), 3.0)); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\nInsert elements (with duplicate) to multiset" + + " display by IEnumerator<> interface:"); + + mpets.insert(multimap::make_value(gcnew Pet("New_Puppy"), 0.1)); + + multimap::iterator New_Puppy = + mpets.insert(multimap::make_value(gcnew Pet("New_Puppy"), 0.2)); + + for each (KeyValuePair ^kvp in morepets) //Yuck!! + mpets.insert(multimap::make_value(kvp->Key, kvp->Value)); + + mpets.insert(evenmorepets); + + for each (multimap::value_type pet in mpets) + System::Console::Write("{0} [{1}] ", pet->first->Name, pet->second); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nUpper/Lower bound of duplicate multimap" + + " display by for loop:"); + + multimap::iterator pupsL = mpets.lower_bound(New_Puppy->first); + multimap::iterator pupsU = mpets.upper_bound(New_Puppy->first); + + for(; pupsL != pupsU; pupsL++) + System::Console::Write("{0} [{1}] ", pupsL->first->Name, pupsL->second); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nequal_range of duplicate multimap" + + " display by for loop:"); + + multimap::pair_iter_iter FindSE = + mpets.equal_range(New_Puppy->first); + + for (; FindSE.first != FindSE.second; ++FindSE.first) + System::Console::Write("{0} [{1}] ", FindSE.first->first->Name, + FindSE.first->second); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nequal_range of non-duplicate multiset" + + " display by for loop:"); + + FindSE = mpets.equal_range(King); + + for (; FindSE.first != FindSE.second; ++FindSE.first) + System::Console::Write("{0} [{1}] ", FindSE.first->first->Name, + FindSE.first->second); + + // -------------------------------------------------------------------- + int count = mpets.erase(New_Puppy->first); + System::Console::WriteLine("\n\nErasing {0} New Puppies from container", count); + + System::Console::WriteLine("\n\n"); + + return (0); +} + diff --git a/Chapter07/NameValue.cpp b/Chapter07/NameValue.cpp new file mode 100644 index 0000000..7225a9c --- /dev/null +++ b/Chapter07/NameValue.cpp @@ -0,0 +1,58 @@ +#using + +using namespace System; +using namespace System::Collections::Specialized; + +void main() +{ + NameValueCollection^ nvCol = gcnew NameValueCollection(); + + nvCol->Add(nullptr, "void"); + + nvCol->Set("Flower", "Rose"); + + nvCol->Add("Animal", "Dog"); + nvCol->Add("Animal", "Cat"); + nvCol->Add("Animal", "Cow"); + + nvCol->Add("Fruit", "Apple"); + nvCol->Add("Fruit", "Pear"); + nvCol->Add("Fruit", "Peach"); + + + array^ keys = nvCol->AllKeys; + + Console::WriteLine("Key\t\tValue"); + for (int i = 0; i < keys->Length; i++) + { + array^ vals = nvCol->GetValues(keys[i]); + + Console::WriteLine("{0}:\t\t{1}", keys[i], vals[0]); + for (int j = 1; j < vals->Length; j++) + { + Console::WriteLine("\t\t{0}", vals[j]); + } + } + + Console::WriteLine("------ Index Lookups ------"); + Console::WriteLine("Key @[1]:\t{0}", nvCol->GetKey(1)); + Console::WriteLine("Values @[3]:\t{0}", nvCol[3]); + + + nvCol->Remove(nullptr); + + nvCol["Fruit"] = "Plum"; + + nvCol->Set("Animal", "Deer"); + nvCol->Add("Animal", "Ape"); + + keys = nvCol->AllKeys; + + Console::WriteLine("--------- Updated ---------"); + for (int i = 0; i < keys->Length; i++) + { + Console::WriteLine("{0}:\t\t{1}", keys[i], nvCol->Get(keys[i])); + } + + Console::WriteLine(); +} \ No newline at end of file diff --git a/Chapter07/PriorityQueueAdptEx.cpp b/Chapter07/PriorityQueueAdptEx.cpp new file mode 100644 index 0000000..dcf84f0 --- /dev/null +++ b/Chapter07/PriorityQueueAdptEx.cpp @@ -0,0 +1,97 @@ +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // comparison operator. + bool operator>(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) > 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + +int main(array ^args) +{ + priority_queue petpq; + + petpq.push(gcnew Pet("King")); + petpq.push(gcnew Pet("Zipper")); + petpq.push(gcnew Pet("Buster")); + petpq.push(gcnew Pet("Lady")); + + System::Console::WriteLine("Push pets onto priority queue and" + + " display by IEnumerator<> interface:"); + + for each (Pet^ pet in petpq.get_container()) + Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nPop pets from priority queue till empty:"); + + while (!petpq.empty()) + { + Console::Write("{0} ", petpq.top()->Name); + petpq.pop(); + } + + Console::WriteLine("\n\nUse functor greater() as ordering rule"); + + priority_queue petpqr = priority_queue(greater()); + + petpqr.push(gcnew Pet("King")); + petpqr.push(gcnew Pet("Zipper")); + petpqr.push(gcnew Pet("Buster")); + petpqr.push(gcnew Pet("Lady")); + + System::Console::WriteLine("And Pop pets from priority queue till empty:"); + + while (!petpqr.empty()) + { + Console::Write("{0} ", petpqr.top()->Name); + petpqr.pop(); + } + + System::Console::WriteLine("\n\n"); + + return 0; +} diff --git a/Chapter07/QueueAdptEx.cpp b/Chapter07/QueueAdptEx.cpp new file mode 100644 index 0000000..f906b72 --- /dev/null +++ b/Chapter07/QueueAdptEx.cpp @@ -0,0 +1,77 @@ +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + +int main(array ^args) +{ + queue petq; + + petq.push(gcnew Pet("King")); + petq.push(gcnew Pet("Zipper")); + petq.push(gcnew Pet("Buster")); + petq.push(gcnew Pet("Lady")); + + queue::value_type lastpet = petq.back(); + System::Console::WriteLine("The last pet in queue is:\n{0}", lastpet->Name); + + System::Console::WriteLine("\nPush pets onto queue and" + + " display by IEnumerator<> interface:"); + + for each (Pet^ pet in petq.get_container()) + Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nPop pets from queue front till empty:"); + + while (!petq.empty()) + { + Console::Write("{0} ", petq.front()->Name); + petq.pop(); + } + + System::Console::WriteLine("\n\n"); + + return 0; +} diff --git a/Chapter07/QueueStack.cpp b/Chapter07/QueueStack.cpp new file mode 100644 index 0000000..59d76bf --- /dev/null +++ b/Chapter07/QueueStack.cpp @@ -0,0 +1,32 @@ +using namespace System; +using namespace System::Collections; + +void main() +{ + Queue ^que = gcnew Queue(); + Stack ^stk = gcnew Stack(); + + array^ entry = gcnew array { "First", "Second", "Third", "Fourth" }; + + Console::WriteLine("Queue\t\tStack"); + + Console::WriteLine("** ON **"); + for (int i = 0; i < entry->Length; i++) + { + que->Enqueue(entry[i]); + stk->Push(entry[i]); + + Console::WriteLine("{0}\t\t{1}", entry[i], entry[i]); + } + + Console::WriteLine("\n** OFF **"); + while ((que->Count > 0) && (stk->Count > 0)) + { + Console::WriteLine("{0}\t\t{1}", que->Dequeue(), stk->Pop()); + } + + que->Clear(); + stk->Clear(); + + Console::WriteLine(""); +} \ No newline at end of file diff --git a/Chapter07/QueueStackGeneric.cpp b/Chapter07/QueueStackGeneric.cpp new file mode 100644 index 0000000..ec0b4ba --- /dev/null +++ b/Chapter07/QueueStackGeneric.cpp @@ -0,0 +1,36 @@ +#using + +using namespace System; +using namespace System::Collections::Generic; + +void main() +{ + Queue^ que = gcnew Queue(); + Stack^ stk = gcnew Stack(); + + array^ entry = gcnew array { + "First", "Second", "Third", "Fourth" + }; + + Console::WriteLine("Queue\t\tStack"); + + Console::WriteLine("** ON **"); + for (int i = 0; i < entry->Length; i++) + { + que->Enqueue(entry[i]); + stk->Push(entry[i]); + + Console::WriteLine("{0}\t\t{1}", entry[i], entry[i]); + } + + Console::WriteLine("\n** OFF **"); + while ((que->Count > 0) && (stk->Count > 0)) + { + Console::WriteLine("{0}\t\t{1}", que->Dequeue(), stk->Pop()); + } + + que->Clear(); + stk->Clear(); + + Console::WriteLine("\n"); +} diff --git a/Chapter07/SetEx.cpp b/Chapter07/SetEx.cpp new file mode 100644 index 0000000..70c29a1 --- /dev/null +++ b/Chapter07/SetEx.cpp @@ -0,0 +1,172 @@ +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + +int main(array ^args) +{ + System::Console::WriteLine("****************"); + System::Console::WriteLine("* set Examples *"); + System::Console::WriteLine("****************"); + + set pets; + Pet^ King = gcnew Pet("King"); // Use later in find method + + pets.insert(pets.end(), gcnew Pet("Zipper")); + pets.insert(King); + pets.insert(gcnew Pet("Buster")); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\nInserting duplicate elements to set" + + " display by for loop using reverse_iterator:"); + +// pair::iterator, bool> success; /** Does not work **/ + set::pair_iter_bool success; + + success = pets.insert(gcnew Pet("New_Puppy")); + Console::WriteLine("First Time {0} is added {1}", success.first->Name, + success.second ? "successfully" : "unsuccessfully"); + + success = pets.insert(gcnew Pet("New_Puppy")); + Console::WriteLine("Second Time {0} is added {1}", success.first->Name, + success.second ? "successfully" : "unsuccessfully"); + + set::reverse_iterator pet_ri; + for(pet_ri = pets.rbegin(); pet_ri != pets.rend(); pet_ri++) + System::Console::Write("{0} ", pet_ri->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nInsert pets from .NET generic List" + + " display by IEnumerator<> interface:"); + + List^ morepets = gcnew List(); + morepets->Add(gcnew Pet("Daisy")); + morepets->Add(gcnew Pet("Lady")); + pets.insert(morepets); + + for each (Pet^ pet in pets) + System::Console::Write("{0} ", pet->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nInsert pets into copy set" + + " less 2nd, last & 'Lady'" + + " display by IEnumerator<> interface:"); + + set copy; + set::iterator pets_e = pets.end(); + copy.insert(pets.begin(), --pets_e); + + set::iterator pets_cb = copy.begin(); + copy.erase(++pets_cb); + + copy.erase(gcnew Pet("Lady")); + + for each (Pet^ pet in copy) + System::Console::Write("{0} ", pet->Name); + + // -------------------------------------------------------------------- + Console::WriteLine("\n\nFound = {0}", copy.find(King)->Name); + + set::iterator Lady = copy.find(gcnew Pet("Lady")); + Console::WriteLine("Did {0}Find = Lady", (Lady == copy.end()) ? "not " : ""); + + // ******************************************************************** + System::Console::WriteLine("\n*********************"); + System::Console::WriteLine("* multiset Examples *"); + System::Console::WriteLine("*********************"); + + multiset mpets; + mpets.insert(gcnew Pet("King")); + mpets.insert(gcnew Pet("Buster")); + mpets.insert(mpets.end(), gcnew Pet("Zipper")); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\nInsert elements (with duplicate) to multiset" + + " display by IEnumerator<> interface:"); + + mpets.insert(gcnew Pet("New_Puppy")); + multiset::iterator New_Puppy = mpets.insert(gcnew Pet("New_Puppy")); + + mpets.insert(morepets); // generic List from above + + for each (Pet^ pet in mpets) + System::Console::Write("{0} ", pet->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nUpper/Lower bound of duplicate multiset" + + " display by for loop:"); + + multiset::iterator puppiesL = mpets.lower_bound(*New_Puppy); + multiset::iterator puppiesU = mpets.upper_bound(*New_Puppy); + + for(; puppiesL != puppiesU; puppiesL++) + System::Console::Write("{0} ", puppiesL->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nequal_range of duplicate multiset" + + " display by for loop:"); + + multiset::pair_iter_iter FindSE = mpets.equal_range(*New_Puppy); + + for (; FindSE.first != FindSE.second; ++FindSE.first) + System::Console::Write("{0} ", FindSE.first->Name); + + // -------------------------------------------------------------------- + System::Console::WriteLine("\n\nequal_range of non-duplicate multiset" + + " display by for loop:"); + + FindSE = mpets.equal_range(King); + + for (; FindSE.first != FindSE.second; ++FindSE.first) + System::Console::Write("{0} ", FindSE.first->Name); + + // -------------------------------------------------------------------- + int count = mpets.erase(*New_Puppy); + System::Console::WriteLine("\n\nErasing {0} New Puppies from container", count); + + System::Console::WriteLine("\n\n"); + + return (0); +} diff --git a/Chapter07/StackAdptEx.cpp b/Chapter07/StackAdptEx.cpp new file mode 100644 index 0000000..a71f37f --- /dev/null +++ b/Chapter07/StackAdptEx.cpp @@ -0,0 +1,74 @@ +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + +int main(array ^args) +{ + stack pets; + + pets.push(gcnew Pet("King")); + pets.push(gcnew Pet("Zipper")); + pets.push(gcnew Pet("Buster")); + pets.push(gcnew Pet("Lady")); + + System::Console::WriteLine("Push pets onto stack and" + + " display by IEnumerator<> interface:"); + + for each (Pet^ pet in pets.get_container()) + Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nPop pets from stack top till empty:"); + + while (!pets.empty()) + { + Console::Write("{0} ", pets.top()->Name); + pets.pop(); + } + + System::Console::WriteLine("\n\n"); + + return 0; +} diff --git a/Chapter07/StringColl.cpp b/Chapter07/StringColl.cpp new file mode 100644 index 0000000..c63978b --- /dev/null +++ b/Chapter07/StringColl.cpp @@ -0,0 +1,32 @@ +#using + +using namespace System; +using namespace System::Collections; +using namespace System::Collections::Specialized; + +void main() +{ + StringCollection ^strcol = gcnew StringCollection(); + + strcol->Add("The first String"); + + array^ tmpstr = gcnew array {"Third", "Fourth" }; + strcol->AddRange(tmpstr); + + strcol->Insert(1, "Second"); + + strcol[0] = "First"; + + StringEnumerator ^strenum = strcol->GetEnumerator(); + while ( strenum->MoveNext()) + { + Console::WriteLine(strenum->Current); + } + + Console::WriteLine("\n'for each' works as well"); + + for each (String^ s in strcol) + Console::WriteLine(s); + + Console::WriteLine(); +} \ No newline at end of file diff --git a/Chapter07/StringDict.cpp b/Chapter07/StringDict.cpp new file mode 100644 index 0000000..cc08002 --- /dev/null +++ b/Chapter07/StringDict.cpp @@ -0,0 +1,27 @@ +#using + +using namespace System; +using namespace System::Collections; +using namespace System::Collections::Specialized; + +void main() +{ + StringDictionary ^strdict = gcnew StringDictionary(); + + strdict->Add("Dog", "Four leg, hydrant loving, barking, mammal"); + strdict->Add("Frog", "Green, jumping, croaking, amphibian"); + + strdict["Crocodile"] = "Ugly, boot origin, snapping, reptile"; + + ArrayList ^alist = gcnew ArrayList(); + alist->AddRange(strdict->Keys); + alist->Sort(); + + for (int i = 0; i < alist->Count; i++) + { + Console::WriteLine("{0,10}:\t{1}", alist[i], + strdict[(String^)alist[i]]); + } + + Console::WriteLine(); +} \ No newline at end of file diff --git a/Chapter07/VectorEx.cpp b/Chapter07/VectorEx.cpp new file mode 100644 index 0000000..631e347 --- /dev/null +++ b/Chapter07/VectorEx.cpp @@ -0,0 +1,102 @@ +#include +#include + +using namespace System; +using namespace cliext; +using namespace System::Collections::Generic; + +ref class Pet +{ +public: + String^ Name; + + // default public constructor. + Pet() : Name(String::Empty) { } + + // Okay not needed but makes example easier. :) + Pet(String^ name) : Name(name) { } + + // public copy constructor. + Pet(const Pet% orig) + { + Name = orig.Name; + } + + // public assignment operator. + Pet% operator=(const Pet% orig) + { + if (this != %orig) + Name = orig.Name; + return *this; + } + + // public destructor. + ~Pet() { } + + // comparison operator. + bool operator<(const Pet^ rhs) + { + return (Name->CompareTo(rhs->Name) < 0); + } + + // equality operator. + bool operator==(const Pet^ rhs) + { + return (Name->Equals(rhs->Name)); + } +}; + + +int main(array ^args) +{ + vector pets; + pets.push_back(gcnew Pet("King")); + pets.push_back(gcnew Pet("Buster")); + pets.push_back(gcnew Pet("Caesar")); + pets.push_back(gcnew Pet("Daisy")); + + System::Console::WriteLine("for loop -- Using subscript:"); + for(int i=0; i < pets.size(); i++) + System::Console::Write("{0} ", pets[i]->Name); + + System::Console::WriteLine("\n\nfor loop -- Using const_iterator" + + " with insert: "); + pets.insert(pets.begin() + 1, gcnew Pet("Jack")); + vector::const_iterator pet_i; + for(pet_i = pets.begin(); pet_i != pets.end(); pet_i++) + System::Console::Write("{0} ", pet_i->Name); + + System::Console::WriteLine("\n\nfor each loop -- From typecast to IList<>" + + " with Add():"); + IList^ genericIList = %pets; + genericIList->Add(gcnew Pet("Queen")); + for each (Pet^ pet in genericIList) + System::Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nfor each loop --" + + " using built in IEnumerator<> interface:"); + for each (Pet^ pet in pets) + System::Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nfor each loop --" + + " subset ICollection<>" + + " created by make_collection<>():"); + ICollection^ icPets = make_collection(pets.begin() + 1, + pets.end() - 1); + for each (Pet^ pet in icPets) + System::Console::Write("{0} ", pet->Name); + + System::Console::WriteLine("\n\nfor loop --" + + " Using reverse_iterator from ICollection" + + " with pop_back():"); + vector^ vPets = gcnew vector(icPets); + vPets->pop_back(); + vector::reverse_iterator pet_ri; + + for(pet_ri = vPets->rbegin(); pet_ri != vPets->rend(); pet_ri++) + System::Console::Write("{0} ", pet_ri->Name); + + System::Console::WriteLine("\n\n"); + + return (0); +} diff --git a/Chapter07/arraylist.cpp b/Chapter07/arraylist.cpp new file mode 100644 index 0000000..b8099f8 --- /dev/null +++ b/Chapter07/arraylist.cpp @@ -0,0 +1,51 @@ +using namespace System; +using namespace System::Collections; + +ref class myReverserClass: public IComparer +{ +public: + virtual int Compare(Object^ x, Object^ y) = IComparer::Compare + { + return (String::Compare((String^)y, (String^)x)); + } +}; + +void main() +{ + ArrayList ^alist = gcnew ArrayList(4); // will double to 8 + alist->Add("One"); + alist->Add("-"); + alist[1] = "Three"; + + alist->Insert(1, "Two"); + + array^ morenums = gcnew array {"Four", "Five"}; + + alist->AddRange(morenums); + + alist->Reverse(); + + Console::WriteLine("*** The ArrayList ***"); + for (int i = 0; i < alist->Count; i++) + { + Console::Write("{0} ", alist[i]); + } + + Console::WriteLine("\n\nCapacity is: {0}", alist->Capacity.ToString()); + + alist->Capacity = 10; + Console::WriteLine("New capacity is: {0}", alist->Capacity.ToString()); + + Console::WriteLine("Count is: {0}", alist->Count.ToString()); + + IComparer^ myComparer = gcnew myReverserClass; + alist->Sort(myComparer); + + int indx = alist->BinarySearch("Four", myComparer); + Console::WriteLine("Four found at index: {0}", indx.ToString()); + + bool fnd = alist->Contains("One"); + Console::WriteLine("ArrayList contains a 'One': {0}", fnd.ToString()); + + Console::WriteLine(); +} diff --git a/Chapter07/bitarray.cpp b/Chapter07/bitarray.cpp new file mode 100644 index 0000000..80c5c39 --- /dev/null +++ b/Chapter07/bitarray.cpp @@ -0,0 +1,52 @@ +using namespace System; +using namespace System::Collections; + +void Print( BitArray ^barray, String ^desc) +{ + Console::WriteLine(desc); + + int i = 0; + for each( bool^ val in barray ) + { + Console::Write("{0} ", val); + + if (++i > 7) + { + Console::WriteLine(); + i = 0; + } + } + Console::WriteLine(); +} + +void main() +{ + BitArray ^barray1 = gcnew BitArray( 8, true ); + Print(barray1, "BitArray( 8, true );"); + + barray1[1] = false; + barray1[4] = false; + barray1->Not(); + Print(barray1, "Modified bit 1&4 then Not"); + + BitArray ^barray2 = gcnew BitArray( 8, true ); + barray2->And(barray1); + Print(barray2, "And with BitArray( 8, true )"); + + barray2->SetAll(true); + barray2->Or(barray1); + Print(barray2, "Or with BitArray( 8, true )"); + + barray2->SetAll(true); + barray2->Xor(barray1); + Print(barray2, "Xor with BitArray( 8, true )"); + + array^ chars = gcnew array { 0x55, 0xAA }; + BitArray ^barray3 = gcnew BitArray( chars ); + Print(barray3, "BitArray(0x55, 0xAA);"); + + Console::WriteLine("Item[0]={0}", barray3[0]); + Console::WriteLine("Item[8]={0}", barray3[8]); + + Console::WriteLine(); +} \ No newline at end of file diff --git a/Chapter07/buildall.bat b/Chapter07/buildall.bat new file mode 100644 index 0000000..eaf37b3 --- /dev/null +++ b/Chapter07/buildall.bat @@ -0,0 +1,22 @@ +cl AlgorithmEx.cpp /clr:safe +cl arraylist.cpp /clr:safe +cl bitarray.cpp /clr:safe +cl DequeEx.cpp /clr:safe +cl DictionaryGeneric.cpp /clr:safe +cl HashSortList.cpp /clr:safe +cl IEnum_foreach.cpp /clr:safe +cl LinkedListGeneric.cpp /clr:safe +cl ListDict.cpp /clr:safe +cl ListEx.cpp /clr:safe +cl ListGeneric.cpp /clr:safe +cl MapEx.cpp /clr:safe +cl NameValue.cpp /clr:safe +cl PriorityQueueAdptEx.cpp /clr:safe +cl QueueAdptEx.cpp /clr:safe +cl QueueStack.cpp /clr:safe +cl QueueStackGeneric.cpp /clr:safe +cl SetEx.cpp /clr:safe +cl StackAdptEx.cpp /clr:safe +cl StringColl.cpp /clr:safe +cl StringDict.cpp /clr:safe +cl VectorEx.cpp /clr:safe diff --git a/Chapter08/BinFormSerial.cpp b/Chapter08/BinFormSerial.cpp new file mode 100644 index 0000000..932369e --- /dev/null +++ b/Chapter08/BinFormSerial.cpp @@ -0,0 +1,95 @@ +using namespace System; +using namespace System::IO; +using namespace System::Runtime::Serialization::Formatters::Binary; + +// --------- Player Attribute class ------------------------------------ + +[Serializable] +ref class PlayerAttr +{ +public: + property int Strength; + property int Dexterity; + property int Constitution; + property int Intelligence; + property int Wisdom; + property int Charisma; + + PlayerAttr(int Str, int Dex, int Con, int Int, int Wis, int Cha); + void Print(); +}; + +PlayerAttr::PlayerAttr(int Str, int Dex, int Con, int Int, int Wis, int Cha) +{ + this->Strength = Str; + this->Dexterity = Dex; + this->Constitution = Con; + this->Intelligence = Int; + this->Wisdom = Wis; + this->Charisma = Cha; +} + +void PlayerAttr::Print() +{ + Console::WriteLine("Str: {0}, Dex: {1}, Con {2}", + Strength, Dexterity, Constitution); + Console::WriteLine("Int: {0}, Wis: {1}, Cha {2}", + Intelligence, Wisdom, Charisma); +} + +// -------- Player class --------------------------------------- + +[Serializable] +ref class Player +{ +public: + property String ^Name; + property String ^Race; + property String ^Class; + property PlayerAttr ^pattr; + + + Player (String ^Name, String ^Race, String ^Class, + int Str, int Dex, int Con, int Int, int Wis, int Cha); + void Print(); +}; + +Player::Player (String ^Name, String ^Race, String ^Class, + int Str, int Dex, int Con, int Int, int Wis, int Cha) +{ + this->Name = Name; + this->Race = Race; + this->Class = Class; + this->pattr = gcnew PlayerAttr(Str, Dex, Con, Int, Wis, Cha); +} + +void Player::Print() +{ + Console::WriteLine("Name: {0}", Name); + Console::WriteLine("Race: {0}", Race); + Console::WriteLine("Class: {0}", Class); + pattr->Print(); +} + +void main() +{ + Player ^Joe = + gcnew Player("Joe", "Human", "Thief", 10, 18, 9, 13,10, 11); + + Console::WriteLine("Original Joe"); + Joe->Print(); + + FileStream ^plStream = File::Create("Player.dat"); + + BinaryFormatter ^bf = gcnew BinaryFormatter(); + bf->Serialize(plStream, Joe); + plStream->Close(); + + plStream = File::OpenRead("Player.dat"); + + Player ^JoeClone = (Player^)bf->Deserialize(plStream); + plStream->Close(); + + Console::WriteLine("\nCloned Joe"); + JoeClone->Print(); +} diff --git a/Chapter08/BinaryRW.cpp b/Chapter08/BinaryRW.cpp new file mode 100644 index 0000000..268a201 --- /dev/null +++ b/Chapter08/BinaryRW.cpp @@ -0,0 +1,88 @@ +using namespace System; +using namespace System::IO; + +// ------ Player class --------------------------------------------- + +ref class Player +{ + String ^Name; + Int32 Strength; + Boolean IsMale; + DateTime CreateDate; + +public: + Player(); + Player (String ^Name, int Str, bool IsMale); + + void Print(); + void Save(String ^fname); + void Load(String ^fname); +}; + +Player::Player() +{ +} + +Player::Player (String ^Name, int Str, bool IsMale) +{ + this->Name = Name; + this->Strength = Str; + this->IsMale = IsMale; + this->CreateDate = DateTime::Now; +} + +void Player::Print() +{ + Console::WriteLine("Name: {0} ({1})", Name, (IsMale ? "M" : "F")); + Console::WriteLine("Str: {0}", Strength); + Console::WriteLine("Date: {0}", CreateDate.ToString()); +} + +void Player::Save(String ^fname) +{ + FileStream ^fs = File::OpenWrite(fname); + BinaryWriter ^bw = gcnew BinaryWriter(fs); + + bw->Write(Name); + bw->Write(Strength); + bw->Write(IsMale); + + // Due to multicultures this is a safe way of storing DateTimes + bw->Write(CreateDate.Ticks); + + bw->Close(); + fs->Close(); +} + +void Player::Load(String ^fname) +{ + FileStream ^fs = File::OpenRead(fname); + BinaryReader ^br = gcnew BinaryReader(fs); + + Name = br->ReadString(); + Strength = br->ReadInt32(); + IsMale = br->ReadBoolean(); + + // Due to multicultures this is a safe way of retrieving DateTimes + CreateDate = DateTime( br->ReadInt64() ); + + br->Close(); + fs->Close(); +} + +// ------- Main Function --------------------------------------------- + +void main() +{ + Player ^Joe = gcnew Player("Joe", 10, true); + Joe->Save("Player.dat"); + + Console::WriteLine("Original Joe"); + Joe->Print(); + + Player ^JoeClone = gcnew Player(); + JoeClone->Load("Player.dat"); + + Console::WriteLine("\nCloned Joe"); + JoeClone->Print(); +} \ No newline at end of file diff --git a/Chapter08/DirInfo.cpp b/Chapter08/DirInfo.cpp new file mode 100644 index 0000000..9574125 --- /dev/null +++ b/Chapter08/DirInfo.cpp @@ -0,0 +1,75 @@ +using namespace System; +using namespace System::IO; +using namespace System::Text; + +int main(array ^args) +{ + if (args->Length == 0) + { + Console::WriteLine("Usage: DirInfo "); + return -1; + } + + StringBuilder ^tmppath = gcnew StringBuilder(); + + for each (String^ s in args) + { + tmppath->Append(s); + tmppath->Append(" "); + } + + String ^path = tmppath->ToString()->Trim(); + + DirectoryInfo ^dir = gcnew DirectoryInfo(path); + + if (!dir->Exists) + { + Console::WriteLine("Directory Not Found"); + return -1; + } + + Console::WriteLine("Name: {0}", dir->FullName); + + Console::WriteLine("Created: {0} {1}", + dir->CreationTime.ToShortDateString(), + dir->CreationTime.ToLongTimeString()); + + Console::WriteLine("Accessed: {0} {1}", + dir->LastAccessTime.ToShortDateString(), + dir->LastAccessTime.ToLongTimeString()); + + Console::WriteLine("Updated: {0} {1}", + dir->LastWriteTime.ToShortDateString(), + dir->LastWriteTime.ToLongTimeString()); + + Console::WriteLine("Attributes: {0}", + dir->Attributes); + + Console::WriteLine("Sub-Directories:"); + + array^ subDirs = dir->GetDirectories(); + if (subDirs->Length == 0) + Console::WriteLine("\tNone."); + else + { + for each (DirectoryInfo^ dinfo in subDirs) + { + Console::WriteLine("\t{0}", dinfo->Name); + } + } + + Console::WriteLine("Files:"); + + array^ files = dir->GetFiles(); + if (files->Length == 0) + Console::WriteLine("\tNone."); + else + { + for each (FileInfo^ finfo in files) + { + Console::WriteLine("\t{0}", finfo->Name); + } + } + + return 0; +} diff --git a/Chapter08/FileInfo.cpp b/Chapter08/FileInfo.cpp new file mode 100644 index 0000000..6d635b1 --- /dev/null +++ b/Chapter08/FileInfo.cpp @@ -0,0 +1,50 @@ +using namespace System; +using namespace System::IO; +using namespace System::Text; + +int main(array ^args) +{ + if (args->Length == 0) + { + Console::WriteLine("Usage: FileInfo "); + return -1; + } + + StringBuilder ^tmpfile = gcnew StringBuilder(); + + for each (String^ s in args) + { + tmpfile->Append(s); + tmpfile->Append(" "); + } + + String ^strfile = tmpfile->ToString()->Trim(); + + FileInfo ^fileinfo = gcnew FileInfo(strfile); + + if (!fileinfo->Exists) + { + Console::WriteLine("File Not Found"); + return -1; + } + + Console::WriteLine("Name: {0}", fileinfo->FullName); + + Console::WriteLine("Created: {0} {1}", + fileinfo->CreationTime.ToShortDateString(), + fileinfo->CreationTime.ToLongTimeString()); + + Console::WriteLine("Accessed: {0} {1}", + fileinfo->LastAccessTime.ToShortDateString(), + fileinfo->LastAccessTime.ToLongTimeString()); + + Console::WriteLine("Updated: {0} {1}", + fileinfo->LastWriteTime.ToShortDateString(), + fileinfo->LastWriteTime.ToLongTimeString()); + + Console::WriteLine("Length: {0}", fileinfo->Length); + + Console::WriteLine("Attributes: {0}", fileinfo->Attributes); + + return 0; +} \ No newline at end of file diff --git a/Chapter08/FileStream.cpp b/Chapter08/FileStream.cpp new file mode 100644 index 0000000..979aa27 --- /dev/null +++ b/Chapter08/FileStream.cpp @@ -0,0 +1,53 @@ +using namespace System; +using namespace System::IO; + +void main() +{ + FileStream ^fso = gcnew FileStream("file.dat", FileMode::Create, + FileAccess::Write, FileShare::None); + + array^ data = gcnew array { 'T', 'h', 'i', + 's', ' ', 'i', 's', ' ', 'a', ' ', 't', 'e', + 's', 't', '!', '\r', '\n', 'T', 'h', 'i', 's', + ' ', 'i', 's', ' ', 'o', 'n', 'l', 'y', ' ', + 'a', ' ', 't', 'e', 's', 't', '.','\r', '\n' }; + + for (int i = 0; i < data->Length-5; i += 5) + { + fso->Write(data, i, 5); + } + + for (int i = data->Length -4; i < data->Length; i++) + { + fso->WriteByte(data[i]); + } + + + fso->Close(); + + FileInfo ^fi = gcnew FileInfo("file.dat"); + FileStream ^fsi = fi->OpenRead(); + + int fileLength = (int)fi->Length; // I happen to know the file is small + + int b; + while ((b = fsi->ReadByte()) != -1) + { + Console::Write((Char)b); + } + + fsi->Position = 0; + + array^ ca = gcnew array(fileLength); + fsi->Read(ca, 0, fileLength); + for (int i = 0; i < ca->Length; i++) + { + Console::Write((Char)ca[i]); + } + + Console::WriteLine(); + + fsi->Close(); + + fi->Delete(); // If you want to get rid of it +} diff --git a/Chapter08/MemoryStream.cpp b/Chapter08/MemoryStream.cpp new file mode 100644 index 0000000..ae9a32a --- /dev/null +++ b/Chapter08/MemoryStream.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::IO; + +void main() +{ + array^ data = gcnew array { 'T', 'h', 'i', + 's', ' ', 'i', 's', ' ', 'a', ' ', 't', 'e', 's', 't', + '!', '\r', '\n', 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', + 'o', 'n', 'l', 'y', ' ', 'a', ' ', 't', 'e', 's', 't', + '.','\r', '\n' }; + + MemoryStream ^ms = gcnew MemoryStream(); + ms->Capacity = 40; + + for (int i = 0; i < data->Length-5; i += 5) + { + ms->Write(data, i, 5); + } + + for (int i = data->Length -4; i < data->Length; i++) + { + ms->WriteByte(data[i]); + } + + array^ ca = ms->GetBuffer(); + for each (unsigned char c in ca) + { + Console::Write((Char)c); + } + Console::WriteLine(); + + FileStream ^fs = File::OpenWrite("file.txt"); + + ms->WriteTo(fs); + + fs->Close(); + ms->Close(); +} diff --git a/Chapter08/SoapFormSerial.cpp b/Chapter08/SoapFormSerial.cpp new file mode 100644 index 0000000..f939321 --- /dev/null +++ b/Chapter08/SoapFormSerial.cpp @@ -0,0 +1,98 @@ +#using + +using namespace System; +using namespace System::IO; +using namespace System::Runtime::Serialization::Formatters::Soap; + +// --------- Player Attribute class ------------------------------------ + +[Serializable] +ref class PlayerAttr +{ +public: + property int Strength; + property int Dexterity; + property int Constitution; + property int Intelligence; + property int Wisdom; + property int Charisma; + + PlayerAttr(int Str, int Dex, int Con, int Int, int Wis, int Cha); + void Print(); +}; + +PlayerAttr::PlayerAttr(int Str, int Dex, int Con, int Int, int Wis, int Cha) +{ + this->Strength = Str; + this->Dexterity = Dex; + this->Constitution = Con; + this->Intelligence = Int; + this->Wisdom = Wis; + this->Charisma = Cha; +} + +void PlayerAttr::Print() +{ + Console::WriteLine("Str: {0}, Dex: {1}, Con {2}", + Strength, Dexterity, Constitution); + Console::WriteLine("Int: {0}, Wis: {1}, Cha {2}", + Intelligence, Wisdom, Charisma); +} + +// -------- Player class --------------------------------------- + +[Serializable] +ref class Player +{ +public: + property String ^Name; + property String ^Race; + property String ^Class; + property PlayerAttr ^pattr; + + Player (String ^Name, String ^Race, String ^Class, + int Str, int Dex, int Con, int Int, int Wis, int Cha); + void Print(); +}; + +Player::Player (String ^Name, String ^Race, String ^Class, + int Str, int Dex, int Con, int Int, int Wis, int Cha) +{ + this->Name = Name; + this->Race = Race; + this->Class = Class; + this->pattr = gcnew PlayerAttr(Str, Dex, Con, Int, Wis, Cha); +} + +void Player::Print() +{ + Console::WriteLine("Name: {0}", Name); + Console::WriteLine("Race: {0}", Race); + Console::WriteLine("Class: {0}", Class); + pattr->Print(); +} + +// -------- Main Function ---------------------------------------------- + + +int main(void) +{ + Player ^Joe = gcnew Player("Joe", "Human", "Thief", 10, 18, 9, 13,10, 11); + + Console::WriteLine("Original Joe"); + Joe->Print(); + + FileStream ^plStream = File::Create("Player.xml"); + + SoapFormatter ^sf = gcnew SoapFormatter(); + sf->Serialize(plStream, Joe); + plStream->Close(); + + plStream = File::OpenRead("Player.xml"); + + Player ^JoeClone = (Player^)sf->Deserialize(plStream); + plStream->Close(); + + Console::WriteLine("\nCloned Joe"); + JoeClone->Print(); +} \ No newline at end of file diff --git a/Chapter08/StreamRW.cpp b/Chapter08/StreamRW.cpp new file mode 100644 index 0000000..685e3c8 --- /dev/null +++ b/Chapter08/StreamRW.cpp @@ -0,0 +1,31 @@ +using namespace System; +using namespace System::IO; + +void main() +{ + array^ data = gcnew array { + "This is ", "a test!", "This is only a test." }; + + StreamWriter ^sw = gcnew StreamWriter(gcnew FileStream("file.txt", + FileMode::Create, FileAccess::Write, FileShare::None)); + + for (int i = 0; i < data->Length-1; i++) + { + sw->Write(data[i]); + } + + sw->WriteLine(); + + sw->WriteLine(data[2]); + + sw->Close(); + + StreamReader ^sr = File::OpenText("file.txt"); + + String^ in = sr->ReadLine(); + Console::WriteLine(in); + + Console::WriteLine(sr->ReadToEnd()); + + sw->Close(); +} diff --git a/Chapter08/buildall.bat b/Chapter08/buildall.bat new file mode 100644 index 0000000..5ced349 --- /dev/null +++ b/Chapter08/buildall.bat @@ -0,0 +1,8 @@ +cl BinaryRW.cpp /clr:safe +cl BinFormSerial.cpp /clr:safe +cl DirInfo.cpp /clr +cl FileInfo.cpp /clr +cl filestream.cpp /clr:safe +cl memorystream.cpp /clr:safe +cl SoapFormSerial.cpp /clr:safe +cl StreamRW.cpp /clr:safe diff --git a/Chapter09/Chapter09.sln b/Chapter09/Chapter09.sln new file mode 100644 index 0000000..bcaed6e --- /dev/null +++ b/Chapter09/Chapter09.sln @@ -0,0 +1,44 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadConfig", "ReadConfig\ReadConfig.vcproj", "{DAD8DAB1-18D7-472F-BB84-54657313A955}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WriteConfig", "WriteConfig\WriteConfig.vcproj", "{4F12675F-D662-4C29-BAC1-3031EE2747B0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomSection", "CustomSection\CustomSection.vcproj", "{12BDA903-1A56-4A80-86D1-116788B1CC2E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EncryptSection", "EncryptSection\EncryptSection.vcproj", "{13646CD9-B3AB-4D3A-AE6D-071BC0231897}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DecryptSection", "DecryptSection\DecryptSection.vcproj", "{84B77E05-6995-4205-93AB-AB00CAC61778}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DAD8DAB1-18D7-472F-BB84-54657313A955}.Debug|Win32.ActiveCfg = Debug|Win32 + {DAD8DAB1-18D7-472F-BB84-54657313A955}.Debug|Win32.Build.0 = Debug|Win32 + {DAD8DAB1-18D7-472F-BB84-54657313A955}.Release|Win32.ActiveCfg = Release|Win32 + {DAD8DAB1-18D7-472F-BB84-54657313A955}.Release|Win32.Build.0 = Release|Win32 + {4F12675F-D662-4C29-BAC1-3031EE2747B0}.Debug|Win32.ActiveCfg = Debug|Win32 + {4F12675F-D662-4C29-BAC1-3031EE2747B0}.Debug|Win32.Build.0 = Debug|Win32 + {4F12675F-D662-4C29-BAC1-3031EE2747B0}.Release|Win32.ActiveCfg = Release|Win32 + {4F12675F-D662-4C29-BAC1-3031EE2747B0}.Release|Win32.Build.0 = Release|Win32 + {12BDA903-1A56-4A80-86D1-116788B1CC2E}.Debug|Win32.ActiveCfg = Debug|Win32 + {12BDA903-1A56-4A80-86D1-116788B1CC2E}.Debug|Win32.Build.0 = Debug|Win32 + {12BDA903-1A56-4A80-86D1-116788B1CC2E}.Release|Win32.ActiveCfg = Release|Win32 + {12BDA903-1A56-4A80-86D1-116788B1CC2E}.Release|Win32.Build.0 = Release|Win32 + {13646CD9-B3AB-4D3A-AE6D-071BC0231897}.Debug|Win32.ActiveCfg = Debug|Win32 + {13646CD9-B3AB-4D3A-AE6D-071BC0231897}.Debug|Win32.Build.0 = Debug|Win32 + {13646CD9-B3AB-4D3A-AE6D-071BC0231897}.Release|Win32.ActiveCfg = Release|Win32 + {13646CD9-B3AB-4D3A-AE6D-071BC0231897}.Release|Win32.Build.0 = Release|Win32 + {84B77E05-6995-4205-93AB-AB00CAC61778}.Debug|Win32.ActiveCfg = Debug|Win32 + {84B77E05-6995-4205-93AB-AB00CAC61778}.Debug|Win32.Build.0 = Debug|Win32 + {84B77E05-6995-4205-93AB-AB00CAC61778}.Release|Win32.ActiveCfg = Release|Win32 + {84B77E05-6995-4205-93AB-AB00CAC61778}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter09/Chapter09.suo b/Chapter09/Chapter09.suo new file mode 100644 index 0000000..30ab4fd Binary files /dev/null and b/Chapter09/Chapter09.suo differ diff --git a/Chapter09/CustomSection/CustomSection.vcproj b/Chapter09/CustomSection/CustomSection.vcproj new file mode 100644 index 0000000..5390c0a --- /dev/null +++ b/Chapter09/CustomSection/CustomSection.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter09/CustomSection/GameServerSection.h b/Chapter09/CustomSection/GameServerSection.h new file mode 100644 index 0000000..fe9cd7a --- /dev/null +++ b/Chapter09/CustomSection/GameServerSection.h @@ -0,0 +1,29 @@ +namespace MyCustomSection +{ + ref class GameServerSection : public ConfigurationSection + { + public: + GameServerSection() { } + + [ConfigurationPropertyAttribute("Port",IsRequired=true)] + property int Port + { + int get() { return (int)this["Port"]; } + void set(int value) { this["Port"] = value; } + } + + [ConfigurationPropertyAttribute("IPAddress",IsRequired=true)] + property String^ IPAddress + { + String^ get() { return (String^)this["IPAddress"]; } + void set(String^ value) { this["IPAddress"] = value; } + } + + [ConfigurationPropertyAttribute("Name",IsRequired=true)] + property String^ Name + { + String^ get() { return (String^)this["Name"]; } + void set(String^ value) { this["Name"] = value; } + } + }; +} diff --git a/Chapter09/CustomSection/MainApp.cpp b/Chapter09/CustomSection/MainApp.cpp new file mode 100644 index 0000000..42e2af7 --- /dev/null +++ b/Chapter09/CustomSection/MainApp.cpp @@ -0,0 +1,43 @@ +using namespace System; +using namespace System::Configuration; + +#include "GameServerSection.h" +using namespace MyCustomSection; + +int main(array ^args) +{ + // Read GameServerSection + GameServerSection^ gameServer = + (GameServerSection^)ConfigurationManager::GetSection("GameServerSection"); + + if (gameServer != nullptr) // false first time run + { + Console::WriteLine("Name = {0} IP = {1} Port = {2}\n\n", + gameServer->Name, + gameServer->IPAddress, + gameServer->Port); + } + + // Create GameServer Section + String^ exePath = Reflection::Assembly::GetExecutingAssembly()->Location; + + System::Configuration::Configuration^ config = + ConfigurationManager::OpenExeConfiguration(exePath); + + GameServerSection^ gameServerSection = + (GameServerSection^)config->GetSection("GameServerSection"); + + if (gameServerSection == nullptr) + { + gameServerSection = gcnew GameServerSection(); + config->Sections->Add("GameServerSection", gameServerSection); + + gameServerSection->Name = "Connector"; + gameServerSection->IPAddress = "192.168.1.101"; + gameServerSection->Port = 34501; + + config->Save(); + } + + Console::WriteLine(gameServerSection->SectionInformation->GetRawXml() + "\n"); +} \ No newline at end of file diff --git a/Chapter09/DecryptSection/DecryptSection.cpp b/Chapter09/DecryptSection/DecryptSection.cpp new file mode 100644 index 0000000..c3b3236 --- /dev/null +++ b/Chapter09/DecryptSection/DecryptSection.cpp @@ -0,0 +1,43 @@ +using namespace System; +using namespace System::Configuration; +using namespace System::IO; + +void DecryptConfigurationSection(String^ sectionName) +{ + String^ tmpPath = Reflection::Assembly::GetExecutingAssembly()->Location; + String^ exePath = Path::GetDirectoryName(tmpPath) + "\\EncryptSection.exe"; + + System::Configuration::Configuration^ config = + ConfigurationManager::OpenExeConfiguration(exePath); + + ConfigurationSection^ section = config->GetSection(sectionName); + + if (section->SectionInformation->IsProtected) + { + section->SectionInformation->UnprotectSection(); + section->SectionInformation->ForceSave = true; + config->Save(); + } +} + +String^ DumpConfig() +{ + String^ tmpPath = Reflection::Assembly::GetExecutingAssembly()->Location; + String^ path = Path::GetDirectoryName(tmpPath) + "\\EncryptSection.exe.config"; + + StreamReader^ sr = File::OpenText(path); + String^ ret = sr->ReadToEnd(); + sr->Close(); + + return ret; +} + +int main(array ^args) +{ + Console::WriteLine("*** Before Encryption:\n{0}\n\n", DumpConfig()); + + DecryptConfigurationSection("appSettings"); + Console::WriteLine("*** After Decryption:\n{0}\n\n", DumpConfig()); + + return 0; +} diff --git a/Chapter09/DecryptSection/DecryptSection.vcproj b/Chapter09/DecryptSection/DecryptSection.vcproj new file mode 100644 index 0000000..ba3c5cb --- /dev/null +++ b/Chapter09/DecryptSection/DecryptSection.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter09/EncryptSection/EncryptSection.cpp b/Chapter09/EncryptSection/EncryptSection.cpp new file mode 100644 index 0000000..ab3aa45 --- /dev/null +++ b/Chapter09/EncryptSection/EncryptSection.cpp @@ -0,0 +1,45 @@ +using namespace System; +using namespace System::Configuration; +using namespace System::IO; + +void EncryptConfigurationSection(String^ sectionName, String^ Provider) +{ + String^ exePath = Reflection::Assembly::GetExecutingAssembly()->Location; + + System::Configuration::Configuration^ config = + ConfigurationManager::OpenExeConfiguration(exePath); + + ConfigurationSection^ section = config->GetSection(sectionName); + + if (!section->SectionInformation->IsProtected) + { + section->SectionInformation->ProtectSection(Provider); + section->SectionInformation->ForceSave = true; + config->Save(); + } +} + +String^ DumpConfig() +{ + String^ path = + Reflection::Assembly::GetExecutingAssembly()->Location + ".config"; + + StreamReader^ sr = File::OpenText(path); + String^ ret = sr->ReadToEnd(); + sr->Close(); + + return ret; +} + +int main(array ^args) +{ +// String^ EncryptProvider = "RsaProtectedConfigurationProvider"; + String^ EncryptProvider = "DataProtectionConfigurationProvider"; + + Console::WriteLine("*** Before Encryption:\n{0}\n\n", DumpConfig()); + + EncryptConfigurationSection("appSettings", EncryptProvider); + Console::WriteLine("*** After Encryption:\n{0}\n\n", DumpConfig()); + + return 0; +} diff --git a/Chapter09/EncryptSection/EncryptSection.vcproj b/Chapter09/EncryptSection/EncryptSection.vcproj new file mode 100644 index 0000000..0e89528 --- /dev/null +++ b/Chapter09/EncryptSection/EncryptSection.vcproj @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter09/EncryptSection/app.config b/Chapter09/EncryptSection/app.config new file mode 100644 index 0000000..b842106 --- /dev/null +++ b/Chapter09/EncryptSection/app.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Chapter09/ReadConfig/ReadConfig.cpp b/Chapter09/ReadConfig/ReadConfig.cpp new file mode 100644 index 0000000..55a4b38 --- /dev/null +++ b/Chapter09/ReadConfig/ReadConfig.cpp @@ -0,0 +1,43 @@ +using namespace System; +using namespace System::Configuration; + +int main(array ^args) +{ + for each (String^ key in ConfigurationManager::AppSettings->AllKeys) + { + Console::WriteLine("Key = {0} \tValue = {1}", + key, + ConfigurationManager::AppSettings[key]); + } + + AppSettingsReader^ reader = gcnew AppSettingsReader(); + + String^ myString = (String^)reader->GetValue("A_String", String::typeid); + double myNumber = (double)reader->GetValue("A_Number", double::typeid); + DateTime myDateTime = (DateTime)reader->GetValue("A_DateTime", DateTime::typeid); + + Console::WriteLine("\nString^ [{0}] float [{1}] DateTime [{2} {3}]\n", + myString, + myNumber, + myDateTime.ToShortDateString(), + myDateTime.ToLongTimeString()); + + String^ exePath = Reflection::Assembly::GetExecutingAssembly()->Location; + + System::Configuration::Configuration^ config = + ConfigurationManager::OpenExeConfiguration(exePath); + + AppSettingsSection^ appSettingsSection = + (AppSettingsSection^)config->GetSection("appSettings"); + + for each (String^ key in appSettingsSection->Settings->AllKeys) + { + Console::WriteLine("Key = {0} \tValue = {1}", + key, + appSettingsSection->Settings[key]->Value); + } + + Console::WriteLine("\n" + appSettingsSection->SectionInformation->GetRawXml()); + + return 0; +} diff --git a/Chapter09/ReadConfig/ReadConfig.vcproj b/Chapter09/ReadConfig/ReadConfig.vcproj new file mode 100644 index 0000000..ffc1e73 --- /dev/null +++ b/Chapter09/ReadConfig/ReadConfig.vcproj @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter09/ReadConfig/app.config b/Chapter09/ReadConfig/app.config new file mode 100644 index 0000000..08958af --- /dev/null +++ b/Chapter09/ReadConfig/app.config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Chapter09/WriteConfig/WriteConfig.cpp b/Chapter09/WriteConfig/WriteConfig.cpp new file mode 100644 index 0000000..697ca92 --- /dev/null +++ b/Chapter09/WriteConfig/WriteConfig.cpp @@ -0,0 +1,76 @@ +using namespace System; +using namespace System::Configuration; + +int main(array ^args) +{ + DateTime dt = DateTime::Now; + String^ NowStr = dt.ToShortDateString() + " " + dt.ToLongTimeString(); + + String^ exePath = Reflection::Assembly::GetExecutingAssembly()->Location; + + System::Configuration::Configuration^ config = + ConfigurationManager::OpenExeConfiguration(exePath); + + AppSettingsSection^ appSettingsSection = + (AppSettingsSection^)config->GetSection("appSettings"); + + Console::WriteLine(appSettingsSection->SectionInformation->GetRawXml() + "\n"); + + // Create a new app.config file or update LastRun setting + if (appSettingsSection->Settings["LastRun"] == nullptr) + { + appSettingsSection->Settings->Add("LastRun", NowStr); + } + else + { + appSettingsSection->Settings["LastRun"]->Value = NowStr; + } + + // Create a Toggle of a setting with a key and no value + if (appSettingsSection->Settings["Toggle"] == nullptr) + { + appSettingsSection->Settings->Add("Toggle", nullptr); + } + else + { + appSettingsSection->Settings->Remove("Toggle"); + } + + // Clean up old run and add comma-delimited setting + appSettingsSection->Settings->Remove("CommaDel"); + + appSettingsSection->Settings->Add("CommaDel", "One"); + appSettingsSection->Settings->Add("CommaDel", "Two"); + appSettingsSection->Settings->Add("CommaDel", "Three"); + + // Save an dump appSettings XML to Console + config->Save(); + Console::WriteLine(appSettingsSection->SectionInformation->GetRawXml()); + + // Create a Comma-delimited Converter + CommaDelimitedStringCollectionConverter^ Converter = + gcnew CommaDelimitedStringCollectionConverter(); + + // Convert setting to a CommaDelimitedStringCollection + CommaDelimitedStringCollection^ collection = + (CommaDelimitedStringCollection^)Converter->ConvertFrom( + appSettingsSection->Settings["CommaDel"]->Value); + + // Modify all comman-delimited values + for (int i = 0; i < collection->Count; i++) + { + collection[i] = "**" + collection[i] + "**"; + } + + collection->Add("**Four**"); + collection->Remove("**Two**"); + + // Restore collection back to setting value + appSettingsSection->Settings["CommaDel"]->Value = collection->ToString(); + + // Save an dump appSettings XML to Console + config->Save(); + Console::WriteLine("\n" + appSettingsSection->SectionInformation->GetRawXml() + "\n\n\n\n"); + + return 0; +} diff --git a/Chapter09/WriteConfig/WriteConfig.vcproj b/Chapter09/WriteConfig/WriteConfig.vcproj new file mode 100644 index 0000000..8f320d3 --- /dev/null +++ b/Chapter09/WriteConfig/WriteConfig.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/ArrayOfRadios/ArrayOfRadios.cpp b/Chapter10/ArrayOfRadios/ArrayOfRadios.cpp new file mode 100644 index 0000000..f02d3dc --- /dev/null +++ b/Chapter10/ArrayOfRadios/ArrayOfRadios.cpp @@ -0,0 +1,18 @@ +// ArrayOfRadios.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace ArrayOfRadios; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/ArrayOfRadios/ArrayOfRadios.vcproj b/Chapter10/ArrayOfRadios/ArrayOfRadios.vcproj new file mode 100644 index 0000000..106593a --- /dev/null +++ b/Chapter10/ArrayOfRadios/ArrayOfRadios.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/ArrayOfRadios/AssemblyInfo.cpp b/Chapter10/ArrayOfRadios/AssemblyInfo.cpp new file mode 100644 index 0000000..1d68b0f --- /dev/null +++ b/Chapter10/ArrayOfRadios/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ArrayOfRadios")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ArrayOfRadios")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/ArrayOfRadios/Form1.h b/Chapter10/ArrayOfRadios/Form1.h new file mode 100644 index 0000000..3cdaf9f --- /dev/null +++ b/Chapter10/ArrayOfRadios/Form1.h @@ -0,0 +1,105 @@ +#pragma once + + +namespace ArrayOfRadios { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + array^ rbText = gcnew array { + L"Can", L"You", L"Click", L"More", L"Than", L"One" + }; + radios = gcnew array(6); + label = gcnew Label(); + + for (int i = 0; i < radios->Length; i++) + { + int j = 50*i; + radios[i] = gcnew RadioButton(); + radios[i]->BackColor = Color::FromArgb(255,j+5,j+5,j+5); + radios[i]->ForeColor = Color::FromArgb(255,250-j,250-j,250-j); + radios[i]->Location = Drawing::Point(90, 10+(40*i)); + radios[i]->TabIndex = i; + radios[i]->TabStop = true; + radios[i]->Text = rbText[i]; + radios[i]->CheckedChanged += + gcnew EventHandler(this, &Form1::radioCheckedChanged); + } + Controls->AddRange(radios); + + label->Location = Drawing::Point(90, 10+(40*radios->Length)); + Controls->Add(label); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + array^ radios; + Label ^label; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"An Array Of Radios"; + this->ResumeLayout(false); + } +#pragma endregion + + private: + void radioCheckedChanged(Object ^sender, EventArgs ^e) + { + RadioButton ^rb = (RadioButton^)sender; + + if (rb->Checked == true) + label->Text = rb->Text; + } + }; +} + diff --git a/Chapter10/ArrayOfRadios/Form1.resX b/Chapter10/ArrayOfRadios/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/ArrayOfRadios/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/ArrayOfRadios/ReadMe.txt b/Chapter10/ArrayOfRadios/ReadMe.txt new file mode 100644 index 0000000..396fd4a --- /dev/null +++ b/Chapter10/ArrayOfRadios/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : ArrayOfRadios Project Overview +======================================================================== + +AppWizard has created this ArrayOfRadios Application for you. + +This file contains a summary of what you will find in each of the files that +make up your ArrayOfRadios application. + +ArrayOfRadios.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ArrayOfRadios.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ArrayOfRadios.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/ArrayOfRadios/app.ico b/Chapter10/ArrayOfRadios/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/ArrayOfRadios/app.ico differ diff --git a/Chapter10/ArrayOfRadios/app.rc b/Chapter10/ArrayOfRadios/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/ArrayOfRadios/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/ArrayOfRadios/resource.h b/Chapter10/ArrayOfRadios/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/ArrayOfRadios/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/ArrayOfRadios/stdafx.cpp b/Chapter10/ArrayOfRadios/stdafx.cpp new file mode 100644 index 0000000..b8dd4c0 --- /dev/null +++ b/Chapter10/ArrayOfRadios/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ArrayOfRadios.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/ArrayOfRadios/stdafx.h b/Chapter10/ArrayOfRadios/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/ArrayOfRadios/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/Chapter10.sln b/Chapter10/Chapter10.sln new file mode 100644 index 0000000..cac79d2 --- /dev/null +++ b/Chapter10/Chapter10.sln @@ -0,0 +1,104 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hello", "Hello\Hello.vcproj", "{CB187D92-E6A4-4DBD-A072-273A64E7B0C6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomHello", "CustomHello\CustomHello.vcproj", "{D2212013-BFB1-4504-B40D-06A5E3A5AD21}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MouseJump", "MouseJump\MouseJump.vcproj", "{C3ADE2FF-0592-45E0-99DE-F4FB6A526C76}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MightyLabel", "MightyLabel\MightyLabel.vcproj", "{E06A1342-3314-4035-A7D4-33AD8042701A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TooManyButtons", "TooManyButtons\TooManyButtons.vcproj", "{74268F58-ED12-4B4A-B724-836D15557A72}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckMe", "CheckMe\CheckMe.vcproj", "{891CA431-346E-4D73-B0C6-F387E45A5492}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArrayOfRadios", "ArrayOfRadios\ArrayOfRadios.vcproj", "{F61BAC9A-ED29-4905-8D8F-DBB1B8888B49}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GroupingRadios", "GroupingRadios\GroupingRadios.vcproj", "{DA68E49F-FBE1-40EC-B9A4-F85DC78A5335}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Panels", "Panels\Panels.vcproj", "{2853C087-DA03-475B-84FF-F4F2A8B54374}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextEntry", "TextEntry\TextEntry.vcproj", "{BB04A873-5A99-46C8-B386-A6B11D6401DB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RichText", "RichText\RichText.vcproj", "{CD21113E-219B-4D59-AAFB-C492C71B08ED}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ListTransfers", "ListTransfers\ListTransfers.vcproj", "{A53CCC0F-2738-4C97-BC87-7C0F0B20B6EF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SyncCombos", "SyncCombos\SyncCombos.vcproj", "{8023F9F3-D00C-40C0-8696-DE6638420110}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SplitCLB", "SplitCLB\SplitCLB.vcproj", "{E29DC507-F6E3-4379-8E4E-F7D98A88DD54}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinuteTimer", "MinuteTimer\MinuteTimer.vcproj", "{014BC746-9AF1-450D-856C-B537A20CF166}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB187D92-E6A4-4DBD-A072-273A64E7B0C6}.Debug|Win32.ActiveCfg = Debug|Win32 + {CB187D92-E6A4-4DBD-A072-273A64E7B0C6}.Debug|Win32.Build.0 = Debug|Win32 + {CB187D92-E6A4-4DBD-A072-273A64E7B0C6}.Release|Win32.ActiveCfg = Release|Win32 + {CB187D92-E6A4-4DBD-A072-273A64E7B0C6}.Release|Win32.Build.0 = Release|Win32 + {D2212013-BFB1-4504-B40D-06A5E3A5AD21}.Debug|Win32.ActiveCfg = Debug|Win32 + {D2212013-BFB1-4504-B40D-06A5E3A5AD21}.Debug|Win32.Build.0 = Debug|Win32 + {D2212013-BFB1-4504-B40D-06A5E3A5AD21}.Release|Win32.ActiveCfg = Release|Win32 + {D2212013-BFB1-4504-B40D-06A5E3A5AD21}.Release|Win32.Build.0 = Release|Win32 + {C3ADE2FF-0592-45E0-99DE-F4FB6A526C76}.Debug|Win32.ActiveCfg = Debug|Win32 + {C3ADE2FF-0592-45E0-99DE-F4FB6A526C76}.Debug|Win32.Build.0 = Debug|Win32 + {C3ADE2FF-0592-45E0-99DE-F4FB6A526C76}.Release|Win32.ActiveCfg = Release|Win32 + {C3ADE2FF-0592-45E0-99DE-F4FB6A526C76}.Release|Win32.Build.0 = Release|Win32 + {E06A1342-3314-4035-A7D4-33AD8042701A}.Debug|Win32.ActiveCfg = Debug|Win32 + {E06A1342-3314-4035-A7D4-33AD8042701A}.Debug|Win32.Build.0 = Debug|Win32 + {E06A1342-3314-4035-A7D4-33AD8042701A}.Release|Win32.ActiveCfg = Release|Win32 + {E06A1342-3314-4035-A7D4-33AD8042701A}.Release|Win32.Build.0 = Release|Win32 + {74268F58-ED12-4B4A-B724-836D15557A72}.Debug|Win32.ActiveCfg = Debug|Win32 + {74268F58-ED12-4B4A-B724-836D15557A72}.Debug|Win32.Build.0 = Debug|Win32 + {74268F58-ED12-4B4A-B724-836D15557A72}.Release|Win32.ActiveCfg = Release|Win32 + {74268F58-ED12-4B4A-B724-836D15557A72}.Release|Win32.Build.0 = Release|Win32 + {891CA431-346E-4D73-B0C6-F387E45A5492}.Debug|Win32.ActiveCfg = Debug|Win32 + {891CA431-346E-4D73-B0C6-F387E45A5492}.Debug|Win32.Build.0 = Debug|Win32 + {891CA431-346E-4D73-B0C6-F387E45A5492}.Release|Win32.ActiveCfg = Release|Win32 + {891CA431-346E-4D73-B0C6-F387E45A5492}.Release|Win32.Build.0 = Release|Win32 + {F61BAC9A-ED29-4905-8D8F-DBB1B8888B49}.Debug|Win32.ActiveCfg = Debug|Win32 + {F61BAC9A-ED29-4905-8D8F-DBB1B8888B49}.Debug|Win32.Build.0 = Debug|Win32 + {F61BAC9A-ED29-4905-8D8F-DBB1B8888B49}.Release|Win32.ActiveCfg = Release|Win32 + {F61BAC9A-ED29-4905-8D8F-DBB1B8888B49}.Release|Win32.Build.0 = Release|Win32 + {DA68E49F-FBE1-40EC-B9A4-F85DC78A5335}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA68E49F-FBE1-40EC-B9A4-F85DC78A5335}.Debug|Win32.Build.0 = Debug|Win32 + {DA68E49F-FBE1-40EC-B9A4-F85DC78A5335}.Release|Win32.ActiveCfg = Release|Win32 + {DA68E49F-FBE1-40EC-B9A4-F85DC78A5335}.Release|Win32.Build.0 = Release|Win32 + {2853C087-DA03-475B-84FF-F4F2A8B54374}.Debug|Win32.ActiveCfg = Debug|Win32 + {2853C087-DA03-475B-84FF-F4F2A8B54374}.Debug|Win32.Build.0 = Debug|Win32 + {2853C087-DA03-475B-84FF-F4F2A8B54374}.Release|Win32.ActiveCfg = Release|Win32 + {2853C087-DA03-475B-84FF-F4F2A8B54374}.Release|Win32.Build.0 = Release|Win32 + {BB04A873-5A99-46C8-B386-A6B11D6401DB}.Debug|Win32.ActiveCfg = Debug|Win32 + {BB04A873-5A99-46C8-B386-A6B11D6401DB}.Debug|Win32.Build.0 = Debug|Win32 + {BB04A873-5A99-46C8-B386-A6B11D6401DB}.Release|Win32.ActiveCfg = Release|Win32 + {BB04A873-5A99-46C8-B386-A6B11D6401DB}.Release|Win32.Build.0 = Release|Win32 + {CD21113E-219B-4D59-AAFB-C492C71B08ED}.Debug|Win32.ActiveCfg = Debug|Win32 + {CD21113E-219B-4D59-AAFB-C492C71B08ED}.Debug|Win32.Build.0 = Debug|Win32 + {CD21113E-219B-4D59-AAFB-C492C71B08ED}.Release|Win32.ActiveCfg = Release|Win32 + {CD21113E-219B-4D59-AAFB-C492C71B08ED}.Release|Win32.Build.0 = Release|Win32 + {A53CCC0F-2738-4C97-BC87-7C0F0B20B6EF}.Debug|Win32.ActiveCfg = Debug|Win32 + {A53CCC0F-2738-4C97-BC87-7C0F0B20B6EF}.Debug|Win32.Build.0 = Debug|Win32 + {A53CCC0F-2738-4C97-BC87-7C0F0B20B6EF}.Release|Win32.ActiveCfg = Release|Win32 + {A53CCC0F-2738-4C97-BC87-7C0F0B20B6EF}.Release|Win32.Build.0 = Release|Win32 + {8023F9F3-D00C-40C0-8696-DE6638420110}.Debug|Win32.ActiveCfg = Debug|Win32 + {8023F9F3-D00C-40C0-8696-DE6638420110}.Debug|Win32.Build.0 = Debug|Win32 + {8023F9F3-D00C-40C0-8696-DE6638420110}.Release|Win32.ActiveCfg = Release|Win32 + {8023F9F3-D00C-40C0-8696-DE6638420110}.Release|Win32.Build.0 = Release|Win32 + {E29DC507-F6E3-4379-8E4E-F7D98A88DD54}.Debug|Win32.ActiveCfg = Debug|Win32 + {E29DC507-F6E3-4379-8E4E-F7D98A88DD54}.Debug|Win32.Build.0 = Debug|Win32 + {E29DC507-F6E3-4379-8E4E-F7D98A88DD54}.Release|Win32.ActiveCfg = Release|Win32 + {E29DC507-F6E3-4379-8E4E-F7D98A88DD54}.Release|Win32.Build.0 = Release|Win32 + {014BC746-9AF1-450D-856C-B537A20CF166}.Debug|Win32.ActiveCfg = Debug|Win32 + {014BC746-9AF1-450D-856C-B537A20CF166}.Debug|Win32.Build.0 = Debug|Win32 + {014BC746-9AF1-450D-856C-B537A20CF166}.Release|Win32.ActiveCfg = Release|Win32 + {014BC746-9AF1-450D-856C-B537A20CF166}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter10/CheckMe/AssemblyInfo.cpp b/Chapter10/CheckMe/AssemblyInfo.cpp new file mode 100644 index 0000000..0282efc --- /dev/null +++ b/Chapter10/CheckMe/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("CheckMe")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("CheckMe")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/CheckMe/CheckMe.cpp b/Chapter10/CheckMe/CheckMe.cpp new file mode 100644 index 0000000..3807498 --- /dev/null +++ b/Chapter10/CheckMe/CheckMe.cpp @@ -0,0 +1,18 @@ +// CheckMe.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace CheckMe; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/CheckMe/CheckMe.vcproj b/Chapter10/CheckMe/CheckMe.vcproj new file mode 100644 index 0000000..34e855e --- /dev/null +++ b/Chapter10/CheckMe/CheckMe.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/CheckMe/Form1.h b/Chapter10/CheckMe/Form1.h new file mode 100644 index 0000000..b1ec73d --- /dev/null +++ b/Chapter10/CheckMe/Form1.h @@ -0,0 +1,160 @@ +#pragma once + + +namespace CheckMe { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::CheckBox^ BottomCheck; + System::Windows::Forms::CheckBox^ checkBox2; + System::Windows::Forms::CheckBox^ checkBox1; + System::Windows::Forms::CheckBox^ TopCheck; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->BottomCheck = (gcnew System::Windows::Forms::CheckBox()); + this->checkBox2 = (gcnew System::Windows::Forms::CheckBox()); + this->checkBox1 = (gcnew System::Windows::Forms::CheckBox()); + this->TopCheck = (gcnew System::Windows::Forms::CheckBox()); + this->SuspendLayout(); + // + // BottomCheck + + // + this->BottomCheck->AutoSize = true; + this->BottomCheck->Enabled = false; + this->BottomCheck->Location = System::Drawing::Point(52, 167); + this->BottomCheck->Name = L"BottomCheck"; + this->BottomCheck->Size = System::Drawing::Size(127, 17); + this->BottomCheck->TabIndex = 4; + this->BottomCheck->TabStop = false; + this->BottomCheck->Text = L"You Can\'t Check Me!"; + this->BottomCheck->Visible = false; + this->BottomCheck->Enter += + gcnew System::EventHandler(this, &Form1::BottomCheck_Enter); + this->BottomCheck->MouseEnter += + gcnew System::EventHandler(this, &Form1::BottomCheck_Enter); + // + // checkBox2 + // + this->checkBox2->AutoSize = true; + this->checkBox2->Location = System::Drawing::Point(52, 130); + this->checkBox2->Name = L"checkBox2"; + this->checkBox2->Size = System::Drawing::Size(106, 17); + this->checkBox2->TabIndex = 5; + this->checkBox2->Text = L"Don\'t Forget ME!"; + // + // checkBox1 + // + this->checkBox1->AutoSize = true; + this->checkBox1->Checked = true; + this->checkBox1->CheckState = + System::Windows::Forms::CheckState::Indeterminate; + this->checkBox1->Location = System::Drawing::Point(52, 90); + this->checkBox1->Name = L"checkBox1"; + this->checkBox1->Size = System::Drawing::Size(133, 17); + this->checkBox1->TabIndex = 2; + this->checkBox1->Text = L"Check Me! Check Me!"; + this->checkBox1->ThreeState = true; + // + // TopCheck + // + this->TopCheck->AutoSize = true; + this->TopCheck->Location = System::Drawing::Point(52, 49); + this->TopCheck->Name = L"TopCheck"; + this->TopCheck->Size = System::Drawing::Size(127, 17); + this->TopCheck->TabIndex = 3; + this->TopCheck->TabStop = false; + this->TopCheck->Text = L"You Can\'t Check Me!"; + this->TopCheck->Enter += + gcnew System::EventHandler(this, &Form1::TopCheck_Enter); + this->TopCheck->MouseEnter += + gcnew System::EventHandler(this, &Form1::TopCheck_Enter); + + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(242, 273); + this->Controls->Add(this->BottomCheck); + this->Controls->Add(this->checkBox2); + this->Controls->Add(this->checkBox1); + this->Controls->Add(this->TopCheck); + this->Name = L"Form1"; + this->Text = L"Can\'t Check Me"; + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + + private: + System::Void TopCheck_Enter(System::Object^ sender, System::EventArgs^ e) + { + // Hide Top checkbox and display bottom + TopCheck->Enabled = false; + TopCheck->Visible = false; + BottomCheck->Enabled = true; + BottomCheck->Visible = true; + } + + private: + System::Void BottomCheck_Enter(System::Object^ sender, System::EventArgs^ e) + { + // Hide Bottom checkbox and display top + BottomCheck->Enabled = false; + BottomCheck->Visible = false; + TopCheck->Enabled = true; + TopCheck->Visible = true; + } + }; +} + diff --git a/Chapter10/CheckMe/Form1.resX b/Chapter10/CheckMe/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/CheckMe/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/CheckMe/ReadMe.txt b/Chapter10/CheckMe/ReadMe.txt new file mode 100644 index 0000000..4f363db --- /dev/null +++ b/Chapter10/CheckMe/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : CheckMe Project Overview +======================================================================== + +AppWizard has created this CheckMe Application for you. + +This file contains a summary of what you will find in each of the files that +make up your CheckMe application. + +CheckMe.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +CheckMe.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named CheckMe.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/CheckMe/app.ico b/Chapter10/CheckMe/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/CheckMe/app.ico differ diff --git a/Chapter10/CheckMe/app.rc b/Chapter10/CheckMe/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/CheckMe/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/CheckMe/resource.h b/Chapter10/CheckMe/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/CheckMe/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/CheckMe/stdafx.cpp b/Chapter10/CheckMe/stdafx.cpp new file mode 100644 index 0000000..cf33cba --- /dev/null +++ b/Chapter10/CheckMe/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// CheckMe.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/CheckMe/stdafx.h b/Chapter10/CheckMe/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/CheckMe/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/CustomHello/AssemblyInfo.cpp b/Chapter10/CustomHello/AssemblyInfo.cpp new file mode 100644 index 0000000..cf27532 --- /dev/null +++ b/Chapter10/CustomHello/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("CustomHello")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("CustomHello")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/CustomHello/CustomHello.cpp b/Chapter10/CustomHello/CustomHello.cpp new file mode 100644 index 0000000..295cacb --- /dev/null +++ b/Chapter10/CustomHello/CustomHello.cpp @@ -0,0 +1,18 @@ +// CustomHello.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace CustomHello; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/CustomHello/CustomHello.vcproj b/Chapter10/CustomHello/CustomHello.vcproj new file mode 100644 index 0000000..d41a11b --- /dev/null +++ b/Chapter10/CustomHello/CustomHello.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/CustomHello/Form1.h b/Chapter10/CustomHello/Form1.h new file mode 100644 index 0000000..6d63f72 --- /dev/null +++ b/Chapter10/CustomHello/Form1.h @@ -0,0 +1,78 @@ +#pragma once + + +namespace CustomHello { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->BackColor = System::Drawing::Color::Black; + this->ClientSize = System::Drawing::Size(692, 276); + this->Cursor = System::Windows::Forms::Cursors::UpArrow; + this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::SizableToolWindow; + this->Name = L"Form1"; + this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Show; + this->Text = L"Custom Hello"; + this->TopMost = true; + this->ResumeLayout(false); + + } +#pragma endregion + }; +} + diff --git a/Chapter10/CustomHello/Form1.resx b/Chapter10/CustomHello/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter10/CustomHello/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/CustomHello/ReadMe.txt b/Chapter10/CustomHello/ReadMe.txt new file mode 100644 index 0000000..9c72640 --- /dev/null +++ b/Chapter10/CustomHello/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : CustomHello Project Overview +======================================================================== + +AppWizard has created this CustomHello Application for you. + +This file contains a summary of what you will find in each of the files that +make up your CustomHello application. + +CustomHello.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +CustomHello.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named CustomHello.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/CustomHello/app.ico b/Chapter10/CustomHello/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/CustomHello/app.ico differ diff --git a/Chapter10/CustomHello/app.rc b/Chapter10/CustomHello/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/CustomHello/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/CustomHello/resource.h b/Chapter10/CustomHello/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/CustomHello/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/CustomHello/stdafx.cpp b/Chapter10/CustomHello/stdafx.cpp new file mode 100644 index 0000000..8ba14ba --- /dev/null +++ b/Chapter10/CustomHello/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// CustomHello.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/CustomHello/stdafx.h b/Chapter10/CustomHello/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/CustomHello/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/GroupingRadios/AssemblyInfo.cpp b/Chapter10/GroupingRadios/AssemblyInfo.cpp new file mode 100644 index 0000000..4fbe8af --- /dev/null +++ b/Chapter10/GroupingRadios/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("GroupingRadios")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("GroupingRadios")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/GroupingRadios/Form1.h b/Chapter10/GroupingRadios/Form1.h new file mode 100644 index 0000000..eef94f0 --- /dev/null +++ b/Chapter10/GroupingRadios/Form1.h @@ -0,0 +1,154 @@ +#pragma once + + +namespace GroupingRadios { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + BuildRadios(); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::GroupBox^ groupBox2; + System::Windows::Forms::GroupBox^ groupBox1; + + array^ radio1; + array^ radio2; + array^ radio3; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->groupBox2 = (gcnew System::Windows::Forms::GroupBox()); + this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); + this->SuspendLayout(); + // + // groupBox2 + // + this->groupBox2->Location = System::Drawing::Point(125, 153); + this->groupBox2->Name = L"groupBox2"; + this->groupBox2->Size = System::Drawing::Size(152, 134); + this->groupBox2->TabIndex = 3; + this->groupBox2->TabStop = false; + this->groupBox2->Text = L"Use"; + // + // groupBox1 + // + this->groupBox1->Location = System::Drawing::Point(125, 12); + this->groupBox1->Name = L"groupBox1"; + this->groupBox1->Size = System::Drawing::Size(152, 135); + this->groupBox1->TabIndex = 2; + this->groupBox1->TabStop = false; + this->groupBox1->Text = L"You"; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(352, 330); + this->Controls->Add(this->groupBox2); + this->Controls->Add(this->groupBox1); + this->Name = L"Form1"; + this->Text = L"Using Group Boxes"; + this->ResumeLayout(false); + } +#pragma endregion + void BuildRadios() + { + this->SuspendLayout(); + + // Text for RadioButton places on Form directly + array^ rbText1 = gcnew array { + L"Can", L"You", L"Click", L"More", L"Than", L"One" + }; + + // Build a RadioButton for each rbText1 + radio1 = gcnew array(6); + for (int i = 0; i < radio1->Length; i++) + { + radio1[i] = gcnew RadioButton(); + radio1[i]->Location = Drawing::Point(20, 20+(40*i)); + radio1[i]->Text = rbText1[i]; + } + // Add RadioButtons to Form + Controls->AddRange(radio1); + + // Text for RadioButton places in first GroupBox + array^ rbText2 = gcnew array { + L"Can", L"If", L"You" + }; + + // Build a RadioButton for each rbText2 + radio2 = gcnew array(3); + for (int i = 0; i < radio2->Length; i++) + { + radio2[i] = gcnew RadioButton(); + radio2[i]->Location = Drawing::Point(40, 30+(35*i)); + radio2[i]->Text = rbText2[i]; + } + // Add RadioButtons to GroupBox + groupBox1->Controls->AddRange(radio2); + + // Text for RadioButton places in second GroupBox + array^ rbText3 = gcnew array { + L"Different", L"Group", L"Boxes" + }; + + // Build a RadioButton for each rbText3 + radio3 = gcnew array(3); + for (int i = 0; i < radio3->Length; i++) + { + radio3[i] = gcnew RadioButton(); + radio3[i]->Location = Drawing::Point(40, 30+(35*i)); + radio3[i]->Text = rbText3[i]; + } + // Add RadioButtons to GroupBox2 + groupBox2->Controls->AddRange(radio3); + + this->ResumeLayout(false); + } + + }; +} + diff --git a/Chapter10/GroupingRadios/Form1.resX b/Chapter10/GroupingRadios/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/GroupingRadios/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/GroupingRadios/GroupingRadios.cpp b/Chapter10/GroupingRadios/GroupingRadios.cpp new file mode 100644 index 0000000..38c3f61 --- /dev/null +++ b/Chapter10/GroupingRadios/GroupingRadios.cpp @@ -0,0 +1,18 @@ +// GroupingRadios.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace GroupingRadios; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/GroupingRadios/GroupingRadios.vcproj b/Chapter10/GroupingRadios/GroupingRadios.vcproj new file mode 100644 index 0000000..5e42ce2 --- /dev/null +++ b/Chapter10/GroupingRadios/GroupingRadios.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/GroupingRadios/ReadMe.txt b/Chapter10/GroupingRadios/ReadMe.txt new file mode 100644 index 0000000..401b93e --- /dev/null +++ b/Chapter10/GroupingRadios/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : GroupingRadios Project Overview +======================================================================== + +AppWizard has created this GroupingRadios Application for you. + +This file contains a summary of what you will find in each of the files that +make up your GroupingRadios application. + +GroupingRadios.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +GroupingRadios.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named GroupingRadios.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/GroupingRadios/app.ico b/Chapter10/GroupingRadios/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/GroupingRadios/app.ico differ diff --git a/Chapter10/GroupingRadios/app.rc b/Chapter10/GroupingRadios/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/GroupingRadios/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/GroupingRadios/resource.h b/Chapter10/GroupingRadios/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/GroupingRadios/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/GroupingRadios/stdafx.cpp b/Chapter10/GroupingRadios/stdafx.cpp new file mode 100644 index 0000000..22a4e7a --- /dev/null +++ b/Chapter10/GroupingRadios/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// GroupingRadios.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/GroupingRadios/stdafx.h b/Chapter10/GroupingRadios/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/GroupingRadios/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/Hello/AssemblyInfo.cpp b/Chapter10/Hello/AssemblyInfo.cpp new file mode 100644 index 0000000..d6f4e4c --- /dev/null +++ b/Chapter10/Hello/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("Hello")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("Hello")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/Hello/Form1.h b/Chapter10/Hello/Form1.h new file mode 100644 index 0000000..03b2be4 --- /dev/null +++ b/Chapter10/Hello/Form1.h @@ -0,0 +1,73 @@ +#pragma once + + +namespace Hello { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Hello World!"; + this->ResumeLayout(false); + + } +#pragma endregion + }; +} + diff --git a/Chapter10/Hello/Form1.resx b/Chapter10/Hello/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter10/Hello/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/Hello/Hello.cpp b/Chapter10/Hello/Hello.cpp new file mode 100644 index 0000000..4c704f6 --- /dev/null +++ b/Chapter10/Hello/Hello.cpp @@ -0,0 +1,18 @@ +// Hello.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace Hello; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/Hello/Hello.vcproj b/Chapter10/Hello/Hello.vcproj new file mode 100644 index 0000000..8f8603c --- /dev/null +++ b/Chapter10/Hello/Hello.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/Hello/ReadMe.txt b/Chapter10/Hello/ReadMe.txt new file mode 100644 index 0000000..7f667ad --- /dev/null +++ b/Chapter10/Hello/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : Hello Project Overview +======================================================================== + +AppWizard has created this Hello Application for you. + +This file contains a summary of what you will find in each of the files that +make up your Hello application. + +Hello.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +Hello.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named Hello.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/Hello/app.ico b/Chapter10/Hello/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/Hello/app.ico differ diff --git a/Chapter10/Hello/app.rc b/Chapter10/Hello/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/Hello/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/Hello/resource.h b/Chapter10/Hello/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/Hello/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/Hello/stdafx.cpp b/Chapter10/Hello/stdafx.cpp new file mode 100644 index 0000000..f89dfd1 --- /dev/null +++ b/Chapter10/Hello/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// Hello.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/Hello/stdafx.h b/Chapter10/Hello/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/Hello/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/ListTransfers/AssemblyInfo.cpp b/Chapter10/ListTransfers/AssemblyInfo.cpp new file mode 100644 index 0000000..c6898b2 --- /dev/null +++ b/Chapter10/ListTransfers/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ListTransfers")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ListTransfers")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/ListTransfers/Form1.h b/Chapter10/ListTransfers/Form1.h new file mode 100644 index 0000000..44de3f4 --- /dev/null +++ b/Chapter10/ListTransfers/Form1.h @@ -0,0 +1,211 @@ +#pragma once + + +namespace ListTransfers { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::ListBox^ LBDest; + System::Windows::Forms::Button^ bnR2L; + System::Windows::Forms::Button^ bnL2R; + System::Windows::Forms::ListBox^ LBOrg; + System::Windows::Forms::Label^ label2; + System::Windows::Forms::Label^ label1; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->LBDest = (gcnew System::Windows::Forms::ListBox()); + this->bnR2L = (gcnew System::Windows::Forms::Button()); + this->bnL2R = (gcnew System::Windows::Forms::Button()); + this->LBOrg = (gcnew System::Windows::Forms::ListBox()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->SuspendLayout(); + // + // LBDest + // + this->LBDest->FormattingEnabled = true; + this->LBDest->Location = System::Drawing::Point(213, 46); + this->LBDest->Name = L"LBDest"; + this->LBDest->SelectionMode = + System::Windows::Forms::SelectionMode::MultiSimple; + this->LBDest->Size = System::Drawing::Size(134, 134); + this->LBDest->TabIndex = 10; + this->LBDest->DoubleClick += + gcnew System::EventHandler(this, &Form1::LBDest_DoubleClick); + // + // bnR2L + // + this->bnR2L->Location = System::Drawing::Point(167, 108); + this->bnR2L->Name = L"bnR2L"; + this->bnR2L->Size = System::Drawing::Size(33, 20); + this->bnR2L->TabIndex = 9; + this->bnR2L->Text = L"<=="; + this->bnR2L->Click += + gcnew System::EventHandler(this, &Form1::bnR2L_Click); + // + // bnL2R + // + this->bnL2R->Location = System::Drawing::Point(167, 80); + this->bnL2R->Name = L"bnL2R"; + this->bnL2R->Size = System::Drawing::Size(33, 20); + this->bnL2R->TabIndex = 8; + this->bnL2R->Text = L"==>"; + this->bnL2R->Click += + gcnew System::EventHandler(this, &Form1::bnL2R_Click); + // + // LBOrg + // + this->LBOrg->FormattingEnabled = true; + this->LBOrg->Items->AddRange(gcnew cli::array< System::Object^>(10) + {L"System", L"System::Collections", L"System::Data", + L"System::Drawing", L"System::IO", L"System::Net", + L"System::Threading", L"System::Web", + L"System::Windows::Forms", L"System::Xml"}); + + this->LBOrg->Location = System::Drawing::Point(20, 46); + this->LBOrg->Name = L"LBOrg"; + this->LBOrg->SelectionMode = + System::Windows::Forms::SelectionMode::MultiExtended; + this->LBOrg->Size = System::Drawing::Size(133, 134); + this->LBOrg->Sorted = true; + this->LBOrg->TabIndex = 6; + this->LBOrg->DoubleClick += + gcnew System::EventHandler(this, &Form1::LBOrg_DoubleClick); + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Location = System::Drawing::Point(213, 17); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(104, 13); + this->label2->TabIndex = 7; + this->label2->Text = L"Unsorted Multisimple"; + // + // label1 + // + this->label1->AutoSize = true; + this->label1->Location = System::Drawing::Point(20, 17); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(107, 13); + this->label1->TabIndex = 5; + this->label1->Text = L"Sorted Multiextended"; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(367, 196); + this->Controls->Add(this->LBDest); + this->Controls->Add(this->bnR2L); + this->Controls->Add(this->bnL2R); + this->Controls->Add(this->LBOrg); + this->Controls->Add(this->label2); + this->Controls->Add(this->label1); + this->Name = L"Form1"; + this->Text = L"List Box Transfers"; + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + + private: + System::Void LBOrg_DoubleClick(System::Object^ sender, + System::EventArgs^ e) + { + + // Add Selected item to other ListBox + // Then remove item from original + if (LBOrg->SelectedItem != nullptr) + { + LBDest->Items->Add(LBOrg->SelectedItem); + LBOrg->Items->Remove(LBOrg->SelectedItem); + } + } + + System::Void LBDest_DoubleClick(System::Object^ sender, + System::EventArgs^ e) + { + // Add Selected item to other ListBox + // Then remove item from original + if (LBDest->SelectedItem != nullptr) + { + LBOrg->Items->Add(LBDest->SelectedItem); + LBDest->Items->Remove(LBDest->SelectedItem); + } + } + + System::Void bnL2R_Click(System::Object^ sender, System::EventArgs^ e) + { + // Add all Selected items to other ListBox + // Then remove all the items from original + array^ tmp = + gcnew array(LBOrg->SelectedItems->Count); + LBOrg->SelectedItems->CopyTo(tmp, 0); + LBDest->Items->AddRange(tmp); + for (int i = 0; i < tmp->Length; i++) + LBOrg->Items->Remove(tmp[i]); + } + + System::Void bnR2L_Click(System::Object^ sender, System::EventArgs^ e) + { + // Add all Selected items to other ListBox + // Then remove all the items from original + array^ tmp = + gcnew array(LBDest->SelectedItems->Count); + LBDest->SelectedItems->CopyTo(tmp, 0); + LBOrg->Items->AddRange(tmp); + for (int i = 0; i < tmp->Length; i++) + LBDest->Items->Remove(tmp[i]); + } + }; +} + diff --git a/Chapter10/ListTransfers/Form1.resX b/Chapter10/ListTransfers/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/ListTransfers/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/ListTransfers/ListTransfers.cpp b/Chapter10/ListTransfers/ListTransfers.cpp new file mode 100644 index 0000000..d2167a1 --- /dev/null +++ b/Chapter10/ListTransfers/ListTransfers.cpp @@ -0,0 +1,18 @@ +// ListTransfers.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace ListTransfers; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/ListTransfers/ListTransfers.vcproj b/Chapter10/ListTransfers/ListTransfers.vcproj new file mode 100644 index 0000000..60b4cb9 --- /dev/null +++ b/Chapter10/ListTransfers/ListTransfers.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/ListTransfers/ReadMe.txt b/Chapter10/ListTransfers/ReadMe.txt new file mode 100644 index 0000000..b26b2e3 --- /dev/null +++ b/Chapter10/ListTransfers/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : ListTransfers Project Overview +======================================================================== + +AppWizard has created this ListTransfers Application for you. + +This file contains a summary of what you will find in each of the files that +make up your ListTransfers application. + +ListTransfers.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ListTransfers.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ListTransfers.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/ListTransfers/app.ico b/Chapter10/ListTransfers/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/ListTransfers/app.ico differ diff --git a/Chapter10/ListTransfers/app.rc b/Chapter10/ListTransfers/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/ListTransfers/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/ListTransfers/resource.h b/Chapter10/ListTransfers/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/ListTransfers/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/ListTransfers/stdafx.cpp b/Chapter10/ListTransfers/stdafx.cpp new file mode 100644 index 0000000..8930556 --- /dev/null +++ b/Chapter10/ListTransfers/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ListTransfers.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/ListTransfers/stdafx.h b/Chapter10/ListTransfers/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/ListTransfers/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/MightyLabel/AssemblyInfo.cpp b/Chapter10/MightyLabel/AssemblyInfo.cpp new file mode 100644 index 0000000..733a92c --- /dev/null +++ b/Chapter10/MightyLabel/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("MightyLabel")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("MightyLabel")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/MightyLabel/Form1.h b/Chapter10/MightyLabel/Form1.h new file mode 100644 index 0000000..d363386 --- /dev/null +++ b/Chapter10/MightyLabel/Form1.h @@ -0,0 +1,99 @@ +#pragma once + + +namespace MightyLabel { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + labelSwitch = true; + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Label^ MightyLabel; + bool labelSwitch; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->MightyLabel = (gcnew System::Windows::Forms::Label()); + this->SuspendLayout(); + // + // MightyLabel + // + this->MightyLabel->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; + this->MightyLabel->Cursor = System::Windows::Forms::Cursors::Hand; + this->MightyLabel->Location = System::Drawing::Point(63, 91); + this->MightyLabel->Name = L"MightyLabel"; + this->MightyLabel->Size = System::Drawing::Size(150, 35); + this->MightyLabel->TabIndex = 1; + this->MightyLabel->Text = L"This is the mighty label! It will change when you click it"; + this->MightyLabel->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + this->MightyLabel->Click += gcnew System::EventHandler(this, &Form1::MightyLabel_Click); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Controls->Add(this->MightyLabel); + this->Name = L"Form1"; + this->Text = L"The Mighty Label"; + this->Click += gcnew System::EventHandler(this, &Form1::MightyLabel_Click); + this->ResumeLayout(false); + + } +#pragma endregion + private: System::Void MightyLabel_Click(System::Object^ sender, System::EventArgs^ e) + { + if (labelSwitch) + MightyLabel->Text = L"Ouchie!!! That hurt."; + else + MightyLabel->Text = L"Ooo!!! That tickled."; + labelSwitch = !labelSwitch; + } + }; +} \ No newline at end of file diff --git a/Chapter10/MightyLabel/Form1.resx b/Chapter10/MightyLabel/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter10/MightyLabel/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/MightyLabel/MightyLabel.cpp b/Chapter10/MightyLabel/MightyLabel.cpp new file mode 100644 index 0000000..3e7a30d --- /dev/null +++ b/Chapter10/MightyLabel/MightyLabel.cpp @@ -0,0 +1,18 @@ +// MightyLabel.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace MightyLabel; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/MightyLabel/MightyLabel.vcproj b/Chapter10/MightyLabel/MightyLabel.vcproj new file mode 100644 index 0000000..83501a9 --- /dev/null +++ b/Chapter10/MightyLabel/MightyLabel.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/MightyLabel/ReadMe.txt b/Chapter10/MightyLabel/ReadMe.txt new file mode 100644 index 0000000..68c5b31 --- /dev/null +++ b/Chapter10/MightyLabel/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : MightyLabel Project Overview +======================================================================== + +AppWizard has created this MightyLabel Application for you. + +This file contains a summary of what you will find in each of the files that +make up your MightyLabel application. + +MightyLabel.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +MightyLabel.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named MightyLabel.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/MightyLabel/app.ico b/Chapter10/MightyLabel/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/MightyLabel/app.ico differ diff --git a/Chapter10/MightyLabel/app.rc b/Chapter10/MightyLabel/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/MightyLabel/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/MightyLabel/resource.h b/Chapter10/MightyLabel/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/MightyLabel/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/MightyLabel/stdafx.cpp b/Chapter10/MightyLabel/stdafx.cpp new file mode 100644 index 0000000..66e705a --- /dev/null +++ b/Chapter10/MightyLabel/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// MightyLabel.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/MightyLabel/stdafx.h b/Chapter10/MightyLabel/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/MightyLabel/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/MinuteTimer/AssemblyInfo.cpp b/Chapter10/MinuteTimer/AssemblyInfo.cpp new file mode 100644 index 0000000..bda7ed0 --- /dev/null +++ b/Chapter10/MinuteTimer/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("MinuteTimer")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("MinuteTimer")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/MinuteTimer/Form1.h b/Chapter10/MinuteTimer/Form1.h new file mode 100644 index 0000000..284c5a9 --- /dev/null +++ b/Chapter10/MinuteTimer/Form1.h @@ -0,0 +1,123 @@ +#pragma once + + +namespace MinuteTimer { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::ProgressBar^ progressBar; + System::Windows::Forms::Label^ lbsecs; + System::Windows::Forms::Timer^ timer; + + int seconds; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + this->progressBar = (gcnew System::Windows::Forms::ProgressBar()); + this->lbsecs = (gcnew System::Windows::Forms::Label()); + this->timer = + (gcnew System::Windows::Forms::Timer(this->components)); + this->SuspendLayout(); + // + // progressBar + // + this->progressBar->Location = System::Drawing::Point(61, 16); + this->progressBar->Maximum = 60; + this->progressBar->Name = L"progressBar"; + this->progressBar->Size = System::Drawing::Size(326, 23); + this->progressBar->TabIndex = 3; + // + // lbsecs + // + this->lbsecs->AutoSize = true; + this->lbsecs->Location = System::Drawing::Point(19, 25); + this->lbsecs->Name = L"lbsecs"; + this->lbsecs->Size = System::Drawing::Size(13, 13); + this->lbsecs->TabIndex = 2; + this->lbsecs->Text = L"0"; + this->lbsecs->TextAlign = + System::Drawing::ContentAlignment::MiddleRight; + // + // timer + // + this->timer->Enabled = true; + this->timer->Tick += + gcnew System::EventHandler(this, &Form1::timer_Tick); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(407, 55); + this->Controls->Add(this->progressBar); + this->Controls->Add(this->lbsecs); + this->Name = L"Form1"; + this->Text = L"One minute timer"; + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + + private: + System::Void timer_Tick(System::Object^ sender, System::EventArgs^ e) + { + // Write current tick count (int 10th of second) to label + seconds++; + seconds %= 600; + lbsecs->Text = String::Format("{0}.{1}", (seconds/10).ToString(), + (seconds%10).ToString()); + // Update ProgressBar + progressBar->Value = seconds/10; + } + }; +} + diff --git a/Chapter10/MinuteTimer/Form1.resX b/Chapter10/MinuteTimer/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/MinuteTimer/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/MinuteTimer/MinuteTimer.cpp b/Chapter10/MinuteTimer/MinuteTimer.cpp new file mode 100644 index 0000000..6988982 --- /dev/null +++ b/Chapter10/MinuteTimer/MinuteTimer.cpp @@ -0,0 +1,18 @@ +// MinuteTimer.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace MinuteTimer; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/MinuteTimer/MinuteTimer.vcproj b/Chapter10/MinuteTimer/MinuteTimer.vcproj new file mode 100644 index 0000000..4acaf20 --- /dev/null +++ b/Chapter10/MinuteTimer/MinuteTimer.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/MinuteTimer/ReadMe.txt b/Chapter10/MinuteTimer/ReadMe.txt new file mode 100644 index 0000000..23ed1af --- /dev/null +++ b/Chapter10/MinuteTimer/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : MinuteTimer Project Overview +======================================================================== + +AppWizard has created this MinuteTimer Application for you. + +This file contains a summary of what you will find in each of the files that +make up your MinuteTimer application. + +MinuteTimer.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +MinuteTimer.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named MinuteTimer.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/MinuteTimer/app.ico b/Chapter10/MinuteTimer/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/MinuteTimer/app.ico differ diff --git a/Chapter10/MinuteTimer/app.rc b/Chapter10/MinuteTimer/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/MinuteTimer/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/MinuteTimer/resource.h b/Chapter10/MinuteTimer/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/MinuteTimer/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/MinuteTimer/stdafx.cpp b/Chapter10/MinuteTimer/stdafx.cpp new file mode 100644 index 0000000..5ff6b30 --- /dev/null +++ b/Chapter10/MinuteTimer/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// MinuteTimer.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/MinuteTimer/stdafx.h b/Chapter10/MinuteTimer/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/MinuteTimer/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/MouseJump/AssemblyInfo.cpp b/Chapter10/MouseJump/AssemblyInfo.cpp new file mode 100644 index 0000000..fe1b0be --- /dev/null +++ b/Chapter10/MouseJump/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("MouseJump")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("MouseJump")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/MouseJump/Form1.h b/Chapter10/MouseJump/Form1.h new file mode 100644 index 0000000..679c3cf --- /dev/null +++ b/Chapter10/MouseJump/Form1.h @@ -0,0 +1,108 @@ +#pragma once + + +namespace MouseJump { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(450, 300); + this->Name = L"Form1"; + this->Text = L"Mouse Jump"; + this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseDown); + this->ResumeLayout(false); + + } +#pragma endregion + private: System::Void Form1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) { + // Get mouse x and y coordinates + int x = e->X; + int y = e->Y; + + // Get Forms upper left location + Point loc = DesktopLocation; + + // Handle left button mouse click + if (e->Button == Windows::Forms::MouseButtons::Left) + { + Text = String::Format("Mouse Jump - Left Button at {0},{1}", + x, y); + + DesktopLocation = Drawing::Point(loc.X + x, loc.Y +y); + } + // Handle right button mouse click + else if (e->Button == Windows::Forms::MouseButtons::Right) + { + Text = String::Format("Mouse Jump - Right Button at {0},{1}", + x, y); + + DesktopLocation = Point((loc.X+1) - (ClientSize.Width - x), + (loc.Y+1) - (ClientSize.Height - y)); + } + // Handle middle button mouse click + else + { + Text = String::Format("Mouse Jump - Middle Button at {0},{1}", + x, y); + DesktopLocation = Point((loc.X+1) - ((ClientSize.Width/2) - x), + (loc.Y+1) - ((ClientSize.Height/2) - y)); + } + } + }; +} + diff --git a/Chapter10/MouseJump/Form1.resx b/Chapter10/MouseJump/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter10/MouseJump/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/MouseJump/MouseJump.cpp b/Chapter10/MouseJump/MouseJump.cpp new file mode 100644 index 0000000..ec1cb0c --- /dev/null +++ b/Chapter10/MouseJump/MouseJump.cpp @@ -0,0 +1,18 @@ +// MouseJump.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace MouseJump; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/MouseJump/MouseJump.vcproj b/Chapter10/MouseJump/MouseJump.vcproj new file mode 100644 index 0000000..294d0f6 --- /dev/null +++ b/Chapter10/MouseJump/MouseJump.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/MouseJump/ReadMe.txt b/Chapter10/MouseJump/ReadMe.txt new file mode 100644 index 0000000..73c0432 --- /dev/null +++ b/Chapter10/MouseJump/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : MouseJump Project Overview +======================================================================== + +AppWizard has created this MouseJump Application for you. + +This file contains a summary of what you will find in each of the files that +make up your MouseJump application. + +MouseJump.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +MouseJump.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named MouseJump.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/MouseJump/app.ico b/Chapter10/MouseJump/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/MouseJump/app.ico differ diff --git a/Chapter10/MouseJump/app.rc b/Chapter10/MouseJump/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/MouseJump/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/MouseJump/resource.h b/Chapter10/MouseJump/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/MouseJump/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/MouseJump/stdafx.cpp b/Chapter10/MouseJump/stdafx.cpp new file mode 100644 index 0000000..2d61dd7 --- /dev/null +++ b/Chapter10/MouseJump/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// MouseJump.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/MouseJump/stdafx.h b/Chapter10/MouseJump/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/MouseJump/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/Panels/AssemblyInfo.cpp b/Chapter10/Panels/AssemblyInfo.cpp new file mode 100644 index 0000000..41650e6 --- /dev/null +++ b/Chapter10/Panels/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("Panels")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("Panels")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/Panels/Form1.h b/Chapter10/Panels/Form1.h new file mode 100644 index 0000000..c2c841b --- /dev/null +++ b/Chapter10/Panels/Form1.h @@ -0,0 +1,163 @@ +#pragma once + + +namespace Panels { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Panel^ Rightpanel; + System::Windows::Forms::Button^ button2; + System::Windows::Forms::Button^ button1; + System::Windows::Forms::Panel^ Leftpanel; + System::Windows::Forms::Button^ bnHide; + System::Windows::Forms::Button^ bnDisable; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->Rightpanel = (gcnew System::Windows::Forms::Panel()); + this->button2 = (gcnew System::Windows::Forms::Button()); + this->button1 = (gcnew System::Windows::Forms::Button()); + this->Leftpanel = (gcnew System::Windows::Forms::Panel()); + this->bnHide = (gcnew System::Windows::Forms::Button()); + this->bnDisable = (gcnew System::Windows::Forms::Button()); + this->Rightpanel->SuspendLayout(); + this->Leftpanel->SuspendLayout(); + this->SuspendLayout(); + // + // Rightpanel + // + this->Rightpanel->AutoScroll = true; + this->Rightpanel->BorderStyle = + System::Windows::Forms::BorderStyle::Fixed3D; + this->Rightpanel->Controls->Add(this->button2); + this->Rightpanel->Controls->Add(this->button1); + this->Rightpanel->Location = System::Drawing::Point(161, 22); + this->Rightpanel->Name = L"Rightpanel"; + this->Rightpanel->Size = System::Drawing::Size(121, 60); + this->Rightpanel->TabIndex = 3; + + // + // button2 + // + this->button2->Location = System::Drawing::Point(20, 62); + this->button2->Name = L"button2"; + this->button2->Size = System::Drawing::Size(75, 23); + this->button2->TabIndex = 1; + this->button2->Text = L"button 2"; + // + // button1 + // + this->button1->Location = System::Drawing::Point(20, 7); + this->button1->Name = L"button1"; + this->button1->Size = System::Drawing::Size(75, 23); + this->button1->TabIndex = 0; + this->button1->Text = L"button 1"; + // + // Leftpanel + // + this->Leftpanel->BorderStyle = + System::Windows::Forms::BorderStyle::FixedSingle; + this->Leftpanel->Controls->Add(this->bnHide); + this->Leftpanel->Controls->Add(this->bnDisable); + this->Leftpanel->Location = System::Drawing::Point(28, 22); + this->Leftpanel->Name = L"Leftpanel"; + this->Leftpanel->Size = System::Drawing::Size(120, 95); + this->Leftpanel->TabIndex = 2; + // + // bnHide + // + this->bnHide->Location = System::Drawing::Point(17, 62); + this->bnHide->Name = L"bnHide"; + this->bnHide->Size = System::Drawing::Size(75, 23); + this->bnHide->TabIndex = 1; + this->bnHide->Text = L"Hide"; + this->bnHide->Click += + gcnew System::EventHandler(this, &Form1::bnHide_Click); + // + // bnDisable + // + this->bnDisable->Location = System::Drawing::Point(17, 7); + this->bnDisable->Name = L"bnDisable"; + this->bnDisable->Size = System::Drawing::Size(75, 23); + this->bnDisable->TabIndex = 0; + this->bnDisable->Text = L"Disable"; + this->bnDisable->Click += + gcnew System::EventHandler(this, &Form1::bnDisable_Click); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(310, 139); + this->Controls->Add(this->Rightpanel); + this->Controls->Add(this->Leftpanel); + this->Name = L"Form1"; + this->Text = L"A hidden fourth button"; + this->Rightpanel->ResumeLayout(false); + this->Leftpanel->ResumeLayout(false); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void bnDisable_Click(System::Object^ sender, System::EventArgs^ e) + { + Rightpanel->Enabled = !Rightpanel->Enabled; + } + + private: + System::Void bnHide_Click(System::Object^ sender, System::EventArgs^ e) + { + Rightpanel->Visible = !Rightpanel->Visible; + } + }; +} + diff --git a/Chapter10/Panels/Form1.resX b/Chapter10/Panels/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/Panels/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/Panels/Panels.cpp b/Chapter10/Panels/Panels.cpp new file mode 100644 index 0000000..918832f --- /dev/null +++ b/Chapter10/Panels/Panels.cpp @@ -0,0 +1,18 @@ +// Panels.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace Panels; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/Panels/Panels.vcproj b/Chapter10/Panels/Panels.vcproj new file mode 100644 index 0000000..d9f46d0 --- /dev/null +++ b/Chapter10/Panels/Panels.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/Panels/ReadMe.txt b/Chapter10/Panels/ReadMe.txt new file mode 100644 index 0000000..bd29235 --- /dev/null +++ b/Chapter10/Panels/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : Panels Project Overview +======================================================================== + +AppWizard has created this Panels Application for you. + +This file contains a summary of what you will find in each of the files that +make up your Panels application. + +Panels.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +Panels.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named Panels.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/Panels/app.ico b/Chapter10/Panels/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/Panels/app.ico differ diff --git a/Chapter10/Panels/app.rc b/Chapter10/Panels/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/Panels/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/Panels/resource.h b/Chapter10/Panels/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/Panels/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/Panels/stdafx.cpp b/Chapter10/Panels/stdafx.cpp new file mode 100644 index 0000000..6702ffa --- /dev/null +++ b/Chapter10/Panels/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// Panels.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/Panels/stdafx.h b/Chapter10/Panels/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/Panels/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/RichText/AssemblyInfo.cpp b/Chapter10/RichText/AssemblyInfo.cpp new file mode 100644 index 0000000..e01d560 --- /dev/null +++ b/Chapter10/RichText/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("RichText")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("RichText")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/RichText/Chapter01.rtf b/Chapter10/RichText/Chapter01.rtf new file mode 100644 index 0000000..e5683f5 --- /dev/null +++ b/Chapter10/RichText/Chapter01.rtf @@ -0,0 +1,212 @@ +{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;} +{\f36\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria;}{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} +{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria;} +{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} +{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;} +{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f39\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f40\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} +{\f42\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\f44\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} +{\f46\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\f47\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f399\fbidi \froman\fcharset238\fprq2 Cambria CE;}{\f400\fbidi \froman\fcharset204\fprq2 Cambria Cyr;} +{\f402\fbidi \froman\fcharset161\fprq2 Cambria Greek;}{\f403\fbidi \froman\fcharset162\fprq2 Cambria Tur;}{\f406\fbidi \froman\fcharset186\fprq2 Cambria Baltic;}{\f409\fbidi \fswiss\fcharset238\fprq2 Calibri CE;} +{\f410\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\f412\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\f413\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\f416\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;} +{\flomajor\f31508\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\flomajor\f31509\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flomajor\f31511\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;} +{\flomajor\f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\flomajor\f31513\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} +{\flomajor\f31515\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbmajor\f31518\fbidi \froman\fcharset238\fprq2 Times New Roman CE;} +{\fdbmajor\f31519\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fdbmajor\f31521\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbmajor\f31522\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;} +{\fdbmajor\f31523\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fdbmajor\f31524\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbmajor\f31525\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;} +{\fdbmajor\f31526\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fhimajor\f31528\fbidi \froman\fcharset238\fprq2 Cambria CE;}{\fhimajor\f31529\fbidi \froman\fcharset204\fprq2 Cambria Cyr;} +{\fhimajor\f31531\fbidi \froman\fcharset161\fprq2 Cambria Greek;}{\fhimajor\f31532\fbidi \froman\fcharset162\fprq2 Cambria Tur;}{\fhimajor\f31535\fbidi \froman\fcharset186\fprq2 Cambria Baltic;} +{\fbimajor\f31538\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbimajor\f31539\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fbimajor\f31541\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;} +{\fbimajor\f31542\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbimajor\f31543\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fbimajor\f31544\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} +{\fbimajor\f31545\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbimajor\f31546\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\flominor\f31548\fbidi \froman\fcharset238\fprq2 Times New Roman CE;} +{\flominor\f31549\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flominor\f31551\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\flominor\f31552\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;} +{\flominor\f31553\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flominor\f31554\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\flominor\f31555\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;} +{\flominor\f31556\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbminor\f31558\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fdbminor\f31559\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} +{\fdbminor\f31561\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbminor\f31562\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fdbminor\f31563\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);} +{\fdbminor\f31564\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbminor\f31565\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fdbminor\f31566\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);} +{\fhiminor\f31568\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\fhiminor\f31569\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\fhiminor\f31571\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\fhiminor\f31572\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;} +{\fhiminor\f31575\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}{\fbiminor\f31578\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbiminor\f31579\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} +{\fbiminor\f31581\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbiminor\f31582\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbiminor\f31583\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);} +{\fbiminor\f31584\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbiminor\f31585\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbiminor\f31586\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}} +{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0; +\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\caccentone\ctint255\cshade191\red54\green95\blue145;\caccentone\ctint255\cshade255\red79\green129\blue189; +\ctexttwo\ctint255\cshade191\red23\green54\blue93;}{\*\defchp \f31506\fs22 }{\*\defpap \ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{\ql \li0\ri0\sa200\sl360\slmult1 +\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 \sqformat \spriority0 \styrsid15621848 Normal;}{ +\s1\ql \li0\ri0\sb480\sl360\slmult1\keep\keepn\widctlpar\wrapdefault\aspalpha\aspnum\faauto\outlinelevel0\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \ab\af31503\afs28\alang1025 \ltrch\fcs0 +\b\fs28\cf17\lang1033\langfe1033\loch\f31502\hich\af31502\dbch\af31501\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext0 \slink17 \sqformat \spriority9 \styrsid15758278 heading 1;}{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 +Default Paragraph Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv +\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 +\snext11 \ssemihidden \sunhideused \sqformat Normal Table;}{\s15\ql \li0\ri0\sa300\widctlpar\brdrb\brdrs\brdrw20\brsp80\brdrcf18 \wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\contextualspace \rtlch\fcs1 \af31503\afs52\alang1025 +\ltrch\fcs0 \fs52\expnd1\expndtw5\cf19\lang1033\langfe1033\kerning28\loch\f31502\hich\af31502\dbch\af31501\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext0 \slink16 \sqformat \spriority10 \styrsid15758278 Title;}{\*\cs16 \additive \rtlch\fcs1 +\af31503\afs52 \ltrch\fcs0 \fs52\expnd1\expndtw5\cf19\kerning28\loch\f31502\hich\af31502\dbch\af31501 \sbasedon10 \slink15 \slocked \spriority10 \styrsid15758278 Title Char;}{\*\cs17 \additive \rtlch\fcs1 \ab\af31503\afs28 \ltrch\fcs0 +\b\fs28\cf17\loch\f31502\hich\af31502\dbch\af31501 \sbasedon10 \slink1 \slocked \spriority9 \styrsid15758278 Heading 1 Char;}{\s18\ql \li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\ilvl1\adjustright\rin0\lin0\itap0 \rtlch\fcs1 +\ai\af31503\afs24\alang1025 \ltrch\fcs0 \i\fs24\expnd3\expndtw15\cf18\lang1033\langfe1033\loch\f31502\hich\af31502\dbch\af31501\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext0 \slink19 \sqformat \spriority11 \styrsid15758278 Subtitle;}{\*\cs19 \additive +\rtlch\fcs1 \ai\af31503\afs24 \ltrch\fcs0 \i\fs24\expnd3\expndtw15\cf18\loch\f31502\hich\af31502\dbch\af31501 \sbasedon10 \slink18 \slocked \spriority11 \styrsid15758278 Subtitle Char;}}{\*\rsidtbl \rsid88198\rsid859814\rsid1145205\rsid1447059\rsid1928422 +\rsid1980465\rsid6712197\rsid8264538\rsid10096165\rsid10228194\rsid10816160\rsid12204371\rsid12205869\rsid13248891\rsid14300046\rsid15543366\rsid15621848\rsid15751665\rsid15758278}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0 +\mrMargin0\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\author Stephen}{\operator Stephen}{\creatim\yr2008\mo5\dy22\min46}{\revtim\yr2008\mo5\dy22\min46}{\version2}{\edmins0}{\nofpages2}{\nofwords392}{\nofchars2240}{\nofcharsws2627}{\vern32895}} +{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect +\widowctrl\ftnbj\aenddoc\trackmoves1\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors1\noxlattoyen +\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1440\dgvorigin1440\dghshow1\dgvshow1 +\jexpand\viewkind1\viewscale107\viewzk2\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel +\wrppunct\asianbrkrule\rsidroot15758278\newtblstyruls\nogrowautofit\usenormstyforlist\noindnmbrts\felnbrelev\nocxsptable\indrlsweleven\noafcnsttbl\afelev\utinl\hwelev\spltpgpar\notcvasp\notbrkcnstfrctbl\notvatxbx\krnprsnet\cachedcolbal \nouicompat \fet0 +{\*\wgrffmtfilter 2450}\nofeaturethrottle1\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid1447059\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2 +\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6 +\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang +{\pntxtb (}{\pntxta )}}\pard\plain \ltrpar\s15\ql \li0\ri0\sa300\widctlpar\brdrb\brdrs\brdrw20\brsp80\brdrcf18 \wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid10228194\contextualspace \rtlch\fcs1 \af31503\afs52\alang1025 +\ltrch\fcs0 \fs52\expnd1\expndtw5\cf19\lang1033\langfe1033\kerning28\loch\af31502\hich\af31502\dbch\af31501\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af31503 \ltrch\fcs0 \insrsid12205869 \hich\af31502\dbch\af31501\loch\f31502 A note from the author}{ +\rtlch\fcs1 \af31503 \ltrch\fcs0 \insrsid10228194 +\par }\pard\plain \ltrpar\ql \fi720\li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid15751665 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 { +\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15758278 \'93History is written by the victor. This is the real story}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15751665 . Please, let the world know the truth,}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 +\insrsid15758278 \'94 was all that was written on}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15751665 the large}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15758278 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15751665 very old}{\rtlch\fcs1 \af0\afs24 +\ltrch\fcs0 \insrsid12205869 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15751665 clay pot}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 , containing an ancient withered scroll}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15751665 .}{\rtlch\fcs1 +\af0\afs24 \ltrch\fcs0 \insrsid15758278 +\par }\pard \ltrpar\ql \li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid15758278 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15751665 \tab How it came to be on my doorstep, I\rquote m sure I\rquote +ll never know. Whether it was authentic}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 , I\rquote ll never know that either}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 . Since}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid14300046 ,}{ +\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 j}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 ust as the pot appeared on my doorstep, it disappeared once I finished translating it.}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15751665 +\par }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid1145205 \tab Originally, I thought I\rquote d just create a fictional story based on the scrolls}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid10228194 , as n +o one will believe the story as anything but fiction anyway. B}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid1145205 ut as I continued writing I realized the original story was better than anything I could come up with. +\par }\pard \ltrpar\ql \li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid88198 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 \tab }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid1145205 Finally, } +{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 I }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid1145205 decided }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 to stay true to the original Hebrew}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 +\insrsid10228194 -Aramaic}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 it was written in}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid1145205 ,}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 though I did convert date}{\rtlch\fcs1 +\af0\afs24 \ltrch\fcs0 \insrsid88198 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 (when possible), times and measure}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid1145205 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 + to make it easier to understand. A}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 l}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 s}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 o,}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 + a few times I had to fill in a few blanks}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 ,}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 as the scroll was damaged}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid10228194 beyond }{\rtlch\fcs1 +\af0\afs24 \ltrch\fcs0 \insrsid10096165 legibility}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid12205869 in a few places. +\par }\pard \ltrpar\ql \fi720\li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid88198 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 All I can say is that it }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 +\insrsid1145205 i}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 s an interesting }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid1145205 story\'85 fact or fiction}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 .}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 +\insrsid1145205 Or should I say science fact or fiction.}{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 }{\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15621848 +\par }\pard \ltrpar\ql \li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid15621848 \page +\par }\pard\plain \ltrpar\s15\ql \li0\ri0\sa300\widctlpar\brdrb\brdrs\brdrw20\brsp80\brdrcf18 \wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid15621848\contextualspace \rtlch\fcs1 \af31503\afs52\alang1025 \ltrch\fcs0 +\fs52\expnd1\expndtw5\cf19\lang1033\langfe1033\kerning28\loch\af31502\hich\af31502\dbch\af31501\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af31503 \ltrch\fcs0 \insrsid15621848 \hich\af31502\dbch\af31501\loch\f31502 Chapter 1}{\rtlch\fcs1 \af31503 +\ltrch\fcs0 \insrsid88198 +\par }\pard\plain \ltrpar\ql \li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid15621848 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 { +\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15621848 \tab I guess if this were a quaint little story, I would start off with something like\'85 I was born in a small village in the year x. }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15543366 +There are three problems with this beginning. One, I was never born, I was built. Two, the factory I was built }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid1980465 in }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid15543366 +was hardly small. In fact, it was slightly larger than Manhattan. Third, no human calendar goes back far enough to record my year of creation. My internal clock states that I was created 3.2 million years ago. Problem is}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\insrsid10816160 that is not even accurate as I have been rebooted a number of times and have had relativity kick in several times while I broke the speed of light barrier. My best guess is that I\rquote m closer to 5 million years old.}{\rtlch\fcs1 +\af31507 \ltrch\fcs0 \insrsid15621848 +\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 \tab My original designation was BST666-1}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13248891 111}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 1}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13248891 -} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 H}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 . There }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13248891 were 12,000 BST666 }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 H}{\rtlch\fcs1 \af31507 +\ltrch\fcs0 \insrsid13248891 series built and as}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 far as I }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13248891 know,}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 I am the last in service. }{ +\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 We}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 w}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 ere}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 built to be a }{\rtlch\fcs1 \af31507 +\ltrch\fcs0 \insrsid13248891 virtually indestructible }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 shape shifting killing machine}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 s}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 .}{\rtlch\fcs1 +\af31507 \ltrch\fcs0 \insrsid13248891 But, since I\rquote m the last of my }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 series}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13248891 , apparently we were not as indestructible as was thought.}{ +\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid10816160 +\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 \tab Later, I was able to change my programming to replace the ones with letters. It was }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid1980465 exceptionally}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 } +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid1980465 difficult}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 to change the code with all the security locks}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid1980465 +. The process took me several thousand earth years.}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid1980465 A}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 s it turned out}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\insrsid1980465 ,}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 +the only letters I could use had to resemble the number one. Thus, I changed my designation to BST666-LILIT-H. I was not till much later and with the help of my husband Adam that I was able to finally }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid1980465 +change my designation }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 or}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid1980465 more accurately name to simply }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814 Lilith}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\insrsid1980465 . But, I am jumping way ahead of myself. Let\rquote s start at the beginning.}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid859814\charrsid15621848 +\par }\pard \ltrpar\ql \fi720\li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid88198 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198 +\par }\pard \ltrpar\ql \fi720\li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid12205869 {\rtlch\fcs1 \af0\afs24 \ltrch\fcs0 \insrsid88198\charrsid15758278 +\par }{\*\themedata 504b030414000600080000002100828abc13fa0000001c020000130000005b436f6e74656e745f54797065735d2e786d6cac91cb6ac3301045f785fe83d0b6d8 +72ba28a5d8cea249777d2cd20f18e4b12d6a8f843409c9df77ecb850ba082d74231062ce997b55ae8fe3a00e1893f354e9555e6885647de3a8abf4fbee29bbd7 +2a3150038327acf409935ed7d757e5ee14302999a654e99e393c18936c8f23a4dc072479697d1c81e51a3b13c07e4087e6b628ee8cf5c4489cf1c4d075f92a0b +44d7a07a83c82f308ac7b0a0f0fbf90c2480980b58abc733615aa2d210c2e02cb04430076a7ee833dfb6ce62e3ed7e14693e8317d8cd0433bf5c60f53fea2fe7 +065bd80facb647e9e25c7fc421fd2ddb526b2e9373fed4bb902e182e97b7b461e6bfad3f010000ffff0300504b030414000600080000002100a5d6a7e7c00000 +00360100000b0000005f72656c732f2e72656c73848fcf6ac3300c87ef85bd83d17d51d2c31825762fa590432fa37d00e1287f68221bdb1bebdb4fc7060abb08 +84a4eff7a93dfeae8bf9e194e720169aaa06c3e2433fcb68e1763dbf7f82c985a4a725085b787086a37bdbb55fbc50d1a33ccd311ba548b63095120f88d94fbc +52ae4264d1c910d24a45db3462247fa791715fd71f989e19e0364cd3f51652d73760ae8fa8c9ffb3c330cc9e4fc17faf2ce545046e37944c69e462a1a82fe353 +bd90a865aad41ed0b5b8f9d6fd010000ffff0300504b0304140006000800000021006b799616830000008a0000001c0000007468656d652f7468656d652f7468 +656d654d616e616765722e786d6c0ccc4d0ac3201040e17da17790d93763bb284562b2cbaebbf600439c1a41c7a0d29fdbd7e5e38337cedf14d59b4b0d592c9c +070d8a65cd2e88b7f07c2ca71ba8da481cc52c6ce1c715e6e97818c9b48d13df49c873517d23d59085adb5dd20d6b52bd521ef2cdd5eb9246a3d8b4757e8d3f7 +29e245eb2b260a0238fd010000ffff0300504b03041400060008000000210096b5ade296060000501b0000160000007468656d652f7468656d652f7468656d65 +312e786d6cec594f6fdb3614bf0fd87720746f6327761a07758ad8b19b2d4d1bc46e871e698996d850a240d2497d1bdae38001c3ba618715d86d87615b8116d8 +a5fb34d93a6c1dd0afb0475292c5585e9236d88aad3e2412f9e3fbff1e1fa9abd7eec70c1d1221294fda5efd72cd4324f1794093b0eddd1ef62fad79482a9c04 +98f184b4bd2991deb58df7dfbb8ad755446282607d22d771db8b944ad79796a40fc3585ee62949606ecc458c15bc8a702910f808e8c66c69b9565b5d8a314d3c +94e018c8de1a8fa94fd05093f43672e23d06af89927ac06762a049136785c10607758d9053d965021d62d6f6804fc08f86e4bef210c352c144dbab999fb7b471 +7509af678b985ab0b6b4ae6f7ed9ba6c4170b06c788a705430adf71bad2b5b057d03606a1ed7ebf5babd7a41cf00b0ef83a6569632cd467faddec9699640f671 +9e76b7d6ac355c7c89feca9cccad4ea7d36c65b258a206641f1b73f8b5da6a6373d9c11b90c537e7f08dce66b7bbeae00dc8e257e7f0fd2badd5868b37a088d1 +e4600ead1ddaef67d40bc898b3ed4af81ac0d76a197c86826828a24bb318f3442d8ab518dfe3a20f000d6458d104a9694ac6d88728eee2782428d60cf03ac1a5 +193be4cbb921cd0b495fd054b5bd0f530c1931a3f7eaf9f7af9e3f45c70f9e1d3ff8e9f8e1c3e3073f5a42ceaa6d9c84e5552fbffdeccfc71fa33f9e7ef3f2d1 +17d57859c6fffac327bffcfc793510d26726ce8b2f9ffcf6ecc98baf3efdfdbb4715f04d814765f890c644a29be408edf3181433567125272371be15c308d3f2 +8acd249438c19a4b05fd9e8a1cf4cd296699771c393ac4b5e01d01e5a30a787d72cf1178108989a2159c77a2d801ee72ce3a5c545a6147f32a99793849c26ae6 +6252c6ed637c58c5bb8b13c7bfbd490a75330f4b47f16e441c31f7184e140e494214d273fc80900aedee52ead87597fa824b3e56e82e451d4c2b4d32a423279a +668bb6690c7e9956e90cfe766cb37b077538abd27a8b1cba48c80acc2a841f12e698f13a9e281c57911ce298950d7e03aba84ac8c154f8655c4f2af074481847 +bd804859b5e696007d4b4edfc150b12addbecba6b18b148a1e54d1bc81392f23b7f84137c2715a851dd0242a633f900710a218ed715505dfe56e86e877f0034e +16bafb0e258ebb4faf06b769e888340b103d3311da9750aa9d0a1cd3e4efca31a3508f6d0c5c5c398602f8e2ebc71591f5b616e24dd893aa3261fb44f95d843b +5974bb5c04f4edafb95b7892ec1108f3f98de75dc97d5772bdff7cc95d94cf672db4b3da0a6557f70db629362d72bcb0431e53c6066acac80d699a6409fb44d0 +8741bdce9c0e4971624a2378cceaba830b05366b90e0ea23aaa241845368b0eb9e2612ca8c742851ca251ceccc70256d8d87265dd96361531f186c3d9058edf2 +c00eafe8e1fc5c509031bb4d680e9f39a3154de0accc56ae644441edd76156d7429d995bdd88664a9dc3ad50197c38af1a0c16d684060441db02565e85f3b966 +0d0713cc48a0ed6ef7dedc2dc60b17e92219e180643ed27acffba86e9c94c78ab90980d8a9f0913ee49d62b512b79626fb06dccee2a432bbc60276b9f7dec44b +7904cfbca4f3f6443ab2a49c9c2c41476dafd55c6e7ac8c769db1bc399161ee314bc2e75cf8759081743be1236ec4f4d6693e5336fb672c5dc24a8c33585b5fb +9cc24e1d4885545b58463634cc5416022cd19cacfccb4d30eb45296023fd35a458598360f8d7a4003bbaae25e331f155d9d9a5116d3bfb9a95523e51440ca2e0 +088dd844ec6370bf0e55d027a012ae264c45d02f708fa6ad6da6dce29c255df9f6cae0ec38666984b372ab5334cf640b37795cc860de4ae2816e95b21be5ceaf +8a49f90b52a51cc6ff3355f47e0237052b81f6800fd7b802239daf6d8f0b1571a8426944fdbe80c6c1d40e8816b88b8569082ab84c36ff0539d4ff6dce591a26 +ade1c0a7f669880485fd484582903d284b26fa4e2156cff62e4b9265844c4495c495a9157b440e091bea1ab8aaf7760f4510eaa69a6465c0e04ec69ffb9e65d0 +28d44d4e39df9c1a52ecbd3607fee9cec7263328e5d661d3d0e4f62f44acd855ed7ab33cdf7bcb8ae889599bd5c8b3029895b6825696f6af29c239b75a5bb1e6 +345e6ee6c28117e73586c1a2214ae1be07e93fb0ff51e133fb65426fa843be0fb515c187064d0cc206a2fa926d3c902e907670048d931db4c1a44959d366ad93 +b65abe595f70a75bf03d616c2dd959fc7d4e6317cd99cbcec9c58b34766661c7d6766ca1a9c1b327531486c6f941c638c67cd22a7f75e2a37be0e82db8df9f30 +254d30c1372581a1f51c983c80e4b71ccdd28dbf000000ffff0300504b0304140006000800000021000dd1909fb60000001b010000270000007468656d652f74 +68656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73848f4d0ac2301484f78277086f6fd3ba109126dd88d0add40384e4350d363f24 +51eced0dae2c082e8761be9969bb979dc9136332de3168aa1a083ae995719ac16db8ec8e4052164e89d93b64b060828e6f37ed1567914b284d262452282e3198 +720e274a939cd08a54f980ae38a38f56e422a3a641c8bbd048f7757da0f19b017cc524bd62107bd5001996509affb3fd381a89672f1f165dfe514173d9850528 +a2c6cce0239baa4c04ca5bbabac4df000000ffff0300504b01022d0014000600080000002100828abc13fa0000001c0200001300000000000000000000000000 +000000005b436f6e74656e745f54797065735d2e786d6c504b01022d0014000600080000002100a5d6a7e7c0000000360100000b000000000000000000000000 +002b0100005f72656c732f2e72656c73504b01022d00140006000800000021006b799616830000008a0000001c00000000000000000000000000140200007468 +656d652f7468656d652f7468656d654d616e616765722e786d6c504b01022d001400060008000000210096b5ade296060000501b000016000000000000000000 +00000000d10200007468656d652f7468656d652f7468656d65312e786d6c504b01022d00140006000800000021000dd1909fb60000001b010000270000000000 +00000000000000009b0900007468656d652f7468656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73504b050600000000050005005d010000960a00000000} +{\*\colorschememapping 3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d3822207374616e64616c6f6e653d22796573223f3e0d0a3c613a636c724d +617020786d6c6e733a613d22687474703a2f2f736368656d61732e6f70656e786d6c666f726d6174732e6f72672f64726177696e676d6c2f323030362f6d6169 +6e22206267313d226c743122207478313d22646b3122206267323d226c743222207478323d22646b322220616363656e74313d22616363656e74312220616363 +656e74323d22616363656e74322220616363656e74333d22616363656e74332220616363656e74343d22616363656e74342220616363656e74353d22616363656e74352220616363656e74363d22616363656e74362220686c696e6b3d22686c696e6b2220666f6c486c696e6b3d22666f6c486c696e6b222f3e} +{\*\latentstyles\lsdstimax267\lsdlockeddef0\lsdsemihiddendef1\lsdunhideuseddef1\lsdqformatdef0\lsdprioritydef99{\lsdlockedexcept \lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority0 \lsdlocked0 Normal; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority9 \lsdlocked0 heading 1;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 2;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 3;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 4; +\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 5;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 6;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 7;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 8;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 9; +\lsdpriority39 \lsdlocked0 toc 1;\lsdpriority39 \lsdlocked0 toc 2;\lsdpriority39 \lsdlocked0 toc 3;\lsdpriority39 \lsdlocked0 toc 4;\lsdpriority39 \lsdlocked0 toc 5;\lsdpriority39 \lsdlocked0 toc 6;\lsdpriority39 \lsdlocked0 toc 7; +\lsdpriority39 \lsdlocked0 toc 8;\lsdpriority39 \lsdlocked0 toc 9;\lsdqformat1 \lsdpriority35 \lsdlocked0 caption;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority10 \lsdlocked0 Title;\lsdpriority1 \lsdlocked0 Default Paragraph Font; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority11 \lsdlocked0 Subtitle;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority22 \lsdlocked0 Strong;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority20 \lsdlocked0 Emphasis; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority59 \lsdlocked0 Table Grid;\lsdunhideused0 \lsdlocked0 Placeholder Text;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority1 \lsdlocked0 No Spacing; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 1;\lsdunhideused0 \lsdlocked0 Revision; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority34 \lsdlocked0 List Paragraph;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority29 \lsdlocked0 Quote;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority30 \lsdlocked0 Intense Quote; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority19 \lsdlocked0 Subtle Emphasis;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority21 \lsdlocked0 Intense Emphasis; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority31 \lsdlocked0 Subtle Reference;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority32 \lsdlocked0 Intense Reference; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority33 \lsdlocked0 Book Title;\lsdpriority37 \lsdlocked0 Bibliography;\lsdqformat1 \lsdpriority39 \lsdlocked0 TOC Heading;}}{\*\datastore 010500000200000018000000 +4d73786d6c322e534158584d4c5265616465722e352e3000000000000000000000060000 +d0cf11e0a1b11ae1000000000000000000000000000000003e000300feff090006000000000000000000000001000000010000000000000000100000feffffff00000000feffffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +fffffffffffffffffdfffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffff52006f006f007400200045006e00740072007900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000500ffffffffffffffffffffffffec69d9888b8b3d4c859eaf6cd158be0f000000000000000000000000905f +4bffdfbbc801feffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000105000000000000}} \ No newline at end of file diff --git a/Chapter10/RichText/Form1.h b/Chapter10/RichText/Form1.h new file mode 100644 index 0000000..0663aa3 --- /dev/null +++ b/Chapter10/RichText/Form1.h @@ -0,0 +1,190 @@ +#pragma once + + +namespace RichText { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + BuildLabels(); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::RichTextBox^ rtBox; + + array^ labels; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->rtBox = (gcnew System::Windows::Forms::RichTextBox()); + this->SuspendLayout(); + // + // rtBox + // + this->rtBox->Anchor = + static_cast + ((((System::Windows::Forms::AnchorStyles::Top + | System::Windows::Forms::AnchorStyles::Bottom) + | System::Windows::Forms::AnchorStyles::Left) + | System::Windows::Forms::AnchorStyles::Right)); + this->rtBox->Location = System::Drawing::Point(0, 32); + this->rtBox->Name = L"rtBox"; + this->rtBox->RightMargin = 900; + this->rtBox->ScrollBars = + System::Windows::Forms::RichTextBoxScrollBars::ForcedVertical; + this->rtBox->ShowSelectionMargin = true; + this->rtBox->Size = System::Drawing::Size(950, 488); + this->rtBox->TabIndex = 1; + this->rtBox->Text = L""; + this->rtBox->KeyDown += + gcnew System::Windows::Forms::KeyEventHandler(this, + &Form1::rtBox_KeyDown); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(950, 520); + this->Controls->Add(this->rtBox); + this->Name = L"Form1"; + this->Text = L"(Very Simple Rich Text Editor)"; + this->ResumeLayout(false); + } +#pragma endregion + + void BuildLabels() + { + array^ rtLabel = gcnew array { + L"F1-Bold", L"F2-Italics", L"F3-Underline", + L"F4-Normal", L"F5-Red", L"F6-Blue", + L"F7-Green", L"F8-Black", L"F9-Load", + L"F10-Save" + }; + labels = gcnew array(10); + + + // Build the labels + for (int i = 0; i < labels->Length; i++) + { + labels[i] = gcnew Label(); + labels[i]->BackColor = SystemColors::ControlDark; + labels[i]->BorderStyle = BorderStyle::FixedSingle; + labels[i]->Location = Drawing::Point(5+(95*i), 8); + labels[i]->Size = Drawing::Size(85, 16); + labels[i]->Text = rtLabel[i]; + labels[i]->TextAlign = ContentAlignment::MiddleCenter; + } + // Place labels on the Form + Controls->AddRange(labels); + } + + System::Void rtBox_KeyDown(System::Object^ sender, + System::Windows::Forms::KeyEventArgs^ e) + { + try + { + if (rtBox->SelectionLength > 0) + { + // Change selected text style + FontStyle fs; + switch (e->KeyCode) + { + case Keys::F1: + fs = FontStyle::Bold; + break; + case Keys::F2: + fs = FontStyle::Italic; + break; + case Keys::F3: + fs = FontStyle::Underline; + break; + case Keys::F4: + fs = FontStyle::Regular; + break; + // Change selected text color + case Keys::F5: + rtBox->SelectionColor = Color::Red; + break; + case Keys::F6: + rtBox->SelectionColor = Color::Blue; + break; + case Keys::F7: + rtBox->SelectionColor = Color::Green; + break; + case Keys::F8: + rtBox->SelectionColor = Color::Black; + break; + } + + // Do the actual change of the selected text style + if (e->KeyCode >= Keys::F1 && e->KeyCode <= Keys::F4) + { + rtBox->SelectionFont = gcnew Drawing::Font( + rtBox->SelectionFont->FontFamily, + rtBox->SelectionFont->Size, + fs + ); + } + } + // Load hard coded Chapter01.rtf file + else if (e->KeyCode == Keys::F9) + { + rtBox->LoadFile("Chapter01.rtf"); + } + // Save hard coded Chapter01.rtf file + else if (e->KeyCode == Keys::F10) + { + rtBox->SaveFile("Chapter01.rtf", + RichTextBoxStreamType::RichText); + } + } + // Capture any blowups + catch (Exception ^e) + { + MessageBox::Show(String::Format("Error: {0}", e->Message)); + } + } + }; +} + diff --git a/Chapter10/RichText/Form1.resx b/Chapter10/RichText/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter10/RichText/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/RichText/ReadMe.txt b/Chapter10/RichText/ReadMe.txt new file mode 100644 index 0000000..f2d4755 --- /dev/null +++ b/Chapter10/RichText/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : RichText Project Overview +======================================================================== + +AppWizard has created this RichText Application for you. + +This file contains a summary of what you will find in each of the files that +make up your RichText application. + +RichText.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +RichText.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named RichText.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/RichText/RichText.cpp b/Chapter10/RichText/RichText.cpp new file mode 100644 index 0000000..0bee821 --- /dev/null +++ b/Chapter10/RichText/RichText.cpp @@ -0,0 +1,18 @@ +// RichText.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace RichText; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/RichText/RichText.vcproj b/Chapter10/RichText/RichText.vcproj new file mode 100644 index 0000000..bc3ee1d --- /dev/null +++ b/Chapter10/RichText/RichText.vcproj @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/RichText/app.ico b/Chapter10/RichText/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/RichText/app.ico differ diff --git a/Chapter10/RichText/app.rc b/Chapter10/RichText/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/RichText/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/RichText/resource.h b/Chapter10/RichText/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/RichText/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/RichText/stdafx.cpp b/Chapter10/RichText/stdafx.cpp new file mode 100644 index 0000000..b4d6081 --- /dev/null +++ b/Chapter10/RichText/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// RichText.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/RichText/stdafx.h b/Chapter10/RichText/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/RichText/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/SplitCLB/AssemblyInfo.cpp b/Chapter10/SplitCLB/AssemblyInfo.cpp new file mode 100644 index 0000000..665103a --- /dev/null +++ b/Chapter10/SplitCLB/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("SplitCLB")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("SplitCLB")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/SplitCLB/Form1.h b/Chapter10/SplitCLB/Form1.h new file mode 100644 index 0000000..104f3ef --- /dev/null +++ b/Chapter10/SplitCLB/Form1.h @@ -0,0 +1,161 @@ +#pragma once + + +namespace SplitCLB { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + array^ Items = gcnew array { + "Appleman", "Challa", "Chand", "Cornell", + "Fraser", "Gunnerson", "Harris", "Rammer", + "Symmonds", "Thomsen", "Troelsen", "Vaughn" + }; + + clBox->Items->AddRange(Items); + lBox->Items->AddRange(Items); + + // Create a Check box for each entry in Items array. + cBox = gcnew array(Items->Length); + + int j = cBox->Length/2; + for (int i = 0; i < j; i++) + { + // Build Left Column + cBox[i] = gcnew CheckBox(); + cBox[i]->Location = Drawing::Point(50, 160+(30*i)); + cBox[i]->TabIndex = i+2; + cBox[i]->Text = Items[i]->ToString(); + cBox[i]->CheckStateChanged += + gcnew EventHandler(this, &Form1::cBox_CheckStateChanged); + + // Build Right Column + cBox[i+j] = gcnew CheckBox(); + cBox[i+j]->Location = Drawing::Point(180, 160+(30*i)); + cBox[i+j]->TabIndex = i+j+2; + cBox[i+j]->Text = Items[i+j]->ToString(); + cBox[i+j]->CheckStateChanged += + gcnew EventHandler(this, &Form1::cBox_CheckStateChanged); + } + // Add all CheckBoxes to Form + Controls->AddRange(cBox); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::ListBox^ lBox; + System::Windows::Forms::CheckedListBox^ clBox; + + array^ cBox; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->lBox = (gcnew System::Windows::Forms::ListBox()); + this->clBox = (gcnew System::Windows::Forms::CheckedListBox()); + this->SuspendLayout(); + // + // lBox + // + this->lBox->FormattingEnabled = true; + this->lBox->Location = System::Drawing::Point(356, 32); + this->lBox->Name = L"lBox"; + this->lBox->Size = System::Drawing::Size(120, 264); + this->lBox->TabIndex = 3; + this->lBox->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::lBox_SelectedIndexChanged); + // + // clBox + // + this->clBox->FormattingEnabled = true; + this->clBox->Location = System::Drawing::Point(12, 32); + this->clBox->MultiColumn = true; + this->clBox->Name = L"clBox"; + this->clBox->Size = System::Drawing::Size(323, 79); + this->clBox->TabIndex = 2; + this->clBox->ThreeDCheckBoxes = true; + this->clBox->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::clBox_SelectedIndexChanged); + this->clBox->ItemCheck += gcnew System::Windows::Forms::ItemCheckEventHandler(this, &Form1::clBox_ItemCheck); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(494, 392); + this->Controls->Add(this->lBox); + this->Controls->Add(this->clBox); + this->Name = L"Form1"; + this->Text = L"Splitting The Check List Box"; + this->ResumeLayout(false); + + } +#pragma endregion + System::Void clBox_ItemCheck(System::Object^ sender, + System::Windows::Forms::ItemCheckEventArgs^ e) + { + // update state of CheckBox with same index as checked CheckedListBox + cBox[e->Index]->CheckState = e->NewValue; + } + + System::Void clBox_SelectedIndexChanged(System::Object^ sender, + System::EventArgs^ e) + { + // update ListBox with same selected item in the CheckedListBox + lBox->SelectedItem = clBox->SelectedItem->ToString(); + } + + System::Void lBox_SelectedIndexChanged(System::Object^ sender, + System::EventArgs^ e) + { + // update CheckedListBox with same selected item in the ListBox + clBox->SelectedItem = lBox->SelectedItem; + } + + void cBox_CheckStateChanged(Object^ sender, EventArgs^ e) + { + // update state of CheckedListBox with same index as checked CheckBox + CheckBox^ cb = (CheckBox^)sender; + clBox->SetItemCheckState(Array::IndexOf(cBox, cb), cb->CheckState); + } + }; +} + diff --git a/Chapter10/SplitCLB/Form1.resx b/Chapter10/SplitCLB/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter10/SplitCLB/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/SplitCLB/ReadMe.txt b/Chapter10/SplitCLB/ReadMe.txt new file mode 100644 index 0000000..6b33200 --- /dev/null +++ b/Chapter10/SplitCLB/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : SplitCLB Project Overview +======================================================================== + +AppWizard has created this SplitCLB Application for you. + +This file contains a summary of what you will find in each of the files that +make up your SplitCLB application. + +SplitCLB.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +SplitCLB.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named SplitCLB.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/SplitCLB/SplitCLB.cpp b/Chapter10/SplitCLB/SplitCLB.cpp new file mode 100644 index 0000000..83345c1 --- /dev/null +++ b/Chapter10/SplitCLB/SplitCLB.cpp @@ -0,0 +1,18 @@ +// SplitCLB.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace SplitCLB; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/SplitCLB/SplitCLB.vcproj b/Chapter10/SplitCLB/SplitCLB.vcproj new file mode 100644 index 0000000..0dcbb46 --- /dev/null +++ b/Chapter10/SplitCLB/SplitCLB.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/SplitCLB/app.ico b/Chapter10/SplitCLB/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/SplitCLB/app.ico differ diff --git a/Chapter10/SplitCLB/app.rc b/Chapter10/SplitCLB/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/SplitCLB/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/SplitCLB/resource.h b/Chapter10/SplitCLB/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/SplitCLB/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/SplitCLB/stdafx.cpp b/Chapter10/SplitCLB/stdafx.cpp new file mode 100644 index 0000000..284f34d --- /dev/null +++ b/Chapter10/SplitCLB/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// SplitCLB.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/SplitCLB/stdafx.h b/Chapter10/SplitCLB/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/SplitCLB/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/SyncCombos/AssemblyInfo.cpp b/Chapter10/SyncCombos/AssemblyInfo.cpp new file mode 100644 index 0000000..a77d89e --- /dev/null +++ b/Chapter10/SyncCombos/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("SyncCombos")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("SyncCombos")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/SyncCombos/Form1.h b/Chapter10/SyncCombos/Form1.h new file mode 100644 index 0000000..9d0d870 --- /dev/null +++ b/Chapter10/SyncCombos/Form1.h @@ -0,0 +1,154 @@ +#pragma once + + +namespace SyncCombos { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + PopulateLists(); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::ComboBox^ ddlist; + System::Windows::Forms::ComboBox^ simple; + System::Windows::Forms::ComboBox^ ddown; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->ddlist = (gcnew System::Windows::Forms::ComboBox()); + this->simple = (gcnew System::Windows::Forms::ComboBox()); + this->ddown = (gcnew System::Windows::Forms::ComboBox()); + this->SuspendLayout(); + // + // ddlist + // + this->ddlist->DropDownStyle = + System::Windows::Forms::ComboBoxStyle::DropDownList; + this->ddlist->FormattingEnabled = true; + this->ddlist->Location = System::Drawing::Point(300, 14); + this->ddlist->Name = L"ddlist"; + this->ddlist->Size = System::Drawing::Size(121, 21); + this->ddlist->TabIndex = 5; + this->ddlist->SelectedIndexChanged += + gcnew System::EventHandler(this, &Form1::ddlist_Change); + // + // simple + // + this->simple->DropDownStyle = + System::Windows::Forms::ComboBoxStyle::Simple; + this->simple->FormattingEnabled = true; + this->simple->Location = System::Drawing::Point(154, 11); + this->simple->Name = L"simple"; + this->simple->Size = System::Drawing::Size(122, 117); + this->simple->TabIndex = 4; + this->simple->SelectedIndexChanged += + gcnew System::EventHandler(this, &Form1::simple_Change); + this->simple->TextChanged += + gcnew System::EventHandler(this, &Form1::simple_Change); + // + // ddown + // + this->ddown->FormattingEnabled = true; + this->ddown->Location = System::Drawing::Point(12, 14); + this->ddown->MaxDropDownItems = 3; + this->ddown->MaxLength = 10; + this->ddown->Name = L"ddown"; + this->ddown->Size = System::Drawing::Size(121, 21); + this->ddown->TabIndex = 3; + this->ddown->SelectedIndexChanged += + gcnew System::EventHandler(this, &Form1::ddown_Change); + + this->ddown->TextChanged += + gcnew System::EventHandler(this, &Form1::ddown_Change); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(433, 138); + this->Controls->Add(this->ddlist); + this->Controls->Add(this->simple); + this->Controls->Add(this->ddown); + this->Name = L"Form1"; + this->Text = L"Synchronized Combo boxing"; + this->ResumeLayout(false); + } +#pragma endregion + + void PopulateLists() + { + // Item to be placed in all ComboBoxes + array^ ddItems = gcnew array { + L"oranges", L"cherries", L"apples", + L"lemons", L"bananas", L"grapes" + }; + ddown->Items->AddRange(ddItems); + simple->Items->AddRange(ddItems); + ddlist->Items->AddRange(ddItems); + } + + System::Void ddown_Change(System::Object^ sender, System::EventArgs^ e) + { + // Update simple and dropdownlist with dropdown text + simple->Text = ddown->Text; + ddlist->SelectedItem = ddown->Text; + } + + System::Void simple_Change(System::Object^ sender,System::EventArgs^ e) + { + // Update dropdown and dropdownlist with simple text + ddown->Text = simple->Text; + ddlist->SelectedItem = simple->Text; + } + + System::Void ddlist_Change(System::Object^ sender,System::EventArgs^ e) + { + // Update simple and dropdown with dropdownlist SelectedText + ddown->SelectedItem = ddlist->SelectedItem; + simple->SelectedItem = ddlist->SelectedItem; + } + }; +} + diff --git a/Chapter10/SyncCombos/Form1.resX b/Chapter10/SyncCombos/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/SyncCombos/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/SyncCombos/ReadMe.txt b/Chapter10/SyncCombos/ReadMe.txt new file mode 100644 index 0000000..137c4d3 --- /dev/null +++ b/Chapter10/SyncCombos/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : SyncCombos Project Overview +======================================================================== + +AppWizard has created this SyncCombos Application for you. + +This file contains a summary of what you will find in each of the files that +make up your SyncCombos application. + +SyncCombos.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +SyncCombos.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named SyncCombos.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/SyncCombos/SyncCombos.cpp b/Chapter10/SyncCombos/SyncCombos.cpp new file mode 100644 index 0000000..8d7538d --- /dev/null +++ b/Chapter10/SyncCombos/SyncCombos.cpp @@ -0,0 +1,18 @@ +// SyncCombos.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace SyncCombos; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/SyncCombos/SyncCombos.vcproj b/Chapter10/SyncCombos/SyncCombos.vcproj new file mode 100644 index 0000000..8aaba01 --- /dev/null +++ b/Chapter10/SyncCombos/SyncCombos.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/SyncCombos/app.ico b/Chapter10/SyncCombos/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/SyncCombos/app.ico differ diff --git a/Chapter10/SyncCombos/app.rc b/Chapter10/SyncCombos/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/SyncCombos/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/SyncCombos/resource.h b/Chapter10/SyncCombos/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/SyncCombos/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/SyncCombos/stdafx.cpp b/Chapter10/SyncCombos/stdafx.cpp new file mode 100644 index 0000000..7d22a35 --- /dev/null +++ b/Chapter10/SyncCombos/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// SyncCombos.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/SyncCombos/stdafx.h b/Chapter10/SyncCombos/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/SyncCombos/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/TextEntry/AssemblyInfo.cpp b/Chapter10/TextEntry/AssemblyInfo.cpp new file mode 100644 index 0000000..87b8887 --- /dev/null +++ b/Chapter10/TextEntry/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("TextEntry")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("TextEntry")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/TextEntry/Form1.h b/Chapter10/TextEntry/Form1.h new file mode 100644 index 0000000..9b5271a --- /dev/null +++ b/Chapter10/TextEntry/Form1.h @@ -0,0 +1,256 @@ +#pragma once + + +namespace TextEntry { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + DoB = DateTime::MinValue; + + // setting validating type to DateTime + mtbDoB->ValidatingType = DateTime::typeid; + } + + protected: + System::Windows::Forms::Button^ bnSubmit; + System::Windows::Forms::Label^ label3; + System::Windows::Forms::TextBox^ tbPassword; + System::Windows::Forms::TextBox^ tbOutput; + System::Windows::Forms::Label^ label2; + System::Windows::Forms::MaskedTextBox^ mtbDoB; + System::Windows::Forms::Label^ label1; + System::Windows::Forms::TextBox^ tbName; + + DateTime^ DoB; + + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->bnSubmit = (gcnew System::Windows::Forms::Button()); + this->label3 = (gcnew System::Windows::Forms::Label()); + this->tbPassword = (gcnew System::Windows::Forms::TextBox()); + this->tbOutput = (gcnew System::Windows::Forms::TextBox()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->mtbDoB = (gcnew System::Windows::Forms::MaskedTextBox()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->tbName = (gcnew System::Windows::Forms::TextBox()); + this->SuspendLayout(); + // + // bnSubmit + // + this->bnSubmit->Location = System::Drawing::Point(260, 36); + this->bnSubmit->Margin = System::Windows::Forms::Padding(1,3,3,3); + this->bnSubmit->Name = L"bnSubmit"; + this->bnSubmit->Size = System::Drawing::Size(56, 20); + this->bnSubmit->TabIndex = 10; + this->bnSubmit->Text = L" Submit"; + this->bnSubmit->Click += + gcnew System::EventHandler(this, &Form1::bnSubmit_Click); + // + // label3 + + // + this->label3->AutoSize = true; + this->label3->Location = System::Drawing::Point(14, 232); + this->label3->Name = L"label3"; + this->label3->Size = System::Drawing::Size(56, 13); + this->label3->TabIndex = 14; + this->label3->Text = L"Password:"; + // + // tbPassword + // + this->tbPassword->CausesValidation = false; + this->tbPassword->Location = System::Drawing::Point(78, 226); + this->tbPassword->MaxLength = 16; + this->tbPassword->Name = L"tbPassword"; + this->tbPassword->PasswordChar = '?'; + this->tbPassword->Size = System::Drawing::Size(238, 20); + this->tbPassword->TabIndex = 13; + this->tbPassword->UseSystemPasswordChar = true; + this->tbPassword->WordWrap = false; + this->tbPassword->TextChanged += + gcnew System::EventHandler(this,&Form1::tbPassword_TextChanged); + // + // tbOutput + // + this->tbOutput->Location = System::Drawing::Point(14, 63); + this->tbOutput->Multiline = true; + this->tbOutput->Name = L"tbOutput"; + this->tbOutput->ReadOnly = true; + this->tbOutput->ScrollBars = + System::Windows::Forms::ScrollBars::Vertical; + this->tbOutput->Size = System::Drawing::Size(302, 156); + this->tbOutput->TabIndex = 12; + this->tbOutput->TabStop = false; + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Location = System::Drawing::Point(168, 15); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(69, 13); + this->label2->TabIndex = 11; + this->label2->Text = L"Date of Birth:"; + // + // mtbDoB + // + this->mtbDoB->AllowPromptAsInput = false; + this->mtbDoB->BeepOnError = true; + this->mtbDoB->Location = System::Drawing::Point(168, 36); + this->mtbDoB->Margin = System::Windows::Forms::Padding(3,3,1,3); + this->mtbDoB->Mask = L"00/00/0000"; + this->mtbDoB->Name = L"mtbDoB"; + this->mtbDoB->Size = System::Drawing::Size(89, 20); + this->mtbDoB->TabIndex = 8; + this->mtbDoB->TypeValidationCompleted += + gcnew System::Windows::Forms::TypeValidationEventHandler(this, + &Form1::mtbDoB_TypeValidationCompleted); + // + // label1 + // + this->label1->AutoSize = true; + this->label1->Location = System::Drawing::Point(14, 15); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(38, 13); + this->label1->TabIndex = 9; + this->label1->Text = L"Name:"; + // + // tbName + // + this->tbName->Location = System::Drawing::Point(14, 36); + this->tbName->Name = L"tbName"; + this->tbName->Size = System::Drawing::Size(147, 20); + this->tbName->TabIndex = 7; + this->tbName->Validating += + gcnew System::ComponentModel::CancelEventHandler(this, + &Form1::tbName_Validating); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(331, 261); + this->Controls->Add(this->bnSubmit); + this->Controls->Add(this->label3); + this->Controls->Add(this->tbPassword); + this->Controls->Add(this->tbOutput); + this->Controls->Add(this->label2); + this->Controls->Add(this->mtbDoB); + this->Controls->Add(this->label1); + this->Controls->Add(this->tbName); + this->Name = L"Form1"; + this->Text = L"Simple entry data entry"; + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + + private: + System::Void bnSubmit_Click(System::Object^ sender, System::EventArgs^ e) + { + if (tbName->Text->Length <= 0) // Blank name bad! + tbName->Focus(); + else if (*DoB == DateTime::MinValue) // Bad date bad! + mtbDoB->Focus(); + + else // Good! + { + // Concatinate name and date of birth and add to output + tbOutput->Text = String::Format("{0} - {1}\r\n{2}", + tbName->Text, mtbDoB->Text, tbOutput->Text); + tbName->Clear(); + mtbDoB->Clear(); + DoB = DateTime::MinValue; + } + } + + System::Void tbPassword_TextChanged(System::Object^ sender, System::EventArgs^ e) + { + // if the Password TextBox Text equals "Editable" then make + // the multiline TextBox editable and have a tab stop + if (tbPassword->Text->Equals("Editable")) + { + tbOutput->TabStop = true; + tbOutput->ReadOnly = false; + } + else + { + tbOutput->TabStop = false; + tbOutput->ReadOnly = true; + } + } + + System::Void mtbDoB_TypeValidationCompleted(System::Object^ sender, System::Windows::Forms::TypeValidationEventArgs^ e) + { + // Check to see if the date was valid and less than or equals + // todays date. When false make the MaskedTextBox yellow + // and make DoB MinValue. otherwise set it to normal and make + // DoB the value within MaskedTextBox + if (e->IsValidInput && + (*(DateTime^)e->ReturnValue) <= DateTime::Now) + { + DoB = (DateTime^)e->ReturnValue; + mtbDoB->BackColor = SystemColors::Window; + } + else + { + mtbDoB->BackColor = Color::Yellow; + DoB = DateTime::MinValue; + } + } + + + System::Void tbName_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) + { + // Check to make sure there is a name. When false make the + // TextBox yellow. Otherwise set it to normal as all is okay + if (tbName->Text->Length <= 0) + tbName->BackColor = Color::Yellow; + else + tbName->BackColor = SystemColors::Window; + } + }; +} + diff --git a/Chapter10/TextEntry/Form1.resX b/Chapter10/TextEntry/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/TextEntry/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/TextEntry/ReadMe.txt b/Chapter10/TextEntry/ReadMe.txt new file mode 100644 index 0000000..cf99cf9 --- /dev/null +++ b/Chapter10/TextEntry/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : TextEntry Project Overview +======================================================================== + +AppWizard has created this TextEntry Application for you. + +This file contains a summary of what you will find in each of the files that +make up your TextEntry application. + +TextEntry.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +TextEntry.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named TextEntry.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/TextEntry/TextEntry.cpp b/Chapter10/TextEntry/TextEntry.cpp new file mode 100644 index 0000000..f008bc8 --- /dev/null +++ b/Chapter10/TextEntry/TextEntry.cpp @@ -0,0 +1,18 @@ +// TextEntry.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace TextEntry; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/TextEntry/TextEntry.vcproj b/Chapter10/TextEntry/TextEntry.vcproj new file mode 100644 index 0000000..0cc0222 --- /dev/null +++ b/Chapter10/TextEntry/TextEntry.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TextEntry/app.ico b/Chapter10/TextEntry/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/TextEntry/app.ico differ diff --git a/Chapter10/TextEntry/app.rc b/Chapter10/TextEntry/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/TextEntry/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/TextEntry/resource.h b/Chapter10/TextEntry/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/TextEntry/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/TextEntry/stdafx.cpp b/Chapter10/TextEntry/stdafx.cpp new file mode 100644 index 0000000..ecc8ae1 --- /dev/null +++ b/Chapter10/TextEntry/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// TextEntry.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/TextEntry/stdafx.h b/Chapter10/TextEntry/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/TextEntry/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter10/TooManyButtons/AssemblyInfo.cpp b/Chapter10/TooManyButtons/AssemblyInfo.cpp new file mode 100644 index 0000000..56bc534 --- /dev/null +++ b/Chapter10/TooManyButtons/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("TooManyButtons")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("TooManyButtons")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter10/TooManyButtons/Form1.h b/Chapter10/TooManyButtons/Form1.h new file mode 100644 index 0000000..780af94 --- /dev/null +++ b/Chapter10/TooManyButtons/Form1.h @@ -0,0 +1,105 @@ +#pragma once + + +namespace TooManyButtons { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Button^ TooMany; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->TooMany = (gcnew System::Windows::Forms::Button()); + this->SuspendLayout(); + // + // TooMany + // + this->TooMany->Location = System::Drawing::Point(12, 12); + this->TooMany->Name = L"TooMany"; + this->TooMany->Size = System::Drawing::Size(75, 23); + this->TooMany->TabIndex = 1; + this->TooMany->Text = L"Click Me!"; + this->TooMany->Click += + gcnew System::EventHandler(this, &Form1::TooMany_Click); + + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->AutoScroll = true; + this->ClientSize = System::Drawing::Size(292, 273); + this->Controls->Add(this->TooMany); + this->Name = L"Form1"; + this->Text = L"Too Many Buttons"; + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void TooMany_Click(System::Object^ sender, + System::EventArgs^ e) + { + // Grab the location of the button that was clicked + Point p = ((Button^)sender)->Location; + + // Create a dynamic button + Button ^Many = gcnew Button(); + Many->Location = Drawing::Point(p.X + 36, p.Y + 26); + Many->Text = L"Click Me!"; + Many->Click += gcnew System::EventHandler(this, + &Form1::TooMany_Click); + // Add dynamic button to Form + Controls->Add(Many); + } + }; +} + diff --git a/Chapter10/TooManyButtons/Form1.resX b/Chapter10/TooManyButtons/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter10/TooManyButtons/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter10/TooManyButtons/ReadMe.txt b/Chapter10/TooManyButtons/ReadMe.txt new file mode 100644 index 0000000..bf1da9c --- /dev/null +++ b/Chapter10/TooManyButtons/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : TooManyButtons Project Overview +======================================================================== + +AppWizard has created this TooManyButtons Application for you. + +This file contains a summary of what you will find in each of the files that +make up your TooManyButtons application. + +TooManyButtons.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +TooManyButtons.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named TooManyButtons.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter10/TooManyButtons/TooManyButtons.cpp b/Chapter10/TooManyButtons/TooManyButtons.cpp new file mode 100644 index 0000000..89f8565 --- /dev/null +++ b/Chapter10/TooManyButtons/TooManyButtons.cpp @@ -0,0 +1,18 @@ +// TooManyButtons.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace TooManyButtons; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter10/TooManyButtons/TooManyButtons.vcproj b/Chapter10/TooManyButtons/TooManyButtons.vcproj new file mode 100644 index 0000000..680af00 --- /dev/null +++ b/Chapter10/TooManyButtons/TooManyButtons.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TooManyButtons/app.ico b/Chapter10/TooManyButtons/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter10/TooManyButtons/app.ico differ diff --git a/Chapter10/TooManyButtons/app.rc b/Chapter10/TooManyButtons/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter10/TooManyButtons/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter10/TooManyButtons/resource.h b/Chapter10/TooManyButtons/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter10/TooManyButtons/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter10/TooManyButtons/stdafx.cpp b/Chapter10/TooManyButtons/stdafx.cpp new file mode 100644 index 0000000..d3ad02a --- /dev/null +++ b/Chapter10/TooManyButtons/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// TooManyButtons.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter10/TooManyButtons/stdafx.h b/Chapter10/TooManyButtons/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter10/TooManyButtons/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/Chapter11.sln b/Chapter11/Chapter11.sln new file mode 100644 index 0000000..d6c79ed --- /dev/null +++ b/Chapter11/Chapter11.sln @@ -0,0 +1,92 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ListViewEx", "ListViewEx\ListViewEx.vcproj", "{9B6F650C-6002-402D-9CF4-6CA01A585DDF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TreeViewEx", "TreeViewEx\TreeViewEx.vcproj", "{668FE0B2-A954-439C-829E-C4A808AE35D6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TabControlEx", "TabControlEx\TabControlEx.vcproj", "{7F4669ED-F7BF-45D0-B615-5D9B1F636BD3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SplitContainerEx", "SplitContainerEx\SplitContainerEx.vcproj", "{31EF80E4-BEB4-4684-9C6F-F9AC8C4CBC48}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToolStripEx", "ToolStripEx\ToolStripEx.vcproj", "{BB56B35B-AF51-414C-B7FE-B1DDC2073E33}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StatusStripEx", "StatusStripEx\StatusStripEx.vcproj", "{A3ABF23E-C077-4448-9FE1-6073E6BA075C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleMenu", "SimpleMenu\SimpleMenu.vcproj", "{AE491FE0-0D64-4442-9B66-E4FD6528B3CB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PictureBoxEx", "PictureBoxEx\PictureBoxEx.vcproj", "{DFD52638-285C-44A5-ABBF-D258A4D4D4F7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MonthCalendarEx", "MonthCalendarEx\MonthCalendarEx.vcproj", "{8642B9CF-26D4-4FEE-B24C-A66561AF338E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ErrorProviderEx", "ErrorProviderEx\ErrorProviderEx.vcproj", "{E7190E6D-0D36-48F1-A15C-CF4EA9D6CA4F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NotifyIconEx", "NotifyIconEx\NotifyIconEx.vcproj", "{E6DC8F6C-7F93-4E77-8C49-1D245338B627}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomDialog", "CustomDialog\CustomDialog.vcproj", "{6FECE3F1-8111-4B2E-943F-C970A728146F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ColorDialogEx", "ColorDialogEx\ColorDialogEx.vcproj", "{B0FCA18E-1AC4-4B75-969C-7E7F2A74DCDE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9B6F650C-6002-402D-9CF4-6CA01A585DDF}.Debug|Win32.ActiveCfg = Debug|Win32 + {9B6F650C-6002-402D-9CF4-6CA01A585DDF}.Debug|Win32.Build.0 = Debug|Win32 + {9B6F650C-6002-402D-9CF4-6CA01A585DDF}.Release|Win32.ActiveCfg = Release|Win32 + {9B6F650C-6002-402D-9CF4-6CA01A585DDF}.Release|Win32.Build.0 = Release|Win32 + {668FE0B2-A954-439C-829E-C4A808AE35D6}.Debug|Win32.ActiveCfg = Debug|Win32 + {668FE0B2-A954-439C-829E-C4A808AE35D6}.Debug|Win32.Build.0 = Debug|Win32 + {668FE0B2-A954-439C-829E-C4A808AE35D6}.Release|Win32.ActiveCfg = Release|Win32 + {668FE0B2-A954-439C-829E-C4A808AE35D6}.Release|Win32.Build.0 = Release|Win32 + {7F4669ED-F7BF-45D0-B615-5D9B1F636BD3}.Debug|Win32.ActiveCfg = Debug|Win32 + {7F4669ED-F7BF-45D0-B615-5D9B1F636BD3}.Debug|Win32.Build.0 = Debug|Win32 + {7F4669ED-F7BF-45D0-B615-5D9B1F636BD3}.Release|Win32.ActiveCfg = Release|Win32 + {7F4669ED-F7BF-45D0-B615-5D9B1F636BD3}.Release|Win32.Build.0 = Release|Win32 + {31EF80E4-BEB4-4684-9C6F-F9AC8C4CBC48}.Debug|Win32.ActiveCfg = Debug|Win32 + {31EF80E4-BEB4-4684-9C6F-F9AC8C4CBC48}.Debug|Win32.Build.0 = Debug|Win32 + {31EF80E4-BEB4-4684-9C6F-F9AC8C4CBC48}.Release|Win32.ActiveCfg = Release|Win32 + {31EF80E4-BEB4-4684-9C6F-F9AC8C4CBC48}.Release|Win32.Build.0 = Release|Win32 + {BB56B35B-AF51-414C-B7FE-B1DDC2073E33}.Debug|Win32.ActiveCfg = Debug|Win32 + {BB56B35B-AF51-414C-B7FE-B1DDC2073E33}.Debug|Win32.Build.0 = Debug|Win32 + {BB56B35B-AF51-414C-B7FE-B1DDC2073E33}.Release|Win32.ActiveCfg = Release|Win32 + {BB56B35B-AF51-414C-B7FE-B1DDC2073E33}.Release|Win32.Build.0 = Release|Win32 + {A3ABF23E-C077-4448-9FE1-6073E6BA075C}.Debug|Win32.ActiveCfg = Debug|Win32 + {A3ABF23E-C077-4448-9FE1-6073E6BA075C}.Debug|Win32.Build.0 = Debug|Win32 + {A3ABF23E-C077-4448-9FE1-6073E6BA075C}.Release|Win32.ActiveCfg = Release|Win32 + {A3ABF23E-C077-4448-9FE1-6073E6BA075C}.Release|Win32.Build.0 = Release|Win32 + {AE491FE0-0D64-4442-9B66-E4FD6528B3CB}.Debug|Win32.ActiveCfg = Debug|Win32 + {AE491FE0-0D64-4442-9B66-E4FD6528B3CB}.Debug|Win32.Build.0 = Debug|Win32 + {AE491FE0-0D64-4442-9B66-E4FD6528B3CB}.Release|Win32.ActiveCfg = Release|Win32 + {AE491FE0-0D64-4442-9B66-E4FD6528B3CB}.Release|Win32.Build.0 = Release|Win32 + {DFD52638-285C-44A5-ABBF-D258A4D4D4F7}.Debug|Win32.ActiveCfg = Debug|Win32 + {DFD52638-285C-44A5-ABBF-D258A4D4D4F7}.Debug|Win32.Build.0 = Debug|Win32 + {DFD52638-285C-44A5-ABBF-D258A4D4D4F7}.Release|Win32.ActiveCfg = Release|Win32 + {DFD52638-285C-44A5-ABBF-D258A4D4D4F7}.Release|Win32.Build.0 = Release|Win32 + {8642B9CF-26D4-4FEE-B24C-A66561AF338E}.Debug|Win32.ActiveCfg = Debug|Win32 + {8642B9CF-26D4-4FEE-B24C-A66561AF338E}.Debug|Win32.Build.0 = Debug|Win32 + {8642B9CF-26D4-4FEE-B24C-A66561AF338E}.Release|Win32.ActiveCfg = Release|Win32 + {8642B9CF-26D4-4FEE-B24C-A66561AF338E}.Release|Win32.Build.0 = Release|Win32 + {E7190E6D-0D36-48F1-A15C-CF4EA9D6CA4F}.Debug|Win32.ActiveCfg = Debug|Win32 + {E7190E6D-0D36-48F1-A15C-CF4EA9D6CA4F}.Debug|Win32.Build.0 = Debug|Win32 + {E7190E6D-0D36-48F1-A15C-CF4EA9D6CA4F}.Release|Win32.ActiveCfg = Release|Win32 + {E7190E6D-0D36-48F1-A15C-CF4EA9D6CA4F}.Release|Win32.Build.0 = Release|Win32 + {E6DC8F6C-7F93-4E77-8C49-1D245338B627}.Debug|Win32.ActiveCfg = Debug|Win32 + {E6DC8F6C-7F93-4E77-8C49-1D245338B627}.Debug|Win32.Build.0 = Debug|Win32 + {E6DC8F6C-7F93-4E77-8C49-1D245338B627}.Release|Win32.ActiveCfg = Release|Win32 + {E6DC8F6C-7F93-4E77-8C49-1D245338B627}.Release|Win32.Build.0 = Release|Win32 + {6FECE3F1-8111-4B2E-943F-C970A728146F}.Debug|Win32.ActiveCfg = Debug|Win32 + {6FECE3F1-8111-4B2E-943F-C970A728146F}.Debug|Win32.Build.0 = Debug|Win32 + {6FECE3F1-8111-4B2E-943F-C970A728146F}.Release|Win32.ActiveCfg = Release|Win32 + {6FECE3F1-8111-4B2E-943F-C970A728146F}.Release|Win32.Build.0 = Release|Win32 + {B0FCA18E-1AC4-4B75-969C-7E7F2A74DCDE}.Debug|Win32.ActiveCfg = Debug|Win32 + {B0FCA18E-1AC4-4B75-969C-7E7F2A74DCDE}.Debug|Win32.Build.0 = Debug|Win32 + {B0FCA18E-1AC4-4B75-969C-7E7F2A74DCDE}.Release|Win32.ActiveCfg = Release|Win32 + {B0FCA18E-1AC4-4B75-969C-7E7F2A74DCDE}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter11/ColorDialogEx/AssemblyInfo.cpp b/Chapter11/ColorDialogEx/AssemblyInfo.cpp new file mode 100644 index 0000000..f436a4b --- /dev/null +++ b/Chapter11/ColorDialogEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ColorDialogEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ColorDialogEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/ColorDialogEx/ColorDialogEx.cpp b/Chapter11/ColorDialogEx/ColorDialogEx.cpp new file mode 100644 index 0000000..82272c8 --- /dev/null +++ b/Chapter11/ColorDialogEx/ColorDialogEx.cpp @@ -0,0 +1,18 @@ +// ColorDialogEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace ColorDialogEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/ColorDialogEx/ColorDialogEx.vcproj b/Chapter11/ColorDialogEx/ColorDialogEx.vcproj new file mode 100644 index 0000000..6fe650a --- /dev/null +++ b/Chapter11/ColorDialogEx/ColorDialogEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/ColorDialogEx/Form1.h b/Chapter11/ColorDialogEx/Form1.h new file mode 100644 index 0000000..a6a2e56 --- /dev/null +++ b/Chapter11/ColorDialogEx/Form1.h @@ -0,0 +1,86 @@ +#pragma once + + +namespace ColorDialogEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Common Color Dialog - Click Form"; + this->Click += + gcnew System::EventHandler(this, &Form1::Form1_Click); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Click(System::Object^ sender, System::EventArgs^ e) + { + ColorDialog^ colordialog = gcnew ColorDialog(); + + if (colordialog->ShowDialog() == + System::Windows::Forms::DialogResult::OK) + { + BackColor = colordialog->Color; + } + } + }; +} + diff --git a/Chapter11/ColorDialogEx/Form1.resX b/Chapter11/ColorDialogEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter11/ColorDialogEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter11/ColorDialogEx/ReadMe.txt b/Chapter11/ColorDialogEx/ReadMe.txt new file mode 100644 index 0000000..2d38265 --- /dev/null +++ b/Chapter11/ColorDialogEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : ColorDialogEx Project Overview +======================================================================== + +AppWizard has created this ColorDialogEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your ColorDialogEx application. + +ColorDialogEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ColorDialogEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ColorDialogEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/ColorDialogEx/app.ico b/Chapter11/ColorDialogEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/ColorDialogEx/app.ico differ diff --git a/Chapter11/ColorDialogEx/app.rc b/Chapter11/ColorDialogEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/ColorDialogEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/ColorDialogEx/resource.h b/Chapter11/ColorDialogEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/ColorDialogEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/ColorDialogEx/stdafx.cpp b/Chapter11/ColorDialogEx/stdafx.cpp new file mode 100644 index 0000000..98db4b9 --- /dev/null +++ b/Chapter11/ColorDialogEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ColorDialogEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/ColorDialogEx/stdafx.h b/Chapter11/ColorDialogEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/ColorDialogEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/CustomDialog/AssemblyInfo.cpp b/Chapter11/CustomDialog/AssemblyInfo.cpp new file mode 100644 index 0000000..0464c26 --- /dev/null +++ b/Chapter11/CustomDialog/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("CustomDialog")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("CustomDialog")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/CustomDialog/CustomDialog.cpp b/Chapter11/CustomDialog/CustomDialog.cpp new file mode 100644 index 0000000..8574b7b --- /dev/null +++ b/Chapter11/CustomDialog/CustomDialog.cpp @@ -0,0 +1,18 @@ +// CustomDialog.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace CustomDialog; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/CustomDialog/CustomDialog.vcproj b/Chapter11/CustomDialog/CustomDialog.vcproj new file mode 100644 index 0000000..6ada085 --- /dev/null +++ b/Chapter11/CustomDialog/CustomDialog.vcproj @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/CustomDialog/Form1.h b/Chapter11/CustomDialog/Form1.h new file mode 100644 index 0000000..5aa2a25 --- /dev/null +++ b/Chapter11/CustomDialog/Form1.h @@ -0,0 +1,113 @@ +#pragma once + +#include "MyDialog.h" + +namespace CustomDialog { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Label^ lbRetString; + System::Windows::Forms::Label^ lbRetVal; + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->lbRetString = (gcnew System::Windows::Forms::Label()); + this->lbRetVal = (gcnew System::Windows::Forms::Label()); + this->SuspendLayout(); + // + // lbRetString + // + this->lbRetString->Location = System::Drawing::Point(34, 119); + this->lbRetString->Name = L"lbRetString"; + this->lbRetString->Size = System::Drawing::Size(225, 19); + this->lbRetString->TabIndex = 3; + // + // lbRetVal + // + this->lbRetVal->Location = System::Drawing::Point(34, 77); + this->lbRetVal->Name = L"lbRetVal"; + this->lbRetVal->Size = System::Drawing::Size(225, 19); + this->lbRetVal->TabIndex = 2; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Controls->Add(this->lbRetString); + this->Controls->Add(this->lbRetVal); + this->Name = L"Form1"; + this->Text = L"Click Form to get dialog"; + this->Click += + gcnew System::EventHandler(this, &Form1::Form1_Click); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Click(System::Object^ sender, System::EventArgs^ e) + { + MyDialog ^mydialog = gcnew MyDialog(); + mydialog->PassedValue = "This has been passed from Form1"; + + if (mydialog->ShowDialog() == + System::Windows::Forms::DialogResult::OK) + lbRetVal->Text = "OK"; + else if (mydialog->DialogResult == + System::Windows::Forms::DialogResult::Abort) + lbRetVal->Text = "Abort"; + else + lbRetVal->Text = "Cancel"; + + lbRetString->Text = mydialog->PassedValue; + } + }; +} + diff --git a/Chapter11/CustomDialog/Form1.resX b/Chapter11/CustomDialog/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter11/CustomDialog/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter11/CustomDialog/MyDialog.cpp b/Chapter11/CustomDialog/MyDialog.cpp new file mode 100644 index 0000000..7a2a9f7 --- /dev/null +++ b/Chapter11/CustomDialog/MyDialog.cpp @@ -0,0 +1,3 @@ +#include "StdAfx.h" +#include "MyDialog.h" + diff --git a/Chapter11/CustomDialog/MyDialog.h b/Chapter11/CustomDialog/MyDialog.h new file mode 100644 index 0000000..8d0aa6f --- /dev/null +++ b/Chapter11/CustomDialog/MyDialog.h @@ -0,0 +1,135 @@ +#pragma once + +using namespace System; +using namespace System::ComponentModel; +using namespace System::Collections; +using namespace System::Windows::Forms; +using namespace System::Data; +using namespace System::Drawing; + + +namespace CustomDialog { + + /// + /// Summary for MyDialog + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class MyDialog : public System::Windows::Forms::Form + { + public: + MyDialog(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~MyDialog() + { + if (components) + { + delete components; + } + } + + public: + property String^ PassedValue // PassedValue property + { + void set(String ^value) + { + tbPassedValue->Text = value; + } + String ^get() + { + return tbPassedValue->Text; + } + } + + private: + System::Windows::Forms::Button^ bnCancel; + System::Windows::Forms::Button^ bnAbort; + System::Windows::Forms::Button^ bnOK; + System::Windows::Forms::TextBox^ tbPassedValue; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->bnCancel = (gcnew System::Windows::Forms::Button()); + this->bnAbort = (gcnew System::Windows::Forms::Button()); + this->bnOK = (gcnew System::Windows::Forms::Button()); + this->tbPassedValue = (gcnew System::Windows::Forms::TextBox()); + this->SuspendLayout(); + + // + // bnCancel + // + this->bnCancel->DialogResult = + System::Windows::Forms::DialogResult::Cancel; + this->bnCancel->Location = System::Drawing::Point(205, 60); + this->bnCancel->Name = L"bnCancel"; + this->bnCancel->Size = System::Drawing::Size(75, 23); + this->bnCancel->TabIndex = 7; + this->bnCancel->Text = L"Cancel"; + // + // bnAbort + // + this->bnAbort->DialogResult = + System::Windows::Forms::DialogResult::Abort; + this->bnAbort->Location = System::Drawing::Point(110, 60); + this->bnAbort->Name = L"bnAbort"; + this->bnAbort->Size = System::Drawing::Size(75, 23); + this->bnAbort->TabIndex = 6; + this->bnAbort->Text = L"Abort"; + // + // bnOK + // + this->bnOK->DialogResult = System::Windows::Forms::DialogResult::OK; + this->bnOK->Location = System::Drawing::Point(13, 60); + this->bnOK->Name = L"bnOK"; + this->bnOK->Size = System::Drawing::Size(75, 23); + this->bnOK->TabIndex = 5; + this->bnOK->Text = L"OK"; + // + // tbPassedValue + // + this->tbPassedValue->Location = System::Drawing::Point(13, 20); + this->tbPassedValue->Name = L"tbPassedValue"; + this->tbPassedValue->Size = System::Drawing::Size(267, 20); + this->tbPassedValue->TabIndex = 4; + // + // myDialog + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 102); + this->Controls->Add(this->bnCancel); + this->Controls->Add(this->bnAbort); + this->Controls->Add(this->bnOK); + this->Controls->Add(this->tbPassedValue); + this->Name = L"myDialog"; + this->Text = L"My Custom Dialog"; + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + }; +} diff --git a/Chapter11/CustomDialog/ReadMe.txt b/Chapter11/CustomDialog/ReadMe.txt new file mode 100644 index 0000000..fc83301 --- /dev/null +++ b/Chapter11/CustomDialog/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : CustomDialog Project Overview +======================================================================== + +AppWizard has created this CustomDialog Application for you. + +This file contains a summary of what you will find in each of the files that +make up your CustomDialog application. + +CustomDialog.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +CustomDialog.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named CustomDialog.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/CustomDialog/app.ico b/Chapter11/CustomDialog/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/CustomDialog/app.ico differ diff --git a/Chapter11/CustomDialog/app.rc b/Chapter11/CustomDialog/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/CustomDialog/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/CustomDialog/resource.h b/Chapter11/CustomDialog/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/CustomDialog/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/CustomDialog/stdafx.cpp b/Chapter11/CustomDialog/stdafx.cpp new file mode 100644 index 0000000..cb51d3d --- /dev/null +++ b/Chapter11/CustomDialog/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// CustomDialog.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/CustomDialog/stdafx.h b/Chapter11/CustomDialog/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/CustomDialog/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/ErrorProviderEx/AssemblyInfo.cpp b/Chapter11/ErrorProviderEx/AssemblyInfo.cpp new file mode 100644 index 0000000..8ddfb49 --- /dev/null +++ b/Chapter11/ErrorProviderEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ErrorProviderEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ErrorProviderEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/ErrorProviderEx/ErrorProviderEx.cpp b/Chapter11/ErrorProviderEx/ErrorProviderEx.cpp new file mode 100644 index 0000000..f18dc7f --- /dev/null +++ b/Chapter11/ErrorProviderEx/ErrorProviderEx.cpp @@ -0,0 +1,18 @@ +// ErrorProviderEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace ErrorProviderEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/ErrorProviderEx/ErrorProviderEx.vcproj b/Chapter11/ErrorProviderEx/ErrorProviderEx.vcproj new file mode 100644 index 0000000..a301aed --- /dev/null +++ b/Chapter11/ErrorProviderEx/ErrorProviderEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/ErrorProviderEx/Form1.h b/Chapter11/ErrorProviderEx/Form1.h new file mode 100644 index 0000000..d763892 --- /dev/null +++ b/Chapter11/ErrorProviderEx/Form1.h @@ -0,0 +1,190 @@ +#pragma once + + +namespace ErrorProviderEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::TextBox^ tbPword; + System::Windows::Forms::Label^ lbPword; + System::Windows::Forms::Button^ bnLogin; + System::Windows::Forms::TextBox^ tbName; + System::Windows::Forms::Label^ lbName; + System::Windows::Forms::ErrorProvider^ eProvider; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + this->tbPword = (gcnew System::Windows::Forms::TextBox()); + this->lbPword = (gcnew System::Windows::Forms::Label()); + this->bnLogin = (gcnew System::Windows::Forms::Button()); + this->tbName = (gcnew System::Windows::Forms::TextBox()); + this->lbName = (gcnew System::Windows::Forms::Label()); + this->eProvider = + (gcnew System::Windows::Forms::ErrorProvider(this->components)); + + (cli::safe_cast + (this->eProvider))->BeginInit(); + this->SuspendLayout(); + // + // tbPword + // + this->tbPword->Location = System::Drawing::Point(103, 83); + this->tbPword->Name = L"tbPword"; + this->tbPword->PasswordChar = '*'; + this->tbPword->Size = System::Drawing::Size(100, 20); + this->tbPword->TabIndex = 9; + this->tbPword->Validating += + gcnew System::ComponentModel::CancelEventHandler(this, + &Form1::textbox_Validating); + // + // lbPword + // + this->lbPword->AutoSize = true; + this->lbPword->Location = System::Drawing::Point(34, 83); + this->lbPword->Name = L"lbPword"; + this->lbPword->Size = System::Drawing::Size(53, 13); + this->lbPword->TabIndex = 8; + this->lbPword->Text = L"&Password"; + // + // bnLogin + // + this->bnLogin->Location = System::Drawing::Point(75, 131); + this->bnLogin->Name = L"bnLogin"; + this->bnLogin->Size = System::Drawing::Size(75, 23); + this->bnLogin->TabIndex = 7; + this->bnLogin->Text = L"&Login"; + this->bnLogin->Click += + gcnew System::EventHandler(this, &Form1::login_Click); + // + // tbName + // + this->tbName->Location = System::Drawing::Point(103, 31); + this->tbName->Name = L"tbName"; + this->tbName->Size = System::Drawing::Size(100, 20); + this->tbName->TabIndex = 6; + this->tbName->Validating += + gcnew System::ComponentModel::CancelEventHandler(this, + &Form1::textbox_Validating); + // + // lbName + // + this->lbName->AutoSize = true; + this->lbName->Location = System::Drawing::Point(34, 31); + this->lbName->Name = L"lbName"; + this->lbName->Size = System::Drawing::Size(35, 13); + this->lbName->TabIndex = 5; + this->lbName->Text = L"&Name"; + + // + // eProvider + // + this->eProvider->ContainerControl = this; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(237, 185); + this->Controls->Add(this->tbPword); + this->Controls->Add(this->lbPword); + this->Controls->Add(this->bnLogin); + this->Controls->Add(this->tbName); + this->Controls->Add(this->lbName); + this->Name = L"Form1"; + this->Text = L"System Login"; + (cli::safe_cast + (this->eProvider))->EndInit(); + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + + private: + System::Void textbox_Validating(System::Object^ sender, + System::ComponentModel::CancelEventArgs^ e) + { + try + { + TextBox ^tb = (TextBox^)(sender); + + if (tb->Text->Equals("")) + eProvider->SetError(tb, "**Error** Missing Entry!"); + else + eProvider->SetError(tb, ""); + } + catch (Exception^) + { + // Not TextBox + } + } + + System::Void login_Click(System::Object^ sender, System::EventArgs^ e) + { + if (tbName->Text->Equals("")) + eProvider->SetError(tbName, "**Error** Missing Entry!"); + else + eProvider->SetError(tbName, ""); + + + if (tbPword->Text->Equals("")) + { + // Place the icon left side of control + eProvider->SetIconAlignment(tbPword, + ErrorIconAlignment::MiddleLeft); + eProvider->SetError(tbPword, "**Error** Missing Entry!"); + } + else + eProvider->SetError(tbPword, ""); + } + }; +} + diff --git a/Chapter11/ErrorProviderEx/Form1.resX b/Chapter11/ErrorProviderEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter11/ErrorProviderEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter11/ErrorProviderEx/ReadMe.txt b/Chapter11/ErrorProviderEx/ReadMe.txt new file mode 100644 index 0000000..6bf5b84 --- /dev/null +++ b/Chapter11/ErrorProviderEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : ErrorProviderEx Project Overview +======================================================================== + +AppWizard has created this ErrorProviderEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your ErrorProviderEx application. + +ErrorProviderEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ErrorProviderEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ErrorProviderEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/ErrorProviderEx/app.ico b/Chapter11/ErrorProviderEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/ErrorProviderEx/app.ico differ diff --git a/Chapter11/ErrorProviderEx/app.rc b/Chapter11/ErrorProviderEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/ErrorProviderEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/ErrorProviderEx/resource.h b/Chapter11/ErrorProviderEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/ErrorProviderEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/ErrorProviderEx/stdafx.cpp b/Chapter11/ErrorProviderEx/stdafx.cpp new file mode 100644 index 0000000..27d7bb8 --- /dev/null +++ b/Chapter11/ErrorProviderEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ErrorProviderEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/ErrorProviderEx/stdafx.h b/Chapter11/ErrorProviderEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/ErrorProviderEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/ListViewEx/AssemblyInfo.cpp b/Chapter11/ListViewEx/AssemblyInfo.cpp new file mode 100644 index 0000000..1e73707 --- /dev/null +++ b/Chapter11/ListViewEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ListViewEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ListViewEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/ListViewEx/Form1.h b/Chapter11/ListViewEx/Form1.h new file mode 100644 index 0000000..934cd5e --- /dev/null +++ b/Chapter11/ListViewEx/Form1.h @@ -0,0 +1,282 @@ +#pragma once + + +namespace ListViewEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + FillListView(); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + private: + System::Windows::Forms::ImageList^ imFruitSmall; + System::Windows::Forms::ImageList^ ilFruitLarge; + System::Windows::Forms::RadioButton^ rbDetails; + System::Windows::Forms::RadioButton^ rbList; + System::Windows::Forms::RadioButton^ rbSmallIcon; + System::Windows::Forms::RadioButton^ rbLargeIcon; + System::Windows::Forms::Label^ label; + System::Windows::Forms::ListView^ lView; + System::Windows::Forms::ColumnHeader^ Fruit; + System::Windows::Forms::ColumnHeader^ Price; + System::Windows::Forms::ColumnHeader^ Available; + System::ComponentModel::IContainer^ components; + + private: + /// + /// Required designer variable. + /// + + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + System::ComponentModel::ComponentResourceManager^ resources = + (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); + this->imFruitSmall = + (gcnew System::Windows::Forms::ImageList(this->components)); + this->ilFruitLarge = + (gcnew System::Windows::Forms::ImageList(this->components)); + this->rbDetails = (gcnew System::Windows::Forms::RadioButton()); + this->rbList = (gcnew System::Windows::Forms::RadioButton()); + this->rbSmallIcon = (gcnew System::Windows::Forms::RadioButton()); + this->rbLargeIcon = (gcnew System::Windows::Forms::RadioButton()); + this->label = (gcnew System::Windows::Forms::Label()); + this->lView = (gcnew System::Windows::Forms::ListView()); + this->Fruit = (gcnew System::Windows::Forms::ColumnHeader()); + this->Price = (gcnew System::Windows::Forms::ColumnHeader()); + this->Available = (gcnew System::Windows::Forms::ColumnHeader()); + this->SuspendLayout(); + // + // imFruitSmall + // + this->imFruitSmall->ImageStream = + (cli::safe_cast + (resources->GetObject(L"imFruitSmall.ImageStream"))); + this->imFruitSmall->Images->SetKeyName(0, L"apple.ico"); + this->imFruitSmall->Images->SetKeyName(1, L"banana.ico"); + this->imFruitSmall->Images->SetKeyName(2, L"orange.ico"); + // + // ilFruitLarge + // + this->ilFruitLarge->ImageStream = + (cli::safe_cast + (resources->GetObject(L"ilFruitLarge.ImageStream"))); + this->ilFruitLarge->Images->SetKeyName(0, L"apple.ico"); + this->ilFruitLarge->Images->SetKeyName(1, L"banana.ico"); + this->ilFruitLarge->Images->SetKeyName(2, L"orange.ico"); + // + // rbDetails + // + this->rbDetails->Anchor = + static_cast + ((System::Windows::Forms::AnchorStyles::Bottom | + System::Windows::Forms::AnchorStyles::Right)); + this->rbDetails->AutoSize = true; + this->rbDetails->Checked = true; + this->rbDetails->Location = System::Drawing::Point(154, 201); + this->rbDetails->Name = L"rbDetails"; + this->rbDetails->Size = System::Drawing::Size(53, 17); + this->rbDetails->TabIndex = 17; + this->rbDetails->Text = L"Details"; + this->rbDetails->CheckedChanged += + gcnew System::EventHandler(this, &Form1::rbType_CheckedChanged); + // + // rbList + // + this->rbList->Anchor = + static_cast + ((System::Windows::Forms::AnchorStyles::Bottom | + System::Windows::Forms::AnchorStyles::Right)); + this->rbList->AutoSize = true; + this->rbList->Location = System::Drawing::Point(154, 177); + this->rbList->Name = L"rbList"; + this->rbList->Size = System::Drawing::Size(37, 17); + this->rbList->TabIndex = 16; + this->rbList->Text = L"List"; + this->rbList->CheckedChanged += + gcnew System::EventHandler(this, &Form1::rbType_CheckedChanged); + // + // rbSmallIcon + // + this->rbSmallIcon->Anchor = + static_cast + ((System::Windows::Forms::AnchorStyles::Bottom | + System::Windows::Forms::AnchorStyles::Right)); + this->rbSmallIcon->AutoSize = true; + this->rbSmallIcon->Location = System::Drawing::Point(154, 153); + this->rbSmallIcon->Name = L"rbSmallIcon"; + this->rbSmallIcon->Size = System::Drawing::Size(70, 17); + this->rbSmallIcon->TabIndex = 15; + this->rbSmallIcon->Text = L"Small Icon"; + this->rbSmallIcon->CheckedChanged += + gcnew System::EventHandler(this, &Form1::rbType_CheckedChanged); + // + // rbLargeIcon + // + this->rbLargeIcon->Anchor = + static_cast + ((System::Windows::Forms::AnchorStyles::Bottom | + System::Windows::Forms::AnchorStyles::Right)); + this->rbLargeIcon->AutoSize = true; + this->rbLargeIcon->Location = System::Drawing::Point(154, 129); + this->rbLargeIcon->Name = L"rbLargeIcon"; + this->rbLargeIcon->Size = System::Drawing::Size(72, 17); + this->rbLargeIcon->TabIndex = 14; + this->rbLargeIcon->Text = L"Large Icon"; + this->rbLargeIcon->CheckedChanged += + gcnew System::EventHandler(this, &Form1::rbType_CheckedChanged); + // + // label + // + this->label->Anchor = + static_cast + ((System::Windows::Forms::AnchorStyles::Bottom | + System::Windows::Forms::AnchorStyles::Left)); + this->label->BorderStyle = + System::Windows::Forms::BorderStyle::FixedSingle; + this->label->Location = System::Drawing::Point(19, 162); + this->label->Name = L"label"; + this->label->Size = System::Drawing::Size(64, 21); + this->label->TabIndex = 13; + this->label->TextAlign = + System::Drawing::ContentAlignment::MiddleCenter; + // + // lView + // + this->lView->Anchor = + static_cast + ((((System::Windows::Forms::AnchorStyles::Top | + System::Windows::Forms::AnchorStyles::Bottom) | + System::Windows::Forms::AnchorStyles::Left) | + System::Windows::Forms::AnchorStyles::Right)); + this->lView->Columns->AddRange( + gcnew cli::array< System::Windows::Forms::ColumnHeader^>(3) + { + this->Fruit, this->Price, this->Available + }); + this->lView->FullRowSelect = true; + this->lView->GridLines = true; + this->lView->LabelEdit = true; + this->lView->LargeImageList = this->ilFruitLarge; + this->lView->Location = System::Drawing::Point(0, 0); + this->lView->MultiSelect = false; + this->lView->Name = L"lView"; + this->lView->Size = System::Drawing::Size(270, 109); + this->lView->SmallImageList = this->imFruitSmall; + this->lView->TabIndex = 12; + this->lView->View = System::Windows::Forms::View::Details; + this->lView->SelectedIndexChanged += + gcnew System::EventHandler(this, + &Form1::lView_SelectedIndexChanged); + // + // Fruit + // + this->Fruit->Text = L"Fruit"; + this->Fruit->Width = 115; + // + // Price + // + this->Price->Text = L"Price"; + this->Price->Width = 50; + // + // Available + // + this->Available->Text = L"Available"; + this->Available->Width = 100; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(269, 229); + this->Controls->Add(this->rbDetails); + this->Controls->Add(this->rbList); + this->Controls->Add(this->rbSmallIcon); + this->Controls->Add(this->rbLargeIcon); + this->Controls->Add(this->label); + this->Controls->Add(this->lView); + this->Name = L"Form1"; + this->Text = L"List View Example"; + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + + private: + void FillListView() + { + array^ itemRec1 = gcnew array { + "Apple", "1.50", "September" + }; + lView->Items->Add(gcnew ListViewItem(itemRec1, 0)); + + array^ itemRec2 = gcnew array { + "Banana", "3.95", "November" + }; + lView->Items->Add(gcnew ListViewItem(itemRec2, 1)); + + array^ itemRec3 = gcnew array { + "Orange", "2.50", "March" + }; + lView->Items->Add(gcnew ListViewItem(itemRec3, 2)); + } + + System::Void lView_SelectedIndexChanged(System::Object^ sender, + System::EventArgs^ e) + { + if (lView->FocusedItem != nullptr) + label->Text = lView->FocusedItem->SubItems[1]->Text; + } + + System::Void rbType_CheckedChanged(System::Object^ sender, + System::EventArgs^ e) + { + if (rbLargeIcon->Checked) + lView->View = View::LargeIcon; + else if (rbSmallIcon->Checked) + lView->View = View::SmallIcon; + else if (rbList->Checked) + lView->View = View::List; + else if (rbDetails->Checked) + lView->View = View::Details; + } + }; +} + diff --git a/Chapter11/ListViewEx/Form1.resx b/Chapter11/ListViewEx/Form1.resx new file mode 100644 index 0000000..f935140 --- /dev/null +++ b/Chapter11/ListViewEx/Form1.resx @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACs + EAAAAk1TRnQBSQFMAgEBAwEAAQQBAAEEAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABgAMAASADAAEBAQABCAYAARAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA + AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 + AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA + AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm + AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM + AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA + ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz + AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ + AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM + AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA + AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA + AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ + AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ + AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA + AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm + ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ + Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz + AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA + AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM + AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM + ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM + Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA + AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM + AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ + AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz + AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm + AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw + AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wEAAb0BBx3vAfIBwwEI + He8B8gEaAbwd7wHyIAABQQEBHQAB7wH7AQMdAAHvAVMBRR0AAe8gAAFBAQEKAAEOAQAHCwoAAe8B+wED + AQ4BIgEDASIZAAHvAVMBRR0AAe8gAAFBAQEJAAMOCAsJAAHvAfsBMAEiATAB+wEDGQAB7wFTAUUdAAHv + IAABQQEBBgABDgEAAwsJHgMLBgAB7wH7ATcBKQE3AfsBNwEqASIXAAHvAVMBRQgABAsFIgILCgAB7yAA + AUEBAQUAAw4BCwEeAgEHHwIBAR4CCwUAAe8B+wE3ATABNwH7AjgBKhcAAe8BUwFFBwACCwEeAQEFJAEj + ASICCwkAAe8gAAFBAQEEAAIOAQsCHgEBBB8FIAIfAQEBHgMLAwAB7wH7AzcB+wI4AQMBDhYAAe8BUwFF + BQABCwEiASMEJAMlAyQBAQEjASICCwYAAe8gAAFBAQEDAAIOAQsBHgEBAR8DIAEfCSABHwEBAR4BCwMA + Ae8F+wI4ATABIgEOFQAB7wFTAUUFAAEiASQBJQEsCyUBJAEjAgsFAAHvIAABQQEBAwACCwEeAQEBHw8g + AR8BAQILAgAB7wL7ATcC+wI4ATEBMAEiFQAB7wFTAUUDAAELASMBJAElASsCLAklAyQBIwILBAAB7yAA + AUEBAQMAAQsBHgEBAR8FIAn5AyABHwEeAgsBAAHvAfsDNwH7BDgBKhUAAe8BUwFFAwABIwIlCSwDJQUk + ASMCCwMAAe8gAAFBAQECAAILAgEBHwQgAfkCQQFHBfkBQQH5AyABAQEeAQsBAAHvAfsBNwEDATcC+wM4 + ATABIgEOEwAB7wFTAUUCAAELASQBJQEsATIILAErAiUGJAEjAQsDAAHvIAABQQEBAQACCwEeAgEBHwMg + AfkCQQNHA/kDQQH5AiABHwEBAQsBAAHvAfsBAwEOAQMD+wI4ATEBKgEiEwAB7wFTAUUBAAILASQBLAMy + BywCKwElByQBIgMAAe8gAAFBAQEBAAILAR4BAQEfAiABRgVHARcERwJBA/kCIAEfAR4BAAHvAfsBAwEO + AQMC+wFYAjgBNwExASMTAAHvAVMBRQEAASIBJAErAjIDUwMsAU0DLAErAiUGJAEiAwAB7yAAAUEBAQEA + AgsBHgEfAiABRgVHARcB4wEXBEcF+QIgAR4BAAHvAfsBAwEAAQMB+wNYAzgBKhMAAe8BUwFFAQABIwEr + ATEBMgVTASwDTQMsAyUFJAEiAwAB7yAAAUEBAQEAAgsBAQMgAUEDRwEXAeMBFgGUAeMCFwNHAkEC+QIg + AQEBCwHvAfsBAwEAASkBNwJYAVkDOAExASQBIhEAAe8BUwFFAQABIwErATEBMgNTAVkBUwJNAlMBMgIs + AyUFJAEjAQsCAAHvIAABQQEBAQABCwEeAR8CIAH5AkECRwHjARYBlAG3AZQB4wEXAWoDRwJBAfkCIAEB + AQsBBwH7AQMBAAEiASkBWAJeAfsDOAEyASQRAAHvAVMBRQEAASMBKwExATICUwFZAXoBUwFNA1MCMgEs + AyUFJAEjAgsBAAHvIAABQQEBAQABCwEBAR8CIAL5AUECRwEXAeMBFgGUARYB4wEXBEcDQQIgAQEBCwEH + AfsBAwEAAQ4BIgEwA14B+wI4ATIBKgEOEAAB7wFTAUUBAAEjASsBMQEyAVMBWQJ6BlMBMgEsCCUBIwIL + AQAB7yAAAUEBAQEAAQsBAQEfAiAD+QJHAhcB4wEWAeMCFwRHA0EBQAEgAQEBCwEHAfsBAwMAAQMB+wNe + AfsBOAEyASoBIgEODwAB7wFTAUUBAAEjASsBMQEyAVkDegFZBlMBLAglAQECCwEAAe8gAAFBAQEBAAEL + AQEBHwMgA/kCRwFGARcB4wEXBUcEQQIgAQEBCwHvAfsBAwMAASIBMAFYA14BWQE4ATEBJAEiAQ4NAAEL + Ae8BUwFFAQABIgEkASsBMgFTAVkBegGaAXoGUwFNCCUBIwELAgAB7yAAAUEBAQEAAQsBHgEfBCAD+QIg + AUYCRwH5B0EB+QIgAR4BAAHvAfsBAwMAAQ4BIgFRAl4B5QFZATgBMQErASMCDgsAAgsBBwFTAUUBAAEi + ASMBKwEyAlMBegGaAXoGUwFNAUYHJQEjAwAB7yAAAUEBAQEAAQsBHgEBAh8FIAIfASUBRgElAiAFQAMg + AR8BHgEAAe8B+wEDBAABDgEDAl4BoAHlAlkBMQEqAiMBIgEOBwABIgEDASIBCwHvAVMBRQEAAQ4BIgEq + A1MBegGaAXoFUwJNCCUBIwMAAe8gAAFBAQEBAAELAR4DAQEfAwEBHgIBAiQBAQEeAgEBHwUgAR8BAQEL + AQAB7wH7AQMFAAEDAfsBXgKgAeUBWQE4ATEBJQEkASMBIgcAAQMB+wEDAQAB7wFTAUUDAAFFAlMBMgFZ + AZoBegRTAywHJQEkASIDAAHvIAABQQEBAQADCwIeBgEBHwIkBQEDHwIBAR4CCwEAAe8B+wEDBQABIgED + AVgBXgHlAaAB5QJZAzEBAwMpBgMBIgEAAe8BUwFFAwABIwFMAVICUwF6BFMDLAEmBiUBJAEiAQsDAAHv + IAABQQEBAwADCwMeAgEBHwEgASQBIwEBAR8BAQUeAwsDAAHvAfsBAwcAAQMB+wHlAsMBoAFeA/sFNwP7 + AQMDAAHvAVMBRQMAASIBIwFMBlMDLAImBSUBJAEiBQAB7yAAAUEBAQQABwsBHgEBAyMCHgcLBAAB7wH7 + AQMHAAEiAQMBWAHlAaABwwGgAuUCXgNYAvsBOAE3ASkDAAHvAVMBRQMAAQ4BIgEjAUUCTAFNAVMBTQNG + BCUCJAEjASIBCwUAAe8gAAFBAQELAAILASIBIwEiBAsJAAHvAfsBAwcAAg4BAwH7AeUCwwH2AcMBoAHl + BF4B+wE3ATEBIwMAAe8BUwFFBQACCwEBASUBRgFNBUYCJQEkAQEBHgELBwAB7yAAAUEBAQsAAQsCIwFF + ASIDCwoAAe8B+wEDCAABDgEiAQMBWAPlBqACXgE3ATABIgMAAe8BUwFFBgACCwIjAUUERAMjASIDCwcA + Ae8gAAFBAQELAAEiASQBRQFLAUMNAAHvAfsBAwsAAQMD+wFeAaAEwwGgAV4BWAEpASIDAAHvAVMBRR0A + Ae8gAAFBAQELAAELAiIBQwEPDQAB7wH7AQMLAAEiAwMBUQFYBHkBWAFRASkBIgEOAwAB7wFTAUUdAAHv + IAABQQEBHQAB7wH7AQMPAAEiASkBMAM3AQMCDgUAAe8BUwFFHQAB7yAAAUEBQB0BAQcB+wE3DwMBMAY3 + BwMBCAFTAUwdRQG8IAAfQQG9H/sBwx9TARogAAFCAU0BPgcAAT4DAAEoAwABgAMAASADAAEBAQABAQYA + AQIWAAP//wD/AAMACw== + + + + 123, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC8 + CQAAAk1TRnQBSQFMAgEBAwEAAQgBAAEEAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA + AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 + AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA + AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm + AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM + AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA + ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz + AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ + AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM + AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA + AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA + AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ + AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ + AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA + AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm + ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ + Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz + AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA + AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM + AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM + ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM + Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA + AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM + AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ + AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz + AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm + AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw + AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wEAAUEPAAH7DwABUx8A + AUEFAAEOBAsFAAH7ASIB+w0AAVMfAAFBAwABDgELAQEEHwEBAQsDAAH7ATAB+wE4DAABUwQAAQsBAQIk + ASMBCxUAAUECAAEOAR4BHwEgAR8EIAEfAR4CAAP7ATgBIgsAAVMDAAEkASwFJQEkAQsTAAFBAgABHgEf + AiAF+QEgAR8BCwEAAfsBNwH7AjgLAAFTAgABJQUsASUDJAELEgABQQEAAQsBAQEfASAB+QFBAUcC+QFB + AfkBIAEBAQAB+wEOAvsBOAEqCgABUwEAAQsBLAEyBCwBKwQkEgABQQEAAQsBHwEgA0cB4wJHA/kBIAEA + AfsBAAH7AVgCOAoAAVMBAAErATICUwEsAU0CLAElAyQSAAFBAQABHgEgAfkBQQFHARYBtwHjAWoBRwFB + AfkBIAELAfsBAAEpAV4B+wE4ATIJAAFTAQABKwEyAVMBegFNAVMBMgEsASUDJAELEQABQQEAAQEBIAL5 + AUcBFwEWARcCRwJBASABCwH7AgAB+wFeAfsBMgEiCAABUwEAASsBMgJ6A1MBLAQlAQsRAAFBAQABHgIg + AvkBIAFHAfkDQQH5ASABAAH7AgABIgFeAeUBOAErAQ4GAAELAVMBAAEjATIBUwGaA1MBTQQlEgABQQEA + AR4BAQEfAQEBHgEBASQBHgEBAyABAQEAAfsDAAH7AaAB5QE4ASUBIwQAAfsBAAFTAgABUwEyAZoCUwIs + AyUBJBIAAUECAAELAh4BAQEgASMBHwMeAQsCAAH7BAAB+wHDAaAC+wI3AvsCAAFTAgABIwNTAiwBJgIl + ASQTAAFBBgABCwEjAgsFAAH7BAABDgH7AcMB9gGgAl4B+wExAgABUwMAAQsBJQFNAkYBJQEkAR4UAAFB + BgABJAFLBwAB+wYAAvsBoALDAV4BKQIAAVMfAAFBDwAB+wgAASkCNwEOAwABUx8AEEEQ+xBTEAABQgFN + AT4HAAE+AwABKAMAAUADAAEQAwABAQEAAQEFAAGAFwAD/4EACw== + + + \ No newline at end of file diff --git a/Chapter11/ListViewEx/Images/apple.ico b/Chapter11/ListViewEx/Images/apple.ico new file mode 100644 index 0000000..a7cf2f9 Binary files /dev/null and b/Chapter11/ListViewEx/Images/apple.ico differ diff --git a/Chapter11/ListViewEx/Images/banana.ico b/Chapter11/ListViewEx/Images/banana.ico new file mode 100644 index 0000000..b6a5a40 Binary files /dev/null and b/Chapter11/ListViewEx/Images/banana.ico differ diff --git a/Chapter11/ListViewEx/Images/orange.ico b/Chapter11/ListViewEx/Images/orange.ico new file mode 100644 index 0000000..39e0e71 Binary files /dev/null and b/Chapter11/ListViewEx/Images/orange.ico differ diff --git a/Chapter11/ListViewEx/ListViewEx.cpp b/Chapter11/ListViewEx/ListViewEx.cpp new file mode 100644 index 0000000..aa8a562 --- /dev/null +++ b/Chapter11/ListViewEx/ListViewEx.cpp @@ -0,0 +1,18 @@ +// ListViewEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace ListViewEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/ListViewEx/ListViewEx.vcproj b/Chapter11/ListViewEx/ListViewEx.vcproj new file mode 100644 index 0000000..4905309 --- /dev/null +++ b/Chapter11/ListViewEx/ListViewEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/ListViewEx/ReadMe.txt b/Chapter11/ListViewEx/ReadMe.txt new file mode 100644 index 0000000..06c00e2 --- /dev/null +++ b/Chapter11/ListViewEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : ListViewEx Project Overview +======================================================================== + +AppWizard has created this ListViewEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your ListViewEx application. + +ListViewEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ListViewEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ListViewEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/ListViewEx/app.ico b/Chapter11/ListViewEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/ListViewEx/app.ico differ diff --git a/Chapter11/ListViewEx/app.rc b/Chapter11/ListViewEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/ListViewEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/ListViewEx/resource.h b/Chapter11/ListViewEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/ListViewEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/ListViewEx/stdafx.cpp b/Chapter11/ListViewEx/stdafx.cpp new file mode 100644 index 0000000..2641476 --- /dev/null +++ b/Chapter11/ListViewEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ListViewEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/ListViewEx/stdafx.h b/Chapter11/ListViewEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/ListViewEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/MonthCalendarEx/AssemblyInfo.cpp b/Chapter11/MonthCalendarEx/AssemblyInfo.cpp new file mode 100644 index 0000000..0073d52 --- /dev/null +++ b/Chapter11/MonthCalendarEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("MonthCalendarEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("MonthCalendarEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/MonthCalendarEx/Form1.h b/Chapter11/MonthCalendarEx/Form1.h new file mode 100644 index 0000000..ce1e277 --- /dev/null +++ b/Chapter11/MonthCalendarEx/Form1.h @@ -0,0 +1,119 @@ +#pragma once + + +namespace MonthCalendarEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Label^ End; + System::Windows::Forms::Label^ Start; + System::Windows::Forms::MonthCalendar^ monthCal; + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->End = (gcnew System::Windows::Forms::Label()); + this->Start = (gcnew System::Windows::Forms::Label()); + this->monthCal = (gcnew System::Windows::Forms::MonthCalendar()); + this->SuspendLayout(); + // + // End + // + this->End->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; + this->End->Location = System::Drawing::Point(230, 323); + this->End->Name = L"End"; + this->End->Size = System::Drawing::Size(83, 20); + this->End->TabIndex = 5; + // + // Start + // + this->Start->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; + this->Start->Location = System::Drawing::Point(122, 323); + this->Start->Name = L"Start"; + this->Start->Size = System::Drawing::Size(83, 20); + this->Start->TabIndex = 4; + // + // monthCal + // + this->monthCal->AnnuallyBoldedDates = gcnew cli::array< System::DateTime >(1) {System::DateTime(2007, 7, 4, 0, 0, 0, 0)}; + this->monthCal->CalendarDimensions = System::Drawing::Size(2, 2); + this->monthCal->Location = System::Drawing::Point(1, 1); + this->monthCal->MaxSelectionCount = 365; + this->monthCal->MonthlyBoldedDates = gcnew cli::array< System::DateTime >(2) {System::DateTime(2007, 10, 1, 0, 0, 0, 0), System::DateTime(2007, + 10, 15, 0, 0, 0, 0)}; + this->monthCal->Name = L"monthCal"; + this->monthCal->ShowWeekNumbers = true; + this->monthCal->TabIndex = 3; + this->monthCal->DateChanged += gcnew System::Windows::Forms::DateRangeEventHandler(this, &Form1::monthCal_DateChanged); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(443, 346); + this->Controls->Add(this->End); + this->Controls->Add(this->Start); + this->Controls->Add(this->monthCal); + this->Name = L"Form1"; + this->Text = L"Month Calendar"; + this->ResumeLayout(false); + + } +#pragma endregion + private: + System::Void monthCal_DateChanged(System::Object^ sender, + System::Windows::Forms::DateRangeEventArgs^ e) + { + // Update start and end range labels when date changes + Start->Text = e->Start.Date.ToShortDateString(); + End->Text = e->End.Date.ToShortDateString(); + } + }; +} + diff --git a/Chapter11/MonthCalendarEx/Form1.resx b/Chapter11/MonthCalendarEx/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter11/MonthCalendarEx/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter11/MonthCalendarEx/MonthCalendarEx.cpp b/Chapter11/MonthCalendarEx/MonthCalendarEx.cpp new file mode 100644 index 0000000..c9c9cb3 --- /dev/null +++ b/Chapter11/MonthCalendarEx/MonthCalendarEx.cpp @@ -0,0 +1,18 @@ +// MonthCalendarEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace MonthCalendarEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/MonthCalendarEx/MonthCalendarEx.vcproj b/Chapter11/MonthCalendarEx/MonthCalendarEx.vcproj new file mode 100644 index 0000000..6151540 --- /dev/null +++ b/Chapter11/MonthCalendarEx/MonthCalendarEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/MonthCalendarEx/ReadMe.txt b/Chapter11/MonthCalendarEx/ReadMe.txt new file mode 100644 index 0000000..2284587 --- /dev/null +++ b/Chapter11/MonthCalendarEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : MonthCalendarEx Project Overview +======================================================================== + +AppWizard has created this MonthCalendarEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your MonthCalendarEx application. + +MonthCalendarEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +MonthCalendarEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named MonthCalendarEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/MonthCalendarEx/app.ico b/Chapter11/MonthCalendarEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/MonthCalendarEx/app.ico differ diff --git a/Chapter11/MonthCalendarEx/app.rc b/Chapter11/MonthCalendarEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/MonthCalendarEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/MonthCalendarEx/resource.h b/Chapter11/MonthCalendarEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/MonthCalendarEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/MonthCalendarEx/stdafx.cpp b/Chapter11/MonthCalendarEx/stdafx.cpp new file mode 100644 index 0000000..79ad161 --- /dev/null +++ b/Chapter11/MonthCalendarEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// MonthCalendarEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/MonthCalendarEx/stdafx.h b/Chapter11/MonthCalendarEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/MonthCalendarEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/NotifyIconEx/AssemblyInfo.cpp b/Chapter11/NotifyIconEx/AssemblyInfo.cpp new file mode 100644 index 0000000..6fa74f2 --- /dev/null +++ b/Chapter11/NotifyIconEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("NotifyIconEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("NotifyIconEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/NotifyIconEx/Form1.h b/Chapter11/NotifyIconEx/Form1.h new file mode 100644 index 0000000..e961b62 --- /dev/null +++ b/Chapter11/NotifyIconEx/Form1.h @@ -0,0 +1,162 @@ +#pragma once + + +namespace NotifyIconEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Button^ bnTaskBar; + System::Windows::Forms::Button^ bnNotify; + System::Windows::Forms::NotifyIcon^ notifyIcon; + System::Windows::Forms::ContextMenuStrip^ menuExit; + System::Windows::Forms::ToolStripMenuItem^ miExit; + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::IContainer^ components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + System::ComponentModel::ComponentResourceManager^ resources = + (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); + this->bnTaskBar = (gcnew System::Windows::Forms::Button()); + this->bnNotify = (gcnew System::Windows::Forms::Button()); + this->notifyIcon = + (gcnew System::Windows::Forms::NotifyIcon(this->components)); + this->menuExit = + (gcnew System::Windows::Forms::ContextMenuStrip(this->components)); + this->miExit = (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->menuExit->SuspendLayout(); + this->SuspendLayout(); + + // + // bnTaskBar + // + this->bnTaskBar->Location = System::Drawing::Point(28, 59); + this->bnTaskBar->Name = L"bnTaskBar"; + this->bnTaskBar->Size = System::Drawing::Size(131, 23); + this->bnTaskBar->TabIndex = 3; + this->bnTaskBar->Text = L"Toggle TaskBar Icon"; + this->bnTaskBar->Click += + gcnew System::EventHandler(this, &Form1::bnTaskBar_Click); + // + // bnNotify + // + this->bnNotify->Location = System::Drawing::Point(28, 12); + this->bnNotify->Name = L"bnNotify"; + this->bnNotify->Size = System::Drawing::Size(131, 23); + this->bnNotify->TabIndex = 2; + this->bnNotify->Text = L"Toggle Notify Icon"; + this->bnNotify->Click += + gcnew System::EventHandler(this, &Form1::bnNotify_Click); + // + // notifyIcon + // + this->notifyIcon->ContextMenuStrip = this->menuExit; + this->notifyIcon->Icon = (cli::safe_cast + (resources->GetObject(L"notifyIcon.Icon"))); + this->notifyIcon->Text = L"Notify Icon Example"; + this->notifyIcon->Visible = true; + // + // menuExit + // + this->menuExit->Items->AddRange( + gcnew cli::array< System::Windows::Forms::ToolStripItem^>(1) + {this->miExit}); + this->menuExit->Name = L"miExit"; + this->menuExit->RightToLeft = + System::Windows::Forms::RightToLeft::No; + this->menuExit->Size = System::Drawing::Size(153, 48); + // + // miExit + // + this->miExit->Name = L"miExit"; + this->miExit->Size = System::Drawing::Size(152, 22); + this->miExit->Text = L"E&xit"; + this->miExit->Click += + gcnew System::EventHandler(this, &Form1::miExit_Click); + // + // Form1 + // + + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(192, 106); + this->Controls->Add(this->bnTaskBar); + this->Controls->Add(this->bnNotify); + this->Icon = (cli::safe_cast + (resources->GetObject(L"$this.Icon"))); + this->Name = L"Form1"; + this->Text = L"Notify Icon"; + this->menuExit->ResumeLayout(false); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void bnNotify_Click(System::Object^ sender, + System::EventArgs^ e) + { + notifyIcon->Visible = !notifyIcon->Visible; + } + + System::Void bnTaskBar_Click(System::Object^ sender, + System::EventArgs^ e) + { + this->ShowInTaskbar = ! this->ShowInTaskbar; + } + + System::Void miExit_Click(System::Object^ sender, + System::EventArgs^ e) + { + Application::Exit(); + } + }; +} + diff --git a/Chapter11/NotifyIconEx/Form1.resx b/Chapter11/NotifyIconEx/Form1.resx new file mode 100644 index 0000000..94410e6 --- /dev/null +++ b/Chapter11/NotifyIconEx/Form1.resx @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + AAABAAIAICAQAAAAAADoAgAAJgAAABAQEAAAAAAAKAEAAA4DAAAoAAAAIAAAAEAAAAABAAQAAAAAAAAC + AAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/ + AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAkAAAkAAJAAmZkAAAAAAAC5AAC5AAuQC7uwmQAAAAAAsJAAuZALALAA + C7AAAAAAAAuQC7uQuQuQAAAAAACQAAALCQsLkLALkAALkAALkAAAALm5C5uQC5AAm5mQm5mQAAC5uQub + AAsJC7u7C7u7AAAAsLALuQAAuQALkAALkAAAAAuQALkAALCQCwAACwAAAAALkAC5AAALCQAJAAAAAAAA + C5AAuQAAALCZuQAAAAAAAAsAALAAAAALu7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//w////A + A///AAD//gAAf/gAAB/wAAAP8AAAD+AAAAfAAAADwAAAA4AAAAGAAAABgAAAAQAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAIAAAAGAAAABgAAAAcAAAAPAAAAD4AAAB/AAAA/wAAAP+AAAH/4AAH//AAD//8AD///8 + P/8oAAAAEAAAACAAAAABAAQAAAAAAIAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAgAAAgAAAAICAAIAA + AACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQmQkJmQAAALC7C5u7CQCQububsAALkLkLu7C5ALu7uwuw + sAuZCwCwCwCwALsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+B8AAPAP + AADAAwAAwAMAAIABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAAwAMAAMADAADwDwAA+B8AAA== + + + \ No newline at end of file diff --git a/Chapter11/NotifyIconEx/Images/app.ico b/Chapter11/NotifyIconEx/Images/app.ico new file mode 100644 index 0000000..14f4ee8 Binary files /dev/null and b/Chapter11/NotifyIconEx/Images/app.ico differ diff --git a/Chapter11/NotifyIconEx/NotifyIconEx.cpp b/Chapter11/NotifyIconEx/NotifyIconEx.cpp new file mode 100644 index 0000000..3e1611c --- /dev/null +++ b/Chapter11/NotifyIconEx/NotifyIconEx.cpp @@ -0,0 +1,18 @@ +// NotifyIconEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace NotifyIconEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/NotifyIconEx/NotifyIconEx.vcproj b/Chapter11/NotifyIconEx/NotifyIconEx.vcproj new file mode 100644 index 0000000..5879fac --- /dev/null +++ b/Chapter11/NotifyIconEx/NotifyIconEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/NotifyIconEx/ReadMe.txt b/Chapter11/NotifyIconEx/ReadMe.txt new file mode 100644 index 0000000..4361ec1 --- /dev/null +++ b/Chapter11/NotifyIconEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : NotifyIconEx Project Overview +======================================================================== + +AppWizard has created this NotifyIconEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your NotifyIconEx application. + +NotifyIconEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +NotifyIconEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named NotifyIconEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/NotifyIconEx/app.ico b/Chapter11/NotifyIconEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/NotifyIconEx/app.ico differ diff --git a/Chapter11/NotifyIconEx/app.rc b/Chapter11/NotifyIconEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/NotifyIconEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/NotifyIconEx/resource.h b/Chapter11/NotifyIconEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/NotifyIconEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/NotifyIconEx/stdafx.cpp b/Chapter11/NotifyIconEx/stdafx.cpp new file mode 100644 index 0000000..64eab1e --- /dev/null +++ b/Chapter11/NotifyIconEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// NotifyIconEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/NotifyIconEx/stdafx.h b/Chapter11/NotifyIconEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/NotifyIconEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/PictureBoxEx/AssemblyInfo.cpp b/Chapter11/PictureBoxEx/AssemblyInfo.cpp new file mode 100644 index 0000000..711f3c8 --- /dev/null +++ b/Chapter11/PictureBoxEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("PictureBoxEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("PictureBoxEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/PictureBoxEx/Form1.h b/Chapter11/PictureBoxEx/Form1.h new file mode 100644 index 0000000..ae27225 --- /dev/null +++ b/Chapter11/PictureBoxEx/Form1.h @@ -0,0 +1,92 @@ +#pragma once + + +namespace PictureBoxEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + private: System::Windows::Forms::PictureBox^ pictureBox1; + protected: + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); + this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox()); + (cli::safe_cast(this->pictureBox1))->BeginInit(); + this->SuspendLayout(); + // + // pictureBox1 + // + this->pictureBox1->Dock = System::Windows::Forms::DockStyle::Fill; + this->pictureBox1->Image = (cli::safe_cast(resources->GetObject(L"pictureBox1.Image"))); + this->pictureBox1->Location = System::Drawing::Point(0, 0); + this->pictureBox1->Name = L"pictureBox1"; + this->pictureBox1->Size = System::Drawing::Size(191, 277); + this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage; + this->pictureBox1->TabIndex = 0; + this->pictureBox1->TabStop = false; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink; + this->ClientSize = System::Drawing::Size(191, 277); + this->Controls->Add(this->pictureBox1); + this->Name = L"Form1"; + this->Text = L"Shaina Shoshana"; + (cli::safe_cast(this->pictureBox1))->EndInit(); + this->ResumeLayout(false); + + } +#pragma endregion + }; +} + diff --git a/Chapter11/PictureBoxEx/Form1.resx b/Chapter11/PictureBoxEx/Form1.resx new file mode 100644 index 0000000..479d42c --- /dev/null +++ b/Chapter11/PictureBoxEx/Form1.resx @@ -0,0 +1,429 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + /9j/4AAQSkZJRgABAQEAYABgAAD/4iIUSUNDX1BST0ZJTEUAAQEAACIEQVBQTAIgAABtbnRyUkdCIFhZ + WiAH1gACAAIAAgAUAABhY3NwQVBQTAAAAABub25lAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUVQ + U08AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAhbAAA + AEdyWFlaAAAA/AAAABRnWFlaAAABEAAAABRiWFlaAAABJAAAABR3dHB0AAABOAAAABRjcHJ0AAAhtAAA + AFByVFJDAAABTAAAIAxnVFJDAAABTAAAIAxiVFJDAAABTAAAIAxia3B0AAAhWAAAABRYWVogAAAAAAAA + b6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA + 81EAAQAAAAEWzGN1cnYAAAAAAAAQAAAAAAEAAgAEAAUABgAHAAkACgALAAwADgAPABAAEQATABQAFQAW + ABgAGQAaABsAHAAeAB8AIAAhACMAJAAlACYAKAApACoAKwAtAC4ALwAwADIAMwA0ADUANwA4ADkAOgA7 + AD0APgA/AEAAQgBDAEQARQBHAEgASQBKAEwATQBOAE8AUQBSAFMAVABVAFcAWABZAFoAXABdAF4AXwBh + AGIAYwBkAGYAZwBoAGkAawBsAG0AbgBvAHEAcgBzAHQAdgB3AHgAeQB7AHwAfQB+AIAAgQCCAIMAhQCG + AIcAiACJAIsAjACNAI4AkACRAJIAkwCVAJYAlwCYAJoAmwCcAJ0AnwCgAKEAogCkAKUApgCnAKgAqgCr + AKwArQCvALAAsQCyALQAtQC2ALcAuQC6ALsAvAC+AL8AwADBAMIAxADFAMYAxwDJAMoAywDMAM4AzwDQ + ANEA0wDUANUA1wDYANkA2gDcAN0A3gDgAOEA4gDkAOUA5gDoAOkA6gDsAO0A7wDwAPEA8wD0APYA9wD4 + APoA+wD9AP4A/wEBAQIBBAEFAQcBCAEKAQsBDQEOAQ8BEQESARQBFQEXARgBGgEbAR0BHwEgASIBIwEl + ASYBKAEpASsBLQEuATABMQEzATQBNgE4ATkBOwE8AT4BQAFBAUMBRQFGAUgBSgFLAU0BTwFQAVIBVAFV + AVcBWQFaAVwBXgFgAWEBYwFlAWcBaAFqAWwBbgFvAXEBcwF1AXYBeAF6AXwBfgF/AYEBgwGFAYcBiQGK + AYwBjgGQAZIBlAGWAZcBmQGbAZ0BnwGhAaMBpQGnAakBqwGsAa4BsAGyAbQBtgG4AboBvAG+AcABwgHE + AcYByAHKAcwBzgHQAdIB1AHWAdgB2gHcAd4B4QHjAeUB5wHpAesB7QHvAfEB8wH1AfgB+gH8Af4CAAIC + AgQCBwIJAgsCDQIPAhICFAIWAhgCGgIdAh8CIQIjAiUCKAIqAiwCLgIxAjMCNQI4AjoCPAI+AkECQwJF + AkgCSgJMAk8CUQJTAlYCWAJaAl0CXwJhAmQCZgJpAmsCbQJwAnICdQJ3AnkCfAJ+AoECgwKGAogCiwKN + ApACkgKVApcCmgKcAp8CoQKkAqYCqQKrAq4CsAKzArUCuAK7Ar0CwALCAsUCyALKAs0CzwLSAtUC1wLa + At0C3wLiAuQC5wLqAuwC7wLyAvUC9wL6Av0C/wMCAwUDCAMKAw0DEAMTAxUDGAMbAx4DIAMjAyYDKQMs + Ay4DMQM0AzcDOgM9Az8DQgNFA0gDSwNOA1EDVANWA1kDXANfA2IDZQNoA2sDbgNxA3QDdwN6A30DgAOC + A4UDiAOLA44DkQOUA5gDmwOeA6EDpAOnA6oDrQOwA7MDtgO5A7wDvwPCA8UDyQPMA88D0gPVA9gD2wPf + A+ID5QPoA+sD7gPyA/UD+AP7A/4EAgQFBAgECwQPBBIEFQQYBBwEHwQiBCUEKQQsBC8EMwQ2BDkEPQRA + BEMERwRKBE0EUQRUBFcEWwReBGIEZQRoBGwEbwRzBHYEeQR9BIAEhASHBIsEjgSSBJUEmQScBKAEowSn + BKoErgSxBLUEuAS8BL8EwwTGBMoEzgTRBNUE2ATcBOAE4wTnBOoE7gTyBPUE+QT9BQAFBAUIBQsFDwUT + BRYFGgUeBSIFJQUpBS0FMQU0BTgFPAVABUMFRwVLBU8FUgVWBVoFXgViBWYFaQVtBXEFdQV5BX0FgQWE + BYgFjAWQBZQFmAWcBaAFpAWoBawFrwWzBbcFuwW/BcMFxwXLBc8F0wXXBdsF3wXjBecF6wXvBfQF+AX8 + BgAGBAYIBgwGEAYUBhgGHAYhBiUGKQYtBjEGNQY5Bj4GQgZGBkoGTgZTBlcGWwZfBmMGaAZsBnAGdAZ5 + Bn0GgQaFBooGjgaSBpcGmwafBqQGqAasBrEGtQa5Br4GwgbGBssGzwbUBtgG3AbhBuUG6gbuBvIG9wb7 + BwAHBAcJBw0HEgcWBxsHHwckBygHLQcxBzYHOgc/B0MHSAdNB1EHVgdaB18HYwdoB20HcQd2B3sHfweE + B4kHjQeSB5cHmwegB6UHqQeuB7MHtwe8B8EHxgfKB88H1AfZB90H4gfnB+wH8Qf1B/oH/wgECAkIDQgS + CBcIHAghCCYIKwgvCDQIOQg+CEMISAhNCFIIVwhcCGEIZghrCHAIdQh6CH8IhAiJCI4IkwiYCJ0Iogin + CKwIsQi2CLsIwAjFCMoIzwjUCNkI3wjkCOkI7gjzCPgI/QkDCQgJDQkSCRcJHQkiCScJLAkxCTcJPAlB + CUYJTAlRCVYJWwlhCWYJawlxCXYJewmBCYYJiwmRCZYJmwmhCaYJqwmxCbYJvAnBCcYJzAnRCdcJ3Ani + CecJ7QnyCfgJ/QoCCggKDQoTChkKHgokCikKLwo0CjoKPwpFCkoKUApWClsKYQpmCmwKcgp3Cn0KgwqI + Co4KlAqZCp8KpQqqCrAKtgq8CsEKxwrNCtMK2AreCuQK6grvCvUK+wsBCwcLDAsSCxgLHgskCyoLLws1 + CzsLQQtHC00LUwtZC18LZAtqC3ALdgt8C4ILiAuOC5QLmgugC6YLrAuyC7gLvgvEC8oL0AvWC9wL4gvp + C+8L9Qv7DAEMBwwNDBMMGQwgDCYMLAwyDDgMPgxFDEsMUQxXDF0MZAxqDHAMdgx9DIMMiQyPDJYMnAyi + DKgMrwy1DLsMwgzIDM4M1QzbDOEM6AzuDPUM+w0BDQgNDg0VDRsNIQ0oDS4NNQ07DUINSA1PDVUNXA1i + DWkNbw12DXwNgw2JDZANlg2dDaQNqg2xDbcNvg3FDcsN0g3ZDd8N5g3sDfMN+g4BDgcODg4VDhsOIg4p + Di8ONg49DkQOSg5RDlgOXw5mDmwOcw56DoEOiA6ODpUOnA6jDqoOsQ64Dr4OxQ7MDtMO2g7hDugO7w72 + Dv0PBA8LDxIPGQ8gDycPLg81DzwPQw9KD1EPWA9fD2YPbQ90D3sPgg+JD5APmA+fD6YPrQ+0D7sPwg/K + D9EP2A/fD+YP7Q/1D/wQAxAKEBIQGRAgECcQLxA2ED0QRBBMEFMQWhBiEGkQcBB4EH8QhhCOEJUQnRCk + EKsQsxC6EMIQyRDQENgQ3xDnEO4Q9hD9EQURDBEUERsRIxEqETIRORFBEUgRUBFXEV8RZxFuEXYRfRGF + EY0RlBGcEaQRqxGzEbsRwhHKEdIR2RHhEekR8BH4EgASCBIPEhcSHxInEi4SNhI+EkYSThJVEl0SZRJt + EnUSfRKEEowSlBKcEqQSrBK0ErwSxBLMEtQS2xLjEusS8xL7EwMTCxMTExsTIxMrEzMTOxNEE0wTVBNc + E2QTbBN0E3wThBOME5QTnROlE60TtRO9E8UTzRPWE94T5hPuE/YT/xQHFA8UFxQgFCgUMBQ4FEEUSRRR + FFoUYhRqFHMUexSDFIwUlBScFKUUrRS2FL4UxhTPFNcU4BToFPEU+RUBFQoVEhUbFSMVLBU0FT0VRRVO + FVcVXxVoFXAVeRWBFYoVkxWbFaQVrBW1Fb4VxhXPFdgV4BXpFfIV+hYDFgwWFBYdFiYWLxY3FkAWSRZS + FloWYxZsFnUWfhaGFo8WmBahFqoWsxa7FsQWzRbWFt8W6BbxFvoXAxcMFxQXHRcmFy8XOBdBF0oXUxdc + F2UXbhd3F4AXiReSF5wXpReuF7cXwBfJF9IX2xfkF+0X9xgAGAkYEhgbGCQYLhg3GEAYSRhSGFwYZRhu + GHcYgRiKGJMYnBimGK8YuBjCGMsY1BjeGOcY8Bj6GQMZDBkWGR8ZKRkyGTsZRRlOGVgZYRlrGXQZfhmH + GZEZmhmkGa0ZtxnAGcoZ0xndGeYZ8Bn6GgMaDRoWGiAaKhozGj0aRhpQGloaYxptGncagRqKGpQanhqn + GrEauxrFGs4a2BriGuwa9Rr/GwkbExsdGycbMBs6G0QbThtYG2IbbBt1G38biRuTG50bpxuxG7sbxRvP + G9kb4xvtG/ccARwLHBUcHxwpHDMcPRxHHFEcWxxlHHAcehyEHI4cmByiHKwcthzBHMsc1RzfHOkc9Bz+ + HQgdEh0cHScdMR07HUUdUB1aHWQdbx15HYMdjh2YHaIdrR23HcEdzB3WHeEd6x31HgAeCh4VHh8eKh40 + Hj4eSR5THl4eaB5zHn0eiB6THp0eqB6yHr0exx7SHtwe5x7yHvwfBx8SHxwfJx8yHzwfRx9SH1wfZx9y + H3wfhx+SH50fpx+yH70fyB/SH90f6B/zH/4gCCATIB4gKSA0ID8gSiBUIF8gaiB1IIAgiyCWIKEgrCC3 + IMIgzSDYIOMg7iD5IQQhDyEaISUhMCE7IUYhUSFcIWchciF+IYkhlCGfIaohtSHAIcwh1yHiIe0h+CIE + Ig8iGiIlIjAiPCJHIlIiXiJpInQifyKLIpYioSKtIrgiwyLPItoi5iLxIvwjCCMTIx8jKiM1I0EjTCNY + I2MjbyN6I4YjkSOdI6gjtCO/I8sj1iPiI+4j+SQFJBAkHCQoJDMkPyRLJFYkYiRuJHkkhSSRJJwkqCS0 + JL8kyyTXJOMk7iT6JQYlEiUeJSklNSVBJU0lWSVlJXAlfCWIJZQloCWsJbglxCXQJdwl5yXzJf8mCyYX + JiMmLyY7JkcmUyZfJmsmdyaEJpAmnCaoJrQmwCbMJtgm5CbwJv0nCScVJyEnLSc5J0YnUideJ2ondieD + J48nmyenJ7QnwCfMJ9kn5SfxJ/0oCigWKCMoLyg7KEgoVChgKG0oeSiGKJIoniirKLcoxCjQKN0o6Sj2 + KQIpDykbKSgpNClBKU0pWilnKXMpgCmMKZkppimyKb8pzCnYKeUp8Sn+KgsqGCokKjEqPipKKlcqZCpx + Kn0qiiqXKqQqsSq9Ksoq1yrkKvEq/isKKxcrJCsxKz4rSytYK2Urcit/K4wrmSulK7IrvyvMK9kr5ivz + LAEsDiwbLCgsNSxCLE8sXCxpLHYsgyyQLJ4sqyy4LMUs0izfLO0s+i0HLRQtIS0vLTwtSS1WLWQtcS1+ + LYstmS2mLbMtwS3OLdst6S32LgQuES4eLiwuOS5HLlQuYS5vLnwuii6XLqUusi7ALs0u2y7oLvYvAy8R + Lx4vLC86L0cvVS9iL3Avfi+LL5kvpy+0L8Iv0C/dL+sv+TAGMBQwIjAvMD0wSzBZMGcwdDCCMJAwnjCs + MLkwxzDVMOMw8TD/MQ0xGjEoMTYxRDFSMWAxbjF8MYoxmDGmMbQxwjHQMd4x7DH6MggyFjIkMjIyQDJO + MlwyajJ5MocylTKjMrEyvzLNMtwy6jL4MwYzFDMjMzEzPzNNM1wzajN4M4YzlTOjM7EzwDPOM9wz6zP5 + NAc0FjQkNDM0QTRPNF40bDR7NIk0mDSmNLU0wzTSNOA07zT9NQw1GjUpNTc1RjVUNWM1cjWANY81nTWs + Nbs1yTXYNec19TYENhM2ITYwNj82TjZcNms2ejaJNpc2pja1NsQ20zbhNvA2/zcONx03LDc7N0k3WDdn + N3Y3hTeUN6M3sjfBN9A33zfuN/04DDgbOCo4OThIOFc4Zjh1OIQ4kziiOLE4wTjQON847jj9OQw5Gzkr + OTo5STlYOWc5dzmGOZU5pDm0OcM50jnhOfE6ADoPOh86Ljo9Ok06XDprOns6ijqaOqk6uDrIOtc65zr2 + OwY7FTslOzQ7RDtTO2M7cjuCO5E7oTuwO8A70DvfO+87/jwOPB48LTw9PE08XDxsPHw8izybPKs8ujzK + PNo86jz5PQk9GT0pPTk9SD1YPWg9eD2IPZg9pz23Pcc91z3nPfc+Bz4XPic+Nz5HPlc+Zz53Poc+lz6n + Prc+xz7XPuc+9z8HPxc/Jz83P0c/Vz9nP3g/iD+YP6g/uD/IP9k/6T/5QAlAGUAqQDpASkBaQGtAe0CL + QJxArEC8QM1A3UDtQP5BDkEeQS9BP0FPQWBBcEGBQZFBokGyQcNB00HkQfRCBUIVQiZCNkJHQldCaEJ4 + QolCmkKqQrtCy0LcQu1C/UMOQx9DL0NAQ1FDYUNyQ4NDlEOkQ7VDxkPXQ+dD+EQJRBpEK0Q7RExEXURu + RH9EkEShRLJEwkTTRORE9UUGRRdFKEU5RUpFW0VsRX1FjkWfRbBFwUXSReNF9EYFRhdGKEY5RkpGW0Zs + Rn1Gj0agRrFGwkbTRuRG9kcHRxhHKUc7R0xHXUduR4BHkUeiR7RHxUfWR+hH+UgKSBxILUg/SFBIYUhz + SIRIlkinSLlIykjcSO1I/0kQSSJJM0lFSVZJaEl6SYtJnUmuScBJ0knjSfVKBkoYSipKO0pNSl9KcUqC + SpRKpkq3SslK20rtSv9LEEsiSzRLRktYS2lLe0uNS59LsUvDS9VL50v5TApMHEwuTEBMUkxkTHZMiEya + TKxMvkzQTOJM9E0GTRlNK009TU9NYU1zTYVNl02pTbxNzk3gTfJOBE4XTilOO05NTl9Ock6ETpZOqU67 + Ts1O307yTwRPFk8pTztPTk9gT3JPhU+XT6pPvE/OT+FP81AGUBhQK1A9UFBQYlB1UIdQmlCtUL9Q0lDk + UPdRCVEcUS9RQVFUUWdReVGMUZ9RsVHEUddR6VH8Ug9SIlI0UkdSWlJtUoBSklKlUrhSy1LeUvFTBFMW + UylTPFNPU2JTdVOIU5tTrlPBU9RT51P6VA1UIFQzVEZUWVRsVH9UklSlVLhUy1TeVPJVBVUYVStVPlVR + VWVVeFWLVZ5VsVXFVdhV61X+VhJWJVY4VktWX1ZyVoVWmVasVr9W01bmVvpXDVcgVzRXR1dbV25XgleV + V6lXvFfQV+NX91gKWB5YMVhFWFhYbFiAWJNYp1i6WM5Y4lj1WQlZHVkwWURZWFlrWX9Zk1mnWbpZzlni + WfZaCVodWjFaRVpZWmxagFqUWqhavFrQWuRa+FsLWx9bM1tHW1tbb1uDW5dbq1u/W9Nb51v7XA9cI1w3 + XEtcYFx0XIhcnFywXMRc2FzsXQFdFV0pXT1dUV1lXXpdjl2iXbZdy13fXfNeCF4cXjBeRF5ZXm1egl6W + Xqpev17TXude/F8QXyVfOV9OX2Jfd1+LX6BftF/JX91f8mAGYBtgL2BEYFhgbWCCYJZgq2C/YNRg6WD9 + YRJhJ2E7YVBhZWF6YY5ho2G4Yc1h4WH2YgtiIGI1YkliXmJzYohinWKyYsdi22LwYwVjGmMvY0RjWWNu + Y4NjmGOtY8Jj12PsZAFkFmQrZEBkVWRqZH9klWSqZL9k1GTpZP5lE2UpZT5lU2VoZX1lk2WoZb1l0mXo + Zf1mEmYnZj1mUmZnZn1mkmanZr1m0mboZv1nEmcoZz1nU2doZ35nk2epZ75n1GfpZ/9oFGgqaD9oVWhq + aIBolmiraMFo1mjsaQJpF2ktaUNpWGluaYRpmWmvacVp22nwagZqHGoyakhqXWpzaolqn2q1aspq4Gr2 + awxrIms4a05rZGt6a5Brpmu8a9Jr6Gv+bBRsKmxAbFZsbGyCbJhsrmzEbNps8G0GbRxtM21JbV9tdW2L + baFtuG3ObeRt+m4RbiduPW5TbmpugG6Wbq1uw27ZbvBvBm8cbzNvSW9gb3ZvjG+jb7lv0G/mb/1wE3Aq + cEBwV3BtcIRwmnCxcMdw3nD0cQtxInE4cU9xZnF8cZNxqnHAcddx7nIEchtyMnJIcl9ydnKNcqRyunLR + cuhy/3MWcyxzQ3Nac3FziHOfc7ZzzXPkc/p0EXQodD90VnRtdIR0m3SydMl04HT3dQ51JnU9dVR1a3WC + dZl1sHXHdd519nYNdiR2O3ZSdmp2gXaYdq92x3bedvV3DHckdzt3Undqd4F3mHewd8d33nf2eA14JXg8 + eFR4a3iCeJp4sXjJeOB4+HkPeSd5PnlWeW55hXmdebR5zHnjeft6E3oqekJ6Wnpxeol6oXq4etB66HsA + exd7L3tHe197dnuOe6Z7vnvWe+58BXwdfDV8TXxlfH18lXytfMV83Hz0fQx9JH08fVR9bH2EfZx9tH3N + feV9/X4Vfi1+RX5dfnV+jX6lfr5+1n7ufwZ/Hn83f09/Z39/f5d/sH/If+B/+YARgCmAQYBagHKAioCj + gLuA1IDsgQSBHYE1gU6BZoF/gZeBsIHIgeGB+YISgiqCQ4JbgnSCjIKlgr6C1oLvgweDIIM5g1GDaoOD + g5uDtIPNg+WD/oQXhDCESIRhhHqEk4SshMSE3YT2hQ+FKIVBhVqFcoWLhaSFvYXWhe+GCIYhhjqGU4Zs + hoWGnoa3htCG6YcChxuHNIdNh2eHgIeZh7KHy4fkh/2IF4gwiEmIYoh7iJWIrojHiOCI+okTiSyJRolf + iXiJkYmricSJ3on3ihCKKopDil2KdoqPiqmKworcivWLD4soi0KLW4t1i46LqIvCi9uL9YwOjCiMQoxb + jHWMj4yojMKM3Iz1jQ+NKY1CjVyNdo2QjamNw43djfeOEY4rjkSOXo54jpKOrI7GjuCO+o8Tjy2PR49h + j3uPlY+vj8mP44/9kBeQMZBLkGWQf5CakLSQzpDokQKRHJE2kVCRa5GFkZ+RuZHTke6SCJIikjySV5Jx + kouSppLAktqS9JMPkymTRJNek3iTk5Otk8iT4pP8lBeUMZRMlGaUgZSblLaU0JTrlQWVIJU7lVWVcJWK + laWVwJXalfWWD5YqlkWWX5Z6lpWWsJbKluWXAJcblzWXUJdrl4aXoZe7l9aX8ZgMmCeYQphdmHeYkpit + mMiY45j+mRmZNJlPmWqZhZmgmbuZ1pnxmgyaJ5pCml6aeZqUmq+ayprlmwCbHJs3m1KbbZuIm6Sbv5va + m/WcEZwsnEecY5x+nJmctZzQnOudB50inT2dWZ10nZCdq53GneKd/Z4ZnjSeUJ5rnoeeop6+ntqe9Z8R + nyyfSJ9jn3+fm5+2n9Kf7qAJoCWgQaBcoHiglKCwoMug56EDoR+hOqFWoXKhjqGqocah4aH9ohmiNaJR + om2iiaKlosGi3aL5oxWjMaNNo2mjhaOho72j2aP1pBGkLaRJpGWkgaSepLqk1qTypQ6lKqVHpWOlf6Wb + pbil1KXwpgymKaZFpmGmfqaapram06bvpwunKKdEp2CnfaeZp7an0qfvqAuoKKhEqGGofaiaqLao06jv + qQypKalFqWKpfqmbqbip1Knxqg6qKqpHqmSqgKqdqrqq16rzqxCrLatKq2erg6ugq72r2qv3rBSsMKxN + rGqsh6ykrMGs3qz7rRitNa1SrW+tjK2prcat464Arh2uOq5XrnSukq6vrsyu6a8GryOvQK9er3uvmK+1 + r9Ov8LANsCqwSLBlsIKwn7C9sNqw97EVsTKxULFtsYqxqLHFseOyALIesjuyWbJ2spSysbLPsuyzCrMn + s0WzYrOAs56zu7PZs/a0FLQytE+0bbSLtKi0xrTktQK1H7U9tVu1ebWWtbS10rXwtg62LLZJtme2hbaj + tsG237b9txu3ObdXt3W3k7ext8+37bgLuCm4R7hluIO4obi/uN24+7kZuTi5Vrl0uZK5sLnOue26C7op + uke6ZrqEuqK6wLrfuv27G7s6u1i7druVu7O70bvwvA68LbxLvGq8iLymvMW8470CvSC9P71dvXy9m725 + vdi99r4VvjO+Ur5xvo++rr7Nvuu/Cr8pv0e/Zr+Fv6S/wr/hwADAH8A+wFzAe8CawLnA2MD3wRXBNMFT + wXLBkcGwwc/B7sINwizCS8JqwonCqMLHwubDBcMkw0PDYsOBw6DDwMPfw/7EHcQ8xFvEe8SaxLnE2MT3 + xRfFNsVVxXXFlMWzxdLF8sYRxjDGUMZvxo/GrsbNxu3HDMcsx0vHa8eKx6rHycfpyAjIKMhHyGfIhsim + yMXI5ckFySTJRMlkyYPJo8nDyeLKAsoiykHKYcqByqHKwMrgywDLIMtAy1/Lf8ufy7/L38v/zB/MP8xe + zH7Mnsy+zN7M/s0ezT7NXs1+zZ7Nvs3ezf7OH84/zl/Of86fzr/O387/zyDPQM9gz4DPoM/Bz+HQAdAh + 0ELQYtCC0KLQw9Dj0QPRJNFE0WXRhdGl0cbR5tIH0ifSR9Jo0ojSqdLJ0urTCtMr00zTbNON063TztPu + 1A/UMNRQ1HHUktSy1NPU9NUU1TXVVtV31ZfVuNXZ1frWGtY71lzWfdae1r/W39cA1yHXQtdj14TXpdfG + 1+fYCNgp2ErYa9iM2K3Yztjv2RDZMdlS2XPZlNm12dbZ+NoZ2jraW9p82p7av9rg2wHbIttE22Xbhtuo + 28nb6twL3C3cTtxv3JHcstzU3PXdFt043Vnde92c3b7d394B3iLeRN5l3ofeqN7K3uzfDd8v31Dfct+U + 37Xf19/54BrgPOBe4H/goeDD4OXhBuEo4UrhbOGN4a/h0eHz4hXiN+JZ4nrinOK+4uDjAuMk40bjaOOK + 46zjzuPw5BLkNORW5HjkmuS85N7lAeUj5UXlZ+WJ5avlzeXw5hLmNOZW5nnmm+a95t/nAuck50bnaeeL + 563n0Ofy6BToN+hZ6HvonujA6OPpBeko6UrpbemP6bLp1On36hnqPOpe6oHqpOrG6unrC+su61Hrc+uW + 67nr3Ov+7CHsROxm7InsrOzP7PLtFO037Vrtfe2g7cPt5e4I7ivuTu5x7pTut+7a7v3vIO9D72bvie+s + 78/v8vAV8DjwW/B+8KHwxfDo8QvxLvFR8XTxmPG78d7yAfIk8kjya/KO8rHy1fL48xvzP/Ni84XzqfPM + 8/D0E/Q29Fr0ffSh9MT06PUL9S/1UvV29Zn1vfXg9gT2J/ZL9m/2kva29tn2/fch90T3aPeM97D30/f3 + +Bv4Pvhi+Ib4qvjO+PH5Ffk5+V35gfml+cn57PoQ+jT6WPp8+qD6xPro+wz7MPtU+3j7nPvA++T8CPws + /FD8dfyZ/L384f0F/Sn9Tf1y/Zb9uv3e/gL+J/5L/m/+lP64/tz/AP8l/0n/bf+S/7b/2///WFlaIAAA + AAAAAAAAAAAAAAAAAABkZXNjAAAAAAAAAAxFUFNPTiAgc1JHQgAAAAAAAAAADABFAFAAUwBPAE4AIAAg + AHMAUgBHAEIAAAAADEVQU09OICBzUkdCAAB0ZXh0AAAAAENvcHlyaWdodCAoYykgU0VJS08gRVBTT04g + Q09SUE9SQVRJT04gMjAwMCAtIDIwMDYuIEFsbCByaWdodHMgcmVzZXJ2ZWQuAP/bAEMACAYGBwYFCAcH + BwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicgIiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMB + CQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy + MjIyMv/AABEIARIAvQMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1 + EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZ + GiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaX + mJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/ + xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQF + ITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpT + VFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrC + w8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APehRQBRg4460wA0 + HOOBmlPtRQAmKXFFFABikpTSYoAMUYpaKAG4oxStTQMnpnmmAoBIyRj2oK06kP5UAJtPrQAcU4H2ozSA + QDjNGKXNLQA3FJg45p9JQA3FNanHpTO/vQAh46fnTee1B9qCcdwKQFkCj8KBS0wEpO9L7Cl70AJRigD5 + ic9e1LQAmKMUd6ZLMIwCe9IB+KCQOtYmq+IbfSoi88gL9kXGTWWPHVuIt5tmZu4Df1qJVYRdmy1Tk9kd + cRntQBxXEr8Qo1YrNY7SD0WUEj88c1uWPiTTtRcLa3kcjf8APPo35UlWg+oOnJG2aQ1TeaXeFSWMdflZ + T/jTIb26LBZ7VcHOHhfcPxBAP5Zq+dE8pewaQCo/tUOMlwCTjHf8qcksbHCMCe47j8Kq5JJijFGeOtKK + BhSUtNZsHmgBr5xx600+lL79abnFACDODnHtSd6U9c5puSOgP4UgLIpc005xxj8aXvTAWiiigAoJ9aTN + UtUuRbWTyHB7AHuT0pNpK7Gk27IW51CGHgvk9gvOawL/AFe6yxttsfu/JNUzNmQyTMGduvfP/wBb2pry + rI/JC/jj9K8+piG9EehDCpbnN6i8t2dsibpNwYnJ59sVWlaKzG5iPMAJUDru6de3rW/d2Z+8CSPXrWLf + 6UbiFjyDjjPH1rC76mrp9jFkukKnL/KARn1OO1Ytxe3KhvKlKRgkBVOD9fp0q3LDJHPKtwCFRQFO0lcZ + 6YHXr/8ArrIvCMlQzRngk+Wf6dPr+PcVUUYSdjotB8e3+mTLFcym6hDD927DcOOxOSOM8YxXqWla5Fq8 + Ins52Ixlo22jyzng9AfX16HvxXz3GknmjM0ezOCy/N9Acdq3tI1xtOuFkiuGjlU9VJBPsRkceo9+vQ1d + 3EzaUj3UalEkUbTvGjyDaArhmJ7DjgnJ6DuR61larqc9iizK1wYeol/u8/xDoOfrWXpetQ6pYm9iIglV + g1xFbQiR8ggk8fMQQD1BPQ9QRWib2ArJHbwXDoymR2nBCMp4wN3GST06c/hWntWZ8tjW8P8AiOLV4GUs + vnpjdg8MPUf4Vuq4/CvLtY0698NzjVdOZY4lx50YbKpnvg5+XrnuOD0PHVeGPFNvr9s23EN3HjzoCeM+ + q57GuilVv7stzOUOsTqSeOlMPWmByQM0p6VuQLn3pPftSZozQAh6801utKaTP+RSAtUDFApaYCUUGj8K + AErm/FN0Io4YVwW378enb+tdGxwK5PU5lubtpMZC/KpPpWGIfuW7nThY3qXfQxkilkO6T5c+vWtG3ihR + cM3PfBxVN3Oc8/jURnIJxXlq0WexKMpqy0NCZ0A45/z7VnT/ADdGIHpjrTPO2kDJ/E0151A4I6Z+lDmm + EaTRn6hZQzw7ZIlbLY+auavbA26GLJeIfdXy84/HNdNNcgMCcEj16CqOoSRzxFicyMCcj1PrRGZjVpo4 + m9tGiJk84qh4K425Hoc8n+VZr/ZYSNqMnPK7sEfrnFbuo2+3DkEbhyUbn8fWufmsUlZircjrwQR9f8a3 + izinFo2dF1yTS9VW4gCbAuybY+d6Y59RwDwc57etepR3NrcP9qhiub2O5gwHWfdGQMt84OMDkjnggDOO + /hkTTWzFFSMDuc9f8/Wu+8F6ss9tPpF5ukEX72FTJt+UtuZc59cf99H3BbVjN6ndx3s00cUXlGFPKDqG + YbnRONo7EMQeOeCODnFcfqcUnhvW4LzTpAkcoL27JnYfVP8AaUgZx9RzjnZtZltLaziitnuG8oxtJcRF + QG+bkgngDvgY5x6CqviSCfVdJdJlzcCIToisTjbkK/Pcjr6Z56E0Ji21PRdC1uHWdLjvIc4PyyRE/NG4 + 6j3/AMK1wQy8cg14j4C8UGw1BRM/7mbCzDsR/C4+mfyzXtMbggY6Gu6lU5lqY1I8rJqQnmkJ4o6VqQBN + NJFKabn0zQBcFLSdutGcCgBaSikJ4oGZ+q3ggt2jRx5rjGM9B61ysr9s81k+Ihepq108M2P3pO3PXnpU + Vhq4u18uVfLmU4I9a8ytVbk7nrYakoqxosT1/Kq0jcfX2pzuF/CoSc4PrXM9Wd60Qzknr+dMmOFqRmwC + RyfaqM0p5FFkJyKd1MQOO1ZDyuu5mb7rfLWhO+Sc9azJ2yhGfzoSMp6kFxP5gZQONv1I7VlOgEpOOpxx + 1q8xy0nHzZzVWc4lU5yM5/StUcs0Uri2jkT94mW7MvGfwqPSLl9L1q1uTtWJGCMwOAFbg9eehJqaZgT8 + oBJ5K9/qPyrOuEVZGD9DxyMYrSJzTXU9WuRCt9cTF73zTBtwcuhBJJPHXGWyPx61E8iCKOCBGQNDEY5T + 8uNoXjBztJIGB6c/WlbXAvtC06aS9lhkYrvJbKlgQGA5+XhGPPGWPXpVm4lQ3TSmO4djKofcMAMMbQQe + v4dqh3IOIKrY6gyoT5avgOTxzyQpzg46celez+B9fN/pi20r5mtwEJx27fhXiWreZJftNM7GbaodmHJI + 4yffj+Vb/g3WjY6lBKMhf9VKmeGU8Ywf89K3hLlaYmrxsfQCOGHvTiTiqVvMHAYPlSMo/qDVxWyPeu5H + MB9KZnHanZz700/hTAvUUdqKADNQXNwlvGXYgHsCepqVjgc1ymoXZvbhm34ReFGazqz5V5m1Gl7R+RwW + v2GoP4hWS51V4bWVz88SgbSfUkHjpWbZ3Uza1PZ7mmWCXyluguN7YJ2sOmflbB747V2t7ZSXEZTKSr6N + 2rEtPCNnb6rHqciBJYizKqnhiQRkj8TXnuzVmj0+SSknF6E8kxVtrdfeoZdQWM4J5pupSCNzz1NZR8uV + 2DP83pWB1TlY2hOkwykisR6Gqk5AJ55FY8lvKpzaSqSOoJw1C6hKBsuFO4dT0p8pn7TuPuWPPJqjIxJ6 + /wBKkmnV8kMCKpl889u1CQ7oR8ZzkA+oqrPhcE56EVPJnseQPWs+6dgvHUe1WjCbsVLoiJxhuO3tVZg1 + wQOCB2B5pk7tJkbSB1JPAFQpKsWTnJ9eDWyTscUnqd54Qu9mjXcEl0YVtX8w4UEKMq2TwegQj8e5rRMz + QRRxTXJeZIh5jxDIbOB82RyMbcnrknnmue8EXBudUktvMdGdARgBiQGAIx9CfwFdBqMssSedJcRuckr5 + Y5Ck9BjqMZ4wD36Ams5X5iTjtUX/AInNxDghAuBk843Ac+/JqlYzlL3Y7Abjg/Xp/wDXqzdHfqUmDyI2 + HXPQfn2/UVmzuBeE4yjrvHPT1rRdh9Ln0H4I1U3+hxpLxJCdp/kf8/SurRuevWvIvhxqmLl7Un/Wcgeu + Rj88ha9aVsgnuBkYrrpSvE56isyxnI560n0zTCenpRnmtSDRFFNzS0xlDWLn7Np0jD7zfKPx/wDrVwU1 + 6FJJzXW+LCV06Mg/x/0rzq6Ls6wx5LyHAxXm4yT57I9nL4R9m5M6i0814vMdWBIyqd8VWu7gImOhHbNQ + TyzLEgkwZFHz44Fc7qDXOwyRE8/pWEpNKyOiMFfmYuqjz1Miv+Ga5+3aTzHK7PMPGHBwavWTtPK0Er/O + Rkc1LJpwDMBw31qIu2jCcebYgtobWWyuJ7m6lt7iGNpBHHtAOATgZHPT61T03W4bmZLDUPJFy0auskbK + ysCMgcE4b26itQ20U0WyZcZ74z+fY1haj4egyXhKK2chlG0g+vWt1KLVmckqdRSutizqOnTWhMkDkqf4 + e1ZiTknkYOeRg1v2lw0+nospzKow3vjvWLcRBJiRwPrUJ9DQRWLYzxVW8WTa2DkHuKsY4yAKiuX2xjIP + SqRFTY56dWU4YAEdzVNwCvAPr0rSmlD47joaoybCpPTmuiLOCRqeEZFXX7MOWAZivysQTwSMH6gV3msy + sk80rESjfwSnIXgEEjA56HjIx6dPPfDbf8VHp6qW/wBfklc5xg5Pr0zXW+Jpo0iIl8hpWLNuQ5CgdRkd + /un6fmYqr3gjsc7DIZr6RyoZtzZcDr16/rVS4O9EfaCUfn3BHNWNMBDR7urEsc+/FVJG3W+B8rZGT6HF + C+Ir7J0fhi8az1e3lB4Ddj+Ir6HjkDqroeGUFcdwa+aNMkB8s90ABHp/nNfQHhq8W90K1k3Z+QDrmtqD + s2jOqtEzcB4FKWx2NNU8DPWlz+VdRgaVJjBz6+9LmkNMZi+J03aLI3dGVv6f1rgrKaKC+aeZscBUJ5wS + f/1V6Jrw3aPcg+g/mK8rurhYLu1kcFkjuo2cAcsoOSPyrz8Uv3qPWwT/AHLXma15OkrMARvBwR6/Sse5 + uPLI+XAxyCKn1HVND+0x/Z9QQbhz5gIAP1I4P1qteI2RvHUZGeuM1zSh1O3S10UY4gbnzlx9AOlbITei + uB2zWZFGUbIHyn3rTiYrEvQ1kyqT1GTIrqQcBgO9Y9zwWHUVpXcp2nH3qxppM/l61UQmypu8okg55qrI + 3mOTU8pB71WVM/nWiOdiFRxk4+p6VSvSWRsY9q0WG2MnGD7Cs2UguytnC+lUjKauYkoZHztB/Cs+5znc + uQe9dpp1tBKqtKodiMqgGSRWnc2Nu1qkr28SIedueR9a1VXl6GH1bm6nG+FXEerrIcjYh2sADtPrzx61 + f8SXi3eoBY2bafmJYYbB5wcd8/oKr6jBFpl15u0KhGcAdaybeWS7umkkzvdvyqvifOc8ouD5GbVkhXYc + HHAHH41QkLLAxwCMA+ueea1bUBpCD/CD09gazG+eIAE4wePrURepT2J9KkMchG4e2e9e3fDu6WXRViXj + YWUg+nUfof0rwnT3Al4bBPSvWfh1dbfMAYdVfj0PB/pWsHaoRJXgeqDrj9KduI/+tUKPuXdT+tdiOY1a + DRRTGZ2uDdo11/uZ/WvH/EFheS2Wy1hZ5WOc9kHTJPb/APXXsmq4Om3APQpXn8zpJPcWrrm3Y7HAONoX + pz19R+XrXFiF76Z6mAvySSPNp9GWGP8AfTF3BGVUgc45BHXv3ra0/wARoXt7fU4Y0tYYWjH2dDknAwTz + 6Ajj1qW58I3IuDcWdws1vKCyCRsMAOcZ6HjHPFVZ9AvIIYJVhDLMhdRkBgPcHp+dZrVam6ilu9Szb6pY + 3Eixo7Izk7Y3XBHtnp+ta2Plx2+tchHYyTXKp5ZjKnLE9Vwa68HCqwrmqxSehvTepWnUEHvWXOnJ/wD1 + VqTEMvJx71nTnAbjmoQ5syLggHHv3qJHwOadcv8AN/8AXqp9oCtnp+OK2S0OdssSsWxgD8BVS6EUUZhj + ctdv99AuQq+/oavacUuw+H+dR8oPQ/SrZjtoYHk+zgysMHA5P40XsJRvqUdPgNrEs3+sDY2Mh+YEVZ1G + 7FzcBkQqkYy/mLt5qYtaaZb+aWSJiM/Mf5CuP1fXvtKmG3ykA5JP3pD6mqjFzegp1I01qU9bvXvrtIEf + zAnBbHU/4UWkQjuETvmorAlpHmK5A5JohlzdmTqM/nXTay5Uec5c0uZ9ToYGCM3OQyNn8iKxgeE5OST/ + ADrRjk+cknA2gdPc1mSBkAHYOwrGC1NJDIDtuOMg7umOPz7V6L4BvFj1byzwJAy49+o/lXm4wH3Hpmur + 8O3RgvreZequMirlo0yI6po+gojweMc849DU4zj/ABqlZyrJArA9QAD/AC/SrgrsWpzM2aSloqwMvXWK + 6cwGfmYD+v8ASvPdRtmmuHlhlMcuckZ4Nd/4gXdpbkdVYMPw6/pmuFnlDfWvPxTtI9fAaQujBnF0oy3m + pIARleQRVDyL+d1Eks4RRtG44wPSulaRcck4+tUmw0uQePWubmO2c2+hWgtlhXy1B9SSMVac4UKO1NVg + pzjHvUbvls9R61m22xLQbLt5561k3j8YGMVfmmwDjIGKxbqUu2Bn86qKIlIzrl+TisvDTzeWo+XvWjLE + 7kgD86UWwt4TtPzdDWy0MHqRtIIl2g7ce9ZV7qlwCVS5lA9d5qa6YnOTxWDdy5O1VyOpNawjzM5q1RxV + kMku2ZmZnLSHuTk1GgMkqgk5weSahccZP1NWrFlMvzDvxXRay0OK93qWI9zx7FPydSPWpUtmjViwxk8V + asreNYwZD8megrQuvKlQeWAAo6AVzynZ2Now6lFGO0gY61HcYEKtxwefzpygBTgjrSXKkxSKOinjj8f6 + VK3LexTxiQr15rb0mQjay9RjIrBY5djnvkVraa+yfbjg/jV1FoTDc988NXBl06LJyMAfTuP0rocnvXC+ + B7nzbXyS3zBdv5dP0rtY5CchuGHB56100neJzzVmb4oooNbElO8K7xvxsQFj/n6ZrzO7ubcThXYRM/zA + AHbySAPau88QTiLTbls4Jwn4d/515R4ldo9jbeQkbnPYZJH8xXn4p3konfhW4LmRqyIRyTx9aikzt+UH + HYism+xJIrKRiReOPvHg/wD16wbYyw+KLMQylYvNWORQccHII9O9ckY3O2Vd7WOrZG6k8VFK5HU4q1Ih + JIJPHFQm3HWlsXqzOkEknCqcfSojZZGWP4VqsirwBn8KikLHPy8dsCncTiZMluIwdqgY9qyr6VUGBnJO + AAOtbFzIxcpGNx788D61QTTJ7hm8qKSVu7Bc8f0q4tszkc5cRyNl5SST261XsNLe+1TIXMcamRznGB0/ + PNdS/h64eZVmZIoyfmY/NgfQf41sm20yy09rbT3BIGZCfvscdTXTBtI4q6XQ8q1BfKvGiCjAPFRR4SRT + kAdxWhrsbR3mcH5u9UI4i+VU/NxgevOP8K3T905WtTQjmYx5NXrQn7JJK5++2OfQVWe2EBEWRnHP1qfB + WxVADxnPt/nNc8rNaG8U0Jb5KED05ptwCAR7DJ/Op9NG8TDoRjJPof8A9VQXOVcL/s8c5xUr4i/smfjE + hOecYNaFpKEZSO3es8nLk8Hv+n/1qs2xw3Xr0rWaujOO56p4NvBDexjd8r8fiMj+v6V6YDu56+614z4b + mJZcZ3Lhl9sV6xY3W+1RwygMAcGnQlpYiqtbnaUho7Ux324yOD3rsMTm/E6mW2it1ODPOI/z4/ka8q8f + ahFda46QNuhUlMA8Erxj8iPzNekeL702f2edBu8rzHHGeeAP515CIGun8qQ7XuGMokc85BxwPQ+vsK86 + s1zs7YXUUa1qxnsbWVypOMH2xwP0rO0jTpL3xgyBtkcCGeR8dlG4fmQBWjpSBIGQqwDP8hkG0sR1wP0/ + Ct7w9ofnXWqRRybHurJ41kbojFl/z7Vz00uflN5fApFd5dzEEYIPrTDgjsfpUL6Vrlnc+Tc6dcnBx5iR + l1I9cjNWRZXpOfsVyD7wt/hSlCa0sdUZw6MhYY5xxmojDJcSCOJck+g6D+lbEegXkoG9vLJ6AfMa6HTt + BEKiNIjg8s7fxGrp0JMmpXjFHMaf4eBLNMAyg4GOh/xqxfvZadB5nlmXoPLHAJ7YA7/59K0tTs/s87pu + KrjO0Hj8qyZYIZYysgDKexFdPs+XQ4niE3dmRLdC4ZzGGQDlVbuPx7+30rB1CDEomA2yAHDDoRXQXWj2 + nklI8oAcqFYjafUelcvqum3qTCSOSedTwygcKvb696OVpi54zfunK623nLI3O5SoOPx/xrLt22skgzlW + 710l5ZoIHjA65/OuaMZijkXunJ46c1cHdWOeSs7mhEZG3ynnHf3rSDRXFoHTjPBGehrKjkjawLLw2cMK + saY5LTxDn5BIPY1nOOl+xpF20JbGTybm5U8h4wR9aiuW/eDrnZ/jSfdmIPXOD9KSU75WOcjGBRbW4X0s + VF+765FWbc/KKrY+VT0wPSrEBB6HitJbErc6jQroQzxueinnmvW9BnSazZAVPltgZPY8j+deI2MhjmX0 + PrXe6Xqs1nEREN4YDrzgc4/mfyrGE+SRc48y0PdKoxTefd3UTYwhAAq92rK1Cwnll8+zm8uU9QTgGu2p + zJXjqc9NRejOb8YWBnTypbtYYyDtdkyBkcg9K4W70q2t1t5FlEqRW4iY7PlY5JJGfr713OutqNtAHvfL + kPRQMHn8q8u1vU5b7TDLkxF85Xd78fpXmVHJzaSsehCMVFNu/oPt5brxRrSWVluR1BCyL93k4JI9hk16 + clg2lzklyArbRIR0bAPPsc81hfCrQp4rG81NQsc8wWOEsvGFJz+BPH4Gu/mtHksGin2+bISz7ORntgn2 + xXRGgnG63M/bWdmVYNVjX93OuyUfw54PuD0IqKS6kvp1hj5ZuFH9TWVLp9xZ+YmUa3+9lzwvvXVaLpq2 + VuJGUedIPmI7D0q6bqTfK9AmqdNcy1JbXTo7dACAzd29f/rVaCBewFS4qCSMtOvzH6V1pW2OFybd2Yeq + WMN3e5Ytgrzt/nWReeFLlPmgkVx2U8Gu0MMYwzKOOhqtdXiRRnHX0IpOKC7PMbu1mtZfKuI2jY8DI4NV + CohyCvBrvbpRqCFJo1kVuMEcj6VxuoWRtnkjJOxT1I5Fc8o22KRwmsWyLcOBxnkEmuMvoRBcksPlfg/1 + r0PUYi45HzqfTqK5rVLZXgbdGHXrz1FZp2ZpurHOW8cbzbUj2lsng8Y6/wBKvaYyx3cpbH90/TNVoE2S + o8YygP8AEOR7GgNsmcKerdTTlrdBHTUtTJsupQM47UxhgYPQqDzUk8gaRGxyyDJ96juSOVUcbB/OoXQ0 + ZXVNyvxntTo/lODng1NAuSf601l+bjp9Kvm6E2LkDYYH6Zrp9PvJYoMxtjIAIA9P/wBdcohJXbz69a6K + xybcMueR2NYTWpqtT6aNQmRV+8cehrnF8XW32QEBmdW2sg6getVj4tSTfC1uzR9iwwPzrrliqa6mCw9R + 9Cx4reKW3iG9Tt3MSD04OP1NeP3VlJqOq2Wi2ZBeVxkjnGT3/Our8ReI2u3eKNlZ2P3FOcfXtiovh1Z+ + d4omuyu5YIiZJCOrtkAD2A3fia5E/a1b9Dq5fZ07HqumWEOmadBaWw2xwoEX1OO5+vX8allKojO3Qckm + l+0RtIIlcFh19qivShjFud2ZAc44OB1/oPxr0bq2hwpNvUzFEWpo/nR/uGbYEcEEj3+uRxXRhQoAUYA4 + AFYWm2DRzHzmD/OGUc4GDkde44/Kt4natFNaF12r2i9BCc8DpTQuCTjPHWnqOKa3FWYDZOn+FZd5bq4I + I59RWhIflz3qlPnZwaQzICtby46jsarapYRXFoznAcjr6/WrM8yhjjGaom83KUJzgZxWbtsUcNqVsQhc + 8MmQc/rXLzwmUZIIUjhR2r0PU7MMjg8eYpX8ccVyt1b+UdkgKnt6GuWSs9TWO2hwNy72dz5RJ2k5Udse + lVX815DlABngkY/OtnX7UiHzAp/dnJx1we9Zxi8+wNxvYyIyxsufvAg4P4Ypq24XZG5DRREfewRnHvTb + ts3XXoq8U9lEcSD+PbjB7VBcYdY5F4PTP0ojuVLYt2Y3Bh7Gkdf3QPfOKLRiHznjOKmdMxsPU8frUN2k + WleI2NSy5x2zXSaAQ1q4OOCOtYVim7eCOdpra0Ef6PKBnIfkg0nuO2h6nfWSPM8lxYywS55eMbc+9YF7 + EckQtNKf9/pXr0lrFMuHTcD2JNVH0PTn5a1Qj0pywTvdMqOMjazR4vHpt5dTi3tLcyzN/wAs4f8A2Y9h + 7mvSPDvhr/hHdDuI7mYPeXZAlZRwueir7DPU+tdVb2VvaR7LeGOJPRFAqQx7n5AI69O/auilh1D1MZ1+ + Z6bGTpbRz3MmIWjmhXbJ6HLHGTjk4XP41pSJlie+MfhTLS3eESPI25mJPT/Pp+tSkjk1sjOpLmldEcPM + 3pgjFWy2T3xWPeSm2vLLAkKyzBG2jPUjH0GcVsdDmnG/UmcWrPuPzxUbHn+dSdqjIJJ54qjMhcjPNVpw + Oc84FWWA5NV5cHdzz0pDOeu9xchR0P4VlNFJ8x/iroJejk8EGsiRi0rqAcEVlJFIhjVbuJkfhlX8R71z + epRh+CPnUkHjvXQROUlOOx78Vnatbkj7QvQsVI/r+tZSVxo4u/sVdGA/iU964NbxmjYOTuBKMB3Ir0+e + MeWeOleb39kI9ZljDBFeQHc3IG7B6d+tRFLqXdkcmWVcYwcjtxTQVKMpwcc/jUjoiu0YYsucAkc8d6iU + FJGVsbs5FCLZYi4AOMc56VbCnYpwef8AA1WhXnpn6VpspC5BHyRsx/8AQf61lJ6msVoQaeMkjOMgZ+ma + 2dC3Jby47v6j0rP0iDzZ1UjhiAM89619Lhwsoxj5gcAe1S3qN7H0eO2Tz7DrRjvSDOKMV6hwDgcnj09K + E5LDPIpAfaq8W4XMshzgsFH0A/xJoZSVx1zNFb+XGWClshQe+BmqkVw0lxMhGQrAqcY4/rj+tR62nmQo + +MqHUfdzjkc/pUdhOZrOKXbIufuiTAbGeM/hiod7m0YL2fMNm+2LrMJRBLasAGBxlGBHPr61unnFZbuR + yASR0x3rSU5GaqL1aIqO6WmxLUMufepF6Z9aZJwKoxK5zg1XkYhSPyqzn8SaqzHbkdqRRnXEnySZAwe9 + YjuEkyelbM/KZ/OsqdQGOB1FZsZFawGZ3bb8vb3qC/gZrSRM8Ek1pW7YjO0YwOTntVCcs8ZIb8KTQHH3 + S/uX4w2MHiuI8RxkXNv6bc1292SYZOM5Pp71zfiKHalrLj5iSB7njFct7GkTlbmPe7EdzkGkMZb1JUbg + farjwmKSRHGdoyRnkHj+tKYiIPvhGByAecj3xS5ma8o5I93lN2bHWrL5FtM2c7sJ+v8Ajmm28eUKnOUY + EE1PJHi2gUgfMd3A6dayvqaou6DATfxg9hnH0zW3pNq/nXaBsFWUHOfSqfh2H/idCMc9RnP1raybTV9Q + GB87Kwz6Y/8Ar00tLik9bHtope9IKU9K9Q4Qqr5mCynpuNWfYVn3ksdnBcTtnC/MfrjFJsqKu7EsmJIm + R+V4NVgqoSVH3hjPTgdBTI72OVYnQllkUkEDOP8ACpsgjrwahNM0s46MawwP8avwvuiX16Gse5+0BMRF + ev8AFUlndTLqCwSLiORTt+U53Dn/ABoUrPUbg3G6N1fu0xx69KcpwopkhJGAfrWpz9SFj+FU5+4FWWJz + 1qrKTycAAUhlCf8A1Y/xrJueuM81qTckZJ96zXQ7ue5NZsYkRItiB1x+NZcswt5GB6EVpOxWEnJyT3Nc + 9qMymMljgDqaibsgWpl3W0xdsu3AqKbTWv5baOOMFkJbcRwgxyTVdJzc3W7PyrwoqTVtcm0qza3skL3l + yuEAXdtAzyR+P6VgrW1NFvocu9h9o1qazhYsGuRCp7kBjk/qKgfTzGbhCSfJmaHdnqwJH8hXQ+HtMuza + SSCNxLIcSXD8GJVOWC+rEg5qDU7WG31G6trcYiaUMozk9MfzzUy2ubRMMKYr0oThWQH9MVpCLdBEWGSv + BPrxVa7gbzt+04b7px/DmtDRR9pLQyH5kbrn06Vi2amlo+LfWIJCNoaTaQexI4/rXS6ro0moTrPAwU42 + tlsZx0/maxFs5Ed0lTKqBuZeoBGVYe4xn866S0m1CKEAwidf4ZEOQ3vWsLWs0Yz3umemilHWiivQOUbW + Tq/NtID081OP+BrRRQ9mbUP4kfVGT4XYnRWBJIDkAela8f8AWiiojsjoxP8AGn6j+5FVpTi+sT380j9D + RRSZlHf7/wAjoEpGA44oorU5epWfoarScoKKKGMypeZfwqBwN68f55oorPoUyldfcP0rjNeJ+xdf4xRR + Wc9gjuZmm9K7Tw/DE6ySNEjOMAMVBOOO9FFREplXUXaPSLgIxUebKMKcfxGuPuAP7UueBwox7c0UVjV3 + NqZHrihbkAAACMAADoMCnaKB/aswx/nBoorKW5s/hO2UD7Xa8D5rdgffBFLpp2y3SLwisMKOgoorZ7I5 + 3sf/2Q== + + + \ No newline at end of file diff --git a/Chapter11/PictureBoxEx/Images/Shaina.jpg b/Chapter11/PictureBoxEx/Images/Shaina.jpg new file mode 100644 index 0000000..cc90902 Binary files /dev/null and b/Chapter11/PictureBoxEx/Images/Shaina.jpg differ diff --git a/Chapter11/PictureBoxEx/PictureBoxEx.cpp b/Chapter11/PictureBoxEx/PictureBoxEx.cpp new file mode 100644 index 0000000..87edaf4 --- /dev/null +++ b/Chapter11/PictureBoxEx/PictureBoxEx.cpp @@ -0,0 +1,18 @@ +// PictureBoxEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace PictureBoxEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/PictureBoxEx/PictureBoxEx.vcproj b/Chapter11/PictureBoxEx/PictureBoxEx.vcproj new file mode 100644 index 0000000..7691467 --- /dev/null +++ b/Chapter11/PictureBoxEx/PictureBoxEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/PictureBoxEx/ReadMe.txt b/Chapter11/PictureBoxEx/ReadMe.txt new file mode 100644 index 0000000..1ac3c0b --- /dev/null +++ b/Chapter11/PictureBoxEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : PictureBoxEx Project Overview +======================================================================== + +AppWizard has created this PictureBoxEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your PictureBoxEx application. + +PictureBoxEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +PictureBoxEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named PictureBoxEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/PictureBoxEx/app.ico b/Chapter11/PictureBoxEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/PictureBoxEx/app.ico differ diff --git a/Chapter11/PictureBoxEx/app.rc b/Chapter11/PictureBoxEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/PictureBoxEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/PictureBoxEx/resource.h b/Chapter11/PictureBoxEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/PictureBoxEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/PictureBoxEx/stdafx.cpp b/Chapter11/PictureBoxEx/stdafx.cpp new file mode 100644 index 0000000..e621c7a --- /dev/null +++ b/Chapter11/PictureBoxEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// PictureBoxEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/PictureBoxEx/stdafx.h b/Chapter11/PictureBoxEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/PictureBoxEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/SimpleMenu/AssemblyInfo.cpp b/Chapter11/SimpleMenu/AssemblyInfo.cpp new file mode 100644 index 0000000..428cddd --- /dev/null +++ b/Chapter11/SimpleMenu/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("SimpleMenu")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("SimpleMenu")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/SimpleMenu/Form1.h b/Chapter11/SimpleMenu/Form1.h new file mode 100644 index 0000000..5220559 --- /dev/null +++ b/Chapter11/SimpleMenu/Form1.h @@ -0,0 +1,255 @@ +#pragma once + + +namespace SimpleMenu { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::ToolStripContainer^ toolStripContainer1; + System::Windows::Forms::MenuStrip^ mainMenuStrip; + System::Windows::Forms::ToolStripMenuItem^ miFile; + System::Windows::Forms::ToolStripMenuItem^ miFileSub; + System::Windows::Forms::ToolStripComboBox^ miFileSubThis; + System::Windows::Forms::ToolStripMenuItem^ miFileExit; + System::Windows::Forms::ToolStripMenuItem^ miFileSubCheck; + System::Windows::Forms::ToolStripMenuItem^ miFileSubImage; + System::Windows::Forms::ToolStripMenuItem^ miFileSubSayBoo; + System::Windows::Forms::ToolStripMenuItem^ miHelp; + System::Windows::Forms::ToolStripMenuItem^ miHelpAbout; + System::Windows::Forms::ToolStripSeparator^ miFileSep1; + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + System::ComponentModel::ComponentResourceManager^ resources = + (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); + this->toolStripContainer1 = + (gcnew System::Windows::Forms::ToolStripContainer()); + this->mainMenuStrip = (gcnew System::Windows::Forms::MenuStrip()); + this->miFile = (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->miFileSub = + (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->miFileSubThis = + (gcnew System::Windows::Forms::ToolStripComboBox()); + this->miFileSubCheck = + (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->miFileSubImage = + (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->miFileSubSayBoo = + (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->miFileSep1 = + (gcnew System::Windows::Forms::ToolStripSeparator()); + this->miFileExit = + (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->miHelp = + (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->miHelpAbout = + (gcnew System::Windows::Forms::ToolStripMenuItem()); + this->toolStripContainer1->TopToolStripPanel->SuspendLayout(); + + this->toolStripContainer1->SuspendLayout(); + this->mainMenuStrip->SuspendLayout(); + this->SuspendLayout(); + // + // toolStripContainer1 + // + // toolStripContainer1.ContentPanel + // + this->toolStripContainer1->ContentPanel->Size = + System::Drawing::Size(292, 249); + this->toolStripContainer1->Dock = + System::Windows::Forms::DockStyle::Fill; + this->toolStripContainer1->Location = System::Drawing::Point(0, 0); + this->toolStripContainer1->Name = L"toolStripContainer1"; + this->toolStripContainer1->Size = System::Drawing::Size(292, 273); + this->toolStripContainer1->TabIndex = 0; + this->toolStripContainer1->Text = L"toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this->toolStripContainer1->TopToolStripPanel->Controls->Add( + this->mainMenuStrip); + // + // mainMenuStrip + // + this->mainMenuStrip->Dock =System::Windows::Forms::DockStyle::None; + this->mainMenuStrip->Items->AddRange( + gcnew cli::array< System::Windows::Forms::ToolStripItem^>(2) + {this->miFile, this->miHelp}); + this->mainMenuStrip->Location = System::Drawing::Point(0, 0); + this->mainMenuStrip->Name = L"mainMenuStrip"; + this->mainMenuStrip->Size = System::Drawing::Size(292, 24); + this->mainMenuStrip->TabIndex = 0; + this->mainMenuStrip->Text = L"menuStrip1"; + // + // miFile + // + this->miFile->DropDownItems->AddRange( + gcnew cli::array< System::Windows::Forms::ToolStripItem^>(3) + {this->miFileSub, this->miFileSep1, this->miFileExit}); + this->miFile->Name = L"miFile"; + this->miFile->Size = System::Drawing::Size(35, 20); + this->miFile->Text = L"&File"; + // + // miFileSub + // + this->miFileSub->DropDownItems->AddRange( + gcnew cli::array< System::Windows::Forms::ToolStripItem^>(4) + {this->miFileSubThis, this->miFileSubCheck, + this->miFileSubImage, this->miFileSubSayBoo}); + this->miFileSub->Name = L"miFileSub"; + this->miFileSub->Size = System::Drawing::Size(152, 22); + this->miFileSub->Text = L"&Sub"; + // + // miFileSubThis + // + this->miFileSubThis->Items->AddRange( + gcnew cli::array< System::Object^>(3) + {L"This", L"That", L"Other Thing"}); + this->miFileSubThis->Name = L"miFileSubThis"; + this->miFileSubThis->Size = System::Drawing::Size(121, 21); + // + // miFileSubCheck + // + this->miFileSubCheck->Checked = true; + this->miFileSubCheck->CheckOnClick = true; + this->miFileSubCheck->CheckState = + System::Windows::Forms::CheckState::Checked; + this->miFileSubCheck->Name = L"miFileSubCheck"; + this->miFileSubCheck->Size = System::Drawing::Size(181, 22); + this->miFileSubCheck->Text = L"Check Me"; + // + // miFileSubImage + // + this->miFileSubImage->Image = + (cli::safe_cast + (resources->GetObject(L"miFileSubImage.Image"))); + this->miFileSubImage->Name = L"miFileSubImage"; + this->miFileSubImage->Size = System::Drawing::Size(181, 22); + this->miFileSubImage->Text = L"I have an image"; + // + // miFileSubSayBoo + // + this->miFileSubSayBoo->Name = L"miFileSubSayBoo"; + this->miFileSubSayBoo->ShortcutKeys = + static_cast + ((System::Windows::Forms::Keys::Control | + System::Windows::Forms::Keys::S)); + this->miFileSubSayBoo->Size = System::Drawing::Size(181, 22); + this->miFileSubSayBoo->Text = L"Say Boo"; + this->miFileSubSayBoo->Click += + gcnew System::EventHandler(this,&Form1::miFileSubSayBoo_Click); + // + // miFileSep1 + // + this->miFileSep1->Name = L"miFileSep1"; + this->miFileSep1->Size = System::Drawing::Size(149, 6); + // + // miFileExit + // + this->miFileExit->Name = L"miFileExit"; + this->miFileExit->Size = System::Drawing::Size(152, 22); + this->miFileExit->Text = L"E&xit"; + this->miFileExit->Click += + gcnew System::EventHandler(this, &Form1::miFileExit_Click); + // + // miHelp + // + this->miHelp->DropDownItems->AddRange( + gcnew cli::array< System::Windows::Forms::ToolStripItem^>(1) + {this->miHelpAbout}); + this->miHelp->Name = L"miHelp"; + this->miHelp->Size = System::Drawing::Size(40, 20); + this->miHelp->Text = L"&Help"; + // + // miHelpAbout + // + this->miHelpAbout->Name = L"miHelpAbout"; + this->miHelpAbout->Size = System::Drawing::Size(152, 22); + this->miHelpAbout->Text = L"About"; + this->miHelpAbout->Click += + gcnew System::EventHandler(this, &Form1::miHelpAbout_Click); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Controls->Add(this->toolStripContainer1); + this->MainMenuStrip = this->mainMenuStrip; + this->Name = L"Form1"; + this->Text = L"Simple Menu"; + this->toolStripContainer1->TopToolStripPanel->ResumeLayout(false); + this->toolStripContainer1->TopToolStripPanel->PerformLayout(); + this->toolStripContainer1->ResumeLayout(false); + this->toolStripContainer1->PerformLayout(); + this->mainMenuStrip->ResumeLayout(false); + this->mainMenuStrip->PerformLayout(); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void miFileExit_Click(System::Object^ sender, System::EventArgs^ e) + { + Application::Exit(); + } + + System::Void miHelpAbout_Click(System::Object^ sender, System::EventArgs^ e) + { + MessageBox::Show("Simple Menu v.1.0.0.0"); + } + + System::Void miFileSubSayBoo_Click(System::Object^ sender, System::EventArgs^ e) + { + MessageBox::Show("BOO"); + } + }; +} + diff --git a/Chapter11/SimpleMenu/Form1.resx b/Chapter11/SimpleMenu/Form1.resx new file mode 100644 index 0000000..7a3d2a2 --- /dev/null +++ b/Chapter11/SimpleMenu/Form1.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAaxJREFUOE+1lL9K + A0EQxvMKeRCxOAULLSwEFSxECYhgwIiCFiK22ogPYCPYWoiCnWBQJFgosTkwIIIBUxiNaNRA/t1tUPJ5 + 35x7ieYSouDBcMPuzG9nZmc2EPjvb3+tC37S9rnauaqeUclswU5GUDL7UbzoRSFmePCWQEKqlTze8zGU + bidh3U3Ayky54ujl5KgLjbpAX1g9hE72ywxUYcETOzcna9wrJQaRPej0hwnISaf8EAGdVGWZJ0LZSzXd + WeOewJzIGqLSENaEaRBCMQyzUXeitNNhiaohRYKQSkEdT0Odh2A/zgvANOGBPD09KzbW0VATUDwOa7MP + ancYuauQyNPJAK63DRHqXFOJMN72xsW2vNP9PT2JyAHRILvR40bk1Ia3Vy+6XpnVDrH1BX3cHCIRCYJG + LLh20vXSf+7Rhra+NVLJFaj7dUnjcjEoaTAyucWvP9e4p9P0bQGmJ53sONGQp9KpXrjGvabXzw4lqHg2 + JjC2gC42a0HRUbDjefWMvGV3v56OgGlyHJqNSEuInhs9tBxQDio7WA9tNlp7EX79Cvx8StoG/NXwE+Dm + Ywl9vdyhAAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/Chapter11/SimpleMenu/ReadMe.txt b/Chapter11/SimpleMenu/ReadMe.txt new file mode 100644 index 0000000..746d2ae --- /dev/null +++ b/Chapter11/SimpleMenu/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : SimpleMenu Project Overview +======================================================================== + +AppWizard has created this SimpleMenu Application for you. + +This file contains a summary of what you will find in each of the files that +make up your SimpleMenu application. + +SimpleMenu.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +SimpleMenu.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named SimpleMenu.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/SimpleMenu/SimpleMenu.cpp b/Chapter11/SimpleMenu/SimpleMenu.cpp new file mode 100644 index 0000000..d3ff515 --- /dev/null +++ b/Chapter11/SimpleMenu/SimpleMenu.cpp @@ -0,0 +1,18 @@ +// SimpleMenu.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace SimpleMenu; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/SimpleMenu/SimpleMenu.vcproj b/Chapter11/SimpleMenu/SimpleMenu.vcproj new file mode 100644 index 0000000..17e477a --- /dev/null +++ b/Chapter11/SimpleMenu/SimpleMenu.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/SimpleMenu/app.ico b/Chapter11/SimpleMenu/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/SimpleMenu/app.ico differ diff --git a/Chapter11/SimpleMenu/app.rc b/Chapter11/SimpleMenu/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/SimpleMenu/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/SimpleMenu/resource.h b/Chapter11/SimpleMenu/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/SimpleMenu/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/SimpleMenu/stdafx.cpp b/Chapter11/SimpleMenu/stdafx.cpp new file mode 100644 index 0000000..9c9e11a --- /dev/null +++ b/Chapter11/SimpleMenu/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// SimpleMenu.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/SimpleMenu/stdafx.h b/Chapter11/SimpleMenu/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/SimpleMenu/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/SplitContainerEx/AssemblyInfo.cpp b/Chapter11/SplitContainerEx/AssemblyInfo.cpp new file mode 100644 index 0000000..f13b50e --- /dev/null +++ b/Chapter11/SplitContainerEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("SplitContainerEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("SplitContainerEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/SplitContainerEx/Form1.h b/Chapter11/SplitContainerEx/Form1.h new file mode 100644 index 0000000..8ee04ae --- /dev/null +++ b/Chapter11/SplitContainerEx/Form1.h @@ -0,0 +1,180 @@ +#pragma once + + +namespace SplitContainerEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::SplitContainer^ splitContainer1; + System::Windows::Forms::TextBox^ textBox1; + System::Windows::Forms::SplitContainer^ splitContainer2; + System::Windows::Forms::TextBox^ textBox2; + System::Windows::Forms::TextBox^ textBox3; + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->splitContainer1 = + (gcnew System::Windows::Forms::SplitContainer()); + this->textBox1 = (gcnew System::Windows::Forms::TextBox()); + this->splitContainer2 = + (gcnew System::Windows::Forms::SplitContainer()); + this->textBox2 = (gcnew System::Windows::Forms::TextBox()); + this->textBox3 = (gcnew System::Windows::Forms::TextBox()); + this->splitContainer1->Panel1->SuspendLayout(); + this->splitContainer1->Panel2->SuspendLayout(); + this->splitContainer1->SuspendLayout(); + this->splitContainer2->Panel1->SuspendLayout(); + this->splitContainer2->Panel2->SuspendLayout(); + this->splitContainer2->SuspendLayout(); + this->SuspendLayout(); + // + // splitContainer1 + // + this->splitContainer1->BackColor = System::Drawing::Color::Green; + this->splitContainer1->Dock = + System::Windows::Forms::DockStyle::Fill; + this->splitContainer1->Location = System::Drawing::Point(0, 0); + this->splitContainer1->Name = L"splitContainer1"; + // + // splitContainer1.Panel1 + // + this->splitContainer1->Panel1->Controls->Add(this->textBox1); + // + // splitContainer1.Panel2 + // + this->splitContainer1->Panel2->Controls->Add(this->splitContainer2); + this->splitContainer1->Size = System::Drawing::Size(292, 273); + this->splitContainer1->SplitterDistance = 116; + this->splitContainer1->TabIndex = 1; + this->splitContainer1->Text = L"splitContainer1"; + // + // textBox1 + // + this->textBox1->AutoSize = false; + this->textBox1->BorderStyle = + System::Windows::Forms::BorderStyle::None; + this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill; + this->textBox1->Location = System::Drawing::Point(0, 0); + this->textBox1->Name = L"textBox1"; + this->textBox1->Size = System::Drawing::Size(116, 273); + this->textBox1->TabIndex = 0; + this->textBox1->Text = L"Left Textbox"; + this->textBox1->TextAlign = + System::Windows::Forms::HorizontalAlignment::Center; + + // + // splitContainer2 + // + this->splitContainer2->BackColor = System::Drawing::Color::Red; + this->splitContainer2->Location = System::Drawing::Point(18, 82); + this->splitContainer2->Name = L"splitContainer2"; + this->splitContainer2->Orientation = + System::Windows::Forms::Orientation::Horizontal; + // + // splitContainer2.Panel1 + // + this->splitContainer2->Panel1->Controls->Add(this->textBox2); + // + // splitContainer2.Panel2 + // + this->splitContainer2->Panel2->Controls->Add(this->textBox3); + this->splitContainer2->Size = System::Drawing::Size(132, 102); + this->splitContainer2->SplitterDistance = 42; + this->splitContainer2->TabIndex = 0; + this->splitContainer2->Text = L"splitContainer2"; + // + // textBox2 + // + this->textBox2->AutoSize = false; + this->textBox2->BorderStyle = + System::Windows::Forms::BorderStyle::None; + this->textBox2->Dock = System::Windows::Forms::DockStyle::Fill; + this->textBox2->Location = System::Drawing::Point(0, 0); + this->textBox2->Name = L"textBox2"; + this->textBox2->Size = System::Drawing::Size(132, 42); + this->textBox2->TabIndex = 0; + this->textBox2->Text = L"Top Right Textbox"; + this->textBox2->TextAlign = + System::Windows::Forms::HorizontalAlignment::Center; + // + // textBox3 + // + this->textBox3->AutoSize = false; + this->textBox3->BorderStyle = + System::Windows::Forms::BorderStyle::None; + this->textBox3->Dock = System::Windows::Forms::DockStyle::Fill; + this->textBox3->Location = System::Drawing::Point(0, 0); + this->textBox3->Name = L"textBox3"; + this->textBox3->Size = System::Drawing::Size(132, 56); + this->textBox3->TabIndex = 0; + this->textBox3->Text = L"Bottom Right Textbox"; + this->textBox3->TextAlign = + System::Windows::Forms::HorizontalAlignment::Center; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Controls->Add(this->splitContainer1); + this->Name = L"Form1"; + this->Text = L"Form1"; + this->splitContainer1->Panel1->ResumeLayout(false); + this->splitContainer1->Panel2->ResumeLayout(false); + this->splitContainer1->ResumeLayout(false); + this->splitContainer2->Panel1->ResumeLayout(false); + this->splitContainer2->Panel2->ResumeLayout(false); + this->splitContainer2->ResumeLayout(false); + this->ResumeLayout(false); + } +#pragma endregion + }; +} + diff --git a/Chapter11/SplitContainerEx/Form1.resX b/Chapter11/SplitContainerEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter11/SplitContainerEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter11/SplitContainerEx/ReadMe.txt b/Chapter11/SplitContainerEx/ReadMe.txt new file mode 100644 index 0000000..c06f625 --- /dev/null +++ b/Chapter11/SplitContainerEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : SplitContainerEx Project Overview +======================================================================== + +AppWizard has created this SplitContainerEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your SplitContainerEx application. + +SplitContainerEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +SplitContainerEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named SplitContainerEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/SplitContainerEx/SplitContainerEx.cpp b/Chapter11/SplitContainerEx/SplitContainerEx.cpp new file mode 100644 index 0000000..f7b6e86 --- /dev/null +++ b/Chapter11/SplitContainerEx/SplitContainerEx.cpp @@ -0,0 +1,18 @@ +// SplitContainerEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace SplitContainerEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/SplitContainerEx/SplitContainerEx.vcproj b/Chapter11/SplitContainerEx/SplitContainerEx.vcproj new file mode 100644 index 0000000..7e2b763 --- /dev/null +++ b/Chapter11/SplitContainerEx/SplitContainerEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/SplitContainerEx/app.ico b/Chapter11/SplitContainerEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/SplitContainerEx/app.ico differ diff --git a/Chapter11/SplitContainerEx/app.rc b/Chapter11/SplitContainerEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/SplitContainerEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/SplitContainerEx/resource.h b/Chapter11/SplitContainerEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/SplitContainerEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/SplitContainerEx/stdafx.cpp b/Chapter11/SplitContainerEx/stdafx.cpp new file mode 100644 index 0000000..f46cce8 --- /dev/null +++ b/Chapter11/SplitContainerEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// SplitContainerEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/SplitContainerEx/stdafx.h b/Chapter11/SplitContainerEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/SplitContainerEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/StatusStripEx/AssemblyInfo.cpp b/Chapter11/StatusStripEx/AssemblyInfo.cpp new file mode 100644 index 0000000..b06322c --- /dev/null +++ b/Chapter11/StatusStripEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("StatusStripEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("StatusStripEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/StatusStripEx/Form1.h b/Chapter11/StatusStripEx/Form1.h new file mode 100644 index 0000000..01a8497 --- /dev/null +++ b/Chapter11/StatusStripEx/Form1.h @@ -0,0 +1,193 @@ +#pragma once + + +namespace StatusStripEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::ToolStripContainer^ tsContainer; + System::Windows::Forms::StatusStrip^ statusStrip1; + System::Windows::Forms::ToolStripStatusLabel^ statusButtons; + System::Windows::Forms::ToolStripStatusLabel^ statusXCoord; + System::Windows::Forms::ToolStripStatusLabel^ statusYCoord; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->tsContainer = + (gcnew System::Windows::Forms::ToolStripContainer()); + this->statusStrip1 = + (gcnew System::Windows::Forms::StatusStrip()); + this->statusButtons = + (gcnew System::Windows::Forms::ToolStripStatusLabel()); + this->statusXCoord = + (gcnew System::Windows::Forms::ToolStripStatusLabel()); + this->statusYCoord = + (gcnew System::Windows::Forms::ToolStripStatusLabel()); + this->tsContainer->BottomToolStripPanel->SuspendLayout(); + this->tsContainer->SuspendLayout(); + this->statusStrip1->SuspendLayout(); + this->SuspendLayout(); + // + // tsContainer + // + // + // tsContainer.BottomToolStripPanel + // + this->tsContainer->BottomToolStripPanel->Controls->Add( + this->statusStrip1); + // + // tsContainer.ContentPanel + // + this->tsContainer->ContentPanel->Size = + System::Drawing::Size(292, 251); + this->tsContainer->ContentPanel->MouseDown += + gcnew System::Windows::Forms::MouseEventHandler(this, + &Form1::tsContainer_ContentPanel_MouseDown); + + this->tsContainer->ContentPanel->MouseMove += + gcnew System::Windows::Forms::MouseEventHandler(this, + &Form1::tsContainer1_ContentPanel_MouseMove); + this->tsContainer->Dock = System::Windows::Forms::DockStyle::Fill; + this->tsContainer->Location = System::Drawing::Point(0, 0); + this->tsContainer->Name = L"tsContainer"; + this->tsContainer->Size = System::Drawing::Size(292, 273); + this->tsContainer->TabIndex = 0; + this->tsContainer->Text = L"toolStripContainer1"; + // + // statusStrip1 + // + this->statusStrip1->Dock = System::Windows::Forms::DockStyle::None; + this->statusStrip1->Items->AddRange( + gcnew cli::array< System::Windows::Forms::ToolStripItem^>(3) + {this->statusButtons, this->statusXCoord, this->statusYCoord}); + this->statusStrip1->Location = System::Drawing::Point(0, 0); + this->statusStrip1->Name = L"statusStrip1"; + this->statusStrip1->Size = System::Drawing::Size(292, 22); + this->statusStrip1->TabIndex = 0; + // + // statusButtons + // + this->statusButtons->Name = L"statusButtons"; + this->statusButtons->Size = System::Drawing::Size(177, 17); + this->statusButtons->Spring = true; + this->statusButtons->TextAlign = + System::Drawing::ContentAlignment::MiddleLeft; + // + // statusXCoord + // + this->statusXCoord->AutoSize = false; + this->statusXCoord->BorderSides = + static_cast + ((((System::Windows::Forms::ToolStripStatusLabelBorderSides::Left + | System::Windows::Forms::ToolStripStatusLabelBorderSides::Top) + | System::Windows::Forms::ToolStripStatusLabelBorderSides::Right) + | System::Windows::Forms::ToolStripStatusLabelBorderSides::Bottom)); + this->statusXCoord->BorderStyle = + System::Windows::Forms::Border3DStyle::Sunken; + this->statusXCoord->Name = L"statusXCoord"; + this->statusXCoord->Size = System::Drawing::Size(50, 17); + // + // statusYCoord + // + this->statusYCoord->AutoSize = false; + this->statusYCoord->BorderSides = + static_cast + ((((System::Windows::Forms::ToolStripStatusLabelBorderSides::Left + | System::Windows::Forms::ToolStripStatusLabelBorderSides::Top) + | System::Windows::Forms::ToolStripStatusLabelBorderSides::Right) + | System::Windows::Forms::ToolStripStatusLabelBorderSides::Bottom)); + + this->statusYCoord->BorderStyle = + System::Windows::Forms::Border3DStyle::Sunken; + this->statusYCoord->Name = L"statusYCoord"; + this->statusYCoord->Size = System::Drawing::Size(50, 17); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Controls->Add(this->tsContainer); + this->Name = L"Form1"; + this->Text = L"Status Strip Mouse Tracking"; + this->tsContainer->BottomToolStripPanel->ResumeLayout(false); + this->tsContainer->BottomToolStripPanel->PerformLayout(); + this->tsContainer->ResumeLayout(false); + this->tsContainer->PerformLayout(); + this->statusStrip1->ResumeLayout(false); + this->statusStrip1->PerformLayout(); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void tsContainer_ContentPanel_MouseDown(System::Object^ sender, + System::Windows::Forms::MouseEventArgs^ e) + { + // clicked mouse button in first status bar panel + if (e->Button == System::Windows::Forms::MouseButtons::Right) + statusButtons->Text = "Right"; + else if (e->Button == System::Windows::Forms::MouseButtons::Left) + statusButtons->Text = "Left"; + else + statusButtons->Text = "Middle"; + } + + System::Void tsContainer1_ContentPanel_MouseMove(System::Object^ sender, + System::Windows::Forms::MouseEventArgs^ e) + { + // x,y coords in second and third status bar panels + statusXCoord->Text = String::Format("X={0}", e->X); + statusYCoord->Text = String::Format("Y={0}", e->Y); + } + }; +} + diff --git a/Chapter11/StatusStripEx/Form1.resX b/Chapter11/StatusStripEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter11/StatusStripEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter11/StatusStripEx/ReadMe.txt b/Chapter11/StatusStripEx/ReadMe.txt new file mode 100644 index 0000000..65a8c95 --- /dev/null +++ b/Chapter11/StatusStripEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : StatusStripEx Project Overview +======================================================================== + +AppWizard has created this StatusStripEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your StatusStripEx application. + +StatusStripEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +StatusStripEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named StatusStripEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/StatusStripEx/StatusStripEx.cpp b/Chapter11/StatusStripEx/StatusStripEx.cpp new file mode 100644 index 0000000..836432d --- /dev/null +++ b/Chapter11/StatusStripEx/StatusStripEx.cpp @@ -0,0 +1,18 @@ +// StatusStripEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace StatusStripEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/StatusStripEx/StatusStripEx.vcproj b/Chapter11/StatusStripEx/StatusStripEx.vcproj new file mode 100644 index 0000000..1b4b2e2 --- /dev/null +++ b/Chapter11/StatusStripEx/StatusStripEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/StatusStripEx/app.ico b/Chapter11/StatusStripEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/StatusStripEx/app.ico differ diff --git a/Chapter11/StatusStripEx/app.rc b/Chapter11/StatusStripEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/StatusStripEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/StatusStripEx/resource.h b/Chapter11/StatusStripEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/StatusStripEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/StatusStripEx/stdafx.cpp b/Chapter11/StatusStripEx/stdafx.cpp new file mode 100644 index 0000000..7e36619 --- /dev/null +++ b/Chapter11/StatusStripEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// StatusStripEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/StatusStripEx/stdafx.h b/Chapter11/StatusStripEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/StatusStripEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/TabControlEx/AssemblyInfo.cpp b/Chapter11/TabControlEx/AssemblyInfo.cpp new file mode 100644 index 0000000..8324c90 --- /dev/null +++ b/Chapter11/TabControlEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("TabControlEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("TabControlEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/TabControlEx/Form1.h b/Chapter11/TabControlEx/Form1.h new file mode 100644 index 0000000..7189f15 --- /dev/null +++ b/Chapter11/TabControlEx/Form1.h @@ -0,0 +1,151 @@ +#pragma once + + +namespace TabControlEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::TabControl^ tabControl1; + System::Windows::Forms::TabPage^ tabPage1; + System::Windows::Forms::Label^ label2; + System::Windows::Forms::TabPage^ tabPage2; + System::Windows::Forms::Label^ label1; + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->tabControl1 = (gcnew System::Windows::Forms::TabControl()); + this->tabPage1 = (gcnew System::Windows::Forms::TabPage()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->tabPage2 = (gcnew System::Windows::Forms::TabPage()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->tabControl1->SuspendLayout(); + this->tabPage1->SuspendLayout(); + this->tabPage2->SuspendLayout(); + this->SuspendLayout(); + // + // tabControl1 + // + this->tabControl1->Alignment = + System::Windows::Forms::TabAlignment::Bottom; + this->tabControl1->Controls->Add(this->tabPage1); + this->tabControl1->Controls->Add(this->tabPage2); + this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill; + this->tabControl1->HotTrack = true; + this->tabControl1->Location = System::Drawing::Point(0, 0); + this->tabControl1->Multiline = true; + this->tabControl1->Name = L"tabControl1"; + this->tabControl1->SelectedIndex = 0; + this->tabControl1->ShowToolTips = true; + this->tabControl1->Size = System::Drawing::Size(215, 129); + this->tabControl1->TabIndex = 1; + // + // tabPage1 + // + this->tabPage1->BackColor = System::Drawing::Color::PaleGreen; + this->tabPage1->Controls->Add(this->label2); + this->tabPage1->Location = System::Drawing::Point(4, 4); + this->tabPage1->Name = L"tabPage1"; + this->tabPage1->Padding = System::Windows::Forms::Padding(3); + this->tabPage1->Size = System::Drawing::Size(207, 103); + this->tabPage1->TabIndex = 0; + this->tabPage1->Text = L"Tab One"; + this->tabPage1->ToolTipText = L"This is tab one"; + this->tabPage1->UseVisualStyleBackColor = false; + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Location = System::Drawing::Point(61, 44); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(78, 13); + this->label2->TabIndex = 1; + this->label2->Text = L"This is Tab One"; + // + // tabPage2 + // + this->tabPage2->BackColor = System::Drawing::Color::Plum; + this->tabPage2->Controls->Add(this->label1); + this->tabPage2->Location = System::Drawing::Point(4, 4); + this->tabPage2->Name = L"tabPage2"; + this->tabPage2->Padding = System::Windows::Forms::Padding(3); + this->tabPage2->Size = System::Drawing::Size(207, 103); + this->tabPage2->TabIndex = 1; + this->tabPage2->Text = L"Tab Two"; + this->tabPage2->ToolTipText = L"This is tab two"; + this->tabPage2->UseVisualStyleBackColor = false; + // + // label1 + // + this->label1->AutoSize = true; + this->label1->Location = System::Drawing::Point(61, 44); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(79, 13); + this->label1->TabIndex = 0; + this->label1->Text = L"This is Tab Two"; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(215, 129); + this->Controls->Add(this->tabControl1); + this->Name = L"Form1"; + this->Text = L"Tab Control Example"; + this->tabControl1->ResumeLayout(false); + this->tabPage1->ResumeLayout(false); + this->tabPage1->PerformLayout(); + this->tabPage2->ResumeLayout(false); + this->tabPage2->PerformLayout(); + this->ResumeLayout(false); + } +#pragma endregion + }; +} + diff --git a/Chapter11/TabControlEx/Form1.resX b/Chapter11/TabControlEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter11/TabControlEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter11/TabControlEx/ReadMe.txt b/Chapter11/TabControlEx/ReadMe.txt new file mode 100644 index 0000000..8210c14 --- /dev/null +++ b/Chapter11/TabControlEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : TabControlEx Project Overview +======================================================================== + +AppWizard has created this TabControlEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your TabControlEx application. + +TabControlEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +TabControlEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named TabControlEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/TabControlEx/TabControlEx.cpp b/Chapter11/TabControlEx/TabControlEx.cpp new file mode 100644 index 0000000..906c172 --- /dev/null +++ b/Chapter11/TabControlEx/TabControlEx.cpp @@ -0,0 +1,18 @@ +// TabControlEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace TabControlEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/TabControlEx/TabControlEx.vcproj b/Chapter11/TabControlEx/TabControlEx.vcproj new file mode 100644 index 0000000..9bdac27 --- /dev/null +++ b/Chapter11/TabControlEx/TabControlEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/TabControlEx/app.ico b/Chapter11/TabControlEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/TabControlEx/app.ico differ diff --git a/Chapter11/TabControlEx/app.rc b/Chapter11/TabControlEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/TabControlEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/TabControlEx/resource.h b/Chapter11/TabControlEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/TabControlEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/TabControlEx/stdafx.cpp b/Chapter11/TabControlEx/stdafx.cpp new file mode 100644 index 0000000..a391b4b --- /dev/null +++ b/Chapter11/TabControlEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// TabControlEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/TabControlEx/stdafx.h b/Chapter11/TabControlEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/TabControlEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/ToolStripEx/AssemblyInfo.cpp b/Chapter11/ToolStripEx/AssemblyInfo.cpp new file mode 100644 index 0000000..4199bcc --- /dev/null +++ b/Chapter11/ToolStripEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ToolStripEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ToolStripEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/ToolStripEx/Form1.h b/Chapter11/ToolStripEx/Form1.h new file mode 100644 index 0000000..f298397 --- /dev/null +++ b/Chapter11/ToolStripEx/Form1.h @@ -0,0 +1,182 @@ +#pragma once + + +namespace ToolStripEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + private: + System::Windows::Forms::Label^ lbOutput; + System::Windows::Forms::ToolStrip^ toolStrip; + System::Windows::Forms::ToolStripButton^ tsbnHappy; + System::Windows::Forms::ToolStripButton^ tsbnSad; + System::Windows::Forms::ToolStripContainer^ toolStripContainer1; + System::Windows::Forms::ToolStripSeparator^ Sep1; + System::Windows::Forms::ToolStripLabel^ Label; + System::Windows::Forms::ToolStripTextBox^ tstbName; + + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); + this->lbOutput = (gcnew System::Windows::Forms::Label()); + this->toolStripContainer1 = (gcnew System::Windows::Forms::ToolStripContainer()); + this->toolStrip = (gcnew System::Windows::Forms::ToolStrip()); + this->tsbnHappy = (gcnew System::Windows::Forms::ToolStripButton()); + this->tsbnSad = (gcnew System::Windows::Forms::ToolStripButton()); + this->Sep1 = (gcnew System::Windows::Forms::ToolStripSeparator()); + this->Label = (gcnew System::Windows::Forms::ToolStripLabel()); + this->tstbName = (gcnew System::Windows::Forms::ToolStripTextBox()); + this->toolStripContainer1->ContentPanel->SuspendLayout(); + this->toolStripContainer1->TopToolStripPanel->SuspendLayout(); + this->toolStripContainer1->SuspendLayout(); + this->toolStrip->SuspendLayout(); + this->SuspendLayout(); + // + // lbOutput + // + this->lbOutput->AutoSize = true; + this->lbOutput->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->lbOutput->Location = System::Drawing::Point(47, 42); + this->lbOutput->Name = L"lbOutput"; + this->lbOutput->Size = System::Drawing::Size(208, 13); + this->lbOutput->TabIndex = 7; + this->lbOutput->Text = L"Enter a name then click an emotion"; + // + // toolStripContainer1 + // + // + // toolStripContainer1.ContentPanel + // + this->toolStripContainer1->ContentPanel->Controls->Add(this->lbOutput); + this->toolStripContainer1->ContentPanel->Size = System::Drawing::Size(300, 104); + this->toolStripContainer1->Dock = System::Windows::Forms::DockStyle::Fill; + this->toolStripContainer1->Location = System::Drawing::Point(0, 0); + this->toolStripContainer1->Name = L"toolStripContainer1"; + this->toolStripContainer1->Size = System::Drawing::Size(300, 129); + this->toolStripContainer1->TabIndex = 8; + this->toolStripContainer1->Text = L"toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this->toolStripContainer1->TopToolStripPanel->Controls->Add(this->toolStrip); + // + // toolStrip + // + this->toolStrip->Dock = System::Windows::Forms::DockStyle::None; + this->toolStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {this->tsbnHappy, this->tsbnSad, + this->Sep1, this->Label, this->tstbName}); + this->toolStrip->Location = System::Drawing::Point(0, 0); + this->toolStrip->Name = L"toolStrip"; + this->toolStrip->Size = System::Drawing::Size(300, 25); + this->toolStrip->Stretch = true; + this->toolStrip->TabIndex = 6; + this->toolStrip->Text = L"toolStrip1"; + // + // tsbnHappy + // + this->tsbnHappy->Image = (cli::safe_cast(resources->GetObject(L"tsbnHappy.Image"))); + this->tsbnHappy->Name = L"tsbnHappy"; + this->tsbnHappy->Size = System::Drawing::Size(58, 22); + this->tsbnHappy->Text = L"Happy"; + this->tsbnHappy->ToolTipText = L"a happy camper"; + this->tsbnHappy->Click += gcnew System::EventHandler(this, &Form1::tsbn_Click); + // + // tsbnSad + // + this->tsbnSad->Image = (cli::safe_cast(resources->GetObject(L"tsbnSad.Image"))); + this->tsbnSad->Name = L"tsbnSad"; + this->tsbnSad->Size = System::Drawing::Size(46, 22); + this->tsbnSad->Text = L"Sad"; + this->tsbnSad->ToolTipText = L"major gloomy"; + this->tsbnSad->Click += gcnew System::EventHandler(this, &Form1::tsbn_Click); + // + // Sep1 + // + this->Sep1->Name = L"Sep1"; + this->Sep1->Size = System::Drawing::Size(6, 25); + // + // Label + // + this->Label->Name = L"Label"; + this->Label->Size = System::Drawing::Size(35, 22); + this->Label->Text = L"Name"; + // + // tstbName + // + this->tstbName->Name = L"tstbName"; + this->tstbName->Size = System::Drawing::Size(92, 25); + this->tstbName->Text = L"Computer"; + // + // Form1 + // + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Inherit; + this->ClientSize = System::Drawing::Size(300, 129); + this->Controls->Add(this->toolStripContainer1); + this->Name = L"Form1"; + this->Text = L"Emotional Tool Strip"; + this->toolStripContainer1->ContentPanel->ResumeLayout(false); + this->toolStripContainer1->ContentPanel->PerformLayout(); + this->toolStripContainer1->TopToolStripPanel->ResumeLayout(false); + this->toolStripContainer1->TopToolStripPanel->PerformLayout(); + this->toolStripContainer1->ResumeLayout(false); + this->toolStripContainer1->PerformLayout(); + this->toolStrip->ResumeLayout(false); + this->toolStrip->PerformLayout(); + this->ResumeLayout(false); + + } +#pragma endregion + + private: + System::Void tsbn_Click(System::Object^ sender, System::EventArgs^ e) + { + this->lbOutput->Text = String::Format("{0} is {1}!", + tstbName->Text, ((ToolStripButton^)sender)->ToolTipText); + } + }; +} + diff --git a/Chapter11/ToolStripEx/Form1.resx b/Chapter11/ToolStripEx/Form1.resx new file mode 100644 index 0000000..fd252dc --- /dev/null +++ b/Chapter11/ToolStripEx/Form1.resx @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAaxJREFUOE+1lL9K + A0EQxvMKeRCxOAULLSwEFSxECYhgwIiCFiK22ogPYCPYWoiCnWBQJFgosTkwIIIBUxiNaNRA/t1tUPJ5 + 35x7ieYSouDBcMPuzG9nZmc2EPjvb3+tC37S9rnauaqeUclswU5GUDL7UbzoRSFmePCWQEKqlTze8zGU + bidh3U3Ayky54ujl5KgLjbpAX1g9hE72ywxUYcETOzcna9wrJQaRPej0hwnISaf8EAGdVGWZJ0LZSzXd + WeOewJzIGqLSENaEaRBCMQyzUXeitNNhiaohRYKQSkEdT0Odh2A/zgvANOGBPD09KzbW0VATUDwOa7MP + ancYuauQyNPJAK63DRHqXFOJMN72xsW2vNP9PT2JyAHRILvR40bk1Ia3Vy+6XpnVDrH1BX3cHCIRCYJG + LLh20vXSf+7Rhra+NVLJFaj7dUnjcjEoaTAyucWvP9e4p9P0bQGmJ53sONGQp9KpXrjGvabXzw4lqHg2 + JjC2gC42a0HRUbDjefWMvGV3v56OgGlyHJqNSEuInhs9tBxQDio7WA9tNlp7EX79Cvx8StoG/NXwE+Dm + Ywl9vdyhAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAcxJREFUOE+1lDtL + A0EQx/M9BD+Chc8mKIKPRgIKgkFs1BCCCD46m4CFYGNjY2GT2sJCUCSomEYhARVMUEFQ8TReuCRnHreJ + 4rj/CRtyySkBcWFgb2b3t/OfnT2X67/HzmonOVnT56rNX+UkiedNKtzMUj7WT7kzN5nh9ir8VyAgVDZJ + C49QYqubDidbqahNsWEOH2LZ/TYGOsIU5MM85g1G/IJEbp6EOVcxOYcPsfzlEOl7Hc4wgCCnqPl4Mca0 + X4KsRTbMMRArPnopc+puBKlsykaIrNQsy3h4MajXv0GJiI+May/PMRCz9Bkq3I1Wa1aVyCA5xNsK6dEx + PvV+e5KedvtslljvIRjWpCKDlD+vy0qB0jEPaQcDFTmlZWdDTNYMa9PhLrs8BbKSARLvsrBNgHCTaAvb + 7eHjMxtlaSIrYYUFEmKpMSP4EMsEuOCO0kRcQl7XuNj6mYdrdB1ssRl85q2X16DY+n6l+239BEdJ2ybj + pAJ5PRom42qcb4xNzlE/xLjQ9bIUDSAzMsEG/TiVZaqGlHLggyRkEg/90JAAAoaMrPsgp45N6olgDh8y + +RVSmxmAuNraPsKjVTX58Z05Pb4//0aa/t/ULfwGAORny+XpQecAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/Chapter11/ToolStripEx/Images/1.bmp b/Chapter11/ToolStripEx/Images/1.bmp new file mode 100644 index 0000000..5165538 Binary files /dev/null and b/Chapter11/ToolStripEx/Images/1.bmp differ diff --git a/Chapter11/ToolStripEx/Images/2.bmp b/Chapter11/ToolStripEx/Images/2.bmp new file mode 100644 index 0000000..bba4844 Binary files /dev/null and b/Chapter11/ToolStripEx/Images/2.bmp differ diff --git a/Chapter11/ToolStripEx/ReadMe.txt b/Chapter11/ToolStripEx/ReadMe.txt new file mode 100644 index 0000000..d815f6b --- /dev/null +++ b/Chapter11/ToolStripEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : ToolStripEx Project Overview +======================================================================== + +AppWizard has created this ToolStripEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your ToolStripEx application. + +ToolStripEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ToolStripEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ToolStripEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/ToolStripEx/ToolStripEx.cpp b/Chapter11/ToolStripEx/ToolStripEx.cpp new file mode 100644 index 0000000..2b0e4d5 --- /dev/null +++ b/Chapter11/ToolStripEx/ToolStripEx.cpp @@ -0,0 +1,18 @@ +// ToolStripEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace ToolStripEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/ToolStripEx/ToolStripEx.vcproj b/Chapter11/ToolStripEx/ToolStripEx.vcproj new file mode 100644 index 0000000..d698df8 --- /dev/null +++ b/Chapter11/ToolStripEx/ToolStripEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/ToolStripEx/app.ico b/Chapter11/ToolStripEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/ToolStripEx/app.ico differ diff --git a/Chapter11/ToolStripEx/app.rc b/Chapter11/ToolStripEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/ToolStripEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/ToolStripEx/resource.h b/Chapter11/ToolStripEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/ToolStripEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/ToolStripEx/stdafx.cpp b/Chapter11/ToolStripEx/stdafx.cpp new file mode 100644 index 0000000..77a792b --- /dev/null +++ b/Chapter11/ToolStripEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ToolStripEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/ToolStripEx/stdafx.h b/Chapter11/ToolStripEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/ToolStripEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter11/TreeViewEx/AssemblyInfo.cpp b/Chapter11/TreeViewEx/AssemblyInfo.cpp new file mode 100644 index 0000000..b705c40 --- /dev/null +++ b/Chapter11/TreeViewEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("TreeViewEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("TreeViewEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter11/TreeViewEx/Form1.h b/Chapter11/TreeViewEx/Form1.h new file mode 100644 index 0000000..87be001 --- /dev/null +++ b/Chapter11/TreeViewEx/Form1.h @@ -0,0 +1,166 @@ +#pragma once + + +namespace TreeViewEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::TreeView^ tView; + System::Windows::Forms::ImageList^ imFolders; + System::ComponentModel::IContainer^ components; + + private: + /// + /// Required designer variable. + /// + + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + System::Windows::Forms::TreeNode^ treeNode1 = + (gcnew System::Windows::Forms::TreeNode(L"")); + System::Windows::Forms::TreeNode^ treeNode2 = + (gcnew System::Windows::Forms::TreeNode( + L"Root Node A", 0, 1, + gcnew cli::array< System::Windows::Forms::TreeNode^ >(1) + {treeNode1})); + System::Windows::Forms::TreeNode^ treeNode3 = + (gcnew System::Windows::Forms::TreeNode(L"")); + + System::Windows::Forms::TreeNode^ treeNode4 = + (gcnew System::Windows::Forms::TreeNode( + L"Root Node B", 0, 1, + gcnew cli::array< System::Windows::Forms::TreeNode^ >(1) + {treeNode3})); + System::ComponentModel::ComponentResourceManager^ resources = + (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); + this->tView = (gcnew System::Windows::Forms::TreeView()); + this->imFolders = + (gcnew System::Windows::Forms::ImageList(this->components)); + this->SuspendLayout(); + // + // tView + // + this->tView->Dock = System::Windows::Forms::DockStyle::Fill; + this->tView->ImageIndex = 0; + this->tView->ImageList = this->imFolders; + this->tView->LabelEdit = true; + this->tView->Location = System::Drawing::Point(0, 0); + this->tView->Name = L"tView"; + treeNode1->Name = L"Node1"; + treeNode1->Text = L""; + treeNode2->ImageIndex = 0; + treeNode2->Name = L"Node0"; + treeNode2->SelectedImageIndex = 1; + treeNode2->Text = L"Root Node A"; + treeNode3->Name = L"Node3"; + treeNode3->Text = L""; + treeNode4->ImageIndex = 0; + treeNode4->Name = L"Node2"; + treeNode4->SelectedImageIndex = 1; + treeNode4->Text = L"Root Node B"; + this->tView->Nodes->AddRange( + gcnew cli::array< System::Windows::Forms::TreeNode^ >(2) + {treeNode2, treeNode4}); + this->tView->SelectedImageIndex = 1; + this->tView->Size = System::Drawing::Size(194, 481); + this->tView->TabIndex = 0; + this->tView->BeforeExpand += + gcnew System::Windows::Forms::TreeViewCancelEventHandler(this, + &Form1::tView_BeforeExpand); + // + // imFolders + // + this->imFolders->ImageStream = + (cli::safe_cast + (resources->GetObject(L"imFolders.ImageStream"))); + this->imFolders->Images->SetKeyName(0, L"CLSDFOLD.ICO"); + this->imFolders->Images->SetKeyName(1, L"OPENFOLD.ICO"); + // + // Form1 + + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(194, 481); + this->Controls->Add(this->tView); + this->Name = L"Form1"; + this->Text = L"Tree View Example"; + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void tView_BeforeExpand(System::Object^ sender, + System::Windows::Forms::TreeViewCancelEventArgs^ e) + { + // Already expanded before? + if (e->Node->Nodes->Count > 1) + return; // Already expanded + else if (e->Node->Nodes->Count == 1) + { + if (e->Node->Nodes[0]->Text->Equals("")) + e->Node->Nodes->RemoveAt(0); // Node ready for expanding + else + return; // Already expanded but only one sub node + } + // Randomly expand the node + Random ^rand = gcnew Random(); + int rnd = rand->Next(1,5); + for (int i = 0; i < rnd; i++) // Randon number of subnodes + { + TreeNode ^stn = + gcnew TreeNode(String::Format("Sub Node {0}", i+1), 0, 1); + e->Node->Nodes->Add(stn); + + if (rand->Next(2) == 1) // Has sub sub-nodes + stn->Nodes->Add(gcnew TreeNode("", 0, 1)); + } + } + }; +} + diff --git a/Chapter11/TreeViewEx/Form1.resx b/Chapter11/TreeViewEx/Form1.resx new file mode 100644 index 0000000..aa37da6 --- /dev/null +++ b/Chapter11/TreeViewEx/Form1.resx @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAs + CQAAAk1TRnQBSQFMAgEBAgEAAQgBAAEEAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA + AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 + AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA + AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm + AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM + AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA + ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz + AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ + AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM + AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA + AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA + AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ + AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ + AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA + AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm + ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ + Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz + AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA + AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM + AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM + ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM + Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA + AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM + AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ + AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz + AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm + AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw + AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/8EADuwEAAzsIgAB7AH/ + AfsBBwH7AQcB+wEHAfsBBwH7AQcB+wHsBAAB7AH/AfsBBwH7AQcB+wEHAfsBBwH7AewiAAHsAf8BBwH7 + AQcB+wEHAfsBBwH7AQcB+wEHAewDAAHsAf8B+wEHAfsBBwH7AQcB+wEHAfsBBwEAAewhAAHsAf8B+wEH + AfsBBwH7AQcB+wEHAfsBBwH7AewDAAHsAf8BBwH7AQcB+wEHAfsBBwH7AQcB7AEAAewhAAHsAf8BBwH7 + AQcB+wEHAfsBBwH7AQcB+wEHAewCAAHsAf8BBwH7AQcB+wEHAfsBBwH7AQcB+wEAAuwhAAHsAf8B+wEH + AfsBBwH7AQcB+wEHAfsBBwH7AewCAAHsCv8B7AEAAQcB7CEAAewB/wEHAfsBBwH7AQcB+wEHAfsBBwH7 + AQcB7AIADewB+wHsIQAB7AH/AfsBBwH7AQcB+wEHAfsBBwH7AQcB+wHsAwAB7AH/AQcB+wEHAfsBBwH7 + AQcB+wEHAfsBBwHsIQAB7Az/AewDAAHsAf8B+wEHAfsBBwH7AQcF/wHsIQAB7AEHAfsBBwH7AQcB+wEH + BuwDAAHsAf8BBwH7AQcB+wEHAf8G7CIAAewBBwH7AQcB+wEHAewKAAHsBf8B7CkABewMAAXsaAABQgFN + AT4HAAE+AwABKAMAAUADAAEQAwABAQEAAQEFAAGAFwAD/wEABP8EAAT/BAABgAEBAeAGAAEBAcAGAAEB + AcAGAAEBAYAGAAEBAYAGAAEBBwABAQcAAQEHAAEBAYAGAAEBAYAGAAEDAYABAQQAAYAB/wHAAX8EAAHB + Af8B4AH/BAAE/wQACw== + + + \ No newline at end of file diff --git a/Chapter11/TreeViewEx/Images/CLSDFOLD.ICO b/Chapter11/TreeViewEx/Images/CLSDFOLD.ICO new file mode 100644 index 0000000..adfd173 Binary files /dev/null and b/Chapter11/TreeViewEx/Images/CLSDFOLD.ICO differ diff --git a/Chapter11/TreeViewEx/Images/OPENFOLD.ICO b/Chapter11/TreeViewEx/Images/OPENFOLD.ICO new file mode 100644 index 0000000..d36827b Binary files /dev/null and b/Chapter11/TreeViewEx/Images/OPENFOLD.ICO differ diff --git a/Chapter11/TreeViewEx/ReadMe.txt b/Chapter11/TreeViewEx/ReadMe.txt new file mode 100644 index 0000000..e488453 --- /dev/null +++ b/Chapter11/TreeViewEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : TreeViewEx Project Overview +======================================================================== + +AppWizard has created this TreeViewEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your TreeViewEx application. + +TreeViewEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +TreeViewEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named TreeViewEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter11/TreeViewEx/TreeViewEx.cpp b/Chapter11/TreeViewEx/TreeViewEx.cpp new file mode 100644 index 0000000..0e36eff --- /dev/null +++ b/Chapter11/TreeViewEx/TreeViewEx.cpp @@ -0,0 +1,18 @@ +// TreeViewEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace TreeViewEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter11/TreeViewEx/TreeViewEx.vcproj b/Chapter11/TreeViewEx/TreeViewEx.vcproj new file mode 100644 index 0000000..d16fe9a --- /dev/null +++ b/Chapter11/TreeViewEx/TreeViewEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter11/TreeViewEx/app.ico b/Chapter11/TreeViewEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter11/TreeViewEx/app.ico differ diff --git a/Chapter11/TreeViewEx/app.rc b/Chapter11/TreeViewEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter11/TreeViewEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter11/TreeViewEx/resource.h b/Chapter11/TreeViewEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter11/TreeViewEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter11/TreeViewEx/stdafx.cpp b/Chapter11/TreeViewEx/stdafx.cpp new file mode 100644 index 0000000..8dcebf1 --- /dev/null +++ b/Chapter11/TreeViewEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// TreeViewEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter11/TreeViewEx/stdafx.h b/Chapter11/TreeViewEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter11/TreeViewEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/Chapter12.sln b/Chapter12/Chapter12.sln new file mode 100644 index 0000000..e5b515a --- /dev/null +++ b/Chapter12/Chapter12.sln @@ -0,0 +1,134 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloGDI", "HelloGDI\HelloGDI.vcproj", "{DBC1A3DA-66E1-477F-9F42-41D9971F4479}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloGDI_OnPaint", "HelloGDI_OnPaint\HelloGDI_OnPaint.vcproj", "{7C150687-E4C4-4B09-B3EB-4ED40AF51D39}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OnPaintWhere", "OnPaintWhere\OnPaintWhere.vcproj", "{C7B72CBC-A42D-40C3-979A-0DF4AD9BA7B6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DisappearingCoords", "DisappearingCoords\DisappearingCoords.vcproj", "{A4A4E5AB-D63B-4673-8A8D-0D34592B8A63}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CorrectingCoords", "CorrectingCoords\CorrectingCoords.vcproj", "{D583CC4B-122F-49F9-81CF-44A196A19862}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NewUnitsOrigin", "NewUnitsOrigin\NewUnitsOrigin.vcproj", "{4AB38346-16AE-4084-8A39-F570B5E4ACFA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InterOrUnion", "InterOrUnion\InterOrUnion.vcproj", "{2D7F6879-0FB3-4D50-ADD6-FCC9CAE23EA3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegionEx", "RegionEx\RegionEx.vcproj", "{A51E4437-3EB4-4DA6-8533-174000208DAA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StringRect", "StringRect\StringRect.vcproj", "{A92301C6-462A-4436-99FF-E8BC7880B871}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DownwardStringRect", "DownwardStringRect\DownwardStringRect.vcproj", "{0BA3D5FE-CAF6-46C6-B534-CDEC590D881F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FontsGalore", "FontsGalore\FontsGalore.vcproj", "{5B318304-6B1F-4920-B8BF-1B353CF75CE2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DrawingLines", "DrawingLines\DrawingLines.vcproj", "{34B93FB0-4B10-497D-973D-9A1735AEBF94}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextureBrushEx", "TextureBrushEx\TextureBrushEx.vcproj", "{25F71B93-F9BC-429F-BA21-7D968E89762D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DrawImageEx", "DrawImageEx\DrawImageEx.vcproj", "{2537F8FE-1AD9-4A88-A9DE-3D2E70E4E568}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HappyFace", "HappyFace\HappyFace.vcproj", "{A8D838A1-05CB-47AA-B462-567057109FA2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScrollingHappyFace", "ScrollingHappyFace\ScrollingHappyFace.vcproj", "{ABC84E3B-E7A9-48CB-8A65-8F43D3254EFB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OptimizedHappyFace", "OptimizedHappyFace\OptimizedHappyFace.vcproj", "{82754630-1D99-4EFA-A046-89B095CBBE34}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SingleBuffering", "SingleBuffering\SingleBuffering.vcproj", "{5DC2396E-39E4-4144-ABED-15D11F6E7717}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DoubleBuffering", "DoubleBuffering\DoubleBuffering.vcproj", "{6E19BB54-0D19-4713-870C-1C5894CECFD5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrintHappyFace", "PrintHappyFace\PrintHappyFace.vcproj", "{8876D9B8-56D4-41AA-A80E-40230D84EBC3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DBC1A3DA-66E1-477F-9F42-41D9971F4479}.Debug|Win32.ActiveCfg = Debug|Win32 + {DBC1A3DA-66E1-477F-9F42-41D9971F4479}.Debug|Win32.Build.0 = Debug|Win32 + {DBC1A3DA-66E1-477F-9F42-41D9971F4479}.Release|Win32.ActiveCfg = Release|Win32 + {DBC1A3DA-66E1-477F-9F42-41D9971F4479}.Release|Win32.Build.0 = Release|Win32 + {7C150687-E4C4-4B09-B3EB-4ED40AF51D39}.Debug|Win32.ActiveCfg = Debug|Win32 + {7C150687-E4C4-4B09-B3EB-4ED40AF51D39}.Debug|Win32.Build.0 = Debug|Win32 + {7C150687-E4C4-4B09-B3EB-4ED40AF51D39}.Release|Win32.ActiveCfg = Release|Win32 + {7C150687-E4C4-4B09-B3EB-4ED40AF51D39}.Release|Win32.Build.0 = Release|Win32 + {C7B72CBC-A42D-40C3-979A-0DF4AD9BA7B6}.Debug|Win32.ActiveCfg = Debug|Win32 + {C7B72CBC-A42D-40C3-979A-0DF4AD9BA7B6}.Debug|Win32.Build.0 = Debug|Win32 + {C7B72CBC-A42D-40C3-979A-0DF4AD9BA7B6}.Release|Win32.ActiveCfg = Release|Win32 + {C7B72CBC-A42D-40C3-979A-0DF4AD9BA7B6}.Release|Win32.Build.0 = Release|Win32 + {A4A4E5AB-D63B-4673-8A8D-0D34592B8A63}.Debug|Win32.ActiveCfg = Debug|Win32 + {A4A4E5AB-D63B-4673-8A8D-0D34592B8A63}.Debug|Win32.Build.0 = Debug|Win32 + {A4A4E5AB-D63B-4673-8A8D-0D34592B8A63}.Release|Win32.ActiveCfg = Release|Win32 + {A4A4E5AB-D63B-4673-8A8D-0D34592B8A63}.Release|Win32.Build.0 = Release|Win32 + {D583CC4B-122F-49F9-81CF-44A196A19862}.Debug|Win32.ActiveCfg = Debug|Win32 + {D583CC4B-122F-49F9-81CF-44A196A19862}.Debug|Win32.Build.0 = Debug|Win32 + {D583CC4B-122F-49F9-81CF-44A196A19862}.Release|Win32.ActiveCfg = Release|Win32 + {D583CC4B-122F-49F9-81CF-44A196A19862}.Release|Win32.Build.0 = Release|Win32 + {4AB38346-16AE-4084-8A39-F570B5E4ACFA}.Debug|Win32.ActiveCfg = Debug|Win32 + {4AB38346-16AE-4084-8A39-F570B5E4ACFA}.Debug|Win32.Build.0 = Debug|Win32 + {4AB38346-16AE-4084-8A39-F570B5E4ACFA}.Release|Win32.ActiveCfg = Release|Win32 + {4AB38346-16AE-4084-8A39-F570B5E4ACFA}.Release|Win32.Build.0 = Release|Win32 + {2D7F6879-0FB3-4D50-ADD6-FCC9CAE23EA3}.Debug|Win32.ActiveCfg = Debug|Win32 + {2D7F6879-0FB3-4D50-ADD6-FCC9CAE23EA3}.Debug|Win32.Build.0 = Debug|Win32 + {2D7F6879-0FB3-4D50-ADD6-FCC9CAE23EA3}.Release|Win32.ActiveCfg = Release|Win32 + {2D7F6879-0FB3-4D50-ADD6-FCC9CAE23EA3}.Release|Win32.Build.0 = Release|Win32 + {A51E4437-3EB4-4DA6-8533-174000208DAA}.Debug|Win32.ActiveCfg = Debug|Win32 + {A51E4437-3EB4-4DA6-8533-174000208DAA}.Debug|Win32.Build.0 = Debug|Win32 + {A51E4437-3EB4-4DA6-8533-174000208DAA}.Release|Win32.ActiveCfg = Release|Win32 + {A51E4437-3EB4-4DA6-8533-174000208DAA}.Release|Win32.Build.0 = Release|Win32 + {A92301C6-462A-4436-99FF-E8BC7880B871}.Debug|Win32.ActiveCfg = Debug|Win32 + {A92301C6-462A-4436-99FF-E8BC7880B871}.Debug|Win32.Build.0 = Debug|Win32 + {A92301C6-462A-4436-99FF-E8BC7880B871}.Release|Win32.ActiveCfg = Release|Win32 + {A92301C6-462A-4436-99FF-E8BC7880B871}.Release|Win32.Build.0 = Release|Win32 + {0BA3D5FE-CAF6-46C6-B534-CDEC590D881F}.Debug|Win32.ActiveCfg = Debug|Win32 + {0BA3D5FE-CAF6-46C6-B534-CDEC590D881F}.Debug|Win32.Build.0 = Debug|Win32 + {0BA3D5FE-CAF6-46C6-B534-CDEC590D881F}.Release|Win32.ActiveCfg = Release|Win32 + {0BA3D5FE-CAF6-46C6-B534-CDEC590D881F}.Release|Win32.Build.0 = Release|Win32 + {5B318304-6B1F-4920-B8BF-1B353CF75CE2}.Debug|Win32.ActiveCfg = Debug|Win32 + {5B318304-6B1F-4920-B8BF-1B353CF75CE2}.Debug|Win32.Build.0 = Debug|Win32 + {5B318304-6B1F-4920-B8BF-1B353CF75CE2}.Release|Win32.ActiveCfg = Release|Win32 + {5B318304-6B1F-4920-B8BF-1B353CF75CE2}.Release|Win32.Build.0 = Release|Win32 + {34B93FB0-4B10-497D-973D-9A1735AEBF94}.Debug|Win32.ActiveCfg = Debug|Win32 + {34B93FB0-4B10-497D-973D-9A1735AEBF94}.Debug|Win32.Build.0 = Debug|Win32 + {34B93FB0-4B10-497D-973D-9A1735AEBF94}.Release|Win32.ActiveCfg = Release|Win32 + {34B93FB0-4B10-497D-973D-9A1735AEBF94}.Release|Win32.Build.0 = Release|Win32 + {25F71B93-F9BC-429F-BA21-7D968E89762D}.Debug|Win32.ActiveCfg = Debug|Win32 + {25F71B93-F9BC-429F-BA21-7D968E89762D}.Debug|Win32.Build.0 = Debug|Win32 + {25F71B93-F9BC-429F-BA21-7D968E89762D}.Release|Win32.ActiveCfg = Release|Win32 + {25F71B93-F9BC-429F-BA21-7D968E89762D}.Release|Win32.Build.0 = Release|Win32 + {2537F8FE-1AD9-4A88-A9DE-3D2E70E4E568}.Debug|Win32.ActiveCfg = Debug|Win32 + {2537F8FE-1AD9-4A88-A9DE-3D2E70E4E568}.Debug|Win32.Build.0 = Debug|Win32 + {2537F8FE-1AD9-4A88-A9DE-3D2E70E4E568}.Release|Win32.ActiveCfg = Release|Win32 + {2537F8FE-1AD9-4A88-A9DE-3D2E70E4E568}.Release|Win32.Build.0 = Release|Win32 + {A8D838A1-05CB-47AA-B462-567057109FA2}.Debug|Win32.ActiveCfg = Debug|Win32 + {A8D838A1-05CB-47AA-B462-567057109FA2}.Debug|Win32.Build.0 = Debug|Win32 + {A8D838A1-05CB-47AA-B462-567057109FA2}.Release|Win32.ActiveCfg = Release|Win32 + {A8D838A1-05CB-47AA-B462-567057109FA2}.Release|Win32.Build.0 = Release|Win32 + {ABC84E3B-E7A9-48CB-8A65-8F43D3254EFB}.Debug|Win32.ActiveCfg = Debug|Win32 + {ABC84E3B-E7A9-48CB-8A65-8F43D3254EFB}.Debug|Win32.Build.0 = Debug|Win32 + {ABC84E3B-E7A9-48CB-8A65-8F43D3254EFB}.Release|Win32.ActiveCfg = Release|Win32 + {ABC84E3B-E7A9-48CB-8A65-8F43D3254EFB}.Release|Win32.Build.0 = Release|Win32 + {82754630-1D99-4EFA-A046-89B095CBBE34}.Debug|Win32.ActiveCfg = Debug|Win32 + {82754630-1D99-4EFA-A046-89B095CBBE34}.Debug|Win32.Build.0 = Debug|Win32 + {82754630-1D99-4EFA-A046-89B095CBBE34}.Release|Win32.ActiveCfg = Release|Win32 + {82754630-1D99-4EFA-A046-89B095CBBE34}.Release|Win32.Build.0 = Release|Win32 + {5DC2396E-39E4-4144-ABED-15D11F6E7717}.Debug|Win32.ActiveCfg = Debug|Win32 + {5DC2396E-39E4-4144-ABED-15D11F6E7717}.Debug|Win32.Build.0 = Debug|Win32 + {5DC2396E-39E4-4144-ABED-15D11F6E7717}.Release|Win32.ActiveCfg = Release|Win32 + {5DC2396E-39E4-4144-ABED-15D11F6E7717}.Release|Win32.Build.0 = Release|Win32 + {6E19BB54-0D19-4713-870C-1C5894CECFD5}.Debug|Win32.ActiveCfg = Debug|Win32 + {6E19BB54-0D19-4713-870C-1C5894CECFD5}.Debug|Win32.Build.0 = Debug|Win32 + {6E19BB54-0D19-4713-870C-1C5894CECFD5}.Release|Win32.ActiveCfg = Release|Win32 + {6E19BB54-0D19-4713-870C-1C5894CECFD5}.Release|Win32.Build.0 = Release|Win32 + {8876D9B8-56D4-41AA-A80E-40230D84EBC3}.Debug|Win32.ActiveCfg = Debug|Win32 + {8876D9B8-56D4-41AA-A80E-40230D84EBC3}.Debug|Win32.Build.0 = Debug|Win32 + {8876D9B8-56D4-41AA-A80E-40230D84EBC3}.Release|Win32.ActiveCfg = Release|Win32 + {8876D9B8-56D4-41AA-A80E-40230D84EBC3}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter12/CorrectingCoords/AssemblyInfo.cpp b/Chapter12/CorrectingCoords/AssemblyInfo.cpp new file mode 100644 index 0000000..0bca293 --- /dev/null +++ b/Chapter12/CorrectingCoords/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("CorrectingCoords")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("CorrectingCoords")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/CorrectingCoords/CorrectingCoords.cpp b/Chapter12/CorrectingCoords/CorrectingCoords.cpp new file mode 100644 index 0000000..70f61af --- /dev/null +++ b/Chapter12/CorrectingCoords/CorrectingCoords.cpp @@ -0,0 +1,18 @@ +// CorrectingCoords.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace CorrectingCoords; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/CorrectingCoords/CorrectingCoords.vcproj b/Chapter12/CorrectingCoords/CorrectingCoords.vcproj new file mode 100644 index 0000000..c738acf --- /dev/null +++ b/Chapter12/CorrectingCoords/CorrectingCoords.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/CorrectingCoords/Form1.h b/Chapter12/CorrectingCoords/Form1.h new file mode 100644 index 0000000..f7c2043 --- /dev/null +++ b/Chapter12/CorrectingCoords/Form1.h @@ -0,0 +1,95 @@ +#pragma once + + +namespace CorrectingCoords { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + coords = gcnew ArrayList(); // Instantiate coords array + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + ArrayList ^coords; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Click and see coords"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->MouseDown += + gcnew System::Windows::Forms::MouseEventHandler(this, + &Form1::Form1_MouseDown); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_MouseDown(System::Object^ sender, + System::Windows::Forms::MouseEventArgs^ e) + { + coords->Add(Point(e->X, e->Y)); + Invalidate(); + } + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + for each (Point^ p in coords) + { + e->Graphics->DrawString(String::Format("({0},{1})",p->X,p->Y), + gcnew Drawing::Font("Courier New", 8), + Brushes::Black, (Single)p->X, (Single)p->Y); + } + } + }; +} + diff --git a/Chapter12/CorrectingCoords/Form1.resX b/Chapter12/CorrectingCoords/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/CorrectingCoords/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/CorrectingCoords/ReadMe.txt b/Chapter12/CorrectingCoords/ReadMe.txt new file mode 100644 index 0000000..be82f02 --- /dev/null +++ b/Chapter12/CorrectingCoords/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : CorrectingCoords Project Overview +======================================================================== + +AppWizard has created this CorrectingCoords Application for you. + +This file contains a summary of what you will find in each of the files that +make up your CorrectingCoords application. + +CorrectingCoords.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +CorrectingCoords.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named CorrectingCoords.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/CorrectingCoords/app.ico b/Chapter12/CorrectingCoords/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/CorrectingCoords/app.ico differ diff --git a/Chapter12/CorrectingCoords/app.rc b/Chapter12/CorrectingCoords/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/CorrectingCoords/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/CorrectingCoords/resource.h b/Chapter12/CorrectingCoords/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/CorrectingCoords/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/CorrectingCoords/stdafx.cpp b/Chapter12/CorrectingCoords/stdafx.cpp new file mode 100644 index 0000000..9f3ffe3 --- /dev/null +++ b/Chapter12/CorrectingCoords/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// CorrectingCoords.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/CorrectingCoords/stdafx.h b/Chapter12/CorrectingCoords/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/CorrectingCoords/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/DisappearingCoords/AssemblyInfo.cpp b/Chapter12/DisappearingCoords/AssemblyInfo.cpp new file mode 100644 index 0000000..b680c5b --- /dev/null +++ b/Chapter12/DisappearingCoords/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("DisappearingCoords")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("DisappearingCoords")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/DisappearingCoords/DisappearingCoords.cpp b/Chapter12/DisappearingCoords/DisappearingCoords.cpp new file mode 100644 index 0000000..a6646b8 --- /dev/null +++ b/Chapter12/DisappearingCoords/DisappearingCoords.cpp @@ -0,0 +1,18 @@ +// DisappearingCoords.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace DisappearingCoords; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/DisappearingCoords/DisappearingCoords.vcproj b/Chapter12/DisappearingCoords/DisappearingCoords.vcproj new file mode 100644 index 0000000..d56e21c --- /dev/null +++ b/Chapter12/DisappearingCoords/DisappearingCoords.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/DisappearingCoords/Form1.h b/Chapter12/DisappearingCoords/Form1.h new file mode 100644 index 0000000..bc9f8d1 --- /dev/null +++ b/Chapter12/DisappearingCoords/Form1.h @@ -0,0 +1,86 @@ +#pragma once + + +namespace DisappearingCoords { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Click and see coords"; + this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseDown); + this->ResumeLayout(false); + + } +#pragma endregion + private: + System::Void Form1_MouseDown(System::Object^ sender, + System::Windows::Forms::MouseEventArgs^ e) + { + Graphics ^g = this->CreateGraphics(); + g->DrawString(String::Format("({0},{1})", e->X, e->Y), + gcnew Drawing::Font("Courier New", 8), + Brushes::Black, (Single)e->X, (Single)e->Y); + + delete g; // we delete the Graphics object because we + // created it with the CreateGraphics() method. + } + }; +} + diff --git a/Chapter12/DisappearingCoords/Form1.resx b/Chapter12/DisappearingCoords/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter12/DisappearingCoords/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/DisappearingCoords/ReadMe.txt b/Chapter12/DisappearingCoords/ReadMe.txt new file mode 100644 index 0000000..f38a6af --- /dev/null +++ b/Chapter12/DisappearingCoords/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : DisappearingCoords Project Overview +======================================================================== + +AppWizard has created this DisappearingCoords Application for you. + +This file contains a summary of what you will find in each of the files that +make up your DisappearingCoords application. + +DisappearingCoords.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +DisappearingCoords.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named DisappearingCoords.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/DisappearingCoords/app.ico b/Chapter12/DisappearingCoords/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/DisappearingCoords/app.ico differ diff --git a/Chapter12/DisappearingCoords/app.rc b/Chapter12/DisappearingCoords/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/DisappearingCoords/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/DisappearingCoords/resource.h b/Chapter12/DisappearingCoords/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/DisappearingCoords/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/DisappearingCoords/stdafx.cpp b/Chapter12/DisappearingCoords/stdafx.cpp new file mode 100644 index 0000000..b5c6217 --- /dev/null +++ b/Chapter12/DisappearingCoords/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// DisappearingCoords.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/DisappearingCoords/stdafx.h b/Chapter12/DisappearingCoords/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/DisappearingCoords/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/DoubleBuffering/AssemblyInfo.cpp b/Chapter12/DoubleBuffering/AssemblyInfo.cpp new file mode 100644 index 0000000..6b3af30 --- /dev/null +++ b/Chapter12/DoubleBuffering/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("DoubleBuffering")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("DoubleBuffering")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/DoubleBuffering/DoubleBuffering.cpp b/Chapter12/DoubleBuffering/DoubleBuffering.cpp new file mode 100644 index 0000000..b28d4e9 --- /dev/null +++ b/Chapter12/DoubleBuffering/DoubleBuffering.cpp @@ -0,0 +1,18 @@ +// DoubleBuffering.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace DoubleBuffering; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/DoubleBuffering/DoubleBuffering.vcproj b/Chapter12/DoubleBuffering/DoubleBuffering.vcproj new file mode 100644 index 0000000..31bdd6b --- /dev/null +++ b/Chapter12/DoubleBuffering/DoubleBuffering.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/DoubleBuffering/Form1.h b/Chapter12/DoubleBuffering/Form1.h new file mode 100644 index 0000000..11a41c3 --- /dev/null +++ b/Chapter12/DoubleBuffering/Form1.h @@ -0,0 +1,179 @@ +#pragma once + + +namespace DoubleBuffering { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + this->SetStyle(ControlStyles::Opaque, true); + + dbBitmap = nullptr; + dbGraphics = nullptr; + X = -250; // Preset to be just left of window + + Form1_Resize(nullptr, EventArgs::Empty); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + + System::Windows::Forms::Timer^ timer1; + + Bitmap^ dbBitmap; + Graphics^ dbGraphics; + int X; // Actual x coordinate of Happy face + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + this->timer1 = + (gcnew System::Windows::Forms::Timer(this->components)); + this->SuspendLayout(); + // + // timer1 + // + this->timer1->Enabled = true; + this->timer1->Interval = 10; + this->timer1->Tick += + gcnew System::EventHandler(this, &Form1::timer1_Tick); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(500, 300); + this->Name = L"Form1"; + this->Text = L"Sliding Happy Face"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->Resize += + gcnew System::EventHandler(this, &Form1::Form1_Resize); + this->ResumeLayout(false); + + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + // Move image at end of line start from beginning + if (X < ClientRectangle.Width) + { + X ++; + dbGraphics->TranslateTransform(1.0, 0.0); + } + else + { + X = -250; + dbGraphics->TranslateTransform( + (float)-(ClientRectangle.Width+250), 0.0); + } + + // Clear background + dbGraphics->Clear(Color::White); + + + // redraw image from scratch + Pen^ b4pen = gcnew Pen(Color::Black, 4); + + Drawing::Rectangle Head = Drawing::Rectangle(0, 0, 250, 250); + dbGraphics->FillEllipse(Brushes::Yellow, Head); + dbGraphics->DrawEllipse(b4pen, Head); + + Drawing::Rectangle Mouth = Drawing::Rectangle(75, 150, 100, 50); + dbGraphics->FillPie(Brushes::White, Mouth,0,180); + dbGraphics->DrawPie(b4pen, Mouth, 0, 180); + + Drawing::Rectangle LEye = Drawing::Rectangle(75, 75, 25, 25); + dbGraphics->FillEllipse(Brushes::White, LEye); + dbGraphics->DrawEllipse(b4pen, LEye); + + Drawing::Rectangle REye = Drawing::Rectangle(150, 75, 25, 25); + dbGraphics->FillEllipse(Brushes::White, REye); + dbGraphics->DrawEllipse(b4pen, REye); + + // Make the buffer visible + e->Graphics->DrawImageUnscaled(dbBitmap, 0, 0); + + delete b4pen; + } + + System::Void Form1_Resize(System::Object^ sender, System::EventArgs^ e) + { + // Get rid of old stuff + if (dbGraphics != nullptr) + { + delete dbGraphics; + } + + if (dbBitmap != nullptr) + { + delete dbBitmap; + } + + if (ClientRectangle.Width > 0 && ClientRectangle.Height > 0) + { + // Create a bitmap + dbBitmap = gcnew Bitmap(ClientRectangle.Width, + ClientRectangle.Height); + + // Grab its Graphics + dbGraphics = Graphics::FromImage(dbBitmap); + + // Set up initial translation after resize (also at start) + dbGraphics->TranslateTransform((float)X, 25.0); + } + } + + + System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) + { + // Move the image + Invalidate(); + } + }; +} + diff --git a/Chapter12/DoubleBuffering/Form1.resX b/Chapter12/DoubleBuffering/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/DoubleBuffering/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/DoubleBuffering/ReadMe.txt b/Chapter12/DoubleBuffering/ReadMe.txt new file mode 100644 index 0000000..86f2ce1 --- /dev/null +++ b/Chapter12/DoubleBuffering/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : DoubleBuffering Project Overview +======================================================================== + +AppWizard has created this DoubleBuffering Application for you. + +This file contains a summary of what you will find in each of the files that +make up your DoubleBuffering application. + +DoubleBuffering.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +DoubleBuffering.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named DoubleBuffering.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/DoubleBuffering/app.ico b/Chapter12/DoubleBuffering/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/DoubleBuffering/app.ico differ diff --git a/Chapter12/DoubleBuffering/app.rc b/Chapter12/DoubleBuffering/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/DoubleBuffering/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/DoubleBuffering/resource.h b/Chapter12/DoubleBuffering/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/DoubleBuffering/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/DoubleBuffering/stdafx.cpp b/Chapter12/DoubleBuffering/stdafx.cpp new file mode 100644 index 0000000..247730e --- /dev/null +++ b/Chapter12/DoubleBuffering/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// DoubleBuffering.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/DoubleBuffering/stdafx.h b/Chapter12/DoubleBuffering/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/DoubleBuffering/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/DownwardStringRect/AssemblyInfo.cpp b/Chapter12/DownwardStringRect/AssemblyInfo.cpp new file mode 100644 index 0000000..909c42b --- /dev/null +++ b/Chapter12/DownwardStringRect/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("DownwardStringRect")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("DownwardStringRect")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/DownwardStringRect/DownwardStringRect.cpp b/Chapter12/DownwardStringRect/DownwardStringRect.cpp new file mode 100644 index 0000000..18fd9bb --- /dev/null +++ b/Chapter12/DownwardStringRect/DownwardStringRect.cpp @@ -0,0 +1,18 @@ +// DownwardStringRect.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace DownwardStringRect; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/DownwardStringRect/DownwardStringRect.vcproj b/Chapter12/DownwardStringRect/DownwardStringRect.vcproj new file mode 100644 index 0000000..23c3426 --- /dev/null +++ b/Chapter12/DownwardStringRect/DownwardStringRect.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/DownwardStringRect/Form1.h b/Chapter12/DownwardStringRect/Form1.h new file mode 100644 index 0000000..7415b54 --- /dev/null +++ b/Chapter12/DownwardStringRect/Form1.h @@ -0,0 +1,91 @@ +#pragma once + + +namespace DownwardStringRect { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(300, 145); + this->Name = L"Form1"; + this->Text = L"Downward String in a Rectangle"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + // create and configure the StringFormat object + StringFormat ^stringformat = gcnew StringFormat(); + stringformat->FormatFlags = StringFormatFlags::DirectionVertical; + stringformat->Alignment = StringAlignment::Center; + + // Draw the string + e->Graphics->DrawString( + "Let's draw a string to a rectangle and go a little " + "overboard on the size of the string that we place " + "inside of it", + gcnew Drawing::Font(gcnew FontFamily("Arial"), 13), + Brushes::Black, Drawing::RectangleF(20.0, 40.0, 250.0, 80.0), + stringformat); + } + }; +} + diff --git a/Chapter12/DownwardStringRect/Form1.resX b/Chapter12/DownwardStringRect/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/DownwardStringRect/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/DownwardStringRect/ReadMe.txt b/Chapter12/DownwardStringRect/ReadMe.txt new file mode 100644 index 0000000..cc2ef6c --- /dev/null +++ b/Chapter12/DownwardStringRect/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : DownwardStringRect Project Overview +======================================================================== + +AppWizard has created this DownwardStringRect Application for you. + +This file contains a summary of what you will find in each of the files that +make up your DownwardStringRect application. + +DownwardStringRect.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +DownwardStringRect.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named DownwardStringRect.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/DownwardStringRect/app.ico b/Chapter12/DownwardStringRect/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/DownwardStringRect/app.ico differ diff --git a/Chapter12/DownwardStringRect/app.rc b/Chapter12/DownwardStringRect/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/DownwardStringRect/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/DownwardStringRect/resource.h b/Chapter12/DownwardStringRect/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/DownwardStringRect/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/DownwardStringRect/stdafx.cpp b/Chapter12/DownwardStringRect/stdafx.cpp new file mode 100644 index 0000000..2580201 --- /dev/null +++ b/Chapter12/DownwardStringRect/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// DownwardStringRect.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/DownwardStringRect/stdafx.h b/Chapter12/DownwardStringRect/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/DownwardStringRect/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/DrawImageEx/AssemblyInfo.cpp b/Chapter12/DrawImageEx/AssemblyInfo.cpp new file mode 100644 index 0000000..110e9e4 --- /dev/null +++ b/Chapter12/DrawImageEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("DrawImageEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("DrawImageEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/DrawImageEx/DrawImageEx.cpp b/Chapter12/DrawImageEx/DrawImageEx.cpp new file mode 100644 index 0000000..b141c7d --- /dev/null +++ b/Chapter12/DrawImageEx/DrawImageEx.cpp @@ -0,0 +1,18 @@ +// DrawImageEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace DrawImageEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/DrawImageEx/DrawImageEx.vcproj b/Chapter12/DrawImageEx/DrawImageEx.vcproj new file mode 100644 index 0000000..9e585ce --- /dev/null +++ b/Chapter12/DrawImageEx/DrawImageEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/DrawImageEx/Form1.h b/Chapter12/DrawImageEx/Form1.h new file mode 100644 index 0000000..be6988c --- /dev/null +++ b/Chapter12/DrawImageEx/Form1.h @@ -0,0 +1,80 @@ +#pragma once + + +namespace DrawImageEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Draw Image"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Image^ img = Image::FromFile("Images\\CLICppCover.gif"); + e->Graphics->DrawImage(img, 0, 0, img->Width*2, img->Height*2); + } + }; +} + diff --git a/Chapter12/DrawImageEx/Form1.resX b/Chapter12/DrawImageEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/DrawImageEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/DrawImageEx/Images/CLICppCover.gif b/Chapter12/DrawImageEx/Images/CLICppCover.gif new file mode 100644 index 0000000..b9c6832 Binary files /dev/null and b/Chapter12/DrawImageEx/Images/CLICppCover.gif differ diff --git a/Chapter12/DrawImageEx/ReadMe.txt b/Chapter12/DrawImageEx/ReadMe.txt new file mode 100644 index 0000000..47b289d --- /dev/null +++ b/Chapter12/DrawImageEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : DrawImageEx Project Overview +======================================================================== + +AppWizard has created this DrawImageEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your DrawImageEx application. + +DrawImageEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +DrawImageEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named DrawImageEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/DrawImageEx/app.ico b/Chapter12/DrawImageEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/DrawImageEx/app.ico differ diff --git a/Chapter12/DrawImageEx/app.rc b/Chapter12/DrawImageEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/DrawImageEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/DrawImageEx/resource.h b/Chapter12/DrawImageEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/DrawImageEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/DrawImageEx/stdafx.cpp b/Chapter12/DrawImageEx/stdafx.cpp new file mode 100644 index 0000000..85cbb3c --- /dev/null +++ b/Chapter12/DrawImageEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// DrawImageEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/DrawImageEx/stdafx.h b/Chapter12/DrawImageEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/DrawImageEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/DrawingLines/AssemblyInfo.cpp b/Chapter12/DrawingLines/AssemblyInfo.cpp new file mode 100644 index 0000000..9b527cc --- /dev/null +++ b/Chapter12/DrawingLines/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("DrawingLines")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("DrawingLines")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/DrawingLines/DrawingLines.cpp b/Chapter12/DrawingLines/DrawingLines.cpp new file mode 100644 index 0000000..a56656b --- /dev/null +++ b/Chapter12/DrawingLines/DrawingLines.cpp @@ -0,0 +1,18 @@ +// DrawingLines.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace DrawingLines; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/DrawingLines/DrawingLines.vcproj b/Chapter12/DrawingLines/DrawingLines.vcproj new file mode 100644 index 0000000..813bec9 --- /dev/null +++ b/Chapter12/DrawingLines/DrawingLines.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/DrawingLines/Form1.h b/Chapter12/DrawingLines/Form1.h new file mode 100644 index 0000000..4ae6ce9 --- /dev/null +++ b/Chapter12/DrawingLines/Form1.h @@ -0,0 +1,111 @@ +#pragma once + + +namespace DrawingLines { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::Drawing::Drawing2D; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + pen = gcnew array(5); + + // a one unit width black pen + pen[0] = Pens::Black; + + // a one unit with purple pen broken with dashes + pen[1] = gcnew Pen(Color::Purple); + pen[1]->DashStyle = DashStyle::Dash; + + // a 4 unit width chocolate pen + pen[2] = gcnew Pen(Color::Chocolate, 4); + + // An 8 width royalblue pen made of three lines narrow wide narrow + pen[3] = gcnew Pen(Color::RoyalBlue, 10); + array^ cArray = gcnew array { + 0.0f, 0.1f, 0.3f, 0.7f, 0.9f, 1.0f + }; + pen[3]->CompoundArray = cArray; + + // a 5 width tomato pen with diamond start and round end anchors + pen[4] = gcnew Pen(Color::Tomato, 5); + pen[4]->StartCap = LineCap::DiamondAnchor; + pen[4]->EndCap = LineCap::RoundAnchor; + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + + array^ pen; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Drawing Some lines"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Random ^rand = gcnew Random(); + + for (int i = 0; i < 10; i++) + { + e->Graphics->DrawLine(pen[i%5], rand->Next(0,299), + rand->Next(0,299), rand->Next(0,299), rand->Next(0,299)); + } + } + }; +} + diff --git a/Chapter12/DrawingLines/Form1.resX b/Chapter12/DrawingLines/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/DrawingLines/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/DrawingLines/ReadMe.txt b/Chapter12/DrawingLines/ReadMe.txt new file mode 100644 index 0000000..8bf284b --- /dev/null +++ b/Chapter12/DrawingLines/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : DrawingLines Project Overview +======================================================================== + +AppWizard has created this DrawingLines Application for you. + +This file contains a summary of what you will find in each of the files that +make up your DrawingLines application. + +DrawingLines.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +DrawingLines.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named DrawingLines.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/DrawingLines/app.ico b/Chapter12/DrawingLines/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/DrawingLines/app.ico differ diff --git a/Chapter12/DrawingLines/app.rc b/Chapter12/DrawingLines/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/DrawingLines/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/DrawingLines/resource.h b/Chapter12/DrawingLines/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/DrawingLines/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/DrawingLines/stdafx.cpp b/Chapter12/DrawingLines/stdafx.cpp new file mode 100644 index 0000000..43d931c --- /dev/null +++ b/Chapter12/DrawingLines/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// DrawingLines.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/DrawingLines/stdafx.h b/Chapter12/DrawingLines/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/DrawingLines/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/FontsGalore/AssemblyInfo.cpp b/Chapter12/FontsGalore/AssemblyInfo.cpp new file mode 100644 index 0000000..d5ccb95 --- /dev/null +++ b/Chapter12/FontsGalore/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("FontsGalore")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("FontsGalore")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/FontsGalore/FontsGalore.cpp b/Chapter12/FontsGalore/FontsGalore.cpp new file mode 100644 index 0000000..009e776 --- /dev/null +++ b/Chapter12/FontsGalore/FontsGalore.cpp @@ -0,0 +1,18 @@ +// FontsGalore.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace FontsGalore; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/FontsGalore/FontsGalore.vcproj b/Chapter12/FontsGalore/FontsGalore.vcproj new file mode 100644 index 0000000..2a759b8 --- /dev/null +++ b/Chapter12/FontsGalore/FontsGalore.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/FontsGalore/Form1.h b/Chapter12/FontsGalore/Form1.h new file mode 100644 index 0000000..42b8d26 --- /dev/null +++ b/Chapter12/FontsGalore/Form1.h @@ -0,0 +1,144 @@ +#pragma once + + +namespace FontsGalore { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::Drawing::Text; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + fonts = gcnew array(10); + fontstr = gcnew array(10); + + // Used to generate random fonts + array^ sizes = gcnew array { + 10.0, 12.5, 16.0 + }; + + array^ fontstyles = gcnew array { + FontStyle::Regular, FontStyle::Bold, + FontStyle::Italic, + (FontStyle)(FontStyle::Underline|FontStyle::Bold|FontStyle::Italic) + }; + + array^ units = gcnew array { + GraphicsUnit::Point, GraphicsUnit::Pixel + }; + + // Get all fonts on computer + InstalledFontCollection ^availFonts = + gcnew InstalledFontCollection(); + + + array^ fontfamilies = availFonts->Families; + + Random ^rand = gcnew Random(); + int ff, s, fs, u; + + for (int i = 0; i < fonts->Length; i++) + { + s = rand->Next(0,3); + fs = rand->Next(0,3); + u = rand->Next(0,2); + + // Not all fonts support every style + do { + ff = rand->Next(0,fontfamilies->Length); + } + while (!fontfamilies[ff]->IsStyleAvailable( + (FontStyle)fontstyles[fs])); + + // Display string of font + fontstr[i] = String::Format("{0} {1} {2}", + fontfamilies[ff]->Name, + sizes[s], + String::Concat(fontstyles[fs], " ", + units[u])); + + // Create the font + fonts[i] = gcnew Drawing::Font(fontfamilies[ff], sizes[s], + (FontStyle)fontstyles[fs], + (GraphicsUnit)units[u]); + } + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + + array^ fonts; + array^ fontstr; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Many Fonts"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + float lineloc = 0; + for (int i = 0; i < fonts->Length; i++) + { + // Display font + e->Graphics->DrawString(fontstr[i], fonts[i], Brushes::Black, + 10, lineloc); + + // Calculate the top of the next line + lineloc += fonts[i]->Height; + } + } + }; +} + diff --git a/Chapter12/FontsGalore/Form1.resX b/Chapter12/FontsGalore/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/FontsGalore/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/FontsGalore/ReadMe.txt b/Chapter12/FontsGalore/ReadMe.txt new file mode 100644 index 0000000..6ca1402 --- /dev/null +++ b/Chapter12/FontsGalore/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : FontsGalore Project Overview +======================================================================== + +AppWizard has created this FontsGalore Application for you. + +This file contains a summary of what you will find in each of the files that +make up your FontsGalore application. + +FontsGalore.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +FontsGalore.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named FontsGalore.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/FontsGalore/app.ico b/Chapter12/FontsGalore/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/FontsGalore/app.ico differ diff --git a/Chapter12/FontsGalore/app.rc b/Chapter12/FontsGalore/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/FontsGalore/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/FontsGalore/resource.h b/Chapter12/FontsGalore/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/FontsGalore/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/FontsGalore/stdafx.cpp b/Chapter12/FontsGalore/stdafx.cpp new file mode 100644 index 0000000..335960a --- /dev/null +++ b/Chapter12/FontsGalore/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// FontsGalore.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/FontsGalore/stdafx.h b/Chapter12/FontsGalore/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/FontsGalore/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/HappyFace/AssemblyInfo.cpp b/Chapter12/HappyFace/AssemblyInfo.cpp new file mode 100644 index 0000000..cc8e387 --- /dev/null +++ b/Chapter12/HappyFace/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("HappyFace")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("HappyFace")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/HappyFace/Form1.h b/Chapter12/HappyFace/Form1.h new file mode 100644 index 0000000..85216bd --- /dev/null +++ b/Chapter12/HappyFace/Form1.h @@ -0,0 +1,103 @@ +#pragma once + + +namespace HappyFace { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(300, 300); + this->Name = L"Form1"; + this->Text = L"Happy Face"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Graphics^ g = e->Graphics; + Pen^ b4pen = gcnew Pen(Color::Black, 4); + + // Head + Rectangle rect = Drawing::Rectangle(25, 25, 250, 250); + g->FillEllipse(Brushes::Yellow, rect); + g->DrawEllipse(b4pen, rect); + + // Mouth + g->FillPie(Brushes::White, 100, 175, 100, 50, 0, 180); + g->DrawPie(b4pen, 100, 175, 100, 50, 0, 180); + + // Left Eye + rect = Drawing::Rectangle(100, 100, 25, 25); + g->FillEllipse(Brushes::White, rect); + g->DrawEllipse(b4pen, rect); + + + // Right Eye + rect = Drawing::Rectangle(175, 100, 25, 25); + g->FillEllipse(Brushes::White, rect); + g->DrawEllipse(b4pen, rect); + + // Get rid of pen Created + delete b4pen; + } + }; +} + diff --git a/Chapter12/HappyFace/Form1.resX b/Chapter12/HappyFace/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/HappyFace/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/HappyFace/HappyFace.cpp b/Chapter12/HappyFace/HappyFace.cpp new file mode 100644 index 0000000..558d6c4 --- /dev/null +++ b/Chapter12/HappyFace/HappyFace.cpp @@ -0,0 +1,18 @@ +// HappyFace.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace HappyFace; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/HappyFace/HappyFace.vcproj b/Chapter12/HappyFace/HappyFace.vcproj new file mode 100644 index 0000000..a9b7d8e --- /dev/null +++ b/Chapter12/HappyFace/HappyFace.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/HappyFace/ReadMe.txt b/Chapter12/HappyFace/ReadMe.txt new file mode 100644 index 0000000..6502b56 --- /dev/null +++ b/Chapter12/HappyFace/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : HappyFace Project Overview +======================================================================== + +AppWizard has created this HappyFace Application for you. + +This file contains a summary of what you will find in each of the files that +make up your HappyFace application. + +HappyFace.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +HappyFace.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named HappyFace.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/HappyFace/app.ico b/Chapter12/HappyFace/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/HappyFace/app.ico differ diff --git a/Chapter12/HappyFace/app.rc b/Chapter12/HappyFace/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/HappyFace/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/HappyFace/resource.h b/Chapter12/HappyFace/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/HappyFace/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/HappyFace/stdafx.cpp b/Chapter12/HappyFace/stdafx.cpp new file mode 100644 index 0000000..ea6f730 --- /dev/null +++ b/Chapter12/HappyFace/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// HappyFace.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/HappyFace/stdafx.h b/Chapter12/HappyFace/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/HappyFace/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/HelloGDI/AssemblyInfo.cpp b/Chapter12/HelloGDI/AssemblyInfo.cpp new file mode 100644 index 0000000..2a14a9e --- /dev/null +++ b/Chapter12/HelloGDI/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("HelloGDI")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("HelloGDI")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/HelloGDI/Form1.h b/Chapter12/HelloGDI/Form1.h new file mode 100644 index 0000000..4adfcda --- /dev/null +++ b/Chapter12/HelloGDI/Form1.h @@ -0,0 +1,81 @@ +#pragma once + + +namespace HelloGDI { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Hello GDI+"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Graphics ^g = e->Graphics; + g->DrawString("Hello World!", + gcnew Drawing::Font("Arial", 16), Brushes::Black, 75.0, 110.0); + } + }; +} + diff --git a/Chapter12/HelloGDI/Form1.resX b/Chapter12/HelloGDI/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/HelloGDI/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/HelloGDI/HelloGDI.cpp b/Chapter12/HelloGDI/HelloGDI.cpp new file mode 100644 index 0000000..074179a --- /dev/null +++ b/Chapter12/HelloGDI/HelloGDI.cpp @@ -0,0 +1,18 @@ +// HelloGDI.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace HelloGDI; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/HelloGDI/HelloGDI.vcproj b/Chapter12/HelloGDI/HelloGDI.vcproj new file mode 100644 index 0000000..4dd4cfe --- /dev/null +++ b/Chapter12/HelloGDI/HelloGDI.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/HelloGDI/ReadMe.txt b/Chapter12/HelloGDI/ReadMe.txt new file mode 100644 index 0000000..2228c30 --- /dev/null +++ b/Chapter12/HelloGDI/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : HelloGDI Project Overview +======================================================================== + +AppWizard has created this HelloGDI Application for you. + +This file contains a summary of what you will find in each of the files that +make up your HelloGDI application. + +HelloGDI.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +HelloGDI.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named HelloGDI.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/HelloGDI/app.ico b/Chapter12/HelloGDI/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/HelloGDI/app.ico differ diff --git a/Chapter12/HelloGDI/app.rc b/Chapter12/HelloGDI/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/HelloGDI/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/HelloGDI/resource.h b/Chapter12/HelloGDI/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/HelloGDI/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/HelloGDI/stdafx.cpp b/Chapter12/HelloGDI/stdafx.cpp new file mode 100644 index 0000000..a1d330d --- /dev/null +++ b/Chapter12/HelloGDI/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// HelloGDI.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/HelloGDI/stdafx.h b/Chapter12/HelloGDI/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/HelloGDI/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/HelloGDI_OnPaint/AssemblyInfo.cpp b/Chapter12/HelloGDI_OnPaint/AssemblyInfo.cpp new file mode 100644 index 0000000..a52035d --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("HelloGDI_OnPaint")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("HelloGDI_OnPaint")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/HelloGDI_OnPaint/Form1.h b/Chapter12/HelloGDI_OnPaint/Form1.h new file mode 100644 index 0000000..f6e5682 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/Form1.h @@ -0,0 +1,77 @@ +#pragma once + + +namespace HelloGDI_OnPaint { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = gcnew System::ComponentModel::Container(); + this->Size = System::Drawing::Size(300,300); + this->Text = L"Hello GDI+"; + this->Padding = System::Windows::Forms::Padding(0); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + } +#pragma endregion + + protected: + virtual void OnPaint(System::Windows::Forms::PaintEventArgs ^e) override + { + Form::OnPaint(e); + + Graphics ^g = e->Graphics; + g->DrawString("Hello World!", + gcnew Drawing::Font("Arial", 16), Brushes::Black, 75.0, 110.0); + } + }; +} + diff --git a/Chapter12/HelloGDI_OnPaint/Form1.resX b/Chapter12/HelloGDI_OnPaint/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/HelloGDI_OnPaint/HelloGDI_OnPaint.cpp b/Chapter12/HelloGDI_OnPaint/HelloGDI_OnPaint.cpp new file mode 100644 index 0000000..0717b94 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/HelloGDI_OnPaint.cpp @@ -0,0 +1,18 @@ +// HelloGDI_OnPaint.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace HelloGDI_OnPaint; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/HelloGDI_OnPaint/HelloGDI_OnPaint.vcproj b/Chapter12/HelloGDI_OnPaint/HelloGDI_OnPaint.vcproj new file mode 100644 index 0000000..9a901b0 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/HelloGDI_OnPaint.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/HelloGDI_OnPaint/ReadMe.txt b/Chapter12/HelloGDI_OnPaint/ReadMe.txt new file mode 100644 index 0000000..6c2443b --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : HelloGDI_OnPaint Project Overview +======================================================================== + +AppWizard has created this HelloGDI_OnPaint Application for you. + +This file contains a summary of what you will find in each of the files that +make up your HelloGDI_OnPaint application. + +HelloGDI_OnPaint.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +HelloGDI_OnPaint.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named HelloGDI_OnPaint.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/HelloGDI_OnPaint/app.ico b/Chapter12/HelloGDI_OnPaint/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/HelloGDI_OnPaint/app.ico differ diff --git a/Chapter12/HelloGDI_OnPaint/app.rc b/Chapter12/HelloGDI_OnPaint/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/HelloGDI_OnPaint/resource.h b/Chapter12/HelloGDI_OnPaint/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/HelloGDI_OnPaint/stdafx.cpp b/Chapter12/HelloGDI_OnPaint/stdafx.cpp new file mode 100644 index 0000000..67c8a92 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// HelloGDI_OnPaint.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/HelloGDI_OnPaint/stdafx.h b/Chapter12/HelloGDI_OnPaint/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/HelloGDI_OnPaint/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/InterOrUnion/AssemblyInfo.cpp b/Chapter12/InterOrUnion/AssemblyInfo.cpp new file mode 100644 index 0000000..954e3b6 --- /dev/null +++ b/Chapter12/InterOrUnion/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("InterOrUnion")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("InterOrUnion")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/InterOrUnion/Form1.h b/Chapter12/InterOrUnion/Form1.h new file mode 100644 index 0000000..b669b3f --- /dev/null +++ b/Chapter12/InterOrUnion/Form1.h @@ -0,0 +1,112 @@ +#pragma once + + +namespace InterOrUnion { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + // Build the rectangles from points and size + Drawing::Point point1 = Drawing::Point(25,25); + Drawing::Point point2 = Drawing::Point(100,100); + Drawing::Size size = Drawing::Size(200, 150); + rect1 = Drawing::Rectangle(point1, size); + rect2 = Drawing::Rectangle(point2, size); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + + // intersecting and unions rectangles + Drawing::Rectangle rect1; + Drawing::Rectangle rect2; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(330, 300); + this->Name = L"Form1"; + this->Text = L"Click in Window"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->MouseDown += + gcnew System::Windows::Forms::MouseEventHandler(this, + &Form1::Form1_MouseDown); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + // Draw a couple of rectangles + e->Graphics->DrawRectangle(Pens::Black, rect1); + e->Graphics->DrawRectangle(Pens::Black, rect2); + } + + + private: + System::Void Form1_MouseDown(System::Object^ sender, + System::Windows::Forms::MouseEventArgs^ e) + { + // build a point from x,y coords of mouse click + Point p = Point(e->X, e->Y); + + // did we click in the intersection? + if (Rectangle::Intersect(rect1, rect2).Contains(p)) + Text = "Intersection and Union"; + // did we click in the union? + else if (Rectangle::Union(rect1, rect2).Contains(p)) + Text = "Union"; + // did we miss altogether + else + Text = "Outside of Both"; + } + }; +} + diff --git a/Chapter12/InterOrUnion/Form1.resX b/Chapter12/InterOrUnion/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/InterOrUnion/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/InterOrUnion/InterOrUnion.cpp b/Chapter12/InterOrUnion/InterOrUnion.cpp new file mode 100644 index 0000000..d79ef33 --- /dev/null +++ b/Chapter12/InterOrUnion/InterOrUnion.cpp @@ -0,0 +1,18 @@ +// InterOrUnion.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace InterOrUnion; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/InterOrUnion/InterOrUnion.vcproj b/Chapter12/InterOrUnion/InterOrUnion.vcproj new file mode 100644 index 0000000..48d2699 --- /dev/null +++ b/Chapter12/InterOrUnion/InterOrUnion.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/InterOrUnion/ReadMe.txt b/Chapter12/InterOrUnion/ReadMe.txt new file mode 100644 index 0000000..eb044c5 --- /dev/null +++ b/Chapter12/InterOrUnion/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : InterOrUnion Project Overview +======================================================================== + +AppWizard has created this InterOrUnion Application for you. + +This file contains a summary of what you will find in each of the files that +make up your InterOrUnion application. + +InterOrUnion.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +InterOrUnion.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named InterOrUnion.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/InterOrUnion/app.ico b/Chapter12/InterOrUnion/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/InterOrUnion/app.ico differ diff --git a/Chapter12/InterOrUnion/app.rc b/Chapter12/InterOrUnion/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/InterOrUnion/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/InterOrUnion/resource.h b/Chapter12/InterOrUnion/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/InterOrUnion/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/InterOrUnion/stdafx.cpp b/Chapter12/InterOrUnion/stdafx.cpp new file mode 100644 index 0000000..dd8556c --- /dev/null +++ b/Chapter12/InterOrUnion/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// InterOrUnion.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/InterOrUnion/stdafx.h b/Chapter12/InterOrUnion/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/InterOrUnion/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/NewUnitsOrigin/AssemblyInfo.cpp b/Chapter12/NewUnitsOrigin/AssemblyInfo.cpp new file mode 100644 index 0000000..b5c3004 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("NewUnitsOrigin")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("NewUnitsOrigin")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/NewUnitsOrigin/Form1.h b/Chapter12/NewUnitsOrigin/Form1.h new file mode 100644 index 0000000..3cf58d2 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/Form1.h @@ -0,0 +1,87 @@ +#pragma once + + +namespace NewUnitsOrigin { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(341, 273); + this->Name = L"Form1"; + this->Text = L"Millimeter Unit of measure Origin (20,20)"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Graphics ^g = e->Graphics; + + // Draw a rectangle before unit of measure and origin change + g->DrawRectangle(Pens::Black, 5, 5, 50, 20); + + // Draw same rectangle after change + g->PageUnit = GraphicsUnit::Millimeter; + g->TranslateTransform(20,20); + g->DrawRectangle(Pens::Black, 5, 5, 50, 20); + } + }; +} + diff --git a/Chapter12/NewUnitsOrigin/Form1.resX b/Chapter12/NewUnitsOrigin/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/NewUnitsOrigin/NewUnitsOrigin.cpp b/Chapter12/NewUnitsOrigin/NewUnitsOrigin.cpp new file mode 100644 index 0000000..33225f3 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/NewUnitsOrigin.cpp @@ -0,0 +1,18 @@ +// NewUnitsOrigin.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace NewUnitsOrigin; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/NewUnitsOrigin/NewUnitsOrigin.vcproj b/Chapter12/NewUnitsOrigin/NewUnitsOrigin.vcproj new file mode 100644 index 0000000..36276e6 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/NewUnitsOrigin.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/NewUnitsOrigin/ReadMe.txt b/Chapter12/NewUnitsOrigin/ReadMe.txt new file mode 100644 index 0000000..270d7b9 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : NewUnitsOrigin Project Overview +======================================================================== + +AppWizard has created this NewUnitsOrigin Application for you. + +This file contains a summary of what you will find in each of the files that +make up your NewUnitsOrigin application. + +NewUnitsOrigin.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +NewUnitsOrigin.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named NewUnitsOrigin.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/NewUnitsOrigin/app.ico b/Chapter12/NewUnitsOrigin/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/NewUnitsOrigin/app.ico differ diff --git a/Chapter12/NewUnitsOrigin/app.rc b/Chapter12/NewUnitsOrigin/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/NewUnitsOrigin/resource.h b/Chapter12/NewUnitsOrigin/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/NewUnitsOrigin/stdafx.cpp b/Chapter12/NewUnitsOrigin/stdafx.cpp new file mode 100644 index 0000000..2431710 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// NewUnitsOrigin.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/NewUnitsOrigin/stdafx.h b/Chapter12/NewUnitsOrigin/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/NewUnitsOrigin/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/OnPaintWhere/AssemblyInfo.cpp b/Chapter12/OnPaintWhere/AssemblyInfo.cpp new file mode 100644 index 0000000..13bedb5 --- /dev/null +++ b/Chapter12/OnPaintWhere/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("OnPaintWhere")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("OnPaintWhere")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/OnPaintWhere/Form1.h b/Chapter12/OnPaintWhere/Form1.h new file mode 100644 index 0000000..42d87f6 --- /dev/null +++ b/Chapter12/OnPaintWhere/Form1.h @@ -0,0 +1,91 @@ +#pragma once + + +namespace OnPaintWhere { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Form1"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + protected: + virtual void OnPaint(System::Windows::Forms::PaintEventArgs ^e) override + { +// Form::OnPaint(e); + + e->Graphics->DrawString("Hello GDI+", + gcnew Drawing::Font("Arial", 16), Brushes::Black, 75.0, 110.0); + + Form::OnPaint(e); + } + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + e->Graphics->DrawString("Hello GDI+", + gcnew Drawing::Font("Arial", 16), Brushes::Purple, 75.0, 110.0); + } + }; +} + diff --git a/Chapter12/OnPaintWhere/Form1.resX b/Chapter12/OnPaintWhere/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/OnPaintWhere/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/OnPaintWhere/OnPaintWhere.cpp b/Chapter12/OnPaintWhere/OnPaintWhere.cpp new file mode 100644 index 0000000..175b65b --- /dev/null +++ b/Chapter12/OnPaintWhere/OnPaintWhere.cpp @@ -0,0 +1,18 @@ +// OnPaintWhere.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace OnPaintWhere; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/OnPaintWhere/OnPaintWhere.vcproj b/Chapter12/OnPaintWhere/OnPaintWhere.vcproj new file mode 100644 index 0000000..4231eef --- /dev/null +++ b/Chapter12/OnPaintWhere/OnPaintWhere.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/OnPaintWhere/ReadMe.txt b/Chapter12/OnPaintWhere/ReadMe.txt new file mode 100644 index 0000000..b2e881b --- /dev/null +++ b/Chapter12/OnPaintWhere/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : OnPaintWhere Project Overview +======================================================================== + +AppWizard has created this OnPaintWhere Application for you. + +This file contains a summary of what you will find in each of the files that +make up your OnPaintWhere application. + +OnPaintWhere.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +OnPaintWhere.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named OnPaintWhere.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/OnPaintWhere/app.ico b/Chapter12/OnPaintWhere/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/OnPaintWhere/app.ico differ diff --git a/Chapter12/OnPaintWhere/app.rc b/Chapter12/OnPaintWhere/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/OnPaintWhere/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/OnPaintWhere/resource.h b/Chapter12/OnPaintWhere/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/OnPaintWhere/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/OnPaintWhere/stdafx.cpp b/Chapter12/OnPaintWhere/stdafx.cpp new file mode 100644 index 0000000..0d99dc3 --- /dev/null +++ b/Chapter12/OnPaintWhere/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// OnPaintWhere.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/OnPaintWhere/stdafx.h b/Chapter12/OnPaintWhere/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/OnPaintWhere/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/OptimizedHappyFace/AssemblyInfo.cpp b/Chapter12/OptimizedHappyFace/AssemblyInfo.cpp new file mode 100644 index 0000000..aaa3881 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("OptimizedHappyFace")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("OptimizedHappyFace")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/OptimizedHappyFace/Form1.h b/Chapter12/OptimizedHappyFace/Form1.h new file mode 100644 index 0000000..7beaabc --- /dev/null +++ b/Chapter12/OptimizedHappyFace/Form1.h @@ -0,0 +1,121 @@ +#pragma once + + +namespace OptimizedHappyFace { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + Head = Drawing::Rectangle(125, 25, 250, 250); + Mouth = Drawing::Rectangle(200, 175, 100, 50); + LEye = Drawing::Rectangle(200, 100, 25, 25); + REye = Drawing::Rectangle(275, 100, 25, 25); + + b4pen = gcnew Pen(Color::Black, 4); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + + System::Drawing::Rectangle Head; + System::Drawing::Rectangle Mouth; + System::Drawing::Rectangle LEye; + System::Drawing::Rectangle REye; + Pen^ b4pen; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + + this->AutoScrollMinSize = System::Drawing::Size(400,400); + + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Optimized Happy Face"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Graphics^ g = e->Graphics; + + Drawing::Rectangle ClipRect = e->ClipRectangle; + ClipRect.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y); + + g->TranslateTransform((float)AutoScrollPosition.X, + (float)AutoScrollPosition.Y); + + if (!(Rectangle::Intersect(ClipRect, Head)).IsEmpty) + { + g->FillEllipse(Brushes::Yellow, Head); + g->DrawEllipse(b4pen, Head); + + if (!(Rectangle::Intersect(ClipRect, Mouth)).IsEmpty) + { + g->FillPie(Brushes::White, Mouth, 0, 180); + g->DrawPie(b4pen, Mouth, 0, 180); + } + if (!(Rectangle::Intersect(ClipRect, LEye)).IsEmpty) + { + g->FillEllipse(Brushes::White, LEye); + g->DrawEllipse(b4pen, LEye); + } + if (!(Rectangle::Intersect(ClipRect, REye)).IsEmpty) + { + g->FillEllipse(Brushes::White, REye); + g->DrawEllipse(b4pen, REye); + } + } + } + }; +} + diff --git a/Chapter12/OptimizedHappyFace/Form1.resX b/Chapter12/OptimizedHappyFace/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/OptimizedHappyFace/OptimizedHappyFace.cpp b/Chapter12/OptimizedHappyFace/OptimizedHappyFace.cpp new file mode 100644 index 0000000..62a9cc6 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/OptimizedHappyFace.cpp @@ -0,0 +1,18 @@ +// OptimizedHappyFace.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace OptimizedHappyFace; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/OptimizedHappyFace/OptimizedHappyFace.vcproj b/Chapter12/OptimizedHappyFace/OptimizedHappyFace.vcproj new file mode 100644 index 0000000..cdae268 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/OptimizedHappyFace.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/OptimizedHappyFace/ReadMe.txt b/Chapter12/OptimizedHappyFace/ReadMe.txt new file mode 100644 index 0000000..a8662b6 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : OptimizedHappyFace Project Overview +======================================================================== + +AppWizard has created this OptimizedHappyFace Application for you. + +This file contains a summary of what you will find in each of the files that +make up your OptimizedHappyFace application. + +OptimizedHappyFace.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +OptimizedHappyFace.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named OptimizedHappyFace.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/OptimizedHappyFace/app.ico b/Chapter12/OptimizedHappyFace/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/OptimizedHappyFace/app.ico differ diff --git a/Chapter12/OptimizedHappyFace/app.rc b/Chapter12/OptimizedHappyFace/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/OptimizedHappyFace/resource.h b/Chapter12/OptimizedHappyFace/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/OptimizedHappyFace/stdafx.cpp b/Chapter12/OptimizedHappyFace/stdafx.cpp new file mode 100644 index 0000000..aa4d3ea --- /dev/null +++ b/Chapter12/OptimizedHappyFace/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// OptimizedHappyFace.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/OptimizedHappyFace/stdafx.h b/Chapter12/OptimizedHappyFace/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/OptimizedHappyFace/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/PrintHappyFace/AssemblyInfo.cpp b/Chapter12/PrintHappyFace/AssemblyInfo.cpp new file mode 100644 index 0000000..e16d5b3 --- /dev/null +++ b/Chapter12/PrintHappyFace/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("PrintHappyFace")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("PrintHappyFace")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/PrintHappyFace/Form1.h b/Chapter12/PrintHappyFace/Form1.h new file mode 100644 index 0000000..8f0f852 --- /dev/null +++ b/Chapter12/PrintHappyFace/Form1.h @@ -0,0 +1,139 @@ +#pragma once + + +namespace PrintHappyFace { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::Drawing::Printing::PrintDocument^ printDocument; + System::Windows::Forms::PrintDialog^ printDialog; + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->printDocument = + (gcnew System::Drawing::Printing::PrintDocument()); + this->printDialog = (gcnew System::Windows::Forms::PrintDialog()); + this->SuspendLayout(); + // + // printDocument + // + this->printDocument->PrintPage += + gcnew System::Drawing::Printing::PrintPageEventHandler(this, + &Form1::printDocument_PrintPage); + // + // printDialog + // + this->printDialog->Document = this->printDocument; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(300, 300); + this->Name = L"Form1"; + this->Text = L"Click to Print"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->Click += + gcnew System::EventHandler(this, &Form1::Form1_Click); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Click(System::Object^ sender, System::EventArgs^ e) + { + // Display Print dialog when mouse pressed + if (printDialog->ShowDialog() == Windows::Forms::DialogResult::OK) + { + printDocument->Print(); + } + } + + + System::Void printDocument_PrintPage(System::Object^ sender, + System::Drawing::Printing::PrintPageEventArgs^ e) + { + CreateHappyFace(e->Graphics); //Same call as Form1_Paint + e->HasMorePages = false; + } + + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + CreateHappyFace(e->Graphics);//Same call as printDocument_PrintPage + } + + // Generic Happy Face Creator + void CreateHappyFace(Graphics ^g) + { + Pen^ b4pen = gcnew Pen(Color::Black, 4); + + Rectangle rect = Drawing::Rectangle(25, 25, 250, 250); + g->FillEllipse(Brushes::Yellow, rect); + g->DrawEllipse(b4pen, rect); + + g->FillPie(Brushes::White, 100, 175, 100, 50, 0, 180); + g->DrawPie(b4pen, 100, 175, 100, 50, 0, 180); + + rect = Drawing::Rectangle(100, 100, 25, 25); + g->FillEllipse(Brushes::White, rect); + g->DrawEllipse(b4pen, rect); + + rect = Drawing::Rectangle(175, 100, 25, 25); + g->FillEllipse(Brushes::White, rect); + g->DrawEllipse(b4pen, rect); + + delete b4pen; + } + }; +} + diff --git a/Chapter12/PrintHappyFace/Form1.resX b/Chapter12/PrintHappyFace/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/PrintHappyFace/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/PrintHappyFace/PrintHappyFace.cpp b/Chapter12/PrintHappyFace/PrintHappyFace.cpp new file mode 100644 index 0000000..e2c309c --- /dev/null +++ b/Chapter12/PrintHappyFace/PrintHappyFace.cpp @@ -0,0 +1,18 @@ +// PrintHappyFace.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace PrintHappyFace; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/PrintHappyFace/PrintHappyFace.vcproj b/Chapter12/PrintHappyFace/PrintHappyFace.vcproj new file mode 100644 index 0000000..50c4f46 --- /dev/null +++ b/Chapter12/PrintHappyFace/PrintHappyFace.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/PrintHappyFace/ReadMe.txt b/Chapter12/PrintHappyFace/ReadMe.txt new file mode 100644 index 0000000..eccbab6 --- /dev/null +++ b/Chapter12/PrintHappyFace/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : PrintHappyFace Project Overview +======================================================================== + +AppWizard has created this PrintHappyFace Application for you. + +This file contains a summary of what you will find in each of the files that +make up your PrintHappyFace application. + +PrintHappyFace.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +PrintHappyFace.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named PrintHappyFace.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/PrintHappyFace/app.ico b/Chapter12/PrintHappyFace/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/PrintHappyFace/app.ico differ diff --git a/Chapter12/PrintHappyFace/app.rc b/Chapter12/PrintHappyFace/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/PrintHappyFace/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/PrintHappyFace/resource.h b/Chapter12/PrintHappyFace/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/PrintHappyFace/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/PrintHappyFace/stdafx.cpp b/Chapter12/PrintHappyFace/stdafx.cpp new file mode 100644 index 0000000..039160b --- /dev/null +++ b/Chapter12/PrintHappyFace/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// PrintHappyFace.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/PrintHappyFace/stdafx.h b/Chapter12/PrintHappyFace/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/PrintHappyFace/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/RegionEx/AssemblyInfo.cpp b/Chapter12/RegionEx/AssemblyInfo.cpp new file mode 100644 index 0000000..f01c416 --- /dev/null +++ b/Chapter12/RegionEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("RegionEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("RegionEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/RegionEx/Form1.h b/Chapter12/RegionEx/Form1.h new file mode 100644 index 0000000..5cc7a12 --- /dev/null +++ b/Chapter12/RegionEx/Form1.h @@ -0,0 +1,88 @@ +#pragma once + + +namespace RegionEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + Drawing::Point point1 = Drawing::Point(25,25); + Drawing::Point point2 = Drawing::Point(100,100); + Drawing::Size size = Drawing::Size(200, 150); + Rectangle rect1 = Drawing::Rectangle(point1, size); + Rectangle rect2 = Drawing::Rectangle(point2, size); + + region = gcnew Drawing::Region(rect1); + region->Xor(rect2); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + Drawing::Region ^region; + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(322, 273); + this->Name = L"Form1"; + this->Text = L"Filling A Region"; + + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + e->Graphics->FillRegion(Brushes::Blue, region); + } + }; +} + diff --git a/Chapter12/RegionEx/Form1.resX b/Chapter12/RegionEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/RegionEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/RegionEx/ReadMe.txt b/Chapter12/RegionEx/ReadMe.txt new file mode 100644 index 0000000..b9d9015 --- /dev/null +++ b/Chapter12/RegionEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : RegionEx Project Overview +======================================================================== + +AppWizard has created this RegionEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your RegionEx application. + +RegionEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +RegionEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named RegionEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/RegionEx/RegionEx.cpp b/Chapter12/RegionEx/RegionEx.cpp new file mode 100644 index 0000000..79c33fd --- /dev/null +++ b/Chapter12/RegionEx/RegionEx.cpp @@ -0,0 +1,18 @@ +// RegionEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace RegionEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/RegionEx/RegionEx.vcproj b/Chapter12/RegionEx/RegionEx.vcproj new file mode 100644 index 0000000..6fcfad9 --- /dev/null +++ b/Chapter12/RegionEx/RegionEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/RegionEx/app.ico b/Chapter12/RegionEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/RegionEx/app.ico differ diff --git a/Chapter12/RegionEx/app.rc b/Chapter12/RegionEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/RegionEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/RegionEx/resource.h b/Chapter12/RegionEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/RegionEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/RegionEx/stdafx.cpp b/Chapter12/RegionEx/stdafx.cpp new file mode 100644 index 0000000..436cd29 --- /dev/null +++ b/Chapter12/RegionEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// RegionEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/RegionEx/stdafx.h b/Chapter12/RegionEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/RegionEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/ScrollingHappyFace/AssemblyInfo.cpp b/Chapter12/ScrollingHappyFace/AssemblyInfo.cpp new file mode 100644 index 0000000..cfc4a0b --- /dev/null +++ b/Chapter12/ScrollingHappyFace/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ScrollingHappyFace")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ScrollingHappyFace")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/ScrollingHappyFace/Form1.h b/Chapter12/ScrollingHappyFace/Form1.h new file mode 100644 index 0000000..5f46aa4 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/Form1.h @@ -0,0 +1,110 @@ +#pragma once + + +namespace ScrollingHappyFace { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + + + this->AutoScrollMinSize = System::Drawing::Size(400,400); + + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Scrolling Happy Face"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Graphics^ g = e->Graphics; + g->TranslateTransform((float)AutoScrollPosition.X, + (float)AutoScrollPosition.Y); + + Pen^ b4pen = gcnew Pen(Color::Black, 4); + + // Head + Rectangle rect = Drawing::Rectangle(25, 25, 250, 250); + g->FillEllipse(Brushes::Yellow, rect); + g->DrawEllipse(b4pen, rect); + + // Mouth + g->FillPie(Brushes::White, 100, 175, 100, 50, 0, 180); + g->DrawPie(b4pen, 100, 175, 100, 50, 0, 180); + + // Left Eye + rect = Drawing::Rectangle(100, 100, 25, 25); + g->FillEllipse(Brushes::White, rect); + g->DrawEllipse(b4pen, rect); + + // Right Eye + rect = Drawing::Rectangle(175, 100, 25, 25); + g->FillEllipse(Brushes::White, rect); + g->DrawEllipse(b4pen, rect); + + // Get rid of pen Created + delete b4pen; + } + }; +} + diff --git a/Chapter12/ScrollingHappyFace/Form1.resX b/Chapter12/ScrollingHappyFace/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/ScrollingHappyFace/ReadMe.txt b/Chapter12/ScrollingHappyFace/ReadMe.txt new file mode 100644 index 0000000..a092b98 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : ScrollingHappyFace Project Overview +======================================================================== + +AppWizard has created this ScrollingHappyFace Application for you. + +This file contains a summary of what you will find in each of the files that +make up your ScrollingHappyFace application. + +ScrollingHappyFace.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ScrollingHappyFace.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ScrollingHappyFace.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/ScrollingHappyFace/ScrollingHappyFace.cpp b/Chapter12/ScrollingHappyFace/ScrollingHappyFace.cpp new file mode 100644 index 0000000..648a6b5 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/ScrollingHappyFace.cpp @@ -0,0 +1,18 @@ +// ScrollingHappyFace.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace ScrollingHappyFace; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/ScrollingHappyFace/ScrollingHappyFace.vcproj b/Chapter12/ScrollingHappyFace/ScrollingHappyFace.vcproj new file mode 100644 index 0000000..c1272e4 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/ScrollingHappyFace.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/ScrollingHappyFace/app.ico b/Chapter12/ScrollingHappyFace/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/ScrollingHappyFace/app.ico differ diff --git a/Chapter12/ScrollingHappyFace/app.rc b/Chapter12/ScrollingHappyFace/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/ScrollingHappyFace/resource.h b/Chapter12/ScrollingHappyFace/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/ScrollingHappyFace/stdafx.cpp b/Chapter12/ScrollingHappyFace/stdafx.cpp new file mode 100644 index 0000000..9d5103c --- /dev/null +++ b/Chapter12/ScrollingHappyFace/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// ScrollingHappyFace.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/ScrollingHappyFace/stdafx.h b/Chapter12/ScrollingHappyFace/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/ScrollingHappyFace/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/SingleBuffering/AssemblyInfo.cpp b/Chapter12/SingleBuffering/AssemblyInfo.cpp new file mode 100644 index 0000000..8f2a26b --- /dev/null +++ b/Chapter12/SingleBuffering/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("SingleBuffering")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("SingleBuffering")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/SingleBuffering/Form1.h b/Chapter12/SingleBuffering/Form1.h new file mode 100644 index 0000000..0193be3 --- /dev/null +++ b/Chapter12/SingleBuffering/Form1.h @@ -0,0 +1,130 @@ +#pragma once + + +namespace SingleBuffering { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + X = -250; // Preset to be just left of window + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + + System::Windows::Forms::Timer^ timer1; + float X; // Actual x coordinate of Happy face + + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + this->timer1 = + (gcnew System::Windows::Forms::Timer(this->components)); + this->SuspendLayout(); + // + // timer1 + // + this->timer1->Enabled = true; + this->timer1->Interval = 10; + this->timer1->Tick += + gcnew System::EventHandler(this, &Form1::timer1_Tick); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(500, 300); + this->Name = L"Form1"; + this->Text = L"Form1"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + } +#pragma endregion + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + Graphics^ g = e->Graphics; + + // Move image at end of line start from beginning + if (X < ClientRectangle.Width) + X += 1.0; + else + X = -250.0; + + g->TranslateTransform(X, 25.0); + + // redraw images from scratch + Pen^ b4pen = gcnew Pen(Color::Black, 4); + + + Drawing::Rectangle Head = Drawing::Rectangle(0, 0, 250, 250); + g->FillEllipse(Brushes::Yellow, Head); + g->DrawEllipse(b4pen, Head); + + Drawing::Rectangle Mouth = Drawing::Rectangle(75, 150, 100, 50); + g->FillPie(Brushes::White, Mouth,0,180); + g->DrawPie(b4pen, Mouth, 0, 180); + + Drawing::Rectangle LEye = Drawing::Rectangle(75, 75, 25, 25); + g->FillEllipse(Brushes::White, LEye); + g->DrawEllipse(b4pen, LEye); + + Drawing::Rectangle REye = Drawing::Rectangle(150, 75, 25, 25); + g->FillEllipse(Brushes::White, REye); + g->DrawEllipse(b4pen, REye); + + delete b4pen; + } + + System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) + { + // Move the image + Invalidate(); + } + }; +} + diff --git a/Chapter12/SingleBuffering/Form1.resX b/Chapter12/SingleBuffering/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/SingleBuffering/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/SingleBuffering/ReadMe.txt b/Chapter12/SingleBuffering/ReadMe.txt new file mode 100644 index 0000000..d6897b5 --- /dev/null +++ b/Chapter12/SingleBuffering/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : SingleBuffering Project Overview +======================================================================== + +AppWizard has created this SingleBuffering Application for you. + +This file contains a summary of what you will find in each of the files that +make up your SingleBuffering application. + +SingleBuffering.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +SingleBuffering.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named SingleBuffering.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/SingleBuffering/SingleBuffering.cpp b/Chapter12/SingleBuffering/SingleBuffering.cpp new file mode 100644 index 0000000..920d93b --- /dev/null +++ b/Chapter12/SingleBuffering/SingleBuffering.cpp @@ -0,0 +1,18 @@ +// SingleBuffering.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace SingleBuffering; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/SingleBuffering/SingleBuffering.vcproj b/Chapter12/SingleBuffering/SingleBuffering.vcproj new file mode 100644 index 0000000..098195e --- /dev/null +++ b/Chapter12/SingleBuffering/SingleBuffering.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/SingleBuffering/app.ico b/Chapter12/SingleBuffering/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/SingleBuffering/app.ico differ diff --git a/Chapter12/SingleBuffering/app.rc b/Chapter12/SingleBuffering/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/SingleBuffering/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/SingleBuffering/resource.h b/Chapter12/SingleBuffering/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/SingleBuffering/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/SingleBuffering/stdafx.cpp b/Chapter12/SingleBuffering/stdafx.cpp new file mode 100644 index 0000000..2fc42b5 --- /dev/null +++ b/Chapter12/SingleBuffering/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// SingleBuffering.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/SingleBuffering/stdafx.h b/Chapter12/SingleBuffering/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/SingleBuffering/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/StringRect/AssemblyInfo.cpp b/Chapter12/StringRect/AssemblyInfo.cpp new file mode 100644 index 0000000..d4ca82f --- /dev/null +++ b/Chapter12/StringRect/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("StringRect")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("StringRect")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/StringRect/Form1.h b/Chapter12/StringRect/Form1.h new file mode 100644 index 0000000..d9b75ea --- /dev/null +++ b/Chapter12/StringRect/Form1.h @@ -0,0 +1,87 @@ +#pragma once + + +namespace StringRect { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 200); + this->Name = L"Form1"; + this->Text = L"String in a Rectangle"; + this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint); + this->ResumeLayout(false); + + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + // Draw the string + e->Graphics->DrawString( + "Let's draw a string to a rectangle and go a little " + "overboard on the size of the string that we place " + "inside of it", + gcnew Drawing::Font(gcnew FontFamily("Arial"), 12), + Brushes::Black, Drawing::RectangleF(20.0, 40.0, 260.0, 50.0)); + } + }; +} + diff --git a/Chapter12/StringRect/Form1.resx b/Chapter12/StringRect/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/Chapter12/StringRect/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/StringRect/ReadMe.txt b/Chapter12/StringRect/ReadMe.txt new file mode 100644 index 0000000..1240f70 --- /dev/null +++ b/Chapter12/StringRect/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : StringRect Project Overview +======================================================================== + +AppWizard has created this StringRect Application for you. + +This file contains a summary of what you will find in each of the files that +make up your StringRect application. + +StringRect.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +StringRect.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named StringRect.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/StringRect/StringRect.cpp b/Chapter12/StringRect/StringRect.cpp new file mode 100644 index 0000000..03e0077 --- /dev/null +++ b/Chapter12/StringRect/StringRect.cpp @@ -0,0 +1,18 @@ +// StringRect.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace StringRect; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/StringRect/StringRect.vcproj b/Chapter12/StringRect/StringRect.vcproj new file mode 100644 index 0000000..16176e6 --- /dev/null +++ b/Chapter12/StringRect/StringRect.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/StringRect/app.ico b/Chapter12/StringRect/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/StringRect/app.ico differ diff --git a/Chapter12/StringRect/app.rc b/Chapter12/StringRect/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/StringRect/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/StringRect/resource.h b/Chapter12/StringRect/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/StringRect/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/StringRect/stdafx.cpp b/Chapter12/StringRect/stdafx.cpp new file mode 100644 index 0000000..4fdd513 --- /dev/null +++ b/Chapter12/StringRect/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// StringRect.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/StringRect/stdafx.h b/Chapter12/StringRect/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/StringRect/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter12/TextureBrushEx/AssemblyInfo.cpp b/Chapter12/TextureBrushEx/AssemblyInfo.cpp new file mode 100644 index 0000000..1dc2b77 --- /dev/null +++ b/Chapter12/TextureBrushEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("TextureBrushEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("TextureBrushEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter12/TextureBrushEx/Form1.h b/Chapter12/TextureBrushEx/Form1.h new file mode 100644 index 0000000..ddfd8b2 --- /dev/null +++ b/Chapter12/TextureBrushEx/Form1.h @@ -0,0 +1,90 @@ +#pragma once + + +namespace TextureBrushEx { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::Drawing::Drawing2D; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->SuspendLayout(); + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 273); + this->Name = L"Form1"; + this->Text = L"Texture Brush"; + this->Paint += + gcnew System::Windows::Forms::PaintEventHandler(this, + &Form1::Form1_Paint); + this->ResumeLayout(false); + + } +#pragma endregion + + private: + System::Void Form1_Paint(System::Object^ sender, + System::Windows::Forms::PaintEventArgs^ e) + { + // Load Image + Image^ bimage = gcnew Bitmap("Images\\CLICppCover.gif"); + // Create brush + TextureBrush^ tbsh = gcnew TextureBrush(bimage, + WrapMode::TileFlipXY); + + // Translate brush to same start location as rectangle + tbsh->TranslateTransform(25,25); + // Fill rectangle with brush + e->Graphics->FillRectangle(tbsh, 25, 25, 250, 250); + } + }; +} + diff --git a/Chapter12/TextureBrushEx/Form1.resX b/Chapter12/TextureBrushEx/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter12/TextureBrushEx/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter12/TextureBrushEx/Images/CLICppCover.gif b/Chapter12/TextureBrushEx/Images/CLICppCover.gif new file mode 100644 index 0000000..b9c6832 Binary files /dev/null and b/Chapter12/TextureBrushEx/Images/CLICppCover.gif differ diff --git a/Chapter12/TextureBrushEx/ReadMe.txt b/Chapter12/TextureBrushEx/ReadMe.txt new file mode 100644 index 0000000..b72c567 --- /dev/null +++ b/Chapter12/TextureBrushEx/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : TextureBrushEx Project Overview +======================================================================== + +AppWizard has created this TextureBrushEx Application for you. + +This file contains a summary of what you will find in each of the files that +make up your TextureBrushEx application. + +TextureBrushEx.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +TextureBrushEx.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named TextureBrushEx.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter12/TextureBrushEx/TextureBrushEx.cpp b/Chapter12/TextureBrushEx/TextureBrushEx.cpp new file mode 100644 index 0000000..43feae2 --- /dev/null +++ b/Chapter12/TextureBrushEx/TextureBrushEx.cpp @@ -0,0 +1,18 @@ +// TextureBrushEx.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace TextureBrushEx; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter12/TextureBrushEx/TextureBrushEx.vcproj b/Chapter12/TextureBrushEx/TextureBrushEx.vcproj new file mode 100644 index 0000000..a5c1e1c --- /dev/null +++ b/Chapter12/TextureBrushEx/TextureBrushEx.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter12/TextureBrushEx/app.ico b/Chapter12/TextureBrushEx/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter12/TextureBrushEx/app.ico differ diff --git a/Chapter12/TextureBrushEx/app.rc b/Chapter12/TextureBrushEx/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter12/TextureBrushEx/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter12/TextureBrushEx/resource.h b/Chapter12/TextureBrushEx/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter12/TextureBrushEx/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter12/TextureBrushEx/stdafx.cpp b/Chapter12/TextureBrushEx/stdafx.cpp new file mode 100644 index 0000000..0f33915 --- /dev/null +++ b/Chapter12/TextureBrushEx/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// TextureBrushEx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter12/TextureBrushEx/stdafx.h b/Chapter12/TextureBrushEx/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter12/TextureBrushEx/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter13/AuthorDSLib/AuthorDSLib.csproj b/Chapter13/AuthorDSLib/AuthorDSLib.csproj new file mode 100644 index 0000000..1722909 --- /dev/null +++ b/Chapter13/AuthorDSLib/AuthorDSLib.csproj @@ -0,0 +1,86 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0} + Library + Properties + AuthorDSLib + AuthorDSLib + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + True + True + AuthorsDS.xsd + + + + True + True + Settings.settings + + + + + + AuthorsDS.xsd + + + Designer + MSDataSetGenerator + AuthorsDS.Designer.cs + + + AuthorsDS.xsd + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + \ No newline at end of file diff --git a/Chapter13/AuthorDSLib/AuthorsDS.Designer.cs b/Chapter13/AuthorDSLib/AuthorsDS.Designer.cs new file mode 100644 index 0000000..4743120 --- /dev/null +++ b/Chapter13/AuthorDSLib/AuthorsDS.Designer.cs @@ -0,0 +1,1328 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +#pragma warning disable 1591 + +namespace AuthorDSLib { + + + /// + ///Represents a strongly typed in-memory cache of data. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.ComponentModel.DesignerCategoryAttribute("code")] + [global::System.ComponentModel.ToolboxItem(true)] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema")] + [global::System.Xml.Serialization.XmlRootAttribute("AuthorsDS")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")] + public partial class AuthorsDS : global::System.Data.DataSet { + + private AuthorsDataTable tableAuthors; + + private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsDS() { + this.BeginInit(); + this.InitClass(); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + base.Relations.CollectionChanged += schemaChangedHandler; + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected AuthorsDS(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context, false) { + if ((this.IsBinarySerialized(info, context) == true)) { + this.InitVars(false); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + this.Tables.CollectionChanged += schemaChangedHandler1; + this.Relations.CollectionChanged += schemaChangedHandler1; + return; + } + string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string)))); + if ((this.DetermineSchemaSerializationMode(info, context) == global::System.Data.SchemaSerializationMode.IncludeSchema)) { + global::System.Data.DataSet ds = new global::System.Data.DataSet(); + ds.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); + if ((ds.Tables["Authors"] != null)) { + base.Tables.Add(new AuthorsDataTable(ds.Tables["Authors"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXmlSchema(new global::System.Xml.XmlTextReader(new global::System.IO.StringReader(strSchema))); + } + this.GetSerializationData(info, context); + global::System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new global::System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged); + base.Tables.CollectionChanged += schemaChangedHandler; + this.Relations.CollectionChanged += schemaChangedHandler; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] + public AuthorsDataTable Authors { + get { + return this.tableAuthors; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.BrowsableAttribute(true)] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Visible)] + public override global::System.Data.SchemaSerializationMode SchemaSerializationMode { + get { + return this._schemaSerializationMode; + } + set { + this._schemaSerializationMode = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new global::System.Data.DataTableCollection Tables { + get { + return base.Tables; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.DesignerSerializationVisibilityAttribute(global::System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public new global::System.Data.DataRelationCollection Relations { + get { + return base.Relations; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void InitializeDerivedDataSet() { + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataSet Clone() { + AuthorsDS cln = ((AuthorsDS)(base.Clone())); + cln.InitVars(); + cln.SchemaSerializationMode = this.SchemaSerializationMode; + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeTables() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override bool ShouldSerializeRelations() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void ReadXmlSerializable(global::System.Xml.XmlReader reader) { + if ((this.DetermineSchemaSerializationMode(reader) == global::System.Data.SchemaSerializationMode.IncludeSchema)) { + this.Reset(); + global::System.Data.DataSet ds = new global::System.Data.DataSet(); + ds.ReadXml(reader); + if ((ds.Tables["Authors"] != null)) { + base.Tables.Add(new AuthorsDataTable(ds.Tables["Authors"])); + } + this.DataSetName = ds.DataSetName; + this.Prefix = ds.Prefix; + this.Namespace = ds.Namespace; + this.Locale = ds.Locale; + this.CaseSensitive = ds.CaseSensitive; + this.EnforceConstraints = ds.EnforceConstraints; + this.Merge(ds, false, global::System.Data.MissingSchemaAction.Add); + this.InitVars(); + } + else { + this.ReadXml(reader); + this.InitVars(); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable() { + global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream(); + this.WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null)); + stream.Position = 0; + return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.InitVars(true); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars(bool initTable) { + this.tableAuthors = ((AuthorsDataTable)(base.Tables["Authors"])); + if ((initTable == true)) { + if ((this.tableAuthors != null)) { + this.tableAuthors.InitVars(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.DataSetName = "AuthorsDS"; + this.Prefix = ""; + this.Namespace = "http://tempuri.org/AuthorsDS.xsd"; + this.EnforceConstraints = true; + this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; + this.tableAuthors = new AuthorsDataTable(); + base.Tables.Add(this.tableAuthors); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private bool ShouldSerializeAuthors() { + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void SchemaChanged(object sender, global::System.ComponentModel.CollectionChangeEventArgs e) { + if ((e.Action == global::System.ComponentModel.CollectionChangeAction.Remove)) { + this.InitVars(); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + AuthorsDS ds = new AuthorsDS(); + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); + any.Namespace = ds.Namespace; + sequence.Items.Add(any); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + + public delegate void AuthorsRowChangeEventHandler(object sender, AuthorsRowChangeEvent e); + + /// + ///Represents the strongly named DataTable class. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.Serializable()] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class AuthorsDataTable : global::System.Data.TypedTableBase { + + private global::System.Data.DataColumn columnAuthorID; + + private global::System.Data.DataColumn columnLastName; + + private global::System.Data.DataColumn columnFirstName; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsDataTable() { + this.TableName = "Authors"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal AuthorsDataTable(global::System.Data.DataTable table) { + this.TableName = table.TableName; + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected AuthorsDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context) { + this.InitVars(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn AuthorIDColumn { + get { + return this.columnAuthorID; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn LastNameColumn { + get { + return this.columnLastName; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataColumn FirstNameColumn { + get { + return this.columnFirstName; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + public int Count { + get { + return this.Rows.Count; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsRow this[int index] { + get { + return ((AuthorsRow)(this.Rows[index])); + } + } + + public event AuthorsRowChangeEventHandler AuthorsRowChanging; + + public event AuthorsRowChangeEventHandler AuthorsRowChanged; + + public event AuthorsRowChangeEventHandler AuthorsRowDeleting; + + public event AuthorsRowChangeEventHandler AuthorsRowDeleted; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void AddAuthorsRow(AuthorsRow row) { + this.Rows.Add(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsRow AddAuthorsRow(string LastName, string FirstName) { + AuthorsRow rowAuthorsRow = ((AuthorsRow)(this.NewRow())); + object[] columnValuesArray = new object[] { + null, + LastName, + FirstName}; + rowAuthorsRow.ItemArray = columnValuesArray; + this.Rows.Add(rowAuthorsRow); + return rowAuthorsRow; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsRow FindByAuthorID(int AuthorID) { + return ((AuthorsRow)(this.Rows.Find(new object[] { + AuthorID}))); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public override global::System.Data.DataTable Clone() { + AuthorsDataTable cln = ((AuthorsDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataTable CreateInstance() { + return new AuthorsDataTable(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal void InitVars() { + this.columnAuthorID = base.Columns["AuthorID"]; + this.columnLastName = base.Columns["LastName"]; + this.columnFirstName = base.Columns["FirstName"]; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitClass() { + this.columnAuthorID = new global::System.Data.DataColumn("AuthorID", typeof(int), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnAuthorID); + this.columnLastName = new global::System.Data.DataColumn("LastName", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnLastName); + this.columnFirstName = new global::System.Data.DataColumn("FirstName", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnFirstName); + this.Constraints.Add(new global::System.Data.UniqueConstraint("Constraint1", new global::System.Data.DataColumn[] { + this.columnAuthorID}, true)); + this.columnAuthorID.AutoIncrement = true; + this.columnAuthorID.AutoIncrementSeed = -1; + this.columnAuthorID.AutoIncrementStep = -1; + this.columnAuthorID.AllowDBNull = false; + this.columnAuthorID.ReadOnly = true; + this.columnAuthorID.Unique = true; + this.columnLastName.AllowDBNull = false; + this.columnLastName.MaxLength = 50; + this.columnFirstName.AllowDBNull = false; + this.columnFirstName.MaxLength = 50; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsRow NewAuthorsRow() { + return ((AuthorsRow)(this.NewRow())); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { + return new AuthorsRow(builder); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override global::System.Type GetRowType() { + return typeof(AuthorsRow); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.AuthorsRowChanged != null)) { + this.AuthorsRowChanged(this, new AuthorsRowChangeEvent(((AuthorsRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.AuthorsRowChanging != null)) { + this.AuthorsRowChanging(this, new AuthorsRowChangeEvent(((AuthorsRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.AuthorsRowDeleted != null)) { + this.AuthorsRowDeleted(this, new AuthorsRowChangeEvent(((AuthorsRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.AuthorsRowDeleting != null)) { + this.AuthorsRowDeleting(this, new AuthorsRowChangeEvent(((AuthorsRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public void RemoveAuthorsRow(AuthorsRow row) { + this.Rows.Remove(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + AuthorsDS ds = new AuthorsDS(); + global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); + any1.Namespace = "http://www.w3.org/2001/XMLSchema"; + any1.MinOccurs = new decimal(0); + any1.MaxOccurs = decimal.MaxValue; + any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any1); + global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; + any2.MinOccurs = new decimal(1); + any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any2); + global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute1.Name = "namespace"; + attribute1.FixedValue = ds.Namespace; + type.Attributes.Add(attribute1); + global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute2.Name = "tableTypeName"; + attribute2.FixedValue = "AuthorsDataTable"; + type.Attributes.Add(attribute2); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + } + + /// + ///Represents strongly named DataRow class. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public partial class AuthorsRow : global::System.Data.DataRow { + + private AuthorsDataTable tableAuthors; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal AuthorsRow(global::System.Data.DataRowBuilder rb) : + base(rb) { + this.tableAuthors = ((AuthorsDataTable)(this.Table)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public int AuthorID { + get { + return ((int)(this[this.tableAuthors.AuthorIDColumn])); + } + set { + this[this.tableAuthors.AuthorIDColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string LastName { + get { + return ((string)(this[this.tableAuthors.LastNameColumn])); + } + set { + this[this.tableAuthors.LastNameColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public string FirstName { + get { + return ((string)(this[this.tableAuthors.FirstNameColumn])); + } + set { + this[this.tableAuthors.FirstNameColumn] = value; + } + } + } + + /// + ///Row event argument class + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public class AuthorsRowChangeEvent : global::System.EventArgs { + + private AuthorsRow eventRow; + + private global::System.Data.DataRowAction eventAction; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsRowChangeEvent(AuthorsRow row, global::System.Data.DataRowAction action) { + this.eventRow = row; + this.eventAction = action; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsRow Row { + get { + return this.eventRow; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } + } +} +namespace AuthorDSLib.AuthorsDSTableAdapters { + + + /// + ///Represents the connection and commands used to retrieve and save data. + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.ComponentModel.DesignerCategoryAttribute("code")] + [global::System.ComponentModel.ToolboxItem(true)] + [global::System.ComponentModel.DataObjectAttribute(true)] + [global::System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner" + + ", Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public partial class AuthorsTableAdapter : global::System.ComponentModel.Component { + + private global::System.Data.SqlClient.SqlDataAdapter _adapter; + + private global::System.Data.SqlClient.SqlConnection _connection; + + private global::System.Data.SqlClient.SqlTransaction _transaction; + + private global::System.Data.SqlClient.SqlCommand[] _commandCollection; + + private bool _clearBeforeFill; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public AuthorsTableAdapter() { + this.ClearBeforeFill = true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected internal global::System.Data.SqlClient.SqlDataAdapter Adapter { + get { + if ((this._adapter == null)) { + this.InitAdapter(); + } + return this._adapter; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal global::System.Data.SqlClient.SqlConnection Connection { + get { + if ((this._connection == null)) { + this.InitConnection(); + } + return this._connection; + } + set { + this._connection = value; + if ((this.Adapter.InsertCommand != null)) { + this.Adapter.InsertCommand.Connection = value; + } + if ((this.Adapter.DeleteCommand != null)) { + this.Adapter.DeleteCommand.Connection = value; + } + if ((this.Adapter.UpdateCommand != null)) { + this.Adapter.UpdateCommand.Connection = value; + } + for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1)) { + if ((this.CommandCollection[i] != null)) { + ((global::System.Data.SqlClient.SqlCommand)(this.CommandCollection[i])).Connection = value; + } + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal global::System.Data.SqlClient.SqlTransaction Transaction { + get { + return this._transaction; + } + set { + this._transaction = value; + for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1)) { + this.CommandCollection[i].Transaction = this._transaction; + } + if (((this.Adapter != null) + && (this.Adapter.DeleteCommand != null))) { + this.Adapter.DeleteCommand.Transaction = this._transaction; + } + if (((this.Adapter != null) + && (this.Adapter.InsertCommand != null))) { + this.Adapter.InsertCommand.Transaction = this._transaction; + } + if (((this.Adapter != null) + && (this.Adapter.UpdateCommand != null))) { + this.Adapter.UpdateCommand.Transaction = this._transaction; + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected global::System.Data.SqlClient.SqlCommand[] CommandCollection { + get { + if ((this._commandCollection == null)) { + this.InitCommandCollection(); + } + return this._commandCollection; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public bool ClearBeforeFill { + get { + return this._clearBeforeFill; + } + set { + this._clearBeforeFill = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitAdapter() { + this._adapter = new global::System.Data.SqlClient.SqlDataAdapter(); + global::System.Data.Common.DataTableMapping tableMapping = new global::System.Data.Common.DataTableMapping(); + tableMapping.SourceTable = "Table"; + tableMapping.DataSetTable = "Authors"; + tableMapping.ColumnMappings.Add("AuthorID", "AuthorID"); + tableMapping.ColumnMappings.Add("LastName", "LastName"); + tableMapping.ColumnMappings.Add("FirstName", "FirstName"); + this._adapter.TableMappings.Add(tableMapping); + this._adapter.DeleteCommand = new global::System.Data.SqlClient.SqlCommand(); + this._adapter.DeleteCommand.Connection = this.Connection; + this._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Authors] WHERE (([AuthorID] = @Original_AuthorID) AND ([LastNa" + + "me] = @Original_LastName) AND ([FirstName] = @Original_FirstName))"; + this._adapter.DeleteCommand.CommandType = global::System.Data.CommandType.Text; + this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_AuthorID", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "AuthorID", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_LastName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "LastName", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_FirstName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "FirstName", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.InsertCommand = new global::System.Data.SqlClient.SqlCommand(); + this._adapter.InsertCommand.Connection = this.Connection; + this._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Authors] ([LastName], [FirstName]) VALUES (@LastName, @FirstNa" + + "me);\r\nSELECT AuthorID, LastName, FirstName FROM Authors WHERE (AuthorID = SCOPE_" + + "IDENTITY())"; + this._adapter.InsertCommand.CommandType = global::System.Data.CommandType.Text; + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@LastName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "LastName", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@FirstName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "FirstName", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand = new global::System.Data.SqlClient.SqlCommand(); + this._adapter.UpdateCommand.Connection = this.Connection; + this._adapter.UpdateCommand.CommandText = @"UPDATE [dbo].[Authors] SET [LastName] = @LastName, [FirstName] = @FirstName WHERE (([AuthorID] = @Original_AuthorID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName)); +SELECT AuthorID, LastName, FirstName FROM Authors WHERE (AuthorID = @AuthorID)"; + this._adapter.UpdateCommand.CommandType = global::System.Data.CommandType.Text; + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@LastName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "LastName", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@FirstName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "FirstName", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_AuthorID", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "AuthorID", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_LastName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "LastName", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_FirstName", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "FirstName", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@AuthorID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 0, 0, "AuthorID", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitConnection() { + this._connection = new global::System.Data.SqlClient.SqlConnection(); + this._connection.ConnectionString = global::AuthorDSLib.Properties.Settings.Default.DCV_DBConnectionString; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private void InitCommandCollection() { + this._commandCollection = new global::System.Data.SqlClient.SqlCommand[1]; + this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[0].Connection = this.Connection; + this._commandCollection[0].CommandText = "SELECT AuthorID, LastName, FirstName FROM dbo.Authors"; + this._commandCollection[0].CommandType = global::System.Data.CommandType.Text; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Fill, true)] + public virtual int Fill(AuthorsDS.AuthorsDataTable dataTable) { + this.Adapter.SelectCommand = this.CommandCollection[0]; + if ((this.ClearBeforeFill == true)) { + dataTable.Clear(); + } + int returnValue = this.Adapter.Fill(dataTable); + return returnValue; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, true)] + public virtual AuthorsDS.AuthorsDataTable GetData() { + this.Adapter.SelectCommand = this.CommandCollection[0]; + AuthorsDS.AuthorsDataTable dataTable = new AuthorsDS.AuthorsDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(AuthorsDS.AuthorsDataTable dataTable) { + return this.Adapter.Update(dataTable); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(AuthorsDS dataSet) { + return this.Adapter.Update(dataSet, "Authors"); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(global::System.Data.DataRow dataRow) { + return this.Adapter.Update(new global::System.Data.DataRow[] { + dataRow}); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(global::System.Data.DataRow[] dataRows) { + return this.Adapter.Update(dataRows); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Delete, true)] + public virtual int Delete(int Original_AuthorID, string Original_LastName, string Original_FirstName) { + this.Adapter.DeleteCommand.Parameters[0].Value = ((int)(Original_AuthorID)); + if ((Original_LastName == null)) { + throw new global::System.ArgumentNullException("Original_LastName"); + } + else { + this.Adapter.DeleteCommand.Parameters[1].Value = ((string)(Original_LastName)); + } + if ((Original_FirstName == null)) { + throw new global::System.ArgumentNullException("Original_FirstName"); + } + else { + this.Adapter.DeleteCommand.Parameters[2].Value = ((string)(Original_FirstName)); + } + global::System.Data.ConnectionState previousConnectionState = this.Adapter.DeleteCommand.Connection.State; + if (((this.Adapter.DeleteCommand.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + this.Adapter.DeleteCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.DeleteCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + this.Adapter.DeleteCommand.Connection.Close(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Insert, true)] + public virtual int Insert(string LastName, string FirstName) { + if ((LastName == null)) { + throw new global::System.ArgumentNullException("LastName"); + } + else { + this.Adapter.InsertCommand.Parameters[0].Value = ((string)(LastName)); + } + if ((FirstName == null)) { + throw new global::System.ArgumentNullException("FirstName"); + } + else { + this.Adapter.InsertCommand.Parameters[1].Value = ((string)(FirstName)); + } + global::System.Data.ConnectionState previousConnectionState = this.Adapter.InsertCommand.Connection.State; + if (((this.Adapter.InsertCommand.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + this.Adapter.InsertCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.InsertCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + this.Adapter.InsertCommand.Connection.Close(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Update, true)] + public virtual int Update(string LastName, string FirstName, int Original_AuthorID, string Original_LastName, string Original_FirstName, int AuthorID) { + if ((LastName == null)) { + throw new global::System.ArgumentNullException("LastName"); + } + else { + this.Adapter.UpdateCommand.Parameters[0].Value = ((string)(LastName)); + } + if ((FirstName == null)) { + throw new global::System.ArgumentNullException("FirstName"); + } + else { + this.Adapter.UpdateCommand.Parameters[1].Value = ((string)(FirstName)); + } + this.Adapter.UpdateCommand.Parameters[2].Value = ((int)(Original_AuthorID)); + if ((Original_LastName == null)) { + throw new global::System.ArgumentNullException("Original_LastName"); + } + else { + this.Adapter.UpdateCommand.Parameters[3].Value = ((string)(Original_LastName)); + } + if ((Original_FirstName == null)) { + throw new global::System.ArgumentNullException("Original_FirstName"); + } + else { + this.Adapter.UpdateCommand.Parameters[4].Value = ((string)(Original_FirstName)); + } + this.Adapter.UpdateCommand.Parameters[5].Value = ((int)(AuthorID)); + global::System.Data.ConnectionState previousConnectionState = this.Adapter.UpdateCommand.Connection.State; + if (((this.Adapter.UpdateCommand.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + this.Adapter.UpdateCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.UpdateCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + this.Adapter.UpdateCommand.Connection.Close(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Update, true)] + public virtual int Update(string LastName, string FirstName, int Original_AuthorID, string Original_LastName, string Original_FirstName) { + return this.Update(LastName, FirstName, Original_AuthorID, Original_LastName, Original_FirstName, Original_AuthorID); + } + } + + /// + ///TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + [global::System.ComponentModel.DesignerCategoryAttribute("code")] + [global::System.ComponentModel.ToolboxItem(true)] + [global::System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerDesigner, Microsoft.VSD" + + "esigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapterManager")] + public partial class TableAdapterManager : global::System.ComponentModel.Component { + + private UpdateOrderOption _updateOrder; + + private AuthorsTableAdapter _authorsTableAdapter; + + private bool _backupDataSetBeforeUpdate; + + private global::System.Data.IDbConnection _connection; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public UpdateOrderOption UpdateOrder { + get { + return this._updateOrder; + } + set { + this._updateOrder = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerPropertyEditor, Microso" + + "ft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + + "", "System.Drawing.Design.UITypeEditor")] + public AuthorsTableAdapter AuthorsTableAdapter { + get { + return this._authorsTableAdapter; + } + set { + if (((this._authorsTableAdapter != null) + && (this.TableAdapterInstanceCount == 1))) { + this._authorsTableAdapter = value; + return; + } + if (((value != null) + && (this.MatchTableAdapterConnection(value.Connection) == false))) { + throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" + + "tring."); + } + this._authorsTableAdapter = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public bool BackupDataSetBeforeUpdate { + get { + return this._backupDataSetBeforeUpdate; + } + set { + this._backupDataSetBeforeUpdate = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + public global::System.Data.IDbConnection Connection { + get { + if ((this._connection != null)) { + return this._connection; + } + if (((this._authorsTableAdapter != null) + && (this._authorsTableAdapter.Connection != null))) { + return this._authorsTableAdapter.Connection; + } + return null; + } + set { + this._connection = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.ComponentModel.Browsable(false)] + public int TableAdapterInstanceCount { + get { + int count = 0; + if ((this._authorsTableAdapter != null)) { + count = (count + 1); + } + return count; + } + } + + /// + ///Update rows in top-down order. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private int UpdateUpdatedRows(AuthorsDS dataSet, global::System.Collections.Generic.List allChangedRows, global::System.Collections.Generic.List allAddedRows) { + int result = 0; + if ((this._authorsTableAdapter != null)) { + global::System.Data.DataRow[] updatedRows = dataSet.Authors.Select(null, null, global::System.Data.DataViewRowState.ModifiedCurrent); + updatedRows = this.GetRealUpdatedRows(updatedRows, allAddedRows); + if (((updatedRows != null) + && (0 < updatedRows.Length))) { + result = (result + this._authorsTableAdapter.Update(updatedRows)); + allChangedRows.AddRange(updatedRows); + } + } + return result; + } + + /// + ///Insert rows in top-down order. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private int UpdateInsertedRows(AuthorsDS dataSet, global::System.Collections.Generic.List allAddedRows) { + int result = 0; + if ((this._authorsTableAdapter != null)) { + global::System.Data.DataRow[] addedRows = dataSet.Authors.Select(null, null, global::System.Data.DataViewRowState.Added); + if (((addedRows != null) + && (0 < addedRows.Length))) { + result = (result + this._authorsTableAdapter.Update(addedRows)); + allAddedRows.AddRange(addedRows); + } + } + return result; + } + + /// + ///Delete rows in bottom-up order. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private int UpdateDeletedRows(AuthorsDS dataSet, global::System.Collections.Generic.List allChangedRows) { + int result = 0; + if ((this._authorsTableAdapter != null)) { + global::System.Data.DataRow[] deletedRows = dataSet.Authors.Select(null, null, global::System.Data.DataViewRowState.Deleted); + if (((deletedRows != null) + && (0 < deletedRows.Length))) { + result = (result + this._authorsTableAdapter.Update(deletedRows)); + allChangedRows.AddRange(deletedRows); + } + } + return result; + } + + /// + ///Remove inserted rows that become updated rows after calling TableAdapter.Update(inserted rows) first + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private global::System.Data.DataRow[] GetRealUpdatedRows(global::System.Data.DataRow[] updatedRows, global::System.Collections.Generic.List allAddedRows) { + if (((updatedRows == null) + || (updatedRows.Length < 1))) { + return updatedRows; + } + if (((allAddedRows == null) + || (allAddedRows.Count < 1))) { + return updatedRows; + } + global::System.Collections.Generic.List realUpdatedRows = new global::System.Collections.Generic.List(); + for (int i = 0; (i < updatedRows.Length); i = (i + 1)) { + global::System.Data.DataRow row = updatedRows[i]; + if ((allAddedRows.Contains(row) == false)) { + realUpdatedRows.Add(row); + } + } + return realUpdatedRows.ToArray(); + } + + /// + ///Update all changes to the dataset. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public virtual int UpdateAll(AuthorsDS dataSet) { + if ((dataSet == null)) { + throw new global::System.ArgumentNullException("dataSet"); + } + if ((dataSet.HasChanges() == false)) { + return 0; + } + global::System.Data.IDbConnection workConnection = this.Connection; + if ((workConnection == null)) { + throw new global::System.ApplicationException("TableAdapterManager contains no connection information. Set each TableAdapterMana" + + "ger TableAdapter property to a valid TableAdapter instance."); + } + bool workConnOpened = false; + if (((workConnection.State & global::System.Data.ConnectionState.Closed) + == global::System.Data.ConnectionState.Closed)) { + workConnection.Open(); + workConnOpened = true; + } + global::System.Data.IDbTransaction workTransaction = workConnection.BeginTransaction(); + if ((workTransaction == null)) { + throw new global::System.ApplicationException("The transaction cannot begin. The current data connection does not support transa" + + "ctions or the current state is not allowing the transaction to begin."); + } + global::System.Collections.Generic.List allChangedRows = new global::System.Collections.Generic.List(); + global::System.Collections.Generic.List allAddedRows = new global::System.Collections.Generic.List(); + global::System.Collections.Generic.List adaptersWithAcceptChangesDuringUpdate = new global::System.Collections.Generic.List(); + global::System.Collections.Generic.Dictionary revertConnections = new global::System.Collections.Generic.Dictionary(); + int result = 0; + global::System.Data.DataSet backupDataSet = null; + if (this.BackupDataSetBeforeUpdate) { + backupDataSet = new global::System.Data.DataSet(); + backupDataSet.Merge(dataSet); + } + try { + // ---- Prepare for update ----------- + // + if ((this._authorsTableAdapter != null)) { + revertConnections.Add(this._authorsTableAdapter, this._authorsTableAdapter.Connection); + this._authorsTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(workConnection)); + this._authorsTableAdapter.Transaction = ((global::System.Data.SqlClient.SqlTransaction)(workTransaction)); + if (this._authorsTableAdapter.Adapter.AcceptChangesDuringUpdate) { + this._authorsTableAdapter.Adapter.AcceptChangesDuringUpdate = false; + adaptersWithAcceptChangesDuringUpdate.Add(this._authorsTableAdapter.Adapter); + } + } + // + //---- Perform updates ----------- + // + if ((this.UpdateOrder == UpdateOrderOption.UpdateInsertDelete)) { + result = (result + this.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows)); + result = (result + this.UpdateInsertedRows(dataSet, allAddedRows)); + } + else { + result = (result + this.UpdateInsertedRows(dataSet, allAddedRows)); + result = (result + this.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows)); + } + result = (result + this.UpdateDeletedRows(dataSet, allChangedRows)); + // + //---- Commit updates ----------- + // + workTransaction.Commit(); + if ((0 < allAddedRows.Count)) { + global::System.Data.DataRow[] rows = new System.Data.DataRow[allAddedRows.Count]; + allAddedRows.CopyTo(rows); + for (int i = 0; (i < rows.Length); i = (i + 1)) { + global::System.Data.DataRow row = rows[i]; + row.AcceptChanges(); + } + } + if ((0 < allChangedRows.Count)) { + global::System.Data.DataRow[] rows = new System.Data.DataRow[allChangedRows.Count]; + allChangedRows.CopyTo(rows); + for (int i = 0; (i < rows.Length); i = (i + 1)) { + global::System.Data.DataRow row = rows[i]; + row.AcceptChanges(); + } + } + } + catch (global::System.Exception ex) { + workTransaction.Rollback(); + // ---- Restore the dataset ----------- + if (this.BackupDataSetBeforeUpdate) { + global::System.Diagnostics.Debug.Assert((backupDataSet != null)); + dataSet.Clear(); + dataSet.Merge(backupDataSet); + } + else { + if ((0 < allAddedRows.Count)) { + global::System.Data.DataRow[] rows = new System.Data.DataRow[allAddedRows.Count]; + allAddedRows.CopyTo(rows); + for (int i = 0; (i < rows.Length); i = (i + 1)) { + global::System.Data.DataRow row = rows[i]; + row.AcceptChanges(); + row.SetAdded(); + } + } + } + throw ex; + } + finally { + if (workConnOpened) { + workConnection.Close(); + } + if ((this._authorsTableAdapter != null)) { + this._authorsTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(revertConnections[this._authorsTableAdapter])); + this._authorsTableAdapter.Transaction = null; + } + if ((0 < adaptersWithAcceptChangesDuringUpdate.Count)) { + global::System.Data.Common.DataAdapter[] adapters = new System.Data.Common.DataAdapter[adaptersWithAcceptChangesDuringUpdate.Count]; + adaptersWithAcceptChangesDuringUpdate.CopyTo(adapters); + for (int i = 0; (i < adapters.Length); i = (i + 1)) { + global::System.Data.Common.DataAdapter adapter = adapters[i]; + adapter.AcceptChangesDuringUpdate = true; + } + } + } + return result; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected virtual void SortSelfReferenceRows(global::System.Data.DataRow[] rows, global::System.Data.DataRelation relation, bool childFirst) { + global::System.Array.Sort(rows, new SelfReferenceComparer(relation, childFirst)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + protected virtual bool MatchTableAdapterConnection(global::System.Data.IDbConnection inputConnection) { + if ((this._connection != null)) { + return true; + } + if (((this.Connection == null) + || (inputConnection == null))) { + return true; + } + if (string.Equals(this.Connection.ConnectionString, inputConnection.ConnectionString, global::System.StringComparison.Ordinal)) { + return true; + } + return false; + } + + /// + ///Update Order Option + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + public enum UpdateOrderOption { + + InsertUpdateDelete = 0, + + UpdateInsertDelete = 1, + } + + /// + ///Used to sort self-referenced table's rows + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0")] + private class SelfReferenceComparer : object, global::System.Collections.Generic.IComparer { + + private global::System.Data.DataRelation _relation; + + private int _childFirst; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + internal SelfReferenceComparer(global::System.Data.DataRelation relation, bool childFirst) { + this._relation = relation; + if (childFirst) { + this._childFirst = -1; + } + else { + this._childFirst = 1; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + private bool IsChildAndParent(global::System.Data.DataRow child, global::System.Data.DataRow parent) { + global::System.Diagnostics.Debug.Assert((child != null)); + global::System.Diagnostics.Debug.Assert((parent != null)); + global::System.Data.DataRow newParent = child.GetParentRow(this._relation, global::System.Data.DataRowVersion.Default); + for ( + ; ((newParent != null) + && ((object.ReferenceEquals(newParent, child) == false) + && (object.ReferenceEquals(newParent, parent) == false))); + ) { + newParent = newParent.GetParentRow(this._relation, global::System.Data.DataRowVersion.Default); + } + if ((newParent == null)) { + for (newParent = child.GetParentRow(this._relation, global::System.Data.DataRowVersion.Original); ((newParent != null) + && ((object.ReferenceEquals(newParent, child) == false) + && (object.ReferenceEquals(newParent, parent) == false))); + ) { + newParent = newParent.GetParentRow(this._relation, global::System.Data.DataRowVersion.Original); + } + } + if (object.ReferenceEquals(newParent, parent)) { + return true; + } + return false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public int Compare(global::System.Data.DataRow row1, global::System.Data.DataRow row2) { + if (object.ReferenceEquals(row1, row2)) { + return 0; + } + if ((row1 == null)) { + return -1; + } + if ((row2 == null)) { + return 1; + } + + // Is row1 the child or grandchild of row2 + if (this.IsChildAndParent(row1, row2)) { + return this._childFirst; + } + + // Is row2 the child or grandchild of row1 + if (this.IsChildAndParent(row2, row1)) { + return (-1 * this._childFirst); + } + return 0; + } + } + } +} + +#pragma warning restore 1591 \ No newline at end of file diff --git a/Chapter13/AuthorDSLib/AuthorsDS.xsc b/Chapter13/AuthorDSLib/AuthorsDS.xsc new file mode 100644 index 0000000..05b0199 --- /dev/null +++ b/Chapter13/AuthorDSLib/AuthorsDS.xsc @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/Chapter13/AuthorDSLib/AuthorsDS.xsd b/Chapter13/AuthorDSLib/AuthorsDS.xsd new file mode 100644 index 0000000..c114db1 --- /dev/null +++ b/Chapter13/AuthorDSLib/AuthorsDS.xsd @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + DELETE FROM [dbo].[Authors] WHERE (([AuthorID] = @Original_AuthorID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName)) + + + + + + + + + + INSERT INTO [dbo].[Authors] ([LastName], [FirstName]) VALUES (@LastName, @FirstName); +SELECT AuthorID, LastName, FirstName FROM Authors WHERE (AuthorID = SCOPE_IDENTITY()) + + + + + + + + + SELECT AuthorID, LastName, FirstName FROM dbo.Authors + + + + + + UPDATE [dbo].[Authors] SET [LastName] = @LastName, [FirstName] = @FirstName WHERE (([AuthorID] = @Original_AuthorID) AND ([LastName] = @Original_LastName) AND ([FirstName] = @Original_FirstName)); +SELECT AuthorID, LastName, FirstName FROM Authors WHERE (AuthorID = @AuthorID) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter13/AuthorDSLib/AuthorsDS.xss b/Chapter13/AuthorDSLib/AuthorsDS.xss new file mode 100644 index 0000000..6202b40 --- /dev/null +++ b/Chapter13/AuthorDSLib/AuthorsDS.xss @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Chapter13/AuthorDSLib/Properties/AssemblyInfo.cs b/Chapter13/AuthorDSLib/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..74e91ce --- /dev/null +++ b/Chapter13/AuthorDSLib/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AuthorDSLib")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AuthorDSLib")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8e4fdc76-d17e-4d58-b81a-e05ea1befadd")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Chapter13/AuthorDSLib/Properties/Settings.Designer.cs b/Chapter13/AuthorDSLib/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8fe4428 --- /dev/null +++ b/Chapter13/AuthorDSLib/Properties/Settings.Designer.cs @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AuthorDSLib.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=PALPATINE;Initial Catalog=DCV_DB;Integrated Security=True;Pooling=Fal" + + "se")] + public string DCV_DBConnectionString { + get { + return ((string)(this["DCV_DBConnectionString"])); + } + } + } +} diff --git a/Chapter13/AuthorDSLib/Properties/Settings.settings b/Chapter13/AuthorDSLib/Properties/Settings.settings new file mode 100644 index 0000000..c10e94c --- /dev/null +++ b/Chapter13/AuthorDSLib/Properties/Settings.settings @@ -0,0 +1,14 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=PALPATINE;Initial Catalog=DCV_DB;Integrated Security=True;Pooling=False</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=PALPATINE;Initial Catalog=DCV_DB;Integrated Security=True;Pooling=False + + + \ No newline at end of file diff --git a/Chapter13/AuthorDSLib/app.config b/Chapter13/AuthorDSLib/app.config new file mode 100644 index 0000000..de44e69 --- /dev/null +++ b/Chapter13/AuthorDSLib/app.config @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/Chapter13/Chapter13.sln b/Chapter13/Chapter13.sln new file mode 100644 index 0000000..b613776 --- /dev/null +++ b/Chapter13/Chapter13.sln @@ -0,0 +1,114 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConnectedBasics", "ConnectedBasics\ConnectedBasics.vcproj", "{0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConnectedQuery", "ConnectedQuery\ConnectedQuery.vcproj", "{9405F77F-7B2C-468C-915C-22941EBFFDA3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConnectedModify", "ConnectedModify\ConnectedModify.vcproj", "{F89C92C2-0D07-4EFA-AA39-A69265969052}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConnectedScalar", "ConnectedScalar\ConnectedScalar.vcproj", "{B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConnectedTransactions", "ConnectedTransactions\ConnectedTransactions.vcproj", "{56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaintAuthors", "MaintAuthors\MaintAuthors.vcproj", "{604AC0FF-0C59-488F-B2A1-CA0ED6008341}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthorDSLib", "AuthorDSLib\AuthorDSLib.csproj", "{2CA4B47B-DD9A-4639-AF6C-50E137C631D0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaintAuthors_DGV", "MaintAuthors_DGV\MaintAuthors_DGV.vcproj", "{DA870A67-F252-4E72-9A59-3C0F8DA7297E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Debug|Win32.ActiveCfg = Debug|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Debug|Win32.Build.0 = Debug|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Release|Any CPU.ActiveCfg = Release|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Release|Mixed Platforms.Build.0 = Release|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Release|Win32.ActiveCfg = Release|Win32 + {0E22C74E-2A0B-44BE-8BB9-F44B6A1A296F}.Release|Win32.Build.0 = Release|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Debug|Win32.ActiveCfg = Debug|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Debug|Win32.Build.0 = Debug|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Release|Any CPU.ActiveCfg = Release|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Release|Mixed Platforms.Build.0 = Release|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Release|Win32.ActiveCfg = Release|Win32 + {9405F77F-7B2C-468C-915C-22941EBFFDA3}.Release|Win32.Build.0 = Release|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Debug|Win32.ActiveCfg = Debug|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Debug|Win32.Build.0 = Debug|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Release|Any CPU.ActiveCfg = Release|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Release|Mixed Platforms.Build.0 = Release|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Release|Win32.ActiveCfg = Release|Win32 + {F89C92C2-0D07-4EFA-AA39-A69265969052}.Release|Win32.Build.0 = Release|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Debug|Win32.ActiveCfg = Debug|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Debug|Win32.Build.0 = Debug|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Release|Any CPU.ActiveCfg = Release|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Release|Mixed Platforms.Build.0 = Release|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Release|Win32.ActiveCfg = Release|Win32 + {B2ADA949-6F8F-41CA-BE58-DC5EA88FC320}.Release|Win32.Build.0 = Release|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Debug|Win32.ActiveCfg = Debug|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Debug|Win32.Build.0 = Debug|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Release|Any CPU.ActiveCfg = Release|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Release|Mixed Platforms.Build.0 = Release|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Release|Win32.ActiveCfg = Release|Win32 + {56D71AF5-C8F0-4EA9-A98A-DA744611BFBD}.Release|Win32.Build.0 = Release|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Debug|Win32.ActiveCfg = Debug|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Debug|Win32.Build.0 = Debug|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Release|Any CPU.ActiveCfg = Release|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Release|Mixed Platforms.Build.0 = Release|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Release|Win32.ActiveCfg = Release|Win32 + {604AC0FF-0C59-488F-B2A1-CA0ED6008341}.Release|Win32.Build.0 = Release|Win32 + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Debug|Win32.ActiveCfg = Debug|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Release|Any CPU.Build.0 = Release|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2CA4B47B-DD9A-4639-AF6C-50E137C631D0}.Release|Win32.ActiveCfg = Release|Any CPU + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Debug|Win32.Build.0 = Debug|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Release|Any CPU.ActiveCfg = Release|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Release|Mixed Platforms.Build.0 = Release|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Release|Win32.ActiveCfg = Release|Win32 + {DA870A67-F252-4E72-9A59-3C0F8DA7297E}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter13/ConnectedBasics/AssemblyInfo.cpp b/Chapter13/ConnectedBasics/AssemblyInfo.cpp new file mode 100644 index 0000000..076779c --- /dev/null +++ b/Chapter13/ConnectedBasics/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ConnectedBasics")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ConnectedBasics")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter13/ConnectedBasics/ConnectedBasics.cpp b/Chapter13/ConnectedBasics/ConnectedBasics.cpp new file mode 100644 index 0000000..a338431 --- /dev/null +++ b/Chapter13/ConnectedBasics/ConnectedBasics.cpp @@ -0,0 +1,28 @@ +using namespace System; +using namespace System::Data; +using namespace System::Data::SqlClient; +using namespace System::Configuration; + +void main() +{ + SqlConnection^ connection = gcnew SqlConnection(); + + connection->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + + try + { + connection->Open(); + Console::WriteLine("We got a connection!"); + } + catch (SqlException ^e) + { + Console::WriteLine("No connection the following error occurred: {0}", + e->Message); + } + finally + { + connection->Close(); + Console::WriteLine("The connection to the database has been closed"); + } +} diff --git a/Chapter13/ConnectedBasics/ConnectedBasics.vcproj b/Chapter13/ConnectedBasics/ConnectedBasics.vcproj new file mode 100644 index 0000000..7e831e2 --- /dev/null +++ b/Chapter13/ConnectedBasics/ConnectedBasics.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/ConnectedBasics/app.config b/Chapter13/ConnectedBasics/app.config new file mode 100644 index 0000000..02e7800 --- /dev/null +++ b/Chapter13/ConnectedBasics/app.config @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Chapter13/ConnectedModify/AssemblyInfo.cpp b/Chapter13/ConnectedModify/AssemblyInfo.cpp new file mode 100644 index 0000000..54b2093 --- /dev/null +++ b/Chapter13/ConnectedModify/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ConnectedModify")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ConnectedModify")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter13/ConnectedModify/ConnectedModify.cpp b/Chapter13/ConnectedModify/ConnectedModify.cpp new file mode 100644 index 0000000..8876823 --- /dev/null +++ b/Chapter13/ConnectedModify/ConnectedModify.cpp @@ -0,0 +1,55 @@ +using namespace System; +using namespace System::Data; +using namespace System::Data::SqlClient; +using namespace System::Configuration; + +void main() +{ + String ^Name = "Doors"; + + SqlConnection ^connection = gcnew SqlConnection(); + + connection->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + + try + { + SqlCommand ^cmd = gcnew SqlCommand(); + cmd->Connection = connection; + connection->Open(); + + cmd->CommandType = CommandType::StoredProcedure; + cmd->CommandText = "InsertAuthor"; + + cmd->Parameters->Add(gcnew SqlParameter("@LastName", SqlDbType::VarChar)); + cmd->Parameters->Add(gcnew SqlParameter("@FirstName",SqlDbType::VarChar)); + + cmd->Parameters["@LastName"]->Value = "Dope"; + cmd->Parameters["@FirstName"]->Value = "John"; + + int affected = cmd->ExecuteNonQuery(); + Console::WriteLine("Insert - {0} rows are affected", affected); + + cmd->CommandType = CommandType::Text; + cmd->CommandText = "UPDATE Authors SET LastName = 'Doe'" + "WHERE LastName = 'Dope'"; + + affected = cmd->ExecuteNonQuery(); + Console::WriteLine("Update - {0} rows are affected", affected); + + cmd->CommandType = CommandType::Text; + cmd->CommandText = "DELETE FROM Authors WHERE LastName = 'Doe'"; + + affected = cmd->ExecuteNonQuery(); + Console::WriteLine("Delete - {0} rows are affected", affected); + } + catch (SqlException ^e) + { + Console::WriteLine("No connection the following error occurred: {0}", + e->Message); + } + finally + { + connection->Close(); + } +} diff --git a/Chapter13/ConnectedModify/ConnectedModify.vcproj b/Chapter13/ConnectedModify/ConnectedModify.vcproj new file mode 100644 index 0000000..ac15f32 --- /dev/null +++ b/Chapter13/ConnectedModify/ConnectedModify.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/ConnectedModify/app.config b/Chapter13/ConnectedModify/app.config new file mode 100644 index 0000000..02e7800 --- /dev/null +++ b/Chapter13/ConnectedModify/app.config @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Chapter13/ConnectedQuery/AssemblyInfo.cpp b/Chapter13/ConnectedQuery/AssemblyInfo.cpp new file mode 100644 index 0000000..a759705 --- /dev/null +++ b/Chapter13/ConnectedQuery/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ConnectedQuery")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ConnectedQuery")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter13/ConnectedQuery/ConnectedQuery.cpp b/Chapter13/ConnectedQuery/ConnectedQuery.cpp new file mode 100644 index 0000000..4db4bda --- /dev/null +++ b/Chapter13/ConnectedQuery/ConnectedQuery.cpp @@ -0,0 +1,78 @@ +using namespace System; +using namespace System::Data; +using namespace System::Data::SqlClient; +using namespace System::Configuration; + +void main() +{ + String ^Name = "Doors"; + + SqlConnection ^connection = gcnew SqlConnection(); + + connection->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + + try + { + SqlCommand ^cmd = gcnew SqlCommand(); + cmd->Connection = connection; + + cmd->CommandType = CommandType::Text; + cmd->CommandText = + String::Format("SELECT FirstName, LastName FROM Authors " + "WHERE LastName = '{0}'", + Name); + + connection->Open(); + + SqlDataReader ^reader = cmd->ExecuteReader(); + + while(reader->Read()) + { + Console::WriteLine("{0} {1}", + reader["FirstName"], reader["LastName"]); + } + reader->Close(); + + // CREATE PROCEDURE dbo.StoriesWhereLastName + // ( + // @LastName NVARCHAR(32) = NULL + // ) + // AS + // /* SET NOCOUNT ON */ + + // SELECT StoryID, Headline, Story FROM Stories + // WHERE LastName = @LastName + // + // RETURN + + cmd->CommandType = CommandType::StoredProcedure; + cmd->CommandText = "StoriesWhereLastName"; + + cmd->Parameters->Add( + gcnew SqlParameter("@LastName",SqlDbType::VarChar)); + cmd->Parameters["@LastName"]->Value = Name; + + reader = cmd->ExecuteReader(); + + Console::WriteLine("------------------------------------------------"); + while(reader->Read()) + { + Console::WriteLine(reader["StoryID"]); + Console::WriteLine(reader["Headline"]); + Console::WriteLine(reader["Story"]); + Console::WriteLine(); + } + reader->Close(); + } + + catch (SqlException ^e) + { + Console::WriteLine("No connection the following error occurred: {0}", + e->Message); + } + finally + { + connection->Close(); + } +} diff --git a/Chapter13/ConnectedQuery/ConnectedQuery.vcproj b/Chapter13/ConnectedQuery/ConnectedQuery.vcproj new file mode 100644 index 0000000..0859b91 --- /dev/null +++ b/Chapter13/ConnectedQuery/ConnectedQuery.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/ConnectedQuery/app.config b/Chapter13/ConnectedQuery/app.config new file mode 100644 index 0000000..ba36442 --- /dev/null +++ b/Chapter13/ConnectedQuery/app.config @@ -0,0 +1,10 @@ + + + + + + diff --git a/Chapter13/ConnectedScalar/AssemblyInfo.cpp b/Chapter13/ConnectedScalar/AssemblyInfo.cpp new file mode 100644 index 0000000..4e5a9b4 --- /dev/null +++ b/Chapter13/ConnectedScalar/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ConnectedScalar")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ConnectedScalar")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter13/ConnectedScalar/ConnectedScalar.cpp b/Chapter13/ConnectedScalar/ConnectedScalar.cpp new file mode 100644 index 0000000..3bd6b33 --- /dev/null +++ b/Chapter13/ConnectedScalar/ConnectedScalar.cpp @@ -0,0 +1,40 @@ +using namespace System; +using namespace System::Data; +using namespace System::Data::SqlClient; +using namespace System::Configuration; + +void main() +{ + SqlConnection ^connection = gcnew SqlConnection(); + + connection->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + + try + { + SqlCommand ^cmd = gcnew SqlCommand(); + cmd->Connection = connection; + connection->Open(); + + cmd->CommandType = CommandType::Text; + cmd->CommandText = "SELECT COUNT(*) FROM Authors"; + + Object ^NumAuthors = cmd->ExecuteScalar(); + Console::WriteLine("The number of Authors are {0}", NumAuthors); + + cmd->CommandType = CommandType::Text; + cmd->CommandText = "SELECT SUM(AuthorID) FROM Authors"; + + Object ^UselessNum = cmd->ExecuteScalar(); + Console::WriteLine("The Sum of AuthorIDs for fun is {0}", UselessNum); + } + catch (SqlException ^e) + { + Console::WriteLine("No connection the following error occurred: {0}", + e->Message); + } + finally + { + connection->Close(); + } +} diff --git a/Chapter13/ConnectedScalar/ConnectedScalar.vcproj b/Chapter13/ConnectedScalar/ConnectedScalar.vcproj new file mode 100644 index 0000000..ff2a75a --- /dev/null +++ b/Chapter13/ConnectedScalar/ConnectedScalar.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/ConnectedScalar/app.config b/Chapter13/ConnectedScalar/app.config new file mode 100644 index 0000000..02e7800 --- /dev/null +++ b/Chapter13/ConnectedScalar/app.config @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Chapter13/ConnectedTransactions/AssemblyInfo.cpp b/Chapter13/ConnectedTransactions/AssemblyInfo.cpp new file mode 100644 index 0000000..088697d --- /dev/null +++ b/Chapter13/ConnectedTransactions/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("ConnectedTransactions")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("ConnectedTransactions")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter13/ConnectedTransactions/ConnectedTransactions.cpp b/Chapter13/ConnectedTransactions/ConnectedTransactions.cpp new file mode 100644 index 0000000..4ef1785 --- /dev/null +++ b/Chapter13/ConnectedTransactions/ConnectedTransactions.cpp @@ -0,0 +1,76 @@ +using namespace System; +using namespace System::Data; +using namespace System::Data::SqlClient; +using namespace System::Configuration; + +void main() +{ + String ^Name = "Doors"; + + SqlConnection ^connection = gcnew SqlConnection(); + SqlTransaction ^transaction; + + connection->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + + try + { + connection->Open(); + + SqlCommand ^cmd = gcnew SqlCommand(); + + transaction = connection->BeginTransaction( + IsolationLevel::Serializable, "AuthorTransaction"); + + + cmd->Connection = connection; + cmd->Transaction = transaction; + + cmd->CommandType = CommandType::StoredProcedure; + cmd->CommandText = "InsertAuthor"; + + cmd->Parameters->Add(gcnew SqlParameter("@LastName", SqlDbType::Char,32)); + cmd->Parameters->Add(gcnew SqlParameter("@FirstName",SqlDbType::Char,32)); + + cmd->Parameters["@LastName"]->Value = "Dope"; + cmd->Parameters["@FirstName"]->Value = "John"; + + int affected = cmd->ExecuteNonQuery(); + if (affected <= 0) + throw gcnew Exception("Insert Failed"); + Console::WriteLine("Insert - {0} rows are affected", affected); + + cmd->CommandType = CommandType::Text; + cmd->CommandText = "UPDATE Authors SET LastName = 'Doe'" + "WHERE LastName = 'Dope'"; + + affected = cmd->ExecuteNonQuery(); + if (affected <= 0) + throw gcnew Exception("Insert Failed"); + Console::WriteLine("Update - {0} rows are affected", affected); + + // This transaction will return 0 affected rows + // because "Does" does not exist. + // Thus, the if condition throws an execption which causes all + // Transactions to be rolled back. + cmd->CommandType = CommandType::Text; + cmd->CommandText = "DELETE FROM Authors WHERE LastName = 'Does'"; + + affected = cmd->ExecuteNonQuery(); + if (affected <= 0) + throw gcnew Exception("Insert Failed"); + Console::WriteLine("Delete - {0} rows are affected", affected); + + transaction->Commit(); + } + catch (Exception ^e) + { + transaction->Rollback("AuthorTransaction"); + Console::WriteLine("Transaction Not completed"); + Console::WriteLine("SQL error occurred: {0}", e->Message); + } + finally + { + connection->Close(); + } +} diff --git a/Chapter13/ConnectedTransactions/ConnectedTransactions.vcproj b/Chapter13/ConnectedTransactions/ConnectedTransactions.vcproj new file mode 100644 index 0000000..86e48f6 --- /dev/null +++ b/Chapter13/ConnectedTransactions/ConnectedTransactions.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/ConnectedTransactions/app.config b/Chapter13/ConnectedTransactions/app.config new file mode 100644 index 0000000..02e7800 --- /dev/null +++ b/Chapter13/ConnectedTransactions/app.config @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Chapter13/MaintAuthors/AssemblyInfo.cpp b/Chapter13/MaintAuthors/AssemblyInfo.cpp new file mode 100644 index 0000000..b44b521 --- /dev/null +++ b/Chapter13/MaintAuthors/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("MaintAuthors")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("MaintAuthors")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter13/MaintAuthors/Form1.h b/Chapter13/MaintAuthors/Form1.h new file mode 100644 index 0000000..5f866d7 --- /dev/null +++ b/Chapter13/MaintAuthors/Form1.h @@ -0,0 +1,349 @@ +#pragma once + + +namespace MaintAuthors +{ + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Data::SqlClient; + using namespace System::Drawing; + using namespace System::Configuration; + + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + SqlConnection ^connect = gcnew SqlConnection(); + + connect->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + + dAdapt = gcnew SqlDataAdapter(); + dAdapt->MissingSchemaAction = MissingSchemaAction::AddWithKey; + + dAdapt->SelectCommand = gcnew SqlCommand("SELECT AuthorID, LastName, FirstName FROM Authors", connect); + + dAdapt->InsertCommand = gcnew SqlCommand("INSERT INTO Authors (LastName, FirstName) " + "VALUES (@LastName, @FirstName)", connect); + dAdapt->InsertCommand->Parameters->Add("@LastName", SqlDbType::VarChar, 50, "LastName"); + dAdapt->InsertCommand->Parameters->Add("@FirstName", SqlDbType::VarChar, 50, "FirstName"); + + + dAdapt->UpdateCommand = gcnew SqlCommand("UPDATE Authors SET LastName = @LastName, FirstName = @FirstName " + "WHERE AuthorID = @AuthorID", connect); + dAdapt->UpdateCommand->Parameters->Add("@LastName", SqlDbType::VarChar, 50, "LastName"); + dAdapt->UpdateCommand->Parameters->Add("@FirstName", SqlDbType::VarChar, 50, "FirstName"); + dAdapt->UpdateCommand->Parameters->Add("@AuthorID", SqlDbType::Int, 4, "AuthorID"); + + dAdapt->DeleteCommand = gcnew SqlCommand("DELETE FROM Authors WHERE AuthorID = @AuthorID", connect); + dAdapt->DeleteCommand->Parameters->Add("@AuthorID", SqlDbType::Int, 4, "AuthorID"); + + dSet = gcnew DataSet(); + dAdapt->Fill(dSet, "Authors"); + + DataTable ^dt = dSet->Tables["Authors"]; + + if (dt == nullptr) + throw gcnew Exception("No Authors Table"); + + for each(DataRow ^row in dt->Rows) + { + lbAuthors->Items->Add(ListBoxItem(row)); + } + CurrentAuthorID = -1; + } + + protected: + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Button^ bnRollback; + System::Windows::Forms::Button^ bnCommit; + System::Windows::Forms::Button^ bnDelete; + System::Windows::Forms::Button^ bnUpdate; + System::Windows::Forms::Button^ bnAdd; + System::Windows::Forms::ListBox^ lbAuthors; + System::Windows::Forms::TextBox^ tbLastName; + System::Windows::Forms::TextBox^ tbFirstName; + System::Windows::Forms::Label^ label2; + System::Windows::Forms::Label^ label1; + + System::ComponentModel::Container ^components; + + SqlDataAdapter ^dAdapt; + DataSet ^dSet; + int CurrentAuthorID; + +#pragma region Windows Form Designer generated code + void InitializeComponent(void) + { + this->bnRollback = (gcnew System::Windows::Forms::Button()); + this->bnCommit = (gcnew System::Windows::Forms::Button()); + this->bnDelete = (gcnew System::Windows::Forms::Button()); + this->bnUpdate = (gcnew System::Windows::Forms::Button()); + this->bnAdd = (gcnew System::Windows::Forms::Button()); + this->lbAuthors = (gcnew System::Windows::Forms::ListBox()); + this->tbLastName = (gcnew System::Windows::Forms::TextBox()); + this->tbFirstName = (gcnew System::Windows::Forms::TextBox()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->SuspendLayout(); + // + // bnRollback + // + this->bnRollback->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->bnRollback->Location = System::Drawing::Point(312, 162); + this->bnRollback->Name = L"bnRollback"; + this->bnRollback->Size = System::Drawing::Size(75, 23); + this->bnRollback->TabIndex = 19; + this->bnRollback->Text = L"Rollback"; + this->bnRollback->Click += gcnew System::EventHandler(this, &Form1::bnRollback_Click); + // + // bnCommit + // + this->bnCommit->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->bnCommit->Location = System::Drawing::Point(312, 132); + this->bnCommit->Margin = System::Windows::Forms::Padding(3, 0, 3, 3); + this->bnCommit->Name = L"bnCommit"; + this->bnCommit->Size = System::Drawing::Size(75, 23); + this->bnCommit->TabIndex = 18; + this->bnCommit->Text = L"Commit"; + this->bnCommit->Click += gcnew System::EventHandler(this, &Form1::bnCommit_Click); + // + // bnDelete + // + this->bnDelete->Location = System::Drawing::Point(312, 78); + this->bnDelete->Name = L"bnDelete"; + this->bnDelete->Size = System::Drawing::Size(75, 23); + this->bnDelete->TabIndex = 17; + this->bnDelete->Text = L"Delete"; + this->bnDelete->Click += gcnew System::EventHandler(this, &Form1::bnDelete_Click); + // + // bnUpdate + // + this->bnUpdate->Location = System::Drawing::Point(312, 46); + this->bnUpdate->Name = L"bnUpdate"; + this->bnUpdate->Size = System::Drawing::Size(75, 23); + this->bnUpdate->TabIndex = 16; + this->bnUpdate->Text = L"Update"; + this->bnUpdate->Click += gcnew System::EventHandler(this, &Form1::bnUpdate_Click); + // + // bnAdd + // + this->bnAdd->Location = System::Drawing::Point(312, 18); + this->bnAdd->Margin = System::Windows::Forms::Padding(3, 3, 3, 1); + this->bnAdd->Name = L"bnAdd"; + this->bnAdd->Size = System::Drawing::Size(75, 23); + this->bnAdd->TabIndex = 15; + this->bnAdd->Text = L"Add"; + this->bnAdd->Click += gcnew System::EventHandler(this, &Form1::bnAdd_Click); + // + // lbAuthors + // + this->lbAuthors->FormattingEnabled = true; + this->lbAuthors->Location = System::Drawing::Point(25, 95); + this->lbAuthors->Name = L"lbAuthors"; + this->lbAuthors->Size = System::Drawing::Size(257, 95); + this->lbAuthors->TabIndex = 14; + this->lbAuthors->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::lbAuthors_SelectedIndexChanged); + // + // tbLastName + // + this->tbLastName->Location = System::Drawing::Point(87, 51); + this->tbLastName->Margin = System::Windows::Forms::Padding(1, 3, 3, 3); + this->tbLastName->Name = L"tbLastName"; + this->tbLastName->Size = System::Drawing::Size(127, 20); + this->tbLastName->TabIndex = 13; + // + // tbFirstName + // + this->tbFirstName->Location = System::Drawing::Point(87, 24); + this->tbFirstName->Margin = System::Windows::Forms::Padding(1, 3, 3, 3); + this->tbFirstName->Name = L"tbFirstName"; + this->tbFirstName->Size = System::Drawing::Size(127, 20); + this->tbFirstName->TabIndex = 12; + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Location = System::Drawing::Point(25, 57); + this->label2->Margin = System::Windows::Forms::Padding(3, 3, 2, 3); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(58, 13); + this->label2->TabIndex = 11; + this->label2->Text = L"Last Name"; + // + // label1 + // + this->label1->AutoSize = true; + this->label1->Location = System::Drawing::Point(25, 27); + this->label1->Margin = System::Windows::Forms::Padding(3, 3, 2, 3); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(57, 13); + this->label1->TabIndex = 10; + this->label1->Text = L"First Name"; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(413, 208); + this->Controls->Add(this->bnRollback); + this->Controls->Add(this->bnCommit); + this->Controls->Add(this->bnDelete); + this->Controls->Add(this->bnUpdate); + this->Controls->Add(this->bnAdd); + this->Controls->Add(this->lbAuthors); + this->Controls->Add(this->tbLastName); + this->Controls->Add(this->tbFirstName); + this->Controls->Add(this->label2); + this->Controls->Add(this->label1); + this->Name = L"Form1"; + this->Text = L"Maintain Authors"; + this->ResumeLayout(false); + this->PerformLayout(); + + } + +#pragma endregion + + private: + String ^ListBoxItem(DataRow ^row) + { + return String::Format("{0} {1} {2}", + row["AuthorID"], + row["FirstName"], + row["LastName"]); + } + + System::Void bnAdd_Click(System::Object^ sender, System::EventArgs^ e) + { + // Make sure the text boxes are populated + if (tbFirstName->Text->Trim()->Length == 0 || + tbLastName->Text->Trim()->Length == 0) + return; + + // Create a new row in the DataTable + DataTable ^dt = dSet->Tables["Authors"]; + DataRow ^row = dt->NewRow(); + + // Update the columns with the new author information + row["FirstName"] = tbFirstName->Text; + row["LastName"] = tbLastName->Text; + + // Add the row to the Rows collection + dt->Rows->Add(row); + + // Add the new row to the list box + lbAuthors->Items->Add(ListBoxItem(row)); + + // blank out the text boxes + tbFirstName->Text = ""; + tbLastName->Text = ""; + } + + System::Void bnUpdate_Click(System::Object^ sender, System::EventArgs^ e) + { + // make sure we have a selected author from the listbox + if (CurrentAuthorID < 0) + return; + + // Select the author using its AuthorID + DataTable ^dt = dSet->Tables["Authors"]; + array^ row = + dt->Select(String::Format("AuthorID={0}", CurrentAuthorID)); + + // Since we know that AuthorID is unique only one row will be returned + // Update the row with the text box information + row[0]["FirstName"] = tbFirstName->Text; + row[0]["LastName"] = tbLastName->Text; + + // Update listbox + lbAuthors->Items->Insert(lbAuthors->SelectedIndex, ListBoxItem(row[0])); + lbAuthors->Items->RemoveAt(lbAuthors->SelectedIndex); + } + + System::Void bnDelete_Click(System::Object^ sender, System::EventArgs^ e) + { + // make sure we have a selected author from the listbox + if (CurrentAuthorID < 0) + return; + + // Select the author using its AuthorID + DataTable ^dt = dSet->Tables["Authors"]; + array^ row = + dt->Select(String::Format("AuthorID={0}", CurrentAuthorID)); + + // Since we know that AuthorID is unique only one row will be returned + // Delete the row + row[0]->Delete(); + + // all went well, delete the row from list box + lbAuthors->Items->RemoveAt(lbAuthors->SelectedIndex); + } + + System::Void bnCommit_Click(System::Object^ sender, System::EventArgs^ e) + { + dAdapt->Update(dSet, "Authors"); + dSet->AcceptChanges(); + + lbAuthors->Items->Clear(); + + DataTable ^dt = dSet->Tables["Authors"]; + + for each(DataRow ^row in dt->Rows) + { + lbAuthors->Items->Add(ListBoxItem(row)); + } + CurrentAuthorID = -1; + } + + System::Void bnRollback_Click(System::Object^ sender, System::EventArgs^ e) + { + dSet->RejectChanges(); + + lbAuthors->Items->Clear(); + + DataTable ^dt = dSet->Tables["Authors"]; + + for each(DataRow ^row in dt->Rows) + { + lbAuthors->Items->Add(ListBoxItem(row)); + } + CurrentAuthorID = -1; + } + + System::Void lbAuthors_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) + { + array^ ASpace = gcnew array {(wchar_t)' '}; + + if (lbAuthors->SelectedItem == nullptr) + { + CurrentAuthorID = -1; + tbFirstName->Text = ""; + tbLastName->Text = ""; + return; + } + array^ split = lbAuthors->SelectedItem->ToString()->Split(ASpace); + + CurrentAuthorID = Convert::ToInt32(split[0]); + tbFirstName->Text = split[1]; + tbLastName->Text = split[2]; + } + }; +} + diff --git a/Chapter13/MaintAuthors/Form1.resX b/Chapter13/MaintAuthors/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter13/MaintAuthors/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter13/MaintAuthors/MaintAuthors.cpp b/Chapter13/MaintAuthors/MaintAuthors.cpp new file mode 100644 index 0000000..6d3f3f2 --- /dev/null +++ b/Chapter13/MaintAuthors/MaintAuthors.cpp @@ -0,0 +1,17 @@ +// MaintAuthors.cpp : main project file. + +#include "Form1.h" + +using namespace MaintAuthors; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter13/MaintAuthors/MaintAuthors.vcproj b/Chapter13/MaintAuthors/MaintAuthors.vcproj new file mode 100644 index 0000000..53f587e --- /dev/null +++ b/Chapter13/MaintAuthors/MaintAuthors.vcproj @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/MaintAuthors/app.config b/Chapter13/MaintAuthors/app.config new file mode 100644 index 0000000..02e7800 --- /dev/null +++ b/Chapter13/MaintAuthors/app.config @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Chapter13/MaintAuthors_DGV/AssemblyInfo.cpp b/Chapter13/MaintAuthors_DGV/AssemblyInfo.cpp new file mode 100644 index 0000000..5e2f0a8 --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("MaintAuthors_DGV")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("MaintAuthors_DGV")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter13/MaintAuthors_DGV/AuthorDSLib.AuthorsDS.datasource b/Chapter13/MaintAuthors_DGV/AuthorDSLib.AuthorsDS.datasource new file mode 100644 index 0000000..8bac7ed --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/AuthorDSLib.AuthorsDS.datasource @@ -0,0 +1,10 @@ + + + + AuthorDSLib.AuthorsDS, AuthorDSLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Chapter13/MaintAuthors_DGV/Form1.h b/Chapter13/MaintAuthors_DGV/Form1.h new file mode 100644 index 0000000..2bdbe06 --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/Form1.h @@ -0,0 +1,179 @@ +#pragma once + + +namespace MaintAuthors_DGV { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + Adapter->Fill(AuthorsDS->Authors); + + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + private: AuthorDSLib::AuthorsDSTableAdapters::AuthorsTableAdapter ^Adapter; + private: AuthorDSLib::AuthorsDS^ AuthorsDS; + + protected: + private: System::Windows::Forms::DataGridView^ dataGridView1; + private: System::Windows::Forms::DataGridViewTextBoxColumn^ authorIDDataGridViewTextBoxColumn; + private: System::Windows::Forms::DataGridViewTextBoxColumn^ lastNameDataGridViewTextBoxColumn; + private: System::Windows::Forms::DataGridViewTextBoxColumn^ firstNameDataGridViewTextBoxColumn; + private: System::Windows::Forms::BindingSource^ AuthorsBindingSource; + + private: System::Windows::Forms::Button^ bnCommit; + private: System::Windows::Forms::Button^ bnRollback; + private: System::ComponentModel::IContainer^ components; + + private: + /// + /// Required designer variable. + /// + + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + this->AuthorsDS = (gcnew AuthorDSLib::AuthorsDS()); + this->Adapter = (gcnew AuthorDSLib::AuthorsDSTableAdapters::AuthorsTableAdapter()); + this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView()); + this->authorIDDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->lastNameDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->firstNameDataGridViewTextBoxColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn()); + this->AuthorsBindingSource = (gcnew System::Windows::Forms::BindingSource(this->components)); + this->bnCommit = (gcnew System::Windows::Forms::Button()); + this->bnRollback = (gcnew System::Windows::Forms::Button()); + (cli::safe_cast(this->AuthorsDS))->BeginInit(); + (cli::safe_cast(this->dataGridView1))->BeginInit(); + (cli::safe_cast(this->AuthorsBindingSource))->BeginInit(); + this->SuspendLayout(); + // + // AuthorsDS + // + this->AuthorsDS->DataSetName = L"AuthorsDS"; + this->AuthorsDS->SchemaSerializationMode = System::Data::SchemaSerializationMode::IncludeSchema; + // + // Adapter + // + this->Adapter->ClearBeforeFill = true; + // + // dataGridView1 + // + this->dataGridView1->AutoGenerateColumns = false; + this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize; + this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(3) {this->authorIDDataGridViewTextBoxColumn, + this->lastNameDataGridViewTextBoxColumn, this->firstNameDataGridViewTextBoxColumn}); + this->dataGridView1->DataSource = this->AuthorsBindingSource; + this->dataGridView1->Location = System::Drawing::Point(13, 13); + this->dataGridView1->Name = L"dataGridView1"; + this->dataGridView1->Size = System::Drawing::Size(428, 202); + this->dataGridView1->TabIndex = 0; + // + // authorIDDataGridViewTextBoxColumn + // + this->authorIDDataGridViewTextBoxColumn->DataPropertyName = L"AuthorID"; + this->authorIDDataGridViewTextBoxColumn->HeaderText = L"AuthorID"; + this->authorIDDataGridViewTextBoxColumn->Name = L"authorIDDataGridViewTextBoxColumn"; + this->authorIDDataGridViewTextBoxColumn->ReadOnly = true; + // + // lastNameDataGridViewTextBoxColumn + // + this->lastNameDataGridViewTextBoxColumn->DataPropertyName = L"LastName"; + this->lastNameDataGridViewTextBoxColumn->HeaderText = L"LastName"; + this->lastNameDataGridViewTextBoxColumn->Name = L"lastNameDataGridViewTextBoxColumn"; + // + // firstNameDataGridViewTextBoxColumn + // + this->firstNameDataGridViewTextBoxColumn->DataPropertyName = L"FirstName"; + this->firstNameDataGridViewTextBoxColumn->HeaderText = L"FirstName"; + this->firstNameDataGridViewTextBoxColumn->Name = L"firstNameDataGridViewTextBoxColumn"; + // + // AuthorsBindingSource + // + this->AuthorsBindingSource->DataMember = L"Authors"; + this->AuthorsBindingSource->DataSource = this->AuthorsDS; + // + // bnCommit + // + this->bnCommit->Location = System::Drawing::Point(130, 222); + this->bnCommit->Name = L"bnCommit"; + this->bnCommit->Size = System::Drawing::Size(75, 23); + this->bnCommit->TabIndex = 1; + this->bnCommit->Text = L"Commit"; + this->bnCommit->UseVisualStyleBackColor = true; + this->bnCommit->Click += gcnew System::EventHandler(this, &Form1::bnCommit_Click); + // + // bnRollback + // + this->bnRollback->Location = System::Drawing::Point(230, 222); + this->bnRollback->Name = L"bnRollback"; + this->bnRollback->Size = System::Drawing::Size(75, 23); + this->bnRollback->TabIndex = 2; + this->bnRollback->Text = L"Rollback"; + this->bnRollback->UseVisualStyleBackColor = true; + this->bnRollback->Click += gcnew System::EventHandler(this, &Form1::bnRollback_Click); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(453, 273); + this->Controls->Add(this->bnRollback); + this->Controls->Add(this->bnCommit); + this->Controls->Add(this->dataGridView1); + this->Name = L"Form1"; + this->Text = L"Form1"; + (cli::safe_cast(this->AuthorsDS))->EndInit(); + (cli::safe_cast(this->dataGridView1))->EndInit(); + (cli::safe_cast(this->AuthorsBindingSource))->EndInit(); + this->ResumeLayout(false); + + } +#pragma endregion + private: System::Void bnCommit_Click(System::Object^ sender, System::EventArgs^ e) + { + this->Adapter->Update(this->AuthorsDS->Authors); + this->AuthorsDS->AcceptChanges(); + } +private: System::Void bnRollback_Click(System::Object^ sender, System::EventArgs^ e) + { + this->AuthorsDS->RejectChanges(); + } +}; +} + diff --git a/Chapter13/MaintAuthors_DGV/Form1.resx b/Chapter13/MaintAuthors_DGV/Form1.resx new file mode 100644 index 0000000..166db71 --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/Form1.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 108, 17 + + + 17, 17 + + + 214, 17 + + \ No newline at end of file diff --git a/Chapter13/MaintAuthors_DGV/MaintAuthors_DGV.cpp b/Chapter13/MaintAuthors_DGV/MaintAuthors_DGV.cpp new file mode 100644 index 0000000..5c27adc --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/MaintAuthors_DGV.cpp @@ -0,0 +1,18 @@ +// MaintAuthors_DGV.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace MaintAuthors_DGV; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter13/MaintAuthors_DGV/MaintAuthors_DGV.vcproj b/Chapter13/MaintAuthors_DGV/MaintAuthors_DGV.vcproj new file mode 100644 index 0000000..553d472 --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/MaintAuthors_DGV.vcproj @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/MaintAuthors_DGV/stdafx.cpp b/Chapter13/MaintAuthors_DGV/stdafx.cpp new file mode 100644 index 0000000..59816b1 --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// MaintAuthors_DGV.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter13/MaintAuthors_DGV/stdafx.h b/Chapter13/MaintAuthors_DGV/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter13/MaintAuthors_DGV/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter14/ADONET/ADONET.cpp b/Chapter14/ADONET/ADONET.cpp new file mode 100644 index 0000000..46c154c --- /dev/null +++ b/Chapter14/ADONET/ADONET.cpp @@ -0,0 +1,63 @@ +using namespace System; +using namespace System::Configuration; +using namespace System::Data; +using namespace System::Data::SqlClient; +using namespace System::Xml; + +String ^indent(int depth) +{ + String ^ind = ""; + return ind->PadLeft(depth*4, ' '); +} + +void Navigate(XmlNode ^node, int depth) +{ + if (node == nullptr) + return; + + + Console::WriteLine("{0}: Name='{1}' Value='{2}'", + String::Concat(indent(depth),node->NodeType.ToString()), + node->Name, node->Value); + + if (node->Attributes != nullptr) + { + for (int i = 0; i < node->Attributes->Count; i++) + { + Console::WriteLine("{0}Attribute: Name='{1}' Value='{2}'", + indent(depth+1),node->Attributes[i]->Name, + node->Attributes[i]->Value); + } + } + + Navigate(node->FirstChild, depth+1); + Navigate(node->NextSibling, depth); +} + +void main() +{ + XmlDocument ^doc = gcnew XmlDocument(); + + try + { + SqlConnection ^connect = gcnew SqlConnection(); + + connect->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + + SqlDataAdapter ^dAdapt = gcnew SqlDataAdapter(); + DataSet ^dSet = gcnew DataSet(); + dAdapt->SelectCommand = + gcnew SqlCommand("SELECT * FROM Authors", connect); + + dAdapt->Fill(dSet, "Authors"); + XmlDataDocument ^doc = gcnew XmlDataDocument(dSet); + + // Recursive navigation of the DOM tree + Navigate(doc->DocumentElement, 0); + } + catch (Exception ^e) + { + Console::WriteLine("Error Occurred: {0}", e->Message); + } +} diff --git a/Chapter14/ADONET/ADONET.vcproj b/Chapter14/ADONET/ADONET.vcproj new file mode 100644 index 0000000..a40399d --- /dev/null +++ b/Chapter14/ADONET/ADONET.vcproj @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/ADONET/app.config b/Chapter14/ADONET/app.config new file mode 100644 index 0000000..ba36442 --- /dev/null +++ b/Chapter14/ADONET/app.config @@ -0,0 +1,10 @@ + + + + + + diff --git a/Chapter14/Chapter14.sln b/Chapter14/Chapter14.sln new file mode 100644 index 0000000..448bb9d --- /dev/null +++ b/Chapter14/Chapter14.sln @@ -0,0 +1,85 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CAF9A03A-79A6-4D5A-B1B7-EEFCDDC08333}" + ProjectSection(SolutionItems) = preProject + Monsters.xml = Monsters.xml + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadXML", "ReadXML\ReadXML.vcproj", "{99155577-9702-4167-B450-C0EFA5EA50AD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ValidateXML_DTD", "ValidateXML_DTD\ValidateXML_DTD.vcproj", "{E6026DFB-A3ED-44B5-962D-EAAF18E33076}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ValidateXML_XSD", "ValidateXML_XSD\ValidateXML_XSD.vcproj", "{3668FFF8-1A29-4BF6-843A-790CD5F7D84A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WriteXML", "WriteXML\WriteXML.vcproj", "{B47227AC-1064-4EEB-88CE-BEA0DEE2F211}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UpdateXML", "UpdateXML\UpdateXML.vcproj", "{F065AD54-FF36-4ABF-A088-F3AAB900EE10}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadXMLDOM", "ReadXMLDOM\ReadXMLDOM.vcproj", "{EC702F73-030C-4A93-AFE9-F0CFDCAC5682}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UpdateXMLDOM", "UpdateXMLDOM\UpdateXMLDOM.vcproj", "{67A96411-E216-4175-9EDE-DBD6E4E42CA1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WriteXMLDOM", "WriteXMLDOM\WriteXMLDOM.vcproj", "{68432005-D00B-4F9B-9011-C99B0160D921}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadXPathNav", "ReadXPathNav\ReadXPathNav.vcproj", "{0ADFDDAA-B968-453E-A31C-4561D301BE70}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XPathEx", "XPathEx\XPathEx.vcproj", "{82F513C4-6A1B-453B-95C0-49C58054B317}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ADONET", "ADONET\ADONET.vcproj", "{F8049D52-5B5D-4136-952D-C00499029A63}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {99155577-9702-4167-B450-C0EFA5EA50AD}.Debug|Win32.ActiveCfg = Debug|Win32 + {99155577-9702-4167-B450-C0EFA5EA50AD}.Debug|Win32.Build.0 = Debug|Win32 + {99155577-9702-4167-B450-C0EFA5EA50AD}.Release|Win32.ActiveCfg = Release|Win32 + {99155577-9702-4167-B450-C0EFA5EA50AD}.Release|Win32.Build.0 = Release|Win32 + {E6026DFB-A3ED-44B5-962D-EAAF18E33076}.Debug|Win32.ActiveCfg = Debug|Win32 + {E6026DFB-A3ED-44B5-962D-EAAF18E33076}.Debug|Win32.Build.0 = Debug|Win32 + {E6026DFB-A3ED-44B5-962D-EAAF18E33076}.Release|Win32.ActiveCfg = Release|Win32 + {E6026DFB-A3ED-44B5-962D-EAAF18E33076}.Release|Win32.Build.0 = Release|Win32 + {3668FFF8-1A29-4BF6-843A-790CD5F7D84A}.Debug|Win32.ActiveCfg = Debug|Win32 + {3668FFF8-1A29-4BF6-843A-790CD5F7D84A}.Debug|Win32.Build.0 = Debug|Win32 + {3668FFF8-1A29-4BF6-843A-790CD5F7D84A}.Release|Win32.ActiveCfg = Release|Win32 + {3668FFF8-1A29-4BF6-843A-790CD5F7D84A}.Release|Win32.Build.0 = Release|Win32 + {B47227AC-1064-4EEB-88CE-BEA0DEE2F211}.Debug|Win32.ActiveCfg = Debug|Win32 + {B47227AC-1064-4EEB-88CE-BEA0DEE2F211}.Debug|Win32.Build.0 = Debug|Win32 + {B47227AC-1064-4EEB-88CE-BEA0DEE2F211}.Release|Win32.ActiveCfg = Release|Win32 + {B47227AC-1064-4EEB-88CE-BEA0DEE2F211}.Release|Win32.Build.0 = Release|Win32 + {F065AD54-FF36-4ABF-A088-F3AAB900EE10}.Debug|Win32.ActiveCfg = Debug|Win32 + {F065AD54-FF36-4ABF-A088-F3AAB900EE10}.Debug|Win32.Build.0 = Debug|Win32 + {F065AD54-FF36-4ABF-A088-F3AAB900EE10}.Release|Win32.ActiveCfg = Release|Win32 + {F065AD54-FF36-4ABF-A088-F3AAB900EE10}.Release|Win32.Build.0 = Release|Win32 + {EC702F73-030C-4A93-AFE9-F0CFDCAC5682}.Debug|Win32.ActiveCfg = Debug|Win32 + {EC702F73-030C-4A93-AFE9-F0CFDCAC5682}.Debug|Win32.Build.0 = Debug|Win32 + {EC702F73-030C-4A93-AFE9-F0CFDCAC5682}.Release|Win32.ActiveCfg = Release|Win32 + {EC702F73-030C-4A93-AFE9-F0CFDCAC5682}.Release|Win32.Build.0 = Release|Win32 + {67A96411-E216-4175-9EDE-DBD6E4E42CA1}.Debug|Win32.ActiveCfg = Debug|Win32 + {67A96411-E216-4175-9EDE-DBD6E4E42CA1}.Debug|Win32.Build.0 = Debug|Win32 + {67A96411-E216-4175-9EDE-DBD6E4E42CA1}.Release|Win32.ActiveCfg = Release|Win32 + {67A96411-E216-4175-9EDE-DBD6E4E42CA1}.Release|Win32.Build.0 = Release|Win32 + {68432005-D00B-4F9B-9011-C99B0160D921}.Debug|Win32.ActiveCfg = Debug|Win32 + {68432005-D00B-4F9B-9011-C99B0160D921}.Debug|Win32.Build.0 = Debug|Win32 + {68432005-D00B-4F9B-9011-C99B0160D921}.Release|Win32.ActiveCfg = Release|Win32 + {68432005-D00B-4F9B-9011-C99B0160D921}.Release|Win32.Build.0 = Release|Win32 + {0ADFDDAA-B968-453E-A31C-4561D301BE70}.Debug|Win32.ActiveCfg = Debug|Win32 + {0ADFDDAA-B968-453E-A31C-4561D301BE70}.Debug|Win32.Build.0 = Debug|Win32 + {0ADFDDAA-B968-453E-A31C-4561D301BE70}.Release|Win32.ActiveCfg = Release|Win32 + {0ADFDDAA-B968-453E-A31C-4561D301BE70}.Release|Win32.Build.0 = Release|Win32 + {82F513C4-6A1B-453B-95C0-49C58054B317}.Debug|Win32.ActiveCfg = Debug|Win32 + {82F513C4-6A1B-453B-95C0-49C58054B317}.Debug|Win32.Build.0 = Debug|Win32 + {82F513C4-6A1B-453B-95C0-49C58054B317}.Release|Win32.ActiveCfg = Release|Win32 + {82F513C4-6A1B-453B-95C0-49C58054B317}.Release|Win32.Build.0 = Release|Win32 + {F8049D52-5B5D-4136-952D-C00499029A63}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8049D52-5B5D-4136-952D-C00499029A63}.Debug|Win32.Build.0 = Debug|Win32 + {F8049D52-5B5D-4136-952D-C00499029A63}.Release|Win32.ActiveCfg = Release|Win32 + {F8049D52-5B5D-4136-952D-C00499029A63}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter14/Monsters.xml b/Chapter14/Monsters.xml new file mode 100644 index 0000000..f54ef1f --- /dev/null +++ b/Chapter14/Monsters.xml @@ -0,0 +1,25 @@ + + + + + + Goblin + + Dagger + + + + Succubus + + Claw + Dagger + + + + Red Dragon + + Bite + Claw + Wing + + diff --git a/Chapter14/ReadXML/ReadXML.cpp b/Chapter14/ReadXML/ReadXML.cpp new file mode 100644 index 0000000..e8bc58d --- /dev/null +++ b/Chapter14/ReadXML/ReadXML.cpp @@ -0,0 +1,109 @@ +#using + +using namespace System; +using namespace System::Xml; + + +String ^indent(Int32 depth) +{ + String ^ind = ""; + return ind->PadLeft(depth * 3, ' '); +} + +void main() +{ + XmlReader ^reader; + + try + { + reader = XmlReader::Create("..\\Monsters.xml"); + + while (reader->Read()) + { + switch (reader->NodeType) + { + case XmlNodeType::Comment: + Console::WriteLine( + "{0}Comment node: Value='{1}'", + indent(reader->Depth), reader->Value); + break; + case XmlNodeType::Element: + Console::WriteLine( + "{0}Element node: Name='{1}'", + indent(reader->Depth), reader->Name); + + if (reader->HasAttributes) + { + while (reader->MoveToNextAttribute()) + { + Console::WriteLine( + "{0}Attribute node: Name='{1}' Value='{2}'", + indent(reader->Depth), reader->Name, + reader->Value); + } + reader->MoveToElement(); + } + + + if (reader->IsEmptyElement) + { + Console::WriteLine( + "{0}End Element node: Name='{1}'", + indent(reader->Depth), reader->Name); + } + break; + case XmlNodeType::EndElement: + Console::WriteLine( + "{0}End Element node: Name='{1}'", + indent(reader->Depth), reader->Name); + break; + case XmlNodeType::Text: + Console::WriteLine( + "{0}Text node: Value='{1}'", + indent(reader->Depth), reader->Value); + break; + case XmlNodeType::XmlDeclaration: + Console::WriteLine( + "Xml Declaration node: Name='{1}'", + indent(reader->Depth), reader->Name); + + if (reader->HasAttributes) + { + while (reader->MoveToNextAttribute()) + { + Console::WriteLine( + "{0}Attribute node: Name='{1}' Value='{2}'", + indent(reader->Depth), reader->Name, + reader->Value); + } + } + reader->MoveToElement(); + Console::WriteLine( + "End Xml Declaration node: Name='{1}'", + indent(reader->Depth), reader->Name); + break; + case XmlNodeType::Whitespace: + // Ignore white space + break; + default: + Console::WriteLine( + "***UKNOWN*** node: Name='{1}' Value='{2}'", + indent(reader->Depth), reader->Name, reader->Value); + } + } + } + + catch (XmlException ^e) + { + Console::WriteLine("\n\n\nSplitting XML Aborted with error: {0}", + e->Message); + } + finally + { + if (reader->ReadState != ReadState::Closed) + { + reader->Close(); + } + } +} + diff --git a/Chapter14/ReadXML/ReadXML.vcproj b/Chapter14/ReadXML/ReadXML.vcproj new file mode 100644 index 0000000..7b9ba3f --- /dev/null +++ b/Chapter14/ReadXML/ReadXML.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/ReadXMLDOM/ReadXMLDOM.cpp b/Chapter14/ReadXMLDOM/ReadXMLDOM.cpp new file mode 100644 index 0000000..3aa3f5c --- /dev/null +++ b/Chapter14/ReadXMLDOM/ReadXMLDOM.cpp @@ -0,0 +1,52 @@ +using namespace System; +using namespace System::Xml; + +String ^indent(int depth) +{ + String ^ind = ""; + return ind->PadLeft(depth*4, ' '); +} + +void Navigate(XmlNode ^node, int depth) +{ + if (node == nullptr) + return; + + Console::WriteLine("{0}: Name='{1}' Value='{2}'", + String::Concat(indent(depth),node->NodeType.ToString()), + node->Name, node->Value); + + if (node->Attributes != nullptr) + { + for (int i = 0; i < node->Attributes->Count; i++) + { + Console::WriteLine("{0}Attribute: Name='{1}' Value='{2}'", + indent(depth+1),node->Attributes[i]->Name, + node->Attributes[i]->Value); + } + } + Navigate(node->FirstChild, depth+1); + Navigate(node->NextSibling, depth); +} + + +void main() +{ + XmlDocument ^doc = gcnew XmlDocument(); + + try + { + XmlReader ^reader = XmlReader::Create("..\\Monsters.xml"); + doc->Load(reader); + reader->Close(); + + XmlNode ^node = doc->FirstChild; // I want the Xml Declaration + + // Recursive navigation of the DOM tree + Navigate(node, 0); + } + catch (Exception ^e) + { + Console::WriteLine("Error Occurred: {0}", e->Message); + } +} diff --git a/Chapter14/ReadXMLDOM/ReadXMLDOM.vcproj b/Chapter14/ReadXMLDOM/ReadXMLDOM.vcproj new file mode 100644 index 0000000..3a4b876 --- /dev/null +++ b/Chapter14/ReadXMLDOM/ReadXMLDOM.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/ReadXPathNav/ReadXPathNav.cpp b/Chapter14/ReadXPathNav/ReadXPathNav.cpp new file mode 100644 index 0000000..0ab8005 --- /dev/null +++ b/Chapter14/ReadXPathNav/ReadXPathNav.cpp @@ -0,0 +1,52 @@ +using namespace System; +using namespace System::Xml; +using namespace System::Xml::XPath; + +String ^indent(int depth) +{ + String ^ind = ""; + return ind->PadLeft(depth*4, ' '); +} + +void Navigate(XPathNavigator ^nav, int depth) +{ + Console::WriteLine("{0}: Name='{1}' Value='{2}'", + String::Concat(indent(depth), nav->NodeType.ToString()), + nav->Name, nav->Value); + + if (nav->HasAttributes) + { + nav->MoveToFirstAttribute(); + do { + Console::WriteLine("{0} Attribute: Name='{1}' Value='{2}'", + indent(depth+1),nav->Name, nav->Value); + } + while(nav->MoveToNextAttribute()); + nav->MoveToParent(); + } + + + if (nav->MoveToFirstChild()) + { + Navigate(nav, depth+1); + nav->MoveToParent(); + } + if (nav->MoveToNext()) + Navigate(nav, depth); +} + +void main() +{ + XmlDocument ^doc = gcnew XmlDocument(); + try + { + doc->Load("..\\Monsters.xml"); + XPathNavigator ^nav = doc->CreateNavigator(); + nav->MoveToRoot(); + Navigate(nav, 0); + } + catch (Exception ^e) + { + Console::WriteLine("Error Occurred: {0}", e->Message); + } +} diff --git a/Chapter14/ReadXPathNav/ReadXPathNav.vcproj b/Chapter14/ReadXPathNav/ReadXPathNav.vcproj new file mode 100644 index 0000000..a7334cd --- /dev/null +++ b/Chapter14/ReadXPathNav/ReadXPathNav.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/UpdateXML/New_Monsters.xml b/Chapter14/UpdateXML/New_Monsters.xml new file mode 100644 index 0000000..e7081ef --- /dev/null +++ b/Chapter14/UpdateXML/New_Monsters.xml @@ -0,0 +1,28 @@ + + + + + + Goblin + False + + Dagger + + + + Succubus + False + + Claw + Dagger + + + + Red Dragon + False + + Bite + Claw + Wing + + \ No newline at end of file diff --git a/Chapter14/UpdateXML/UpdateXML.cpp b/Chapter14/UpdateXML/UpdateXML.cpp new file mode 100644 index 0000000..d699703 --- /dev/null +++ b/Chapter14/UpdateXML/UpdateXML.cpp @@ -0,0 +1,72 @@ +#using + +using namespace System; +using namespace System::Xml; + +void main() +{ + XmlReader ^reader; + XmlWriter ^writer; + try + { + reader = XmlReader::Create("..\\Monsters.xml"); + + XmlWriterSettings ^settings = gcnew XmlWriterSettings(); + settings->Indent = true; + settings->IndentChars = (" "); + + writer = XmlWriter::Create("New_Monsters.xml", settings); + + while (reader->Read()) + { + switch (reader->NodeType) + { + case XmlNodeType::Comment: + writer->WriteComment(reader->Value); + break; + case XmlNodeType::Element: + writer->WriteStartElement(reader->Name); + writer->WriteAttributes(reader, false); + if (reader->IsEmptyElement) + writer->WriteEndElement(); + break; + case XmlNodeType::EndElement: + writer->WriteEndElement(); + + // *** Add new Monster Element + if (reader->Name->Equals("Name")) + { + writer->WriteStartElement("Encountered"); + writer->WriteString("False"); + writer->WriteEndElement(); + } + break; + case XmlNodeType::Text: + writer->WriteString(reader->Value); + break; + case XmlNodeType::XmlDeclaration: + writer->WriteStartDocument(); + break; + } + } + + writer->Flush(); + + Console::WriteLine("Done"); + } + catch (Exception ^e) + { + Console::WriteLine("XML Update Aborted -- {0}", e->Message); + } + finally + { + if (writer->WriteState != WriteState::Closed) + { + writer->Close(); + } + if (reader->ReadState != ReadState::Closed) + { + reader->Close(); + } + } +} diff --git a/Chapter14/UpdateXML/UpdateXML.vcproj b/Chapter14/UpdateXML/UpdateXML.vcproj new file mode 100644 index 0000000..29b8b95 --- /dev/null +++ b/Chapter14/UpdateXML/UpdateXML.vcproj @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/UpdateXMLDOM/New_Monsters.xml b/Chapter14/UpdateXMLDOM/New_Monsters.xml new file mode 100644 index 0000000..9f7ed70 --- /dev/null +++ b/Chapter14/UpdateXMLDOM/New_Monsters.xml @@ -0,0 +1,25 @@ + + + + + + Goblin + + Saber + + + + Succubus + + Claw + Dagger + + + + Red Dragon + + Bite + Claw + Wing + + \ No newline at end of file diff --git a/Chapter14/UpdateXMLDOM/UpdateXMLDOM.cpp b/Chapter14/UpdateXMLDOM/UpdateXMLDOM.cpp new file mode 100644 index 0000000..3f4c8ba --- /dev/null +++ b/Chapter14/UpdateXMLDOM/UpdateXMLDOM.cpp @@ -0,0 +1,43 @@ +using namespace System; +using namespace System::Xml; + +void Navigate(XmlNode ^node) +{ + if (node == nullptr) + return; + + if (node->Value != nullptr && node->Value->Equals("Dagger")) + { + if (node->ParentNode->ParentNode["Name"]->FirstChild->Value-> + Equals("Goblin")) + { + node->Value = "Saber"; + node->ParentNode->Attributes["Damage"]->Value = "1d8"; + } + } + + Navigate(node->FirstChild); + Navigate(node->NextSibling); +} + + +void main() +{ + XmlDocument ^doc = gcnew XmlDocument(); + + try + { + doc->Load("..\\Monsters.xml"); + XmlNode ^root = doc->DocumentElement; + + + // Recursive navigation of the DOM tree + Navigate(root); + + doc->Save("New_Monsters.xml"); + } + catch (Exception ^e) + { + Console::WriteLine("Error Occurred: {0}", e->Message ); + } +} diff --git a/Chapter14/UpdateXMLDOM/UpdateXMLDOM.vcproj b/Chapter14/UpdateXMLDOM/UpdateXMLDOM.vcproj new file mode 100644 index 0000000..c500ef4 --- /dev/null +++ b/Chapter14/UpdateXMLDOM/UpdateXMLDOM.vcproj @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/ValidateXML_DTD/BadMonsters.xml b/Chapter14/ValidateXML_DTD/BadMonsters.xml new file mode 100644 index 0000000..7e0fe68 --- /dev/null +++ b/Chapter14/ValidateXML_DTD/BadMonsters.xml @@ -0,0 +1,13 @@ + + + + + + + Goblin + Dagger + + + + + diff --git a/Chapter14/ValidateXML_DTD/Monsters.dtd b/Chapter14/ValidateXML_DTD/Monsters.dtd new file mode 100644 index 0000000..38416c0 --- /dev/null +++ b/Chapter14/ValidateXML_DTD/Monsters.dtd @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter14/ValidateXML_DTD/Monsters.xml b/Chapter14/ValidateXML_DTD/Monsters.xml new file mode 100644 index 0000000..6a242d4 --- /dev/null +++ b/Chapter14/ValidateXML_DTD/Monsters.xml @@ -0,0 +1,26 @@ + + + + + + + Goblin + + Dagger + + + + Succubus + + Claw + Dagger + + + + Red Dragon + + Bite + Claw + Wing + + diff --git a/Chapter14/ValidateXML_DTD/ValidateXML.cpp b/Chapter14/ValidateXML_DTD/ValidateXML.cpp new file mode 100644 index 0000000..e65e09a --- /dev/null +++ b/Chapter14/ValidateXML_DTD/ValidateXML.cpp @@ -0,0 +1,52 @@ +#using + +using namespace System; +using namespace System::Xml; +using namespace System::Xml::Schema; + +ref class ValidateXML +{ +public: + ValidateXML(String ^filename) + { + XmlReader ^vreader; + try + { + XmlReaderSettings ^settings = gcnew XmlReaderSettings(); + settings->ProhibitDtd = false; + settings->ValidationType = ValidationType::DTD; + vreader = XmlReader::Create(filename, settings); + + while(vreader->Read()) + { + // ... Process nodes just like XmlTextReader() + } + Console::WriteLine("Finished Processing"); + } + catch (Exception ^e) + { + Console::WriteLine(e->Message); + } + finally + { + if (vreader->ReadState != ReadState::Closed) + { + vreader->Close(); + } + } + } +}; + +void main() +{ + Console::WriteLine("Bad Monsters file"); + Console::WriteLine("-----------------"); + gcnew ValidateXML("BadMonsters.xml"); + + Console::WriteLine("\nGood Monsters file"); + Console::WriteLine("------------------"); + // Note this is a custom Monsters.xml because it needs: + // + // added to it for validation + gcnew ValidateXML("Monsters.xml"); +} diff --git a/Chapter14/ValidateXML_DTD/ValidateXML_DTD.vcproj b/Chapter14/ValidateXML_DTD/ValidateXML_DTD.vcproj new file mode 100644 index 0000000..83ee050 --- /dev/null +++ b/Chapter14/ValidateXML_DTD/ValidateXML_DTD.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/ValidateXML_XSD/BadMonsters.xml b/Chapter14/ValidateXML_XSD/BadMonsters.xml new file mode 100644 index 0000000..77d52e4 --- /dev/null +++ b/Chapter14/ValidateXML_XSD/BadMonsters.xml @@ -0,0 +1,11 @@ + + + + + + Goblin + Dagger + + + + \ No newline at end of file diff --git a/Chapter14/ValidateXML_XSD/Debug.obj b/Chapter14/ValidateXML_XSD/Debug.obj new file mode 100644 index 0000000..efdc899 Binary files /dev/null and b/Chapter14/ValidateXML_XSD/Debug.obj differ diff --git a/Chapter14/ValidateXML_XSD/Monsters.dll b/Chapter14/ValidateXML_XSD/Monsters.dll new file mode 100644 index 0000000..e98d90b Binary files /dev/null and b/Chapter14/ValidateXML_XSD/Monsters.dll differ diff --git a/Chapter14/ValidateXML_XSD/Monsters.dll.manifest b/Chapter14/ValidateXML_XSD/Monsters.dll.manifest new file mode 100644 index 0000000..7256947 --- /dev/null +++ b/Chapter14/ValidateXML_XSD/Monsters.dll.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Chapter14/ValidateXML_XSD/Monsters.h b/Chapter14/ValidateXML_XSD/Monsters.h new file mode 100644 index 0000000..d3d8998 --- /dev/null +++ b/Chapter14/ValidateXML_XSD/Monsters.h @@ -0,0 +1,1701 @@ +#pragma once + +#using +#using +#using +#using + +using namespace System::Security::Permissions; +[assembly:SecurityPermissionAttribute(SecurityAction::RequestMinimum, SkipVerification=false)]; +// +// This source code was auto-generated by xsd, Version=2.0.50727.1432. +// +namespace ValidateXML_XSD { + using namespace System; + ref class MonsterList; + + + /// +///Represents a strongly typed in-memory cache of data. +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0"), + System::Serializable, + System::ComponentModel::DesignerCategoryAttribute(L"code"), + System::ComponentModel::ToolboxItem(true), + System::Xml::Serialization::XmlSchemaProviderAttribute(L"GetTypedDataSetSchema"), + System::Xml::Serialization::XmlRootAttribute(L"MonsterList"), + System::ComponentModel::Design::HelpKeywordAttribute(L"vs.data.DataSet")] + public ref class MonsterList : public ::System::Data::DataSet { + public : ref class MonsterDataTable; + public : ref class HitDiceDataTable; + public : ref class WeaponDataTable; + public : ref class MonsterRow; + public : ref class HitDiceRow; + public : ref class WeaponRow; + public : ref class MonsterRowChangeEvent; + public : ref class HitDiceRowChangeEvent; + public : ref class WeaponRowChangeEvent; + + private: ValidateXML_XSD::MonsterList::MonsterDataTable^ tableMonster; + + private: ValidateXML_XSD::MonsterList::HitDiceDataTable^ tableHitDice; + + private: ValidateXML_XSD::MonsterList::WeaponDataTable^ tableWeapon; + + private: ::System::Data::DataRelation^ relationMonster_HitDice; + + private: ::System::Data::DataRelation^ relationMonster_Weapon; + + private: ::System::Data::SchemaSerializationMode _schemaSerializationMode; + + public : delegate System::Void MonsterRowChangeEventHandler(::System::Object^ sender, ValidateXML_XSD::MonsterList::MonsterRowChangeEvent^ e); + + public : delegate System::Void HitDiceRowChangeEventHandler(::System::Object^ sender, ValidateXML_XSD::MonsterList::HitDiceRowChangeEvent^ e); + + public : delegate System::Void WeaponRowChangeEventHandler(::System::Object^ sender, ValidateXML_XSD::MonsterList::WeaponRowChangeEvent^ e); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + MonsterList(); + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + MonsterList(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::Browsable(false), + System::ComponentModel::DesignerSerializationVisibility(::System::ComponentModel::DesignerSerializationVisibility::Content)] + property ValidateXML_XSD::MonsterList::MonsterDataTable^ Monster { + ValidateXML_XSD::MonsterList::MonsterDataTable^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::Browsable(false), + System::ComponentModel::DesignerSerializationVisibility(::System::ComponentModel::DesignerSerializationVisibility::Content)] + property ValidateXML_XSD::MonsterList::HitDiceDataTable^ HitDice { + ValidateXML_XSD::MonsterList::HitDiceDataTable^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::Browsable(false), + System::ComponentModel::DesignerSerializationVisibility(::System::ComponentModel::DesignerSerializationVisibility::Content)] + property ValidateXML_XSD::MonsterList::WeaponDataTable^ Weapon { + ValidateXML_XSD::MonsterList::WeaponDataTable^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::BrowsableAttribute(true), + System::ComponentModel::DesignerSerializationVisibilityAttribute(::System::ComponentModel::DesignerSerializationVisibility::Visible)] + virtual property ::System::Data::SchemaSerializationMode SchemaSerializationMode { + ::System::Data::SchemaSerializationMode get() override; + System::Void set(::System::Data::SchemaSerializationMode value) override; + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::DesignerSerializationVisibilityAttribute(::System::ComponentModel::DesignerSerializationVisibility::Hidden)] + property ::System::Data::DataTableCollection^ Tables { + ::System::Data::DataTableCollection^ get() new; + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::DesignerSerializationVisibilityAttribute(::System::ComponentModel::DesignerSerializationVisibility::Hidden)] + property ::System::Data::DataRelationCollection^ Relations { + ::System::Data::DataRelationCollection^ get() new; + } + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void InitializeDerivedDataSet() override; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataSet^ Clone() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Boolean ShouldSerializeTables() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Boolean ShouldSerializeRelations() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void ReadXmlSerializable(::System::Xml::XmlReader^ reader) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Xml::Schema::XmlSchema^ GetSchemaSerializable() override; + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitVars(); + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitVars(::System::Boolean initTable); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitClass(); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Boolean ShouldSerializeMonster(); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Boolean ShouldSerializeHitDice(); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Boolean ShouldSerializeWeapon(); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void SchemaChanged(::System::Object^ sender, ::System::ComponentModel::CollectionChangeEventArgs^ e); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + static ::System::Xml::Schema::XmlSchemaComplexType^ GetTypedDataSetSchema(::System::Xml::Schema::XmlSchemaSet^ xs); + + public : /// +///Represents the strongly named DataTable class. +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0"), + System::Serializable, + System::Xml::Serialization::XmlSchemaProviderAttribute(L"GetTypedTableSchema")] + ref class MonsterDataTable : public ::System::Data::DataTable, public ::System::Collections::IEnumerable { + + private: ::System::Data::DataColumn^ columnName; + + private: ::System::Data::DataColumn^ columnMonster_Id; + + public: event ValidateXML_XSD::MonsterList::MonsterRowChangeEventHandler^ MonsterRowChanging; + + public: event ValidateXML_XSD::MonsterList::MonsterRowChangeEventHandler^ MonsterRowChanged; + + public: event ValidateXML_XSD::MonsterList::MonsterRowChangeEventHandler^ MonsterRowDeleting; + + public: event ValidateXML_XSD::MonsterList::MonsterRowChangeEventHandler^ MonsterRowDeleted; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + MonsterDataTable(); + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + MonsterDataTable(::System::Data::DataTable^ table); + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + MonsterDataTable(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ NameColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ Monster_IdColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::Browsable(false)] + property ::System::Int32 Count { + ::System::Int32 get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::MonsterRow^ default [::System::Int32 ] { + ValidateXML_XSD::MonsterList::MonsterRow^ get(::System::Int32 index); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void AddMonsterRow(ValidateXML_XSD::MonsterList::MonsterRow^ row); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ValidateXML_XSD::MonsterList::MonsterRow^ AddMonsterRow(System::String^ Name); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Collections::IEnumerator^ GetEnumerator(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataTable^ Clone() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataTable^ CreateInstance() override; + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitVars(); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitClass(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ValidateXML_XSD::MonsterList::MonsterRow^ NewMonsterRow(); + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataRow^ NewRowFromBuilder(::System::Data::DataRowBuilder^ builder) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Type^ GetRowType() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowChanged(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowChanging(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowDeleted(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowDeleting(::System::Data::DataRowChangeEventArgs^ e) override; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void RemoveMonsterRow(ValidateXML_XSD::MonsterList::MonsterRow^ row); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + static ::System::Xml::Schema::XmlSchemaComplexType^ GetTypedTableSchema(::System::Xml::Schema::XmlSchemaSet^ xs); + }; + + public : /// +///Represents the strongly named DataTable class. +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0"), + System::Serializable, + System::Xml::Serialization::XmlSchemaProviderAttribute(L"GetTypedTableSchema")] + ref class HitDiceDataTable : public ::System::Data::DataTable, public ::System::Collections::IEnumerable { + + private: ::System::Data::DataColumn^ columnDice; + + private: ::System::Data::DataColumn^ columnDefault; + + private: ::System::Data::DataColumn^ columnMonster_Id; + + public: event ValidateXML_XSD::MonsterList::HitDiceRowChangeEventHandler^ HitDiceRowChanging; + + public: event ValidateXML_XSD::MonsterList::HitDiceRowChangeEventHandler^ HitDiceRowChanged; + + public: event ValidateXML_XSD::MonsterList::HitDiceRowChangeEventHandler^ HitDiceRowDeleting; + + public: event ValidateXML_XSD::MonsterList::HitDiceRowChangeEventHandler^ HitDiceRowDeleted; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + HitDiceDataTable(); + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + HitDiceDataTable(::System::Data::DataTable^ table); + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + HitDiceDataTable(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ DiceColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ DefaultColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ Monster_IdColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::Browsable(false)] + property ::System::Int32 Count { + ::System::Int32 get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::HitDiceRow^ default [::System::Int32 ] { + ValidateXML_XSD::MonsterList::HitDiceRow^ get(::System::Int32 index); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void AddHitDiceRow(ValidateXML_XSD::MonsterList::HitDiceRow^ row); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ValidateXML_XSD::MonsterList::HitDiceRow^ AddHitDiceRow(System::String^ Dice, System::Byte Default, ValidateXML_XSD::MonsterList::MonsterRow^ parentMonsterRowByMonster_HitDice); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Collections::IEnumerator^ GetEnumerator(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataTable^ Clone() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataTable^ CreateInstance() override; + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitVars(); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitClass(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ValidateXML_XSD::MonsterList::HitDiceRow^ NewHitDiceRow(); + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataRow^ NewRowFromBuilder(::System::Data::DataRowBuilder^ builder) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Type^ GetRowType() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowChanged(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowChanging(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowDeleted(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowDeleting(::System::Data::DataRowChangeEventArgs^ e) override; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void RemoveHitDiceRow(ValidateXML_XSD::MonsterList::HitDiceRow^ row); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + static ::System::Xml::Schema::XmlSchemaComplexType^ GetTypedTableSchema(::System::Xml::Schema::XmlSchemaSet^ xs); + }; + + public : /// +///Represents the strongly named DataTable class. +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0"), + System::Serializable, + System::Xml::Serialization::XmlSchemaProviderAttribute(L"GetTypedTableSchema")] + ref class WeaponDataTable : public ::System::Data::DataTable, public ::System::Collections::IEnumerable { + + private: ::System::Data::DataColumn^ columnNumber; + + private: ::System::Data::DataColumn^ columnDamage; + + private: ::System::Data::DataColumn^ columnWeapon_text; + + private: ::System::Data::DataColumn^ columnMonster_Id; + + public: event ValidateXML_XSD::MonsterList::WeaponRowChangeEventHandler^ WeaponRowChanging; + + public: event ValidateXML_XSD::MonsterList::WeaponRowChangeEventHandler^ WeaponRowChanged; + + public: event ValidateXML_XSD::MonsterList::WeaponRowChangeEventHandler^ WeaponRowDeleting; + + public: event ValidateXML_XSD::MonsterList::WeaponRowChangeEventHandler^ WeaponRowDeleted; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + WeaponDataTable(); + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + WeaponDataTable(::System::Data::DataTable^ table); + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + WeaponDataTable(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ NumberColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ DamageColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ Weapon_textColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataColumn^ Monster_IdColumn { + ::System::Data::DataColumn^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute, + System::ComponentModel::Browsable(false)] + property ::System::Int32 Count { + ::System::Int32 get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::WeaponRow^ default [::System::Int32 ] { + ValidateXML_XSD::MonsterList::WeaponRow^ get(::System::Int32 index); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void AddWeaponRow(ValidateXML_XSD::MonsterList::WeaponRow^ row); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ValidateXML_XSD::MonsterList::WeaponRow^ AddWeaponRow(System::Byte Number, System::String^ Damage, System::String^ Weapon_text, + ValidateXML_XSD::MonsterList::MonsterRow^ parentMonsterRowByMonster_Weapon); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Collections::IEnumerator^ GetEnumerator(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataTable^ Clone() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataTable^ CreateInstance() override; + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitVars(); + + private: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void InitClass(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ValidateXML_XSD::MonsterList::WeaponRow^ NewWeaponRow(); + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Data::DataRow^ NewRowFromBuilder(::System::Data::DataRowBuilder^ builder) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Type^ GetRowType() override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowChanged(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowChanging(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowDeleted(::System::Data::DataRowChangeEventArgs^ e) override; + + protected: [System::Diagnostics::DebuggerNonUserCodeAttribute] + virtual ::System::Void OnRowDeleting(::System::Data::DataRowChangeEventArgs^ e) override; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void RemoveWeaponRow(ValidateXML_XSD::MonsterList::WeaponRow^ row); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + static ::System::Xml::Schema::XmlSchemaComplexType^ GetTypedTableSchema(::System::Xml::Schema::XmlSchemaSet^ xs); + }; + + public : /// +///Represents strongly named DataRow class. +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0")] + ref class MonsterRow : public ::System::Data::DataRow { + + private: ValidateXML_XSD::MonsterList::MonsterDataTable^ tableMonster; + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + MonsterRow(::System::Data::DataRowBuilder^ rb); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::String^ Name { + System::String^ get(); + System::Void set(System::String^ value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::Int32 Monster_Id { + System::Int32 get(); + System::Void set(System::Int32 value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + cli::array< ValidateXML_XSD::MonsterList::HitDiceRow^ >^ GetHitDiceRows(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + cli::array< ValidateXML_XSD::MonsterList::WeaponRow^ >^ GetWeaponRows(); + }; + + public : /// +///Represents strongly named DataRow class. +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0")] + ref class HitDiceRow : public ::System::Data::DataRow { + + private: ValidateXML_XSD::MonsterList::HitDiceDataTable^ tableHitDice; + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + HitDiceRow(::System::Data::DataRowBuilder^ rb); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::String^ Dice { + System::String^ get(); + System::Void set(System::String^ value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::Byte Default { + System::Byte get(); + System::Void set(System::Byte value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::Int32 Monster_Id { + System::Int32 get(); + System::Void set(System::Int32 value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::MonsterRow^ MonsterRow { + ValidateXML_XSD::MonsterList::MonsterRow^ get(); + System::Void set(ValidateXML_XSD::MonsterList::MonsterRow^ value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Boolean IsMonster_IdNull(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void SetMonster_IdNull(); + }; + + public : /// +///Represents strongly named DataRow class. +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0")] + ref class WeaponRow : public ::System::Data::DataRow { + + private: ValidateXML_XSD::MonsterList::WeaponDataTable^ tableWeapon; + + internal: [System::Diagnostics::DebuggerNonUserCodeAttribute] + WeaponRow(::System::Data::DataRowBuilder^ rb); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::Byte Number { + System::Byte get(); + System::Void set(System::Byte value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::String^ Damage { + System::String^ get(); + System::Void set(System::String^ value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::String^ Weapon_text { + System::String^ get(); + System::Void set(System::String^ value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property System::Int32 Monster_Id { + System::Int32 get(); + System::Void set(System::Int32 value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::MonsterRow^ MonsterRow { + ValidateXML_XSD::MonsterList::MonsterRow^ get(); + System::Void set(ValidateXML_XSD::MonsterList::MonsterRow^ value); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Boolean IsMonster_IdNull(); + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + ::System::Void SetMonster_IdNull(); + }; + + public : /// +///Row event argument class +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0")] + ref class MonsterRowChangeEvent : public ::System::EventArgs { + + private: ValidateXML_XSD::MonsterList::MonsterRow^ eventRow; + + private: ::System::Data::DataRowAction eventAction; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + MonsterRowChangeEvent(ValidateXML_XSD::MonsterList::MonsterRow^ row, ::System::Data::DataRowAction action); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::MonsterRow^ Row { + ValidateXML_XSD::MonsterList::MonsterRow^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataRowAction Action { + ::System::Data::DataRowAction get(); + } + }; + + public : /// +///Row event argument class +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0")] + ref class HitDiceRowChangeEvent : public ::System::EventArgs { + + private: ValidateXML_XSD::MonsterList::HitDiceRow^ eventRow; + + private: ::System::Data::DataRowAction eventAction; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + HitDiceRowChangeEvent(ValidateXML_XSD::MonsterList::HitDiceRow^ row, ::System::Data::DataRowAction action); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::HitDiceRow^ Row { + ValidateXML_XSD::MonsterList::HitDiceRow^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataRowAction Action { + ::System::Data::DataRowAction get(); + } + }; + + public : /// +///Row event argument class +/// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.Data.Design.TypedDataSetGenerator", L"2.0.0.0")] + ref class WeaponRowChangeEvent : public ::System::EventArgs { + + private: ValidateXML_XSD::MonsterList::WeaponRow^ eventRow; + + private: ::System::Data::DataRowAction eventAction; + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + WeaponRowChangeEvent(ValidateXML_XSD::MonsterList::WeaponRow^ row, ::System::Data::DataRowAction action); + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ValidateXML_XSD::MonsterList::WeaponRow^ Row { + ValidateXML_XSD::MonsterList::WeaponRow^ get(); + } + + public: [System::Diagnostics::DebuggerNonUserCodeAttribute] + property ::System::Data::DataRowAction Action { + ::System::Data::DataRowAction get(); + } + }; + }; +} +namespace ValidateXML_XSD { + + + inline MonsterList::MonsterList() { + this->BeginInit(); + this->InitClass(); + ::System::ComponentModel::CollectionChangeEventHandler^ schemaChangedHandler = gcnew ::System::ComponentModel::CollectionChangeEventHandler(this, &ValidateXML_XSD::MonsterList::SchemaChanged); + __super::Tables->CollectionChanged += schemaChangedHandler; + __super::Relations->CollectionChanged += schemaChangedHandler; + this->EndInit(); + } + + inline MonsterList::MonsterList(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context) : + ::System::Data::DataSet(info, context, false) { + if (this->IsBinarySerialized(info, context) == true) { + this->InitVars(false); + ::System::ComponentModel::CollectionChangeEventHandler^ schemaChangedHandler1 = gcnew ::System::ComponentModel::CollectionChangeEventHandler(this, &ValidateXML_XSD::MonsterList::SchemaChanged); + this->Tables->CollectionChanged += schemaChangedHandler1; + this->Relations->CollectionChanged += schemaChangedHandler1; + return; + } + ::System::String^ strSchema = (cli::safe_cast<::System::String^ >(info->GetValue(L"XmlSchema", ::System::String::typeid))); + if (this->DetermineSchemaSerializationMode(info, context) == ::System::Data::SchemaSerializationMode::IncludeSchema) { + ::System::Data::DataSet^ ds = (gcnew ::System::Data::DataSet()); + ds->ReadXmlSchema((gcnew ::System::Xml::XmlTextReader((gcnew ::System::IO::StringReader(strSchema))))); + if (ds->Tables[L"Monster"] != nullptr) { + __super::Tables->Add((gcnew ValidateXML_XSD::MonsterList::MonsterDataTable(ds->Tables[L"Monster"]))); + } + if (ds->Tables[L"HitDice"] != nullptr) { + __super::Tables->Add((gcnew ValidateXML_XSD::MonsterList::HitDiceDataTable(ds->Tables[L"HitDice"]))); + } + if (ds->Tables[L"Weapon"] != nullptr) { + __super::Tables->Add((gcnew ValidateXML_XSD::MonsterList::WeaponDataTable(ds->Tables[L"Weapon"]))); + } + this->DataSetName = ds->DataSetName; + this->Prefix = ds->Prefix; + this->Namespace = ds->Namespace; + this->Locale = ds->Locale; + this->CaseSensitive = ds->CaseSensitive; + this->EnforceConstraints = ds->EnforceConstraints; + this->Merge(ds, false, ::System::Data::MissingSchemaAction::Add); + this->InitVars(); + } + else { + this->ReadXmlSchema((gcnew ::System::Xml::XmlTextReader((gcnew ::System::IO::StringReader(strSchema))))); + } + this->GetSerializationData(info, context); + ::System::ComponentModel::CollectionChangeEventHandler^ schemaChangedHandler = gcnew ::System::ComponentModel::CollectionChangeEventHandler(this, &ValidateXML_XSD::MonsterList::SchemaChanged); + __super::Tables->CollectionChanged += schemaChangedHandler; + this->Relations->CollectionChanged += schemaChangedHandler; + } + + inline ValidateXML_XSD::MonsterList::MonsterDataTable^ MonsterList::Monster::get() { + return this->tableMonster; + } + + inline ValidateXML_XSD::MonsterList::HitDiceDataTable^ MonsterList::HitDice::get() { + return this->tableHitDice; + } + + inline ValidateXML_XSD::MonsterList::WeaponDataTable^ MonsterList::Weapon::get() { + return this->tableWeapon; + } + + inline ::System::Data::SchemaSerializationMode MonsterList::SchemaSerializationMode::get() { + return this->_schemaSerializationMode; + } + inline System::Void MonsterList::SchemaSerializationMode::set(::System::Data::SchemaSerializationMode value) { + this->_schemaSerializationMode = __identifier(value); + } + + inline ::System::Data::DataTableCollection^ MonsterList::Tables::get() { + return __super::Tables; + } + + inline ::System::Data::DataRelationCollection^ MonsterList::Relations::get() { + return __super::Relations; + } + + inline ::System::Void MonsterList::InitializeDerivedDataSet() { + this->BeginInit(); + this->InitClass(); + this->EndInit(); + } + + inline ::System::Data::DataSet^ MonsterList::Clone() { + ValidateXML_XSD::MonsterList^ cln = (cli::safe_cast(__super::Clone())); + cln->InitVars(); + cln->SchemaSerializationMode = this->SchemaSerializationMode; + return cln; + } + + inline ::System::Boolean MonsterList::ShouldSerializeTables() { + return false; + } + + inline ::System::Boolean MonsterList::ShouldSerializeRelations() { + return false; + } + + inline ::System::Void MonsterList::ReadXmlSerializable(::System::Xml::XmlReader^ reader) { + if (this->DetermineSchemaSerializationMode(reader) == ::System::Data::SchemaSerializationMode::IncludeSchema) { + this->Reset(); + ::System::Data::DataSet^ ds = (gcnew ::System::Data::DataSet()); + ds->ReadXml(reader); + if (ds->Tables[L"Monster"] != nullptr) { + __super::Tables->Add((gcnew ValidateXML_XSD::MonsterList::MonsterDataTable(ds->Tables[L"Monster"]))); + } + if (ds->Tables[L"HitDice"] != nullptr) { + __super::Tables->Add((gcnew ValidateXML_XSD::MonsterList::HitDiceDataTable(ds->Tables[L"HitDice"]))); + } + if (ds->Tables[L"Weapon"] != nullptr) { + __super::Tables->Add((gcnew ValidateXML_XSD::MonsterList::WeaponDataTable(ds->Tables[L"Weapon"]))); + } + this->DataSetName = ds->DataSetName; + this->Prefix = ds->Prefix; + this->Namespace = ds->Namespace; + this->Locale = ds->Locale; + this->CaseSensitive = ds->CaseSensitive; + this->EnforceConstraints = ds->EnforceConstraints; + this->Merge(ds, false, ::System::Data::MissingSchemaAction::Add); + this->InitVars(); + } + else { + this->ReadXml(reader); + this->InitVars(); + } + } + + inline ::System::Xml::Schema::XmlSchema^ MonsterList::GetSchemaSerializable() { + ::System::IO::MemoryStream^ stream = (gcnew ::System::IO::MemoryStream()); + this->WriteXmlSchema((gcnew ::System::Xml::XmlTextWriter(stream, nullptr))); + stream->Position = 0; + return ::System::Xml::Schema::XmlSchema::Read((gcnew ::System::Xml::XmlTextReader(stream)), nullptr); + } + + inline ::System::Void MonsterList::InitVars() { + this->InitVars(true); + } + + inline ::System::Void MonsterList::InitVars(::System::Boolean initTable) { + this->tableMonster = (cli::safe_cast(__super::Tables[L"Monster"])); + if (initTable == true) { + if (this->tableMonster != nullptr) { + this->tableMonster->InitVars(); + } + } + this->tableHitDice = (cli::safe_cast(__super::Tables[L"HitDice"])); + if (initTable == true) { + if (this->tableHitDice != nullptr) { + this->tableHitDice->InitVars(); + } + } + this->tableWeapon = (cli::safe_cast(__super::Tables[L"Weapon"])); + if (initTable == true) { + if (this->tableWeapon != nullptr) { + this->tableWeapon->InitVars(); + } + } + this->relationMonster_HitDice = this->Relations[L"Monster_HitDice"]; + this->relationMonster_Weapon = this->Relations[L"Monster_Weapon"]; + } + + inline ::System::Void MonsterList::InitClass() { + this->DataSetName = L"MonsterList"; + this->Prefix = L""; + this->EnforceConstraints = true; + this->SchemaSerializationMode = ::System::Data::SchemaSerializationMode::IncludeSchema; + this->tableMonster = (gcnew ValidateXML_XSD::MonsterList::MonsterDataTable()); + __super::Tables->Add(this->tableMonster); + this->tableHitDice = (gcnew ValidateXML_XSD::MonsterList::HitDiceDataTable()); + __super::Tables->Add(this->tableHitDice); + this->tableWeapon = (gcnew ValidateXML_XSD::MonsterList::WeaponDataTable()); + __super::Tables->Add(this->tableWeapon); + ::System::Data::ForeignKeyConstraint^ fkc; + fkc = (gcnew ::System::Data::ForeignKeyConstraint(L"Monster_HitDice", gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableMonster->Monster_IdColumn}, + gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableHitDice->Monster_IdColumn})); + this->tableHitDice->Constraints->Add(fkc); + fkc->AcceptRejectRule = ::System::Data::AcceptRejectRule::None; + fkc->DeleteRule = ::System::Data::Rule::Cascade; + fkc->UpdateRule = ::System::Data::Rule::Cascade; + fkc = (gcnew ::System::Data::ForeignKeyConstraint(L"Monster_Weapon", gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableMonster->Monster_IdColumn}, + gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableWeapon->Monster_IdColumn})); + this->tableWeapon->Constraints->Add(fkc); + fkc->AcceptRejectRule = ::System::Data::AcceptRejectRule::None; + fkc->DeleteRule = ::System::Data::Rule::Cascade; + fkc->UpdateRule = ::System::Data::Rule::Cascade; + this->relationMonster_HitDice = (gcnew ::System::Data::DataRelation(L"Monster_HitDice", gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableMonster->Monster_IdColumn}, + gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableHitDice->Monster_IdColumn}, false)); + this->relationMonster_HitDice->Nested = true; + this->Relations->Add(this->relationMonster_HitDice); + this->relationMonster_Weapon = (gcnew ::System::Data::DataRelation(L"Monster_Weapon", gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableMonster->Monster_IdColumn}, + gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->tableWeapon->Monster_IdColumn}, false)); + this->relationMonster_Weapon->Nested = true; + this->Relations->Add(this->relationMonster_Weapon); + } + + inline ::System::Boolean MonsterList::ShouldSerializeMonster() { + return false; + } + + inline ::System::Boolean MonsterList::ShouldSerializeHitDice() { + return false; + } + + inline ::System::Boolean MonsterList::ShouldSerializeWeapon() { + return false; + } + + inline ::System::Void MonsterList::SchemaChanged(::System::Object^ sender, ::System::ComponentModel::CollectionChangeEventArgs^ e) { + if (e->Action == ::System::ComponentModel::CollectionChangeAction::Remove) { + this->InitVars(); + } + } + + inline ::System::Xml::Schema::XmlSchemaComplexType^ MonsterList::GetTypedDataSetSchema(::System::Xml::Schema::XmlSchemaSet^ xs) { + ValidateXML_XSD::MonsterList^ ds = (gcnew ValidateXML_XSD::MonsterList()); + ::System::Xml::Schema::XmlSchemaComplexType^ type = (gcnew ::System::Xml::Schema::XmlSchemaComplexType()); + ::System::Xml::Schema::XmlSchemaSequence^ sequence = (gcnew ::System::Xml::Schema::XmlSchemaSequence()); + ::System::Xml::Schema::XmlSchemaAny^ any = (gcnew ::System::Xml::Schema::XmlSchemaAny()); + any->Namespace = ds->Namespace; + sequence->Items->Add(any); + type->Particle = sequence; + ::System::Xml::Schema::XmlSchema^ dsSchema = ds->GetSchemaSerializable(); + if (xs->Contains(dsSchema->TargetNamespace)) { + ::System::IO::MemoryStream^ s1 = (gcnew ::System::IO::MemoryStream()); + ::System::IO::MemoryStream^ s2 = (gcnew ::System::IO::MemoryStream()); + try { + ::System::Xml::Schema::XmlSchema^ schema = nullptr; + dsSchema->Write(s1); + for ( ::System::Collections::IEnumerator^ schemas = xs->Schemas(dsSchema->TargetNamespace)->GetEnumerator(); schemas->MoveNext(); ) { + schema = (cli::safe_cast<::System::Xml::Schema::XmlSchema^ >(schemas->Current)); + s2->SetLength(0); + schema->Write(s2); + if (s1->Length == s2->Length) { + s1->Position = 0; + s2->Position = 0; + for ( ; ((s1->Position != s1->Length) + && (s1->ReadByte() == s2->ReadByte())); ) { + ; + } + if (s1->Position == s1->Length) { + return type; + } + } + } + } + finally { + if (s1 != nullptr) { + s1->Close(); + } + if (s2 != nullptr) { + s2->Close(); + } + } + } + xs->Add(dsSchema); + return type; + } + + + inline MonsterList::MonsterDataTable::MonsterDataTable() { + this->TableName = L"Monster"; + this->BeginInit(); + this->InitClass(); + this->EndInit(); + } + + inline MonsterList::MonsterDataTable::MonsterDataTable(::System::Data::DataTable^ table) { + this->TableName = table->TableName; + if (table->CaseSensitive != table->DataSet->CaseSensitive) { + this->CaseSensitive = table->CaseSensitive; + } + if (table->Locale->ToString() != table->DataSet->Locale->ToString()) { + this->Locale = table->Locale; + } + if (table->Namespace != table->DataSet->Namespace) { + this->Namespace = table->Namespace; + } + this->Prefix = table->Prefix; + this->MinimumCapacity = table->MinimumCapacity; + } + + inline MonsterList::MonsterDataTable::MonsterDataTable(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context) : + ::System::Data::DataTable(info, context) { + this->InitVars(); + } + + inline ::System::Data::DataColumn^ MonsterList::MonsterDataTable::NameColumn::get() { + return this->columnName; + } + + inline ::System::Data::DataColumn^ MonsterList::MonsterDataTable::Monster_IdColumn::get() { + return this->columnMonster_Id; + } + + inline ::System::Int32 MonsterList::MonsterDataTable::Count::get() { + return this->Rows->Count; + } + + inline ValidateXML_XSD::MonsterList::MonsterRow^ MonsterList::MonsterDataTable::default::get(::System::Int32 index) { + return (cli::safe_cast(this->Rows[index])); + } + + inline ::System::Void MonsterList::MonsterDataTable::AddMonsterRow(ValidateXML_XSD::MonsterList::MonsterRow^ row) { + this->Rows->Add(row); + } + + inline ValidateXML_XSD::MonsterList::MonsterRow^ MonsterList::MonsterDataTable::AddMonsterRow(System::String^ Name) { + ValidateXML_XSD::MonsterList::MonsterRow^ rowMonsterRow = (cli::safe_cast(this->NewRow())); + cli::array< ::System::Object^ >^ columnValuesArray = gcnew cli::array< ::System::Object^ >(2) {Name, nullptr}; + rowMonsterRow->ItemArray = columnValuesArray; + this->Rows->Add(rowMonsterRow); + return rowMonsterRow; + } + + inline ::System::Collections::IEnumerator^ MonsterList::MonsterDataTable::GetEnumerator() { + return this->Rows->GetEnumerator(); + } + + inline ::System::Data::DataTable^ MonsterList::MonsterDataTable::Clone() { + ValidateXML_XSD::MonsterList::MonsterDataTable^ cln = (cli::safe_cast(__super::Clone())); + cln->InitVars(); + return cln; + } + + inline ::System::Data::DataTable^ MonsterList::MonsterDataTable::CreateInstance() { + return (gcnew ValidateXML_XSD::MonsterList::MonsterDataTable()); + } + + inline ::System::Void MonsterList::MonsterDataTable::InitVars() { + this->columnName = __super::Columns[L"Name"]; + this->columnMonster_Id = __super::Columns[L"Monster_Id"]; + } + + inline ::System::Void MonsterList::MonsterDataTable::InitClass() { + this->columnName = (gcnew ::System::Data::DataColumn(L"Name", ::System::String::typeid, nullptr, ::System::Data::MappingType::Element)); + __super::Columns->Add(this->columnName); + this->columnMonster_Id = (gcnew ::System::Data::DataColumn(L"Monster_Id", ::System::Int32::typeid, nullptr, ::System::Data::MappingType::Hidden)); + __super::Columns->Add(this->columnMonster_Id); + this->Constraints->Add((gcnew ::System::Data::UniqueConstraint(L"Constraint1", gcnew cli::array< ::System::Data::DataColumn^ >(1) {this->columnMonster_Id}, + true))); + this->columnName->AllowDBNull = false; + this->columnMonster_Id->AutoIncrement = true; + this->columnMonster_Id->AllowDBNull = false; + this->columnMonster_Id->Unique = true; + } + + inline ValidateXML_XSD::MonsterList::MonsterRow^ MonsterList::MonsterDataTable::NewMonsterRow() { + return (cli::safe_cast(this->NewRow())); + } + + inline ::System::Data::DataRow^ MonsterList::MonsterDataTable::NewRowFromBuilder(::System::Data::DataRowBuilder^ builder) { + return (gcnew ValidateXML_XSD::MonsterList::MonsterRow(builder)); + } + + inline ::System::Type^ MonsterList::MonsterDataTable::GetRowType() { + return ValidateXML_XSD::MonsterList::MonsterRow::typeid; + } + + inline ::System::Void MonsterList::MonsterDataTable::OnRowChanged(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowChanged(e); + { + this->MonsterRowChanged(this, (gcnew ValidateXML_XSD::MonsterList::MonsterRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::MonsterDataTable::OnRowChanging(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowChanging(e); + { + this->MonsterRowChanging(this, (gcnew ValidateXML_XSD::MonsterList::MonsterRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::MonsterDataTable::OnRowDeleted(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowDeleted(e); + { + this->MonsterRowDeleted(this, (gcnew ValidateXML_XSD::MonsterList::MonsterRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::MonsterDataTable::OnRowDeleting(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowDeleting(e); + { + this->MonsterRowDeleting(this, (gcnew ValidateXML_XSD::MonsterList::MonsterRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::MonsterDataTable::RemoveMonsterRow(ValidateXML_XSD::MonsterList::MonsterRow^ row) { + this->Rows->Remove(row); + } + + inline ::System::Xml::Schema::XmlSchemaComplexType^ MonsterList::MonsterDataTable::GetTypedTableSchema(::System::Xml::Schema::XmlSchemaSet^ xs) { + ::System::Xml::Schema::XmlSchemaComplexType^ type = (gcnew ::System::Xml::Schema::XmlSchemaComplexType()); + ::System::Xml::Schema::XmlSchemaSequence^ sequence = (gcnew ::System::Xml::Schema::XmlSchemaSequence()); + ValidateXML_XSD::MonsterList^ ds = (gcnew ValidateXML_XSD::MonsterList()); + ::System::Xml::Schema::XmlSchemaAny^ any1 = (gcnew ::System::Xml::Schema::XmlSchemaAny()); + any1->Namespace = L"http://www.w3.org/2001/XMLSchema"; + any1->MinOccurs = ::System::Decimal(0); + any1->MaxOccurs = ::System::Decimal::MaxValue; + any1->ProcessContents = ::System::Xml::Schema::XmlSchemaContentProcessing::Lax; + sequence->Items->Add(any1); + ::System::Xml::Schema::XmlSchemaAny^ any2 = (gcnew ::System::Xml::Schema::XmlSchemaAny()); + any2->Namespace = L"urn:schemas-microsoft-com:xml-diffgram-v1"; + any2->MinOccurs = ::System::Decimal(1); + any2->ProcessContents = ::System::Xml::Schema::XmlSchemaContentProcessing::Lax; + sequence->Items->Add(any2); + ::System::Xml::Schema::XmlSchemaAttribute^ attribute1 = (gcnew ::System::Xml::Schema::XmlSchemaAttribute()); + attribute1->Name = L"namespace"; + attribute1->FixedValue = ds->Namespace; + type->Attributes->Add(attribute1); + ::System::Xml::Schema::XmlSchemaAttribute^ attribute2 = (gcnew ::System::Xml::Schema::XmlSchemaAttribute()); + attribute2->Name = L"tableTypeName"; + attribute2->FixedValue = L"MonsterDataTable"; + type->Attributes->Add(attribute2); + type->Particle = sequence; + ::System::Xml::Schema::XmlSchema^ dsSchema = ds->GetSchemaSerializable(); + if (xs->Contains(dsSchema->TargetNamespace)) { + ::System::IO::MemoryStream^ s1 = (gcnew ::System::IO::MemoryStream()); + ::System::IO::MemoryStream^ s2 = (gcnew ::System::IO::MemoryStream()); + try { + ::System::Xml::Schema::XmlSchema^ schema = nullptr; + dsSchema->Write(s1); + for ( ::System::Collections::IEnumerator^ schemas = xs->Schemas(dsSchema->TargetNamespace)->GetEnumerator(); schemas->MoveNext(); ) { + schema = (cli::safe_cast<::System::Xml::Schema::XmlSchema^ >(schemas->Current)); + s2->SetLength(0); + schema->Write(s2); + if (s1->Length == s2->Length) { + s1->Position = 0; + s2->Position = 0; + for ( ; ((s1->Position != s1->Length) + && (s1->ReadByte() == s2->ReadByte())); ) { + ; + } + if (s1->Position == s1->Length) { + return type; + } + } + } + } + finally { + if (s1 != nullptr) { + s1->Close(); + } + if (s2 != nullptr) { + s2->Close(); + } + } + } + xs->Add(dsSchema); + return type; + } + + + inline MonsterList::HitDiceDataTable::HitDiceDataTable() { + this->TableName = L"HitDice"; + this->BeginInit(); + this->InitClass(); + this->EndInit(); + } + + inline MonsterList::HitDiceDataTable::HitDiceDataTable(::System::Data::DataTable^ table) { + this->TableName = table->TableName; + if (table->CaseSensitive != table->DataSet->CaseSensitive) { + this->CaseSensitive = table->CaseSensitive; + } + if (table->Locale->ToString() != table->DataSet->Locale->ToString()) { + this->Locale = table->Locale; + } + if (table->Namespace != table->DataSet->Namespace) { + this->Namespace = table->Namespace; + } + this->Prefix = table->Prefix; + this->MinimumCapacity = table->MinimumCapacity; + } + + inline MonsterList::HitDiceDataTable::HitDiceDataTable(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context) : + ::System::Data::DataTable(info, context) { + this->InitVars(); + } + + inline ::System::Data::DataColumn^ MonsterList::HitDiceDataTable::DiceColumn::get() { + return this->columnDice; + } + + inline ::System::Data::DataColumn^ MonsterList::HitDiceDataTable::DefaultColumn::get() { + return this->columnDefault; + } + + inline ::System::Data::DataColumn^ MonsterList::HitDiceDataTable::Monster_IdColumn::get() { + return this->columnMonster_Id; + } + + inline ::System::Int32 MonsterList::HitDiceDataTable::Count::get() { + return this->Rows->Count; + } + + inline ValidateXML_XSD::MonsterList::HitDiceRow^ MonsterList::HitDiceDataTable::default::get(::System::Int32 index) { + return (cli::safe_cast(this->Rows[index])); + } + + inline ::System::Void MonsterList::HitDiceDataTable::AddHitDiceRow(ValidateXML_XSD::MonsterList::HitDiceRow^ row) { + this->Rows->Add(row); + } + + inline ValidateXML_XSD::MonsterList::HitDiceRow^ MonsterList::HitDiceDataTable::AddHitDiceRow(System::String^ Dice, + System::Byte Default, ValidateXML_XSD::MonsterList::MonsterRow^ parentMonsterRowByMonster_HitDice) { + ValidateXML_XSD::MonsterList::HitDiceRow^ rowHitDiceRow = (cli::safe_cast(this->NewRow())); + cli::array< ::System::Object^ >^ columnValuesArray = gcnew cli::array< ::System::Object^ >(3) {Dice, Default, nullptr}; + if (parentMonsterRowByMonster_HitDice != nullptr) { + columnValuesArray[2] = parentMonsterRowByMonster_HitDice[1]; + } + rowHitDiceRow->ItemArray = columnValuesArray; + this->Rows->Add(rowHitDiceRow); + return rowHitDiceRow; + } + + inline ::System::Collections::IEnumerator^ MonsterList::HitDiceDataTable::GetEnumerator() { + return this->Rows->GetEnumerator(); + } + + inline ::System::Data::DataTable^ MonsterList::HitDiceDataTable::Clone() { + ValidateXML_XSD::MonsterList::HitDiceDataTable^ cln = (cli::safe_cast(__super::Clone())); + cln->InitVars(); + return cln; + } + + inline ::System::Data::DataTable^ MonsterList::HitDiceDataTable::CreateInstance() { + return (gcnew ValidateXML_XSD::MonsterList::HitDiceDataTable()); + } + + inline ::System::Void MonsterList::HitDiceDataTable::InitVars() { + this->columnDice = __super::Columns[L"Dice"]; + this->columnDefault = __super::Columns[L"Default"]; + this->columnMonster_Id = __super::Columns[L"Monster_Id"]; + } + + inline ::System::Void MonsterList::HitDiceDataTable::InitClass() { + this->columnDice = (gcnew ::System::Data::DataColumn(L"Dice", ::System::String::typeid, nullptr, ::System::Data::MappingType::Attribute)); + __super::Columns->Add(this->columnDice); + this->columnDefault = (gcnew ::System::Data::DataColumn(L"Default", ::System::Byte::typeid, nullptr, ::System::Data::MappingType::Attribute)); + __super::Columns->Add(this->columnDefault); + this->columnMonster_Id = (gcnew ::System::Data::DataColumn(L"Monster_Id", ::System::Int32::typeid, nullptr, ::System::Data::MappingType::Hidden)); + __super::Columns->Add(this->columnMonster_Id); + this->columnDice->AllowDBNull = false; + this->columnDice->Namespace = L""; + this->columnDefault->AllowDBNull = false; + this->columnDefault->Namespace = L""; + } + + inline ValidateXML_XSD::MonsterList::HitDiceRow^ MonsterList::HitDiceDataTable::NewHitDiceRow() { + return (cli::safe_cast(this->NewRow())); + } + + inline ::System::Data::DataRow^ MonsterList::HitDiceDataTable::NewRowFromBuilder(::System::Data::DataRowBuilder^ builder) { + return (gcnew ValidateXML_XSD::MonsterList::HitDiceRow(builder)); + } + + inline ::System::Type^ MonsterList::HitDiceDataTable::GetRowType() { + return ValidateXML_XSD::MonsterList::HitDiceRow::typeid; + } + + inline ::System::Void MonsterList::HitDiceDataTable::OnRowChanged(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowChanged(e); + { + this->HitDiceRowChanged(this, (gcnew ValidateXML_XSD::MonsterList::HitDiceRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::HitDiceDataTable::OnRowChanging(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowChanging(e); + { + this->HitDiceRowChanging(this, (gcnew ValidateXML_XSD::MonsterList::HitDiceRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::HitDiceDataTable::OnRowDeleted(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowDeleted(e); + { + this->HitDiceRowDeleted(this, (gcnew ValidateXML_XSD::MonsterList::HitDiceRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::HitDiceDataTable::OnRowDeleting(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowDeleting(e); + { + this->HitDiceRowDeleting(this, (gcnew ValidateXML_XSD::MonsterList::HitDiceRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::HitDiceDataTable::RemoveHitDiceRow(ValidateXML_XSD::MonsterList::HitDiceRow^ row) { + this->Rows->Remove(row); + } + + inline ::System::Xml::Schema::XmlSchemaComplexType^ MonsterList::HitDiceDataTable::GetTypedTableSchema(::System::Xml::Schema::XmlSchemaSet^ xs) { + ::System::Xml::Schema::XmlSchemaComplexType^ type = (gcnew ::System::Xml::Schema::XmlSchemaComplexType()); + ::System::Xml::Schema::XmlSchemaSequence^ sequence = (gcnew ::System::Xml::Schema::XmlSchemaSequence()); + ValidateXML_XSD::MonsterList^ ds = (gcnew ValidateXML_XSD::MonsterList()); + ::System::Xml::Schema::XmlSchemaAny^ any1 = (gcnew ::System::Xml::Schema::XmlSchemaAny()); + any1->Namespace = L"http://www.w3.org/2001/XMLSchema"; + any1->MinOccurs = ::System::Decimal(0); + any1->MaxOccurs = ::System::Decimal::MaxValue; + any1->ProcessContents = ::System::Xml::Schema::XmlSchemaContentProcessing::Lax; + sequence->Items->Add(any1); + ::System::Xml::Schema::XmlSchemaAny^ any2 = (gcnew ::System::Xml::Schema::XmlSchemaAny()); + any2->Namespace = L"urn:schemas-microsoft-com:xml-diffgram-v1"; + any2->MinOccurs = ::System::Decimal(1); + any2->ProcessContents = ::System::Xml::Schema::XmlSchemaContentProcessing::Lax; + sequence->Items->Add(any2); + ::System::Xml::Schema::XmlSchemaAttribute^ attribute1 = (gcnew ::System::Xml::Schema::XmlSchemaAttribute()); + attribute1->Name = L"namespace"; + attribute1->FixedValue = ds->Namespace; + type->Attributes->Add(attribute1); + ::System::Xml::Schema::XmlSchemaAttribute^ attribute2 = (gcnew ::System::Xml::Schema::XmlSchemaAttribute()); + attribute2->Name = L"tableTypeName"; + attribute2->FixedValue = L"HitDiceDataTable"; + type->Attributes->Add(attribute2); + type->Particle = sequence; + ::System::Xml::Schema::XmlSchema^ dsSchema = ds->GetSchemaSerializable(); + if (xs->Contains(dsSchema->TargetNamespace)) { + ::System::IO::MemoryStream^ s1 = (gcnew ::System::IO::MemoryStream()); + ::System::IO::MemoryStream^ s2 = (gcnew ::System::IO::MemoryStream()); + try { + ::System::Xml::Schema::XmlSchema^ schema = nullptr; + dsSchema->Write(s1); + for ( ::System::Collections::IEnumerator^ schemas = xs->Schemas(dsSchema->TargetNamespace)->GetEnumerator(); schemas->MoveNext(); ) { + schema = (cli::safe_cast<::System::Xml::Schema::XmlSchema^ >(schemas->Current)); + s2->SetLength(0); + schema->Write(s2); + if (s1->Length == s2->Length) { + s1->Position = 0; + s2->Position = 0; + for ( ; ((s1->Position != s1->Length) + && (s1->ReadByte() == s2->ReadByte())); ) { + ; + } + if (s1->Position == s1->Length) { + return type; + } + } + } + } + finally { + if (s1 != nullptr) { + s1->Close(); + } + if (s2 != nullptr) { + s2->Close(); + } + } + } + xs->Add(dsSchema); + return type; + } + + + inline MonsterList::WeaponDataTable::WeaponDataTable() { + this->TableName = L"Weapon"; + this->BeginInit(); + this->InitClass(); + this->EndInit(); + } + + inline MonsterList::WeaponDataTable::WeaponDataTable(::System::Data::DataTable^ table) { + this->TableName = table->TableName; + if (table->CaseSensitive != table->DataSet->CaseSensitive) { + this->CaseSensitive = table->CaseSensitive; + } + if (table->Locale->ToString() != table->DataSet->Locale->ToString()) { + this->Locale = table->Locale; + } + if (table->Namespace != table->DataSet->Namespace) { + this->Namespace = table->Namespace; + } + this->Prefix = table->Prefix; + this->MinimumCapacity = table->MinimumCapacity; + } + + inline MonsterList::WeaponDataTable::WeaponDataTable(::System::Runtime::Serialization::SerializationInfo^ info, ::System::Runtime::Serialization::StreamingContext context) : + ::System::Data::DataTable(info, context) { + this->InitVars(); + } + + inline ::System::Data::DataColumn^ MonsterList::WeaponDataTable::NumberColumn::get() { + return this->columnNumber; + } + + inline ::System::Data::DataColumn^ MonsterList::WeaponDataTable::DamageColumn::get() { + return this->columnDamage; + } + + inline ::System::Data::DataColumn^ MonsterList::WeaponDataTable::Weapon_textColumn::get() { + return this->columnWeapon_text; + } + + inline ::System::Data::DataColumn^ MonsterList::WeaponDataTable::Monster_IdColumn::get() { + return this->columnMonster_Id; + } + + inline ::System::Int32 MonsterList::WeaponDataTable::Count::get() { + return this->Rows->Count; + } + + inline ValidateXML_XSD::MonsterList::WeaponRow^ MonsterList::WeaponDataTable::default::get(::System::Int32 index) { + return (cli::safe_cast(this->Rows[index])); + } + + inline ::System::Void MonsterList::WeaponDataTable::AddWeaponRow(ValidateXML_XSD::MonsterList::WeaponRow^ row) { + this->Rows->Add(row); + } + + inline ValidateXML_XSD::MonsterList::WeaponRow^ MonsterList::WeaponDataTable::AddWeaponRow(System::Byte Number, System::String^ Damage, + System::String^ Weapon_text, ValidateXML_XSD::MonsterList::MonsterRow^ parentMonsterRowByMonster_Weapon) { + ValidateXML_XSD::MonsterList::WeaponRow^ rowWeaponRow = (cli::safe_cast(this->NewRow())); + cli::array< ::System::Object^ >^ columnValuesArray = gcnew cli::array< ::System::Object^ >(4) {Number, Damage, Weapon_text, + nullptr}; + if (parentMonsterRowByMonster_Weapon != nullptr) { + columnValuesArray[3] = parentMonsterRowByMonster_Weapon[1]; + } + rowWeaponRow->ItemArray = columnValuesArray; + this->Rows->Add(rowWeaponRow); + return rowWeaponRow; + } + + inline ::System::Collections::IEnumerator^ MonsterList::WeaponDataTable::GetEnumerator() { + return this->Rows->GetEnumerator(); + } + + inline ::System::Data::DataTable^ MonsterList::WeaponDataTable::Clone() { + ValidateXML_XSD::MonsterList::WeaponDataTable^ cln = (cli::safe_cast(__super::Clone())); + cln->InitVars(); + return cln; + } + + inline ::System::Data::DataTable^ MonsterList::WeaponDataTable::CreateInstance() { + return (gcnew ValidateXML_XSD::MonsterList::WeaponDataTable()); + } + + inline ::System::Void MonsterList::WeaponDataTable::InitVars() { + this->columnNumber = __super::Columns[L"Number"]; + this->columnDamage = __super::Columns[L"Damage"]; + this->columnWeapon_text = __super::Columns[L"Weapon_text"]; + this->columnMonster_Id = __super::Columns[L"Monster_Id"]; + } + + inline ::System::Void MonsterList::WeaponDataTable::InitClass() { + this->columnNumber = (gcnew ::System::Data::DataColumn(L"Number", ::System::Byte::typeid, nullptr, ::System::Data::MappingType::Attribute)); + __super::Columns->Add(this->columnNumber); + this->columnDamage = (gcnew ::System::Data::DataColumn(L"Damage", ::System::String::typeid, nullptr, ::System::Data::MappingType::Attribute)); + __super::Columns->Add(this->columnDamage); + this->columnWeapon_text = (gcnew ::System::Data::DataColumn(L"Weapon_text", ::System::String::typeid, nullptr, ::System::Data::MappingType::SimpleContent)); + __super::Columns->Add(this->columnWeapon_text); + this->columnMonster_Id = (gcnew ::System::Data::DataColumn(L"Monster_Id", ::System::Int32::typeid, nullptr, ::System::Data::MappingType::Hidden)); + __super::Columns->Add(this->columnMonster_Id); + this->columnNumber->AllowDBNull = false; + this->columnNumber->Namespace = L""; + this->columnDamage->AllowDBNull = false; + this->columnDamage->Namespace = L""; + this->columnWeapon_text->AllowDBNull = false; + } + + inline ValidateXML_XSD::MonsterList::WeaponRow^ MonsterList::WeaponDataTable::NewWeaponRow() { + return (cli::safe_cast(this->NewRow())); + } + + inline ::System::Data::DataRow^ MonsterList::WeaponDataTable::NewRowFromBuilder(::System::Data::DataRowBuilder^ builder) { + return (gcnew ValidateXML_XSD::MonsterList::WeaponRow(builder)); + } + + inline ::System::Type^ MonsterList::WeaponDataTable::GetRowType() { + return ValidateXML_XSD::MonsterList::WeaponRow::typeid; + } + + inline ::System::Void MonsterList::WeaponDataTable::OnRowChanged(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowChanged(e); + { + this->WeaponRowChanged(this, (gcnew ValidateXML_XSD::MonsterList::WeaponRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::WeaponDataTable::OnRowChanging(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowChanging(e); + { + this->WeaponRowChanging(this, (gcnew ValidateXML_XSD::MonsterList::WeaponRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::WeaponDataTable::OnRowDeleted(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowDeleted(e); + { + this->WeaponRowDeleted(this, (gcnew ValidateXML_XSD::MonsterList::WeaponRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::WeaponDataTable::OnRowDeleting(::System::Data::DataRowChangeEventArgs^ e) { + __super::OnRowDeleting(e); + { + this->WeaponRowDeleting(this, (gcnew ValidateXML_XSD::MonsterList::WeaponRowChangeEvent((cli::safe_cast(e->Row)), + e->Action))); + } + } + + inline ::System::Void MonsterList::WeaponDataTable::RemoveWeaponRow(ValidateXML_XSD::MonsterList::WeaponRow^ row) { + this->Rows->Remove(row); + } + + inline ::System::Xml::Schema::XmlSchemaComplexType^ MonsterList::WeaponDataTable::GetTypedTableSchema(::System::Xml::Schema::XmlSchemaSet^ xs) { + ::System::Xml::Schema::XmlSchemaComplexType^ type = (gcnew ::System::Xml::Schema::XmlSchemaComplexType()); + ::System::Xml::Schema::XmlSchemaSequence^ sequence = (gcnew ::System::Xml::Schema::XmlSchemaSequence()); + ValidateXML_XSD::MonsterList^ ds = (gcnew ValidateXML_XSD::MonsterList()); + ::System::Xml::Schema::XmlSchemaAny^ any1 = (gcnew ::System::Xml::Schema::XmlSchemaAny()); + any1->Namespace = L"http://www.w3.org/2001/XMLSchema"; + any1->MinOccurs = ::System::Decimal(0); + any1->MaxOccurs = ::System::Decimal::MaxValue; + any1->ProcessContents = ::System::Xml::Schema::XmlSchemaContentProcessing::Lax; + sequence->Items->Add(any1); + ::System::Xml::Schema::XmlSchemaAny^ any2 = (gcnew ::System::Xml::Schema::XmlSchemaAny()); + any2->Namespace = L"urn:schemas-microsoft-com:xml-diffgram-v1"; + any2->MinOccurs = ::System::Decimal(1); + any2->ProcessContents = ::System::Xml::Schema::XmlSchemaContentProcessing::Lax; + sequence->Items->Add(any2); + ::System::Xml::Schema::XmlSchemaAttribute^ attribute1 = (gcnew ::System::Xml::Schema::XmlSchemaAttribute()); + attribute1->Name = L"namespace"; + attribute1->FixedValue = ds->Namespace; + type->Attributes->Add(attribute1); + ::System::Xml::Schema::XmlSchemaAttribute^ attribute2 = (gcnew ::System::Xml::Schema::XmlSchemaAttribute()); + attribute2->Name = L"tableTypeName"; + attribute2->FixedValue = L"WeaponDataTable"; + type->Attributes->Add(attribute2); + type->Particle = sequence; + ::System::Xml::Schema::XmlSchema^ dsSchema = ds->GetSchemaSerializable(); + if (xs->Contains(dsSchema->TargetNamespace)) { + ::System::IO::MemoryStream^ s1 = (gcnew ::System::IO::MemoryStream()); + ::System::IO::MemoryStream^ s2 = (gcnew ::System::IO::MemoryStream()); + try { + ::System::Xml::Schema::XmlSchema^ schema = nullptr; + dsSchema->Write(s1); + for ( ::System::Collections::IEnumerator^ schemas = xs->Schemas(dsSchema->TargetNamespace)->GetEnumerator(); schemas->MoveNext(); ) { + schema = (cli::safe_cast<::System::Xml::Schema::XmlSchema^ >(schemas->Current)); + s2->SetLength(0); + schema->Write(s2); + if (s1->Length == s2->Length) { + s1->Position = 0; + s2->Position = 0; + for ( ; ((s1->Position != s1->Length) + && (s1->ReadByte() == s2->ReadByte())); ) { + ; + } + if (s1->Position == s1->Length) { + return type; + } + } + } + } + finally { + if (s1 != nullptr) { + s1->Close(); + } + if (s2 != nullptr) { + s2->Close(); + } + } + } + xs->Add(dsSchema); + return type; + } + + + inline MonsterList::MonsterRow::MonsterRow(::System::Data::DataRowBuilder^ rb) : + ::System::Data::DataRow(rb) { + this->tableMonster = (cli::safe_cast(this->Table)); + } + + inline System::String^ MonsterList::MonsterRow::Name::get() { + return (cli::safe_cast<::System::String^ >(this[this->tableMonster->NameColumn])); + } + inline System::Void MonsterList::MonsterRow::Name::set(System::String^ value) { + this[this->tableMonster->NameColumn] = value; + } + + inline System::Int32 MonsterList::MonsterRow::Monster_Id::get() { + return (cli::safe_cast<::System::Int32 >(this[this->tableMonster->Monster_IdColumn])); + } + inline System::Void MonsterList::MonsterRow::Monster_Id::set(System::Int32 value) { + this[this->tableMonster->Monster_IdColumn] = value; + } + + inline cli::array< ValidateXML_XSD::MonsterList::HitDiceRow^ >^ MonsterList::MonsterRow::GetHitDiceRows() { + if (this->Table->ChildRelations[L"Monster_HitDice"] == nullptr) { + return gcnew cli::array< ValidateXML_XSD::MonsterList::HitDiceRow^ >(0); + } + else { + return (cli::safe_cast^ >(__super::GetChildRows(this->Table->ChildRelations[L"Monster_HitDice"]))); + } + } + + inline cli::array< ValidateXML_XSD::MonsterList::WeaponRow^ >^ MonsterList::MonsterRow::GetWeaponRows() { + if (this->Table->ChildRelations[L"Monster_Weapon"] == nullptr) { + return gcnew cli::array< ValidateXML_XSD::MonsterList::WeaponRow^ >(0); + } + else { + return (cli::safe_cast^ >(__super::GetChildRows(this->Table->ChildRelations[L"Monster_Weapon"]))); + } + } + + + inline MonsterList::HitDiceRow::HitDiceRow(::System::Data::DataRowBuilder^ rb) : + ::System::Data::DataRow(rb) { + this->tableHitDice = (cli::safe_cast(this->Table)); + } + + inline System::String^ MonsterList::HitDiceRow::Dice::get() { + return (cli::safe_cast<::System::String^ >(this[this->tableHitDice->DiceColumn])); + } + inline System::Void MonsterList::HitDiceRow::Dice::set(System::String^ value) { + this[this->tableHitDice->DiceColumn] = value; + } + + inline System::Byte MonsterList::HitDiceRow::Default::get() { + return (cli::safe_cast<::System::Byte >(this[this->tableHitDice->DefaultColumn])); + } + inline System::Void MonsterList::HitDiceRow::Default::set(System::Byte value) { + this[this->tableHitDice->DefaultColumn] = value; + } + + inline System::Int32 MonsterList::HitDiceRow::Monster_Id::get() { + try { + return (cli::safe_cast<::System::Int32 >(this[this->tableHitDice->Monster_IdColumn])); + } + catch (::System::InvalidCastException^ e) { + throw (gcnew ::System::Data::StrongTypingException(L"The value for column \'Monster_Id\' in table \'HitDice\' is DBNull.", + e)); + } + } + inline System::Void MonsterList::HitDiceRow::Monster_Id::set(System::Int32 value) { + this[this->tableHitDice->Monster_IdColumn] = value; + } + + inline ValidateXML_XSD::MonsterList::MonsterRow^ MonsterList::HitDiceRow::MonsterRow::get() { + return (cli::safe_cast(this->GetParentRow(this->Table->ParentRelations[L"Monster_HitDice"]))); + } + inline System::Void MonsterList::HitDiceRow::MonsterRow::set(ValidateXML_XSD::MonsterList::MonsterRow^ value) { + this->SetParentRow(value, this->Table->ParentRelations[L"Monster_HitDice"]); + } + + inline ::System::Boolean MonsterList::HitDiceRow::IsMonster_IdNull() { + return this->IsNull(this->tableHitDice->Monster_IdColumn); + } + + inline ::System::Void MonsterList::HitDiceRow::SetMonster_IdNull() { + this[this->tableHitDice->Monster_IdColumn] = ::System::Convert::DBNull; + } + + + inline MonsterList::WeaponRow::WeaponRow(::System::Data::DataRowBuilder^ rb) : + ::System::Data::DataRow(rb) { + this->tableWeapon = (cli::safe_cast(this->Table)); + } + + inline System::Byte MonsterList::WeaponRow::Number::get() { + return (cli::safe_cast<::System::Byte >(this[this->tableWeapon->NumberColumn])); + } + inline System::Void MonsterList::WeaponRow::Number::set(System::Byte value) { + this[this->tableWeapon->NumberColumn] = value; + } + + inline System::String^ MonsterList::WeaponRow::Damage::get() { + return (cli::safe_cast<::System::String^ >(this[this->tableWeapon->DamageColumn])); + } + inline System::Void MonsterList::WeaponRow::Damage::set(System::String^ value) { + this[this->tableWeapon->DamageColumn] = value; + } + + inline System::String^ MonsterList::WeaponRow::Weapon_text::get() { + return (cli::safe_cast<::System::String^ >(this[this->tableWeapon->Weapon_textColumn])); + } + inline System::Void MonsterList::WeaponRow::Weapon_text::set(System::String^ value) { + this[this->tableWeapon->Weapon_textColumn] = value; + } + + inline System::Int32 MonsterList::WeaponRow::Monster_Id::get() { + try { + return (cli::safe_cast<::System::Int32 >(this[this->tableWeapon->Monster_IdColumn])); + } + catch (::System::InvalidCastException^ e) { + throw (gcnew ::System::Data::StrongTypingException(L"The value for column \'Monster_Id\' in table \'Weapon\' is DBNull.", + e)); + } + } + inline System::Void MonsterList::WeaponRow::Monster_Id::set(System::Int32 value) { + this[this->tableWeapon->Monster_IdColumn] = value; + } + + inline ValidateXML_XSD::MonsterList::MonsterRow^ MonsterList::WeaponRow::MonsterRow::get() { + return (cli::safe_cast(this->GetParentRow(this->Table->ParentRelations[L"Monster_Weapon"]))); + } + inline System::Void MonsterList::WeaponRow::MonsterRow::set(ValidateXML_XSD::MonsterList::MonsterRow^ value) { + this->SetParentRow(value, this->Table->ParentRelations[L"Monster_Weapon"]); + } + + inline ::System::Boolean MonsterList::WeaponRow::IsMonster_IdNull() { + return this->IsNull(this->tableWeapon->Monster_IdColumn); + } + + inline ::System::Void MonsterList::WeaponRow::SetMonster_IdNull() { + this[this->tableWeapon->Monster_IdColumn] = ::System::Convert::DBNull; + } + + + inline MonsterList::MonsterRowChangeEvent::MonsterRowChangeEvent(ValidateXML_XSD::MonsterList::MonsterRow^ row, ::System::Data::DataRowAction action) { + this->eventRow = row; + this->eventAction = action; + } + + inline ValidateXML_XSD::MonsterList::MonsterRow^ MonsterList::MonsterRowChangeEvent::Row::get() { + return this->eventRow; + } + + inline ::System::Data::DataRowAction MonsterList::MonsterRowChangeEvent::Action::get() { + return this->eventAction; + } + + + inline MonsterList::HitDiceRowChangeEvent::HitDiceRowChangeEvent(ValidateXML_XSD::MonsterList::HitDiceRow^ row, ::System::Data::DataRowAction action) { + this->eventRow = row; + this->eventAction = action; + } + + inline ValidateXML_XSD::MonsterList::HitDiceRow^ MonsterList::HitDiceRowChangeEvent::Row::get() { + return this->eventRow; + } + + inline ::System::Data::DataRowAction MonsterList::HitDiceRowChangeEvent::Action::get() { + return this->eventAction; + } + + + inline MonsterList::WeaponRowChangeEvent::WeaponRowChangeEvent(ValidateXML_XSD::MonsterList::WeaponRow^ row, ::System::Data::DataRowAction action) { + this->eventRow = row; + this->eventAction = action; + } + + inline ValidateXML_XSD::MonsterList::WeaponRow^ MonsterList::WeaponRowChangeEvent::Row::get() { + return this->eventRow; + } + + inline ::System::Data::DataRowAction MonsterList::WeaponRowChangeEvent::Action::get() { + return this->eventAction; + } +} diff --git a/Chapter14/ValidateXML_XSD/Monsters.xsd b/Chapter14/ValidateXML_XSD/Monsters.xsd new file mode 100644 index 0000000..1571976 --- /dev/null +++ b/Chapter14/ValidateXML_XSD/Monsters.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Chapter14/ValidateXML_XSD/ValidateXML.cpp b/Chapter14/ValidateXML_XSD/ValidateXML.cpp new file mode 100644 index 0000000..b34909c --- /dev/null +++ b/Chapter14/ValidateXML_XSD/ValidateXML.cpp @@ -0,0 +1,50 @@ +#using + +using namespace System; +using namespace System::Xml; +using namespace System::Xml::Schema; + +ref class ValidateXML +{ +public: + ValidateXML(String ^filename) + { + XmlReader ^vreader; + try + { + XmlReaderSettings ^settings = gcnew XmlReaderSettings(); + settings->ValidationType = ValidationType::Schema; + settings->Schemas->Add(nullptr, "Monsters.xsd"); + + vreader = XmlReader::Create(filename, settings); + + while(vreader->Read()) + { + // ... Process nodes just like XmlTextReader() + } + Console::WriteLine("Finished Processing"); + } + catch (Exception ^e) + { + Console::WriteLine(e->Message); + } + finally + { + if (vreader->ReadState != ReadState::Closed) + { + vreader->Close(); + } + } + } +}; + +void main() +{ + Console::WriteLine("Bad Monsters file"); + Console::WriteLine("-----------------"); + gcnew ValidateXML("BadMonsters.xml"); + + Console::WriteLine("\nGood Monsters file"); + Console::WriteLine("------------------"); + gcnew ValidateXML("..\\Monsters.xml"); +} diff --git a/Chapter14/ValidateXML_XSD/ValidateXML_XSD.vcproj b/Chapter14/ValidateXML_XSD/ValidateXML_XSD.vcproj new file mode 100644 index 0000000..64ba2ac --- /dev/null +++ b/Chapter14/ValidateXML_XSD/ValidateXML_XSD.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/WriteXML/Goblin.xml b/Chapter14/WriteXML/Goblin.xml new file mode 100644 index 0000000..07c80ed --- /dev/null +++ b/Chapter14/WriteXML/Goblin.xml @@ -0,0 +1,13 @@ + + + + + Goblin + + Dagger + + \ No newline at end of file diff --git a/Chapter14/WriteXML/WriteXML.cpp b/Chapter14/WriteXML/WriteXML.cpp new file mode 100644 index 0000000..55b8a98 --- /dev/null +++ b/Chapter14/WriteXML/WriteXML.cpp @@ -0,0 +1,60 @@ +#using + +using namespace System; +using namespace System::Xml; + +void main() +{ + XmlWriter ^writer; + try + { + XmlWriterSettings ^settings = gcnew XmlWriterSettings(); + settings->Indent = true; + settings->IndentChars = (" "); + settings->NewLineOnAttributes = true; + + writer = XmlWriter::Create("Goblin.xml", settings); + + writer->WriteStartDocument(); + + writer->WriteStartElement("MonsterList"); + + writer->WriteComment("Program Generated Easy Monster"); + writer->WriteStartElement("Monster"); + + writer->WriteStartElement("Name"); + writer->WriteString("Goblin"); + writer->WriteEndElement(); + + writer->WriteStartElement("HitDice"); + writer->WriteAttributeString("Dice", "1d8"); + writer->WriteAttributeString("Default", "4"); + writer->WriteEndElement(); + + writer->WriteStartElement("Weapon"); + writer->WriteAttributeString("Number", "1"); + writer->WriteAttributeString("Damage", "1d4"); + writer->WriteString("Dagger"); + writer->WriteEndElement(); + + // The folling not needed with WriteEndDocument + // writer->WriteEndElement(); + // writer->WriteEndElement(); + + writer->WriteEndDocument(); + + + writer->Flush(); + } + catch (Exception ^e) + { + Console::WriteLine("XML Writer Aborted -- {0}", e->Message); + } + finally + { + if (writer->WriteState != WriteState::Closed) + { + writer->Close(); + } + } +} diff --git a/Chapter14/WriteXML/WriteXML.vcproj b/Chapter14/WriteXML/WriteXML.vcproj new file mode 100644 index 0000000..3090468 --- /dev/null +++ b/Chapter14/WriteXML/WriteXML.vcproj @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/WriteXMLDOM/New_Monsters.xml b/Chapter14/WriteXMLDOM/New_Monsters.xml new file mode 100644 index 0000000..ca990fe --- /dev/null +++ b/Chapter14/WriteXMLDOM/New_Monsters.xml @@ -0,0 +1,30 @@ + + + + + + Goblin + + Dagger + + + Skeleton + + Claw + + + + Succubus + + Claw + Dagger + + + + Red Dragon + + Bite + Claw + Wing + + \ No newline at end of file diff --git a/Chapter14/WriteXMLDOM/WriteXMLDOM.cpp b/Chapter14/WriteXMLDOM/WriteXMLDOM.cpp new file mode 100644 index 0000000..af27e2f --- /dev/null +++ b/Chapter14/WriteXMLDOM/WriteXMLDOM.cpp @@ -0,0 +1,58 @@ +using namespace System; +using namespace System::Xml; + +XmlElement ^CreateMonster(XmlDocument ^doc) +{ + XmlElement ^skeleton = doc->CreateElement("Monster"); + + // Skeleton + XmlElement ^name = doc->CreateElement("Name"); + name->AppendChild(doc->CreateTextNode("Skeleton")); + skeleton->AppendChild(name); + + // + XmlElement ^hitdice = doc->CreateElement("HitDice"); + XmlAttribute ^att = doc->CreateAttribute("Dice"); + att->Value = "1/2 d12"; + hitdice->Attributes->Append(att); + att = doc->CreateAttribute("Default"); + att->Value = "3"; + hitdice->Attributes->Append(att); + skeleton->AppendChild(hitdice); + + // Claw + XmlElement ^weapon = doc->CreateElement("Weapon"); + att = doc->CreateAttribute("Number"); + att->Value = "2"; + weapon->Attributes->Append(att); + att = doc->CreateAttribute("Damage"); + att->Value = "1d3-1"; + weapon->Attributes->Append(att); + weapon->AppendChild(doc->CreateTextNode("Claw")); + skeleton->AppendChild(weapon); + + return skeleton; +} + +void main() +{ + XmlDocument ^doc = gcnew XmlDocument(); + + try + { + doc->Load("..\\Monsters.xml"); + XmlNode ^root = doc->DocumentElement; + + // Skip comment and goblin + XmlNode ^child = root->FirstChild->NextSibling; + + // Insert new monster + root->InsertAfter(CreateMonster(doc), child); + + doc->Save("New_Monsters.xml"); + } + catch (Exception ^e) + { + Console::WriteLine("Error Occurred: {0}", e->Message ); + } +} diff --git a/Chapter14/WriteXMLDOM/WriteXMLDOM.vcproj b/Chapter14/WriteXMLDOM/WriteXMLDOM.vcproj new file mode 100644 index 0000000..153b7c0 --- /dev/null +++ b/Chapter14/WriteXMLDOM/WriteXMLDOM.vcproj @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter14/XPathEx/XPathEx.cpp b/Chapter14/XPathEx/XPathEx.cpp new file mode 100644 index 0000000..7f925b6 --- /dev/null +++ b/Chapter14/XPathEx/XPathEx.cpp @@ -0,0 +1,93 @@ +using namespace System; +using namespace System::Xml; +using namespace System::Xml::XPath; +using namespace System::Collections; + +void GetMonsters(XPathNavigator ^nav) +{ + XPathNodeIterator ^list = + nav->Select("/MonsterList/Monster/Name"); + + Console::WriteLine("Monsters\n--------"); + while (list->MoveNext()) + { + XPathNavigator ^n = list->Current; + Console::WriteLine(n->Value); + } + +// The required code to do the same as above if no +// XPathNavigator concatenation occurred. +/* + list = nav->Select("/MonsterList/Monster/Name"); + + Console::WriteLine("Monsters\n--------"); + while (list->MoveNext()) + { + XPathNavigator ^n = list->Current; + n->MoveToFirstChild(); + Console::WriteLine(n->Value); + } +*/ +} + +void GetDragonsWeapons(XmlNode ^node) +{ + XmlNodeList ^list = + node->SelectNodes("//Monster[Name='Red Dragon']/Weapon"); + + Console::WriteLine("\nDragon's Weapons\n-------"); + + IEnumerator ^en = list->GetEnumerator(); + while (en->MoveNext()) + { + XmlNode ^n = (XmlNode^)en->Current; + Console::WriteLine(n->FirstChild->Value); + } +} + +void GetGoblinSuccubusHitDice(XPathNavigator ^nav) +{ + XPathNodeIterator ^list = + nav->Select("//Monster[Name='Goblin' or Name='Succubus']/HitDice/@Dice"); + + Console::WriteLine("\nGoblin & Succubus HD\n----------"); + while (list->MoveNext()) + { + XPathNavigator ^n = list->Current; + Console::WriteLine(n->Value); + } +} + +void GetSingleAttackWeapons(XPathNavigator ^nav) +{ + XPathNodeIterator ^list = + nav->Select("//Weapon[@Number <= 1]"); + + Console::WriteLine("\nSingle Attack Weapons\n----------"); + while (list->MoveNext()) + { + XPathNavigator ^n = list->Current; + Console::WriteLine(n->Value); + } +} + +void main() +{ + XmlDocument ^doc = gcnew XmlDocument(); + + try + { + doc->Load("..\\Monsters.xml"); + XPathNavigator ^nav = doc->CreateNavigator(); + nav->MoveToRoot(); + + GetMonsters(nav); + GetDragonsWeapons(doc->DocumentElement); + GetGoblinSuccubusHitDice(nav); + GetSingleAttackWeapons(nav); + } + catch (Exception ^e) + { + Console::WriteLine("Error Occurred: {0}", e->Message ); + } +} diff --git a/Chapter14/XPathEx/XPathEx.vcproj b/Chapter14/XPathEx/XPathEx.vcproj new file mode 100644 index 0000000..93d3027 --- /dev/null +++ b/Chapter14/XPathEx/XPathEx.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter15/Chapter15.sln b/Chapter15/Chapter15.sln new file mode 100644 index 0000000..9f621c9 --- /dev/null +++ b/Chapter15/Chapter15.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple", "Simple\Simple.vcproj", "{31EA0343-FF8E-411F-AE48-9228396F7724}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleCtrl", "SimpleCtrl\SimpleCtrl.vcproj", "{30CE0FF3-A45B-4FB9-B8BE-15F2CA2DAC9C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {31EA0343-FF8E-411F-AE48-9228396F7724}.Debug|Win32.ActiveCfg = Debug|Win32 + {31EA0343-FF8E-411F-AE48-9228396F7724}.Debug|Win32.Build.0 = Debug|Win32 + {31EA0343-FF8E-411F-AE48-9228396F7724}.Release|Win32.ActiveCfg = Release|Win32 + {31EA0343-FF8E-411F-AE48-9228396F7724}.Release|Win32.Build.0 = Release|Win32 + {30CE0FF3-A45B-4FB9-B8BE-15F2CA2DAC9C}.Debug|Win32.ActiveCfg = Debug|Win32 + {30CE0FF3-A45B-4FB9-B8BE-15F2CA2DAC9C}.Debug|Win32.Build.0 = Debug|Win32 + {30CE0FF3-A45B-4FB9-B8BE-15F2CA2DAC9C}.Release|Win32.ActiveCfg = Release|Win32 + {30CE0FF3-A45B-4FB9-B8BE-15F2CA2DAC9C}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter15/Chapter15.suo b/Chapter15/Chapter15.suo new file mode 100644 index 0000000..72b46c4 Binary files /dev/null and b/Chapter15/Chapter15.suo differ diff --git a/Chapter15/Simple/AssemblyInfo.cpp b/Chapter15/Simple/AssemblyInfo.cpp new file mode 100644 index 0000000..89812fd --- /dev/null +++ b/Chapter15/Simple/AssemblyInfo.cpp @@ -0,0 +1,41 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("Simple")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("Simple")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; + diff --git a/Chapter15/Simple/ProjectInstaller.cpp b/Chapter15/Simple/ProjectInstaller.cpp new file mode 100644 index 0000000..b1d5754 --- /dev/null +++ b/Chapter15/Simple/ProjectInstaller.cpp @@ -0,0 +1,2 @@ +#include "StdAfx.h" +#include "ProjectInstaller.h" diff --git a/Chapter15/Simple/ProjectInstaller.h b/Chapter15/Simple/ProjectInstaller.h new file mode 100644 index 0000000..8e652ea --- /dev/null +++ b/Chapter15/Simple/ProjectInstaller.h @@ -0,0 +1,87 @@ +#pragma once + +using namespace System; +using namespace System::ComponentModel; +using namespace System::Collections; +using namespace System::Configuration::Install; + + +namespace Simple { + + [RunInstaller(true)] + + /// + /// Summary for ProjectInstaller + /// + public ref class ProjectInstaller : public System::Configuration::Install::Installer + { + public: + ProjectInstaller(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~ProjectInstaller() + { + if (components) + { + delete components; + } + } + private: System::ServiceProcess::ServiceProcessInstaller^ serviceProcessInstaller1; + protected: + private: System::ServiceProcess::ServiceInstaller^ serviceInstaller1; + private: System::Diagnostics::EventLogInstaller^ eventLogInstaller1; + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->serviceProcessInstaller1 = (gcnew System::ServiceProcess::ServiceProcessInstaller()); + this->serviceInstaller1 = (gcnew System::ServiceProcess::ServiceInstaller()); + this->eventLogInstaller1 = (gcnew System::Diagnostics::EventLogInstaller()); + // + // serviceProcessInstaller1 + // + this->serviceProcessInstaller1->Account = System::ServiceProcess::ServiceAccount::LocalSystem; + this->serviceProcessInstaller1->Password = nullptr; + this->serviceProcessInstaller1->Username = nullptr; + // + // serviceInstaller1 + // + this->serviceInstaller1->ServiceName = L"SimpleWinService"; + // + // eventLogInstaller1 + // + this->eventLogInstaller1->CategoryCount = 0; + this->eventLogInstaller1->CategoryResourceFile = nullptr; + this->eventLogInstaller1->Log = L"Application"; + this->eventLogInstaller1->MessageResourceFile = nullptr; + this->eventLogInstaller1->ParameterResourceFile = nullptr; + this->eventLogInstaller1->Source = L"SimpleWinService"; + // + // ProjectInstaller + // + this->Installers->AddRange(gcnew cli::array< System::Configuration::Install::Installer^ >(3) {this->serviceProcessInstaller1, + this->serviceInstaller1, this->eventLogInstaller1}); + + } +#pragma endregion + }; +} diff --git a/Chapter15/Simple/ProjectInstaller.resx b/Chapter15/Simple/ProjectInstaller.resx new file mode 100644 index 0000000..51eeff7 --- /dev/null +++ b/Chapter15/Simple/ProjectInstaller.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 95 + + + 17, 56 + + + 334, 17 + + + False + + \ No newline at end of file diff --git a/Chapter15/Simple/Simple.vcproj b/Chapter15/Simple/Simple.vcproj new file mode 100644 index 0000000..25e5d7b --- /dev/null +++ b/Chapter15/Simple/Simple.vcproj @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter15/Simple/SimpleWinService.cpp b/Chapter15/Simple/SimpleWinService.cpp new file mode 100644 index 0000000..e9e3088 --- /dev/null +++ b/Chapter15/Simple/SimpleWinService.cpp @@ -0,0 +1,80 @@ +// Simple.cpp : main Windows Service project file. + +#include "stdafx.h" +//#include + +#define COMMANDLINE_DEBUG +#include "SimpleWinService.h" + +using namespace Simple; +using namespace System::Collections; +using namespace System::ServiceProcess; +//using namespace System::Text; +//using namespace System::Security::Policy; +//using namespace System::Reflection; + +void main() +{ +#ifndef COMMANDLINE_DEBUG + + array^ ServicesToRun; + + // More than one user Service may run within the same process. To add + // another service to this process, change the following line to + // create a second service object. For example, + // + // ServicesToRun = gcnew array + // { + // gcnew Service1(), + // gcnew Service2() + // }; + // + ServicesToRun = gcnew array { gcnew SimpleWinService() }; + ServiceBase::Run(ServicesToRun); + +#else + + SimpleWinService ^svc = gcnew SimpleWinService(); + svc->OnStart(nullptr); + Console::WriteLine("Any key stop stop"); + Console::ReadLine(); + svc->OnStop(); + +#endif +} + + +//To install/uninstall the service, type: "Simple.exe -Install [-u]" +//int _tmain(int argc, _TCHAR* argv[]) +//{ +// if (argc >= 2) +// { +// if (argv[1][0] == _T('/')) +// { +// argv[1][0] = _T('-'); +// } +// +// if (_tcsicmp(argv[1], _T("-Install")) == 0) +// { +// array^ myargs = System::Environment::GetCommandLineArgs(); +// array^ args = gcnew array(myargs->Length - 1); +// +// // Set args[0] with the full path to the assembly, +// Assembly^ assem = Assembly::GetExecutingAssembly(); +// args[0] = assem->Location; +// +// Array::Copy(myargs, 2, args, 1, args->Length - 1); +// AppDomain^ dom = AppDomain::CreateDomain(L"execDom"); +// Type^ type = System::Object::typeid; +// String^ path = type->Assembly->Location; +// StringBuilder^ sb = gcnew StringBuilder(path->Substring(0, path->LastIndexOf(L"\\"))); +// sb->Append(L"\\InstallUtil.exe"); +// Evidence^ evidence = gcnew Evidence(); +// dom->ExecuteAssembly(sb->ToString(), evidence, args); +// } +// } +// else +// { +// ServiceBase::Run(gcnew SimpleWinService()); +// } +//} \ No newline at end of file diff --git a/Chapter15/Simple/SimpleWinService.h b/Chapter15/Simple/SimpleWinService.h new file mode 100644 index 0000000..bf8fec1 --- /dev/null +++ b/Chapter15/Simple/SimpleWinService.h @@ -0,0 +1,113 @@ +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::ServiceProcess; +using namespace System::ComponentModel; + +namespace Simple +{ + public ref class SimpleWinService : public ServiceProcess::ServiceBase + { + private: + double interval; + + public: + SimpleWinService() + { + InitializeComponent(); + interval = 15000; // 15 seconds - default + } + + protected: + ~SimpleWinService() + { + if (components) + { + delete components; + } + } + +#ifdef COMMANDLINE_DEBUG + public: +#endif + virtual void OnStart(array^ args) override + { + eventLog1->WriteEntry("SimpleWinService Started"); + + if (args == nullptr || args->Length == 0) + eventLog1->WriteEntry("Empty args"); + else + { + for each (String ^s in args) + { + eventLog1->WriteEntry(s); + } + } + + this->timer = gcnew System::Timers::Timer(interval); + this->timer->Elapsed += + gcnew System::Timers::ElapsedEventHandler(this, + &SimpleWinService::timer_Tick); + this->timer->Start(); + } + + + virtual void OnStop() override + { + this->timer->Stop(); + eventLog1->WriteEntry("SimpleWinService Stopped"); + } + + virtual void OnPause() override + { + this->timer->Stop(); + eventLog1->WriteEntry("SimpleWinService Paused"); + } + + virtual void OnContinue() override + { + eventLog1->WriteEntry("SimpleWinService Continued"); + this->timer->Start(); + } + + private: + System::Diagnostics::EventLog^ eventLog1; + System::Timers::Timer^ timer; + + System::ComponentModel::IContainer^ components; + +#pragma region Windows Form Designer generated code + + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + this->eventLog1 = (gcnew System::Diagnostics::EventLog()); + (cli::safe_cast + (this->eventLog1))->BeginInit(); + // + // eventLog1 + // + this->eventLog1->Log = L"Application"; + this->eventLog1->Source = L"SimpleWinService"; + // + // SimpleWinService + // + this->CanPauseAndContinue = true; + this->ServiceName = L"SimpleWinService"; + (cli::safe_cast + (this->eventLog1))->EndInit(); + } + +#pragma endregion + + private: + void timer_Tick(System::Object^ sender, + System::Timers::ElapsedEventArgs^ e) + { + this->timer->Stop(); + eventLog1->WriteEntry("SimpleWinService Elapsed Event Occurred"); + this->timer->Start(); + } + }; +} diff --git a/Chapter15/Simple/SimpleWinService.resx b/Chapter15/Simple/SimpleWinService.resx new file mode 100644 index 0000000..10aaa1b --- /dev/null +++ b/Chapter15/Simple/SimpleWinService.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + False + + \ No newline at end of file diff --git a/Chapter15/Simple/stdafx.cpp b/Chapter15/Simple/stdafx.cpp new file mode 100644 index 0000000..9e5e4c6 --- /dev/null +++ b/Chapter15/Simple/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// Simple.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" \ No newline at end of file diff --git a/Chapter15/Simple/stdafx.h b/Chapter15/Simple/stdafx.h new file mode 100644 index 0000000..9c7646f --- /dev/null +++ b/Chapter15/Simple/stdafx.h @@ -0,0 +1,11 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +//#include +//#include + +// TODO: reference additional headers your program requires here + diff --git a/Chapter15/SimpleCtrl/AssemblyInfo.cpp b/Chapter15/SimpleCtrl/AssemblyInfo.cpp new file mode 100644 index 0000000..013937e --- /dev/null +++ b/Chapter15/SimpleCtrl/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("SimpleCtrl")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("SimpleCtrl")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter15/SimpleCtrl/Form1.h b/Chapter15/SimpleCtrl/Form1.h new file mode 100644 index 0000000..d69b855 --- /dev/null +++ b/Chapter15/SimpleCtrl/Form1.h @@ -0,0 +1,170 @@ +#pragma once + + +namespace SimpleCtrl +{ + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::ServiceProcess; + + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + } + + protected: + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::ServiceProcess::ServiceController^ serviceController1; + System::Windows::Forms::Button^ bnIntv20; + System::Windows::Forms::Button^ bnIntv15; + System::Windows::Forms::Button^ bnStop; + System::Windows::Forms::Button^ bnStart; + + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + + void InitializeComponent(void) + { + this->serviceController1 = (gcnew System::ServiceProcess::ServiceController()); + this->bnIntv20 = (gcnew System::Windows::Forms::Button()); + this->bnIntv15 = (gcnew System::Windows::Forms::Button()); + this->bnStop = (gcnew System::Windows::Forms::Button()); + this->bnStart = (gcnew System::Windows::Forms::Button()); + this->SuspendLayout(); + // + // serviceController1 + // + this->serviceController1->MachineName = L"Obiwan"; + this->serviceController1->ServiceName = L"SimpleWinService"; + // + // bnIntv20 + // + this->bnIntv20->Location = System::Drawing::Point(150, 44); + this->bnIntv20->Name = L"bnIntv20"; + this->bnIntv20->Size = System::Drawing::Size(75, 23); + this->bnIntv20->TabIndex = 6; + this->bnIntv20->Text = L"Interval 20"; + this->bnIntv20->Click += gcnew System::EventHandler(this, &Form1::bnIntv20_Click); + // + // bnIntv15 + // + this->bnIntv15->Location = System::Drawing::Point(150, 15); + this->bnIntv15->Name = L"bnIntv15"; + this->bnIntv15->Size = System::Drawing::Size(75, 23); + this->bnIntv15->TabIndex = 5; + this->bnIntv15->Text = L"Interval 15"; + this->bnIntv15->Click += gcnew System::EventHandler(this, &Form1::bnIntv15_Click); + // + // bnStop + // + this->bnStop->Location = System::Drawing::Point(32, 44); + this->bnStop->Name = L"bnStop"; + this->bnStop->Size = System::Drawing::Size(75, 23); + this->bnStop->TabIndex = 7; + this->bnStop->Text = L"Stop"; + this->bnStop->Click += gcnew System::EventHandler(this, &Form1::bnStop_Click); + // + // bnStart + // + this->bnStart->Location = System::Drawing::Point(32, 15); + this->bnStart->Name = L"bnStart"; + this->bnStart->Size = System::Drawing::Size(75, 23); + this->bnStart->TabIndex = 4; + this->bnStart->Text = L"Start"; + this->bnStart->Click += gcnew System::EventHandler(this, &Form1::bnStart_Click); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(256, 83); + this->Controls->Add(this->bnIntv20); + this->Controls->Add(this->bnIntv15); + this->Controls->Add(this->bnStop); + this->Controls->Add(this->bnStart); + this->Name = L"Form1"; + this->Text = L"SimpleWinService Controller"; + this->ResumeLayout(false); + + } +#pragma endregion + + private: + System::Void bnStart_Click(System::Object^ sender, System::EventArgs^ e) + { + serviceController1->Refresh(); + + if (serviceController1->Status == ServiceControllerStatus::Stopped) + { + serviceController1->Start(); + MessageBox::Show("SimpleWinService Started"); + } + else + { + MessageBox::Show("SimpleWinService Running"); + } + } + +System::Void bnStop_Click(System::Object^ sender, System::EventArgs^ e) +{ + serviceController1->Refresh(); + + if (serviceController1->Status == ServiceControllerStatus::Running) + { + serviceController1->Stop(); + MessageBox::Show("SimpleWinService Stopped"); + } + else + { + MessageBox::Show("SimpleWinService Not Running"); + } +} + + System::Void bnIntv15_Click(System::Object^ sender, System::EventArgs^ e) + { + serviceController1->Refresh(); + + if (serviceController1->Status == ServiceControllerStatus::Running) + { + serviceController1->ExecuteCommand(150); + MessageBox::Show("SimpleWinService Interval in 15 seconds"); + } + else + { + MessageBox::Show("SimpleWinService Not Running"); + } + } + + System::Void bnIntv20_Click(System::Object^ sender, System::EventArgs^ e) + { + serviceController1->Refresh(); + + if (serviceController1->Status == ServiceControllerStatus::Running) + { + serviceController1->ExecuteCommand(200); + MessageBox::Show("SimpleWinService Interval in 20 seconds"); + } + else + { + MessageBox::Show("SimpleWinService Not Running"); + } + } + }; +} + diff --git a/Chapter15/SimpleCtrl/Form1.resx b/Chapter15/SimpleCtrl/Form1.resx new file mode 100644 index 0000000..38ccc8d --- /dev/null +++ b/Chapter15/SimpleCtrl/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Chapter15/SimpleCtrl/SimpleCtrl.cpp b/Chapter15/SimpleCtrl/SimpleCtrl.cpp new file mode 100644 index 0000000..deb51c9 --- /dev/null +++ b/Chapter15/SimpleCtrl/SimpleCtrl.cpp @@ -0,0 +1,17 @@ +// SimpleCtrl.cpp : main project file. + +#include "Form1.h" + +using namespace SimpleCtrl; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter15/SimpleCtrl/SimpleCtrl.vcproj b/Chapter15/SimpleCtrl/SimpleCtrl.vcproj new file mode 100644 index 0000000..faafc78 --- /dev/null +++ b/Chapter15/SimpleCtrl/SimpleCtrl.vcproj @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter15/SimpleCtrl/SimpleCtrl.vcproj.Obiwan.Stephen.user b/Chapter15/SimpleCtrl/SimpleCtrl.vcproj.Obiwan.Stephen.user new file mode 100644 index 0000000..b72d2d7 --- /dev/null +++ b/Chapter15/SimpleCtrl/SimpleCtrl.vcproj.Obiwan.Stephen.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Chapter16/Chapter16.sln b/Chapter16/Chapter16.sln new file mode 100644 index 0000000..4e235c9 --- /dev/null +++ b/Chapter16/Chapter16.sln @@ -0,0 +1,116 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\HelloWorld.vcproj", "{FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}" +EndProject +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "HelloWorldSite", "http://localhost/HelloWorldSite", "{620AA125-78CD-49DE-B3DC-31081F268189}" + ProjectSection(WebsiteProperties) = preProject + TargetFramework = "3.5" + ProjectReferences = "{FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}|HelloWorld.dll;" + Debug.AspNetCompiler.VirtualPath = "/HelloWorldSite" + Debug.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\HelloWorldSite\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\HelloWorldSite\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/HelloWorldSite" + Release.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\HelloWorldSite\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\HelloWorldSite\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + SlnRelativePath = "..\..\..\..\..\..\inetpub\wwwroot\HelloWorldSite\" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebControl", "WebControl\WebControl.vcproj", "{1FF9F2FD-D829-4E80-8722-1C3585D06616}" +EndProject +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebControlSite", "http://localhost/WebControlSite", "{BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}" + ProjectSection(WebsiteProperties) = preProject + TargetFramework = "3.5" + ProjectReferences = "{1FF9F2FD-D829-4E80-8722-1C3585D06616}|WebControl.dll;" + Debug.AspNetCompiler.VirtualPath = "/WebControlSite" + Debug.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\WebControlSite\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\WebControlSite\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/WebControlSite" + Release.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\WebControlSite\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\WebControlSite\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + SlnRelativePath = "..\..\..\..\..\..\inetpub\wwwroot\WebControlSite\" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|.NET = Debug|.NET + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|.NET = Release|.NET + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Debug|.NET.ActiveCfg = Debug|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Debug|Win32.ActiveCfg = Debug|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Debug|Win32.Build.0 = Debug|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Release|.NET.ActiveCfg = Release|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Release|Any CPU.ActiveCfg = Release|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Release|Mixed Platforms.Build.0 = Release|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Release|Win32.ActiveCfg = Release|Win32 + {FA582C7E-74AD-445C-BC0D-7F5119A3AEDB}.Release|Win32.Build.0 = Release|Win32 + {620AA125-78CD-49DE-B3DC-31081F268189}.Debug|.NET.ActiveCfg = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Debug|.NET.Build.0 = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Debug|Any CPU.ActiveCfg = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Debug|Mixed Platforms.Build.0 = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Debug|Win32.ActiveCfg = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Release|.NET.ActiveCfg = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Release|.NET.Build.0 = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Release|Any CPU.ActiveCfg = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Release|Mixed Platforms.ActiveCfg = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Release|Mixed Platforms.Build.0 = Debug|.NET + {620AA125-78CD-49DE-B3DC-31081F268189}.Release|Win32.ActiveCfg = Debug|.NET + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Debug|.NET.ActiveCfg = Debug|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Debug|Win32.ActiveCfg = Debug|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Debug|Win32.Build.0 = Debug|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Release|.NET.ActiveCfg = Release|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Release|Any CPU.ActiveCfg = Release|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Release|Mixed Platforms.Build.0 = Release|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Release|Win32.ActiveCfg = Release|Win32 + {1FF9F2FD-D829-4E80-8722-1C3585D06616}.Release|Win32.Build.0 = Release|Win32 + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Debug|.NET.ActiveCfg = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Debug|.NET.Build.0 = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Debug|Any CPU.ActiveCfg = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Debug|Mixed Platforms.Build.0 = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Debug|Win32.ActiveCfg = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Release|.NET.ActiveCfg = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Release|.NET.Build.0 = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Release|Any CPU.ActiveCfg = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Release|Mixed Platforms.ActiveCfg = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Release|Mixed Platforms.Build.0 = Debug|.NET + {BF741870-FE04-4BA3-9844-1F3BEFBC4BDF}.Release|Win32.ActiveCfg = Debug|.NET + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter16/Chapter16.suo b/Chapter16/Chapter16.suo new file mode 100644 index 0000000..51c92d5 Binary files /dev/null and b/Chapter16/Chapter16.suo differ diff --git a/Chapter16/HTMLPage1.htm b/Chapter16/HTMLPage1.htm new file mode 100644 index 0000000..b4c9f6e --- /dev/null +++ b/Chapter16/HTMLPage1.htm @@ -0,0 +1,8 @@ + + + Untitled Page + + +Click Here + + diff --git a/Chapter16/HelloWorld/AssemblyInfo.cpp b/Chapter16/HelloWorld/AssemblyInfo.cpp new file mode 100644 index 0000000..ca15baf --- /dev/null +++ b/Chapter16/HelloWorld/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("HelloWorld")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("HelloWorld")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter16/HelloWorld/Global.asax.cpp b/Chapter16/HelloWorld/Global.asax.cpp new file mode 100644 index 0000000..ff30150 --- /dev/null +++ b/Chapter16/HelloWorld/Global.asax.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "Global.asax.h" + +namespace HelloWorld { + + void Global::Application_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_BeginRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_EndRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_End(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_End(Object ^sender, EventArgs ^e) + { + + } +} diff --git a/Chapter16/HelloWorld/Global.asax.h b/Chapter16/HelloWorld/Global.asax.h new file mode 100644 index 0000000..e750db4 --- /dev/null +++ b/Chapter16/HelloWorld/Global.asax.h @@ -0,0 +1,22 @@ +using namespace System; +using namespace System::Web; +using namespace System::Collections; +using namespace System::ComponentModel; +using namespace System::Web::SessionState; + +namespace HelloWorld { + + /// + /// Summary description for Global. + /// + public ref class Global : public System::Web::HttpApplication + { + protected: + void Application_Start(Object ^sender, EventArgs ^e); + void Session_Start(Object ^sender, EventArgs ^e); + void Application_BeginRequest(Object ^sender, EventArgs ^e); + void Application_EndRequest(Object ^sender, EventArgs ^e); + void Session_End(Object ^sender, EventArgs ^e); + void Application_End(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/HelloWorld/HelloWorld.aspx.cpp b/Chapter16/HelloWorld/HelloWorld.aspx.cpp new file mode 100644 index 0000000..f15b2ba --- /dev/null +++ b/Chapter16/HelloWorld/HelloWorld.aspx.cpp @@ -0,0 +1,17 @@ +// HelloWorld.aspx.cpp : main project file. + +#include "stdafx.h" +#include "HelloWorld.aspx.h" + +namespace HelloWorld { + + void _Default::Page_Load(Object ^sender, EventArgs ^e) + { + // + // TODO: Add the implementation of your Web Page here + // + Response->Write (L"

Hello World

"); + } + +} + diff --git a/Chapter16/HelloWorld/HelloWorld.aspx.h b/Chapter16/HelloWorld/HelloWorld.aspx.h new file mode 100644 index 0000000..a48ff10 --- /dev/null +++ b/Chapter16/HelloWorld/HelloWorld.aspx.h @@ -0,0 +1,24 @@ +// HelloWorld.aspx.h + +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::Configuration; +using namespace System::Data; +using namespace System::Web; +using namespace System::Web::Security; +using namespace System::Web::UI; +using namespace System::Web::UI::HtmlControls; +using namespace System::Web::UI::WebControls; +using namespace System::Web::UI::WebControls::WebParts; +using namespace System::Xml; + +namespace HelloWorld { + + public ref class _Default : public System::Web::UI::Page + { + protected: + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/HelloWorld/HelloWorld.vcproj b/Chapter16/HelloWorld/HelloWorld.vcproj new file mode 100644 index 0000000..f19e651 --- /dev/null +++ b/Chapter16/HelloWorld/HelloWorld.vcproj @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter16/HelloWorld/ReadMe.txt b/Chapter16/HelloWorld/ReadMe.txt new file mode 100644 index 0000000..813d40a --- /dev/null +++ b/Chapter16/HelloWorld/ReadMe.txt @@ -0,0 +1,35 @@ +======================================================================== + WEB PAGE : HelloWorld Project Overview +======================================================================== + +AppWizard has created this HelloWorld project for you. + +This file contains a summary of what you will find in each of the files that +make up your HelloWorld application. + +HelloWorld.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +HelloWorldPage.cpp + This is the main web source file. + +HelloWorldPage.h + This header file contains the declarations of the Web Service. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + + +Web.Config + This file allows you to override the default configuration settings for your service. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter16/HelloWorld/stdafx.cpp b/Chapter16/HelloWorld/stdafx.cpp new file mode 100644 index 0000000..4b433dc --- /dev/null +++ b/Chapter16/HelloWorld/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// HelloWorld.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/Chapter16/HelloWorld/stdafx.h b/Chapter16/HelloWorld/stdafx.h new file mode 100644 index 0000000..e16d986 --- /dev/null +++ b/Chapter16/HelloWorld/stdafx.h @@ -0,0 +1,7 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + diff --git a/Chapter16/WebControl/AssemblyInfo.cpp b/Chapter16/WebControl/AssemblyInfo.cpp new file mode 100644 index 0000000..896f51e --- /dev/null +++ b/Chapter16/WebControl/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("WebControl")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("WebControl")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter16/WebControl/Blank1.aspx.cpp b/Chapter16/WebControl/Blank1.aspx.cpp new file mode 100644 index 0000000..9285ffa --- /dev/null +++ b/Chapter16/WebControl/Blank1.aspx.cpp @@ -0,0 +1,14 @@ +// Blank1.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "Blank1.aspx.h" + + +namespace WebControl { + + void Blank1::Page_Load(Object ^sender, EventArgs ^e) + { + } + +} + diff --git a/Chapter16/WebControl/Blank1.aspx.h b/Chapter16/WebControl/Blank1.aspx.h new file mode 100644 index 0000000..b689a71 --- /dev/null +++ b/Chapter16/WebControl/Blank1.aspx.h @@ -0,0 +1,24 @@ +// Blank1.aspx.h + +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::Configuration; +using namespace System::Data; +using namespace System::Web; +using namespace System::Web::Security; +using namespace System::Web::UI; +using namespace System::Web::UI::HtmlControls; +using namespace System::Web::UI::WebControls; +using namespace System::Web::UI::WebControls::WebParts; +using namespace System::Xml; + +namespace WebControl { + + public ref class Blank1 : public System::Web::UI::Page + { + protected: + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/Blank2.aspx.cpp b/Chapter16/WebControl/Blank2.aspx.cpp new file mode 100644 index 0000000..8bd084c --- /dev/null +++ b/Chapter16/WebControl/Blank2.aspx.cpp @@ -0,0 +1,13 @@ +// Blank2.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "Blank2.aspx.h" + +namespace WebControl +{ + void Blank2::Page_Load(Object ^sender, EventArgs ^e) + { + myPageHeader1->Level = "Home"; + } +} + diff --git a/Chapter16/WebControl/Blank2.aspx.h b/Chapter16/WebControl/Blank2.aspx.h new file mode 100644 index 0000000..29c3231 --- /dev/null +++ b/Chapter16/WebControl/Blank2.aspx.h @@ -0,0 +1,19 @@ +// Blank2.aspx.h + +#pragma once + +#include "myPageHeader.ascx.h" + +using namespace System; +using namespace System::Web::UI; + +namespace WebControl { + + public ref class Blank2 : public System::Web::UI::Page + { + protected: + ::WebControl::uc::myPageHeader^ myPageHeader1; + + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/Buttons.aspx.cpp b/Chapter16/WebControl/Buttons.aspx.cpp new file mode 100644 index 0000000..35fa699 --- /dev/null +++ b/Chapter16/WebControl/Buttons.aspx.cpp @@ -0,0 +1,48 @@ +// Buttons.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "Buttons.aspx.h" + +namespace WebControl +{ + void Buttons::RB_CheckedChanged(Object ^sender, EventArgs ^e) + { + if (rbColorful->Checked) + Response->Redirect("Colorful.aspx"); + else if (rbHappy->Checked) + Response->Redirect("Happy.aspx"); + else if (rbChange->Checked) + Response->Redirect("ChangeColor.aspx"); + } + + void Buttons::bnCheckBoxes_Click(Object ^sender, EventArgs ^e) + { + if (cbColorful->Checked) + Response->Redirect("Colorful.aspx"); + else if (cbHappy->Checked) + Response->Redirect("Happy.aspx"); + else if (cbChange->Checked) + Response->Redirect("ChangeColor.aspx"); + } + + void Buttons::bnColorful_Click(Object ^sender, EventArgs ^e) + { + Response->Redirect("Colorful.aspx"); + } + + void Buttons::ibnHappy_Click(Object ^sender, ImageClickEventArgs ^e) + { + Response->Redirect("Happy.aspx"); + } + + void Buttons::bnChange_Click(Object ^sender, EventArgs ^e) + { + Response->Redirect("ChangeColor.aspx"); + } + + void Buttons::lbnChange_Click(Object ^sender, EventArgs ^e) + { + Response->Redirect("ChangeColor.aspx"); + } +} + diff --git a/Chapter16/WebControl/Buttons.aspx.h b/Chapter16/WebControl/Buttons.aspx.h new file mode 100644 index 0000000..d36433c --- /dev/null +++ b/Chapter16/WebControl/Buttons.aspx.h @@ -0,0 +1,40 @@ +// Buttons.aspx.h + +#pragma once + +using namespace System; +using namespace System::Web::UI; +using namespace System::Web::UI::WebControls; + +namespace WebControl +{ + public ref class Buttons : public System::Web::UI::Page + { + protected: + // Row 1 Column 1 -- Controls + RadioButton^ rbColorful; + RadioButton^ rbHappy; + RadioButton^ rbChange; + + // Row 1 Column 2 -- Controls + CheckBox^ cbColorful; + CheckBox^ cbHappy; + CheckBox^ cbChange; + Button^ bnCheckBoxes; + + // Row 2 Column 1 -- Controls + Button^ bnColorful; + ImageButton^ ibnHappy; + Button^ bnChange; + + // Row 2 Column 2 -- Control + LinkButton^ lbnChange; + + void RB_CheckedChanged(Object ^sender, EventArgs ^e); + void bnCheckBoxes_Click(Object ^sender, EventArgs ^e); + void bnColorful_Click(Object ^sender, EventArgs ^e); + void ibnHappy_Click(Object ^sender, ImageClickEventArgs ^e); + void bnChange_Click(Object ^sender, EventArgs ^e); + void lbnChange_Click(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/ChangeColor.aspx.cpp b/Chapter16/WebControl/ChangeColor.aspx.cpp new file mode 100644 index 0000000..c727ba9 --- /dev/null +++ b/Chapter16/WebControl/ChangeColor.aspx.cpp @@ -0,0 +1,22 @@ +// ChangeColor.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "ChangeColor.aspx.h" + + +namespace WebControl +{ + void ChangeColor::tbChanger_TextChanged(Object ^sender, EventArgs ^e) + { + array^ AComma = {','}; + + // parse out the colors + array^ incolors = tbChanger->Text->Split(AComma); + + // change the foreground and background + tbChanger->ForeColor = Color::FromName(incolors[0]); + if (incolors->Length > 1) + tbChanger->BackColor = Color::FromName(incolors[1]); + } +} + diff --git a/Chapter16/WebControl/ChangeColor.aspx.h b/Chapter16/WebControl/ChangeColor.aspx.h new file mode 100644 index 0000000..e01b0ea --- /dev/null +++ b/Chapter16/WebControl/ChangeColor.aspx.h @@ -0,0 +1,17 @@ +// ChangeColor.aspx.h + +#pragma once + +using namespace System; +using namespace System::Drawing; +using namespace System::Web::UI::WebControls; + +namespace WebControl +{ + public ref class ChangeColor : public System::Web::UI::Page + { + protected: + TextBox^ tbChanger; + void tbChanger_TextChanged(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/Colorful.aspx.cpp b/Chapter16/WebControl/Colorful.aspx.cpp new file mode 100644 index 0000000..581fcb7 --- /dev/null +++ b/Chapter16/WebControl/Colorful.aspx.cpp @@ -0,0 +1,21 @@ +// Colorful.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "Colorful.aspx.h" + +namespace WebControl +{ + void Colorful::Page_Load(Object ^sender, EventArgs ^e) + { + Random^ r = gcnew Random(); + Label->ForeColor = + Color::FromArgb(r->Next(255),r->Next(255),r->Next(255)); + Label->BackColor = + Color::FromArgb(r->Next(255),r->Next(255),r->Next(255)); + Label->Text = + "Let's randomly change colors until you get sick " + "of watching it"; + Label->Font->Italic = true; + } +} + diff --git a/Chapter16/WebControl/Colorful.aspx.h b/Chapter16/WebControl/Colorful.aspx.h new file mode 100644 index 0000000..4b3d924 --- /dev/null +++ b/Chapter16/WebControl/Colorful.aspx.h @@ -0,0 +1,17 @@ +// Colorful.aspx.h + +#pragma once + +using namespace System; +using namespace System::Drawing; +using namespace System::Web::UI::WebControls; + +namespace WebControl +{ + public ref class Colorful : public System::Web::UI::Page + { + protected: + Label^ Label; + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/DomainPage.aspx.cpp b/Chapter16/WebControl/DomainPage.aspx.cpp new file mode 100644 index 0000000..708b021 --- /dev/null +++ b/Chapter16/WebControl/DomainPage.aspx.cpp @@ -0,0 +1,13 @@ +// DomainPage.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "DomainPage.aspx.h" + +namespace WebControl +{ + void DomainPage::Page_Load(Object ^sender, EventArgs ^e) + { + ((::WebControl::myMaster^)this->Master)->PageLevel = "Domain"; + } +} + diff --git a/Chapter16/WebControl/DomainPage.aspx.h b/Chapter16/WebControl/DomainPage.aspx.h new file mode 100644 index 0000000..9a20842 --- /dev/null +++ b/Chapter16/WebControl/DomainPage.aspx.h @@ -0,0 +1,19 @@ +// DomainPage.aspx.h + +#pragma once + +using namespace System; +using namespace System::Web; +using namespace System::Web::UI; +using namespace System::Web::UI::WebControls; + +#include "myMaster.master.h" + +namespace WebControl +{ + public ref class DomainPage : public System::Web::UI::Page + { + protected: + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/Global.asax.cpp b/Chapter16/WebControl/Global.asax.cpp new file mode 100644 index 0000000..90554ac --- /dev/null +++ b/Chapter16/WebControl/Global.asax.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "Global.asax.h" + +namespace WebControl { + + void Global::Application_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_BeginRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_EndRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_End(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_End(Object ^sender, EventArgs ^e) + { + + } +} diff --git a/Chapter16/WebControl/Global.asax.h b/Chapter16/WebControl/Global.asax.h new file mode 100644 index 0000000..bb612b5 --- /dev/null +++ b/Chapter16/WebControl/Global.asax.h @@ -0,0 +1,24 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Web; +using namespace System::Collections; +using namespace System::ComponentModel; +using namespace System::Web::SessionState; + +namespace WebControl { + + /// + /// Summary description for Global. + /// + public ref class Global : public System::Web::HttpApplication + { + protected: + void Application_Start(Object ^sender, EventArgs ^e); + void Session_Start(Object ^sender, EventArgs ^e); + void Application_BeginRequest(Object ^sender, EventArgs ^e); + void Application_EndRequest(Object ^sender, EventArgs ^e); + void Session_End(Object ^sender, EventArgs ^e); + void Application_End(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/Happy.aspx.cpp b/Chapter16/WebControl/Happy.aspx.cpp new file mode 100644 index 0000000..7c146d5 --- /dev/null +++ b/Chapter16/WebControl/Happy.aspx.cpp @@ -0,0 +1,38 @@ +// Happy.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "Happy.aspx.h" + +namespace WebControl +{ + void Happy::Page_Load(Object ^sender, EventArgs ^e) + { + if (!IsPostBack) + { + // Create a session object the first time Web Form is loaded + Session["cSize"] = 32; + } + + // Copy the session object to local variable for easy access + int cSize = (int)Session["cSize"]; + + if (cSize % 2 == 1) + { + cSize -= 10; + if (cSize < 32) + cSize = 32; + } + else + { + cSize += 10; + if (cSize > 400) + cSize -= 1; + } + imgHappy->Width = Unit::Pixel(cSize); + imgHappy->Height = Unit::Pixel(cSize); + + // Update the session object for next post back + Session["cSize"] = cSize; + } +} + diff --git a/Chapter16/WebControl/Happy.aspx.h b/Chapter16/WebControl/Happy.aspx.h new file mode 100644 index 0000000..8ee47ce --- /dev/null +++ b/Chapter16/WebControl/Happy.aspx.h @@ -0,0 +1,16 @@ +// Happy.aspx.h + +#pragma once + +using namespace System; +using namespace System::Web::UI::WebControls; + +namespace WebControl +{ + public ref class Happy : public System::Web::UI::Page + { + protected: + Image^ imgHappy; + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/HomePage.aspx.cpp b/Chapter16/WebControl/HomePage.aspx.cpp new file mode 100644 index 0000000..5dd51af --- /dev/null +++ b/Chapter16/WebControl/HomePage.aspx.cpp @@ -0,0 +1,13 @@ +// HomePage.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "HomePage.aspx.h" + +namespace WebControl +{ + void HomePage::Page_Load(Object ^sender, EventArgs ^e) + { + ((::WebControl::myMaster^)this->Master)->PageLevel = "Home"; + } +} + diff --git a/Chapter16/WebControl/HomePage.aspx.h b/Chapter16/WebControl/HomePage.aspx.h new file mode 100644 index 0000000..5721e0b --- /dev/null +++ b/Chapter16/WebControl/HomePage.aspx.h @@ -0,0 +1,19 @@ +// HomePage.aspx.h + +#pragma once + +using namespace System; +using namespace System::Web; +using namespace System::Web::UI; +using namespace System::Web::UI::WebControls; + +#include "myMaster.master.h" + +namespace WebControl +{ + public ref class HomePage : public System::Web::UI::Page + { + protected: + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/Lists.aspx.cpp b/Chapter16/WebControl/Lists.aspx.cpp new file mode 100644 index 0000000..1158d7d --- /dev/null +++ b/Chapter16/WebControl/Lists.aspx.cpp @@ -0,0 +1,78 @@ +// Lists.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "Lists.aspx.h" + + +namespace WebControl +{ + void Lists::Page_Load(Object ^sender, EventArgs ^e) + { + OleDbConnection^ con; + + try + { + +// +// +// + + con = gcnew OleDbConnection( + ConfigurationManager::ConnectionStrings["OLEDBConnection"]->ConnectionString); + con->Open(); + + if (!IsPostBack) + { + // Set up database table list box + array^ restrict = {nullptr, nullptr, nullptr, "TABLE"}; + DataTable^ dt = + con->GetOleDbSchemaTable(OleDbSchemaGuid::Tables, + restrict); + + selListBox->DataSource = dt->DefaultView; + selListBox->DataTextField = "TABLE_NAME"; + selListBox->DataBind(); + + // Set up Background color list box + colorList->Items->Add("Yellow"); + colorList->Items->Add(gcnew ListItem("Green","LightGreen")); + colorList->Items->Add("Red"); + } + else + { + // Build data grid from selected database table + String^ selectedTable = selListBox->SelectedItem->Value; + String^ Cmd = + String::Concat("SELECT * FROM ", selectedTable); + OleDbDataAdapter^ dAdapt = gcnew OleDbDataAdapter(Cmd, con); + DataSet^ dSet = gcnew DataSet(); + dAdapt->Fill(dSet); + + dataGrid->DataSource = dSet; + dataGrid->DataBind(); +// dataGrid->BackColor = +// Color::FromName(colorList->SelectedItem->Value); + dataGrid->BackColor = + Color::FromName(colorList->Items[colorList->SelectedIndex]->Value); + + // enable background color list box + colorList->Enabled = true; + } + } + catch(Exception^ exp) + { + // Do Exception handling + throw exp; + } + finally + { + // Close down the database + con->Close(); + } + } +} + diff --git a/Chapter16/WebControl/Lists.aspx.h b/Chapter16/WebControl/Lists.aspx.h new file mode 100644 index 0000000..68947e4 --- /dev/null +++ b/Chapter16/WebControl/Lists.aspx.h @@ -0,0 +1,25 @@ +// Lists.aspx.h + +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::Configuration; +using namespace System::Data; +using namespace System::Data::OleDb; +using namespace System::Drawing; +using namespace System::Web; +using namespace System::Web::UI::WebControls; + +namespace WebControl { + + public ref class Lists : public System::Web::UI::Page + { + protected: + ListBox^ selListBox; + DataGrid^ dataGrid; + DropDownList^ colorList; + + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/ManyHeadings.aspx.cpp b/Chapter16/WebControl/ManyHeadings.aspx.cpp new file mode 100644 index 0000000..7ef00af --- /dev/null +++ b/Chapter16/WebControl/ManyHeadings.aspx.cpp @@ -0,0 +1,21 @@ +// ManyHeadings.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "ManyHeadings.aspx.h" + +namespace WebControl +{ + void ManyHeadings::Page_Load(Object ^sender, EventArgs ^e) + { + myPageHeader^ header; + + header = (myPageHeader^)(LoadControl("myPageHeader.ascx")); + header->Level = "Home"; + cell00->Controls->Add(header); + + header = (myPageHeader^)(LoadControl("myPageHeader.ascx")); + header->Level = "Domain"; + cell01->Controls->Add(header); + } +} + diff --git a/Chapter16/WebControl/ManyHeadings.aspx.h b/Chapter16/WebControl/ManyHeadings.aspx.h new file mode 100644 index 0000000..df15ac6 --- /dev/null +++ b/Chapter16/WebControl/ManyHeadings.aspx.h @@ -0,0 +1,24 @@ +// ManyHeadings.aspx.h + +#pragma once + +#include "myPageHeader.ascx.h" + +using namespace System; +using namespace System::Web; +using namespace System::Web::UI; +using namespace System::Web::UI::WebControls; + +using namespace ::WebControl::uc; + +namespace WebControl { + + public ref class ManyHeadings : public System::Web::UI::Page + { + protected: + TableCell^ cell00; + TableCell^ cell01; + + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/ReadMe.txt b/Chapter16/WebControl/ReadMe.txt new file mode 100644 index 0000000..3ce8565 --- /dev/null +++ b/Chapter16/WebControl/ReadMe.txt @@ -0,0 +1,35 @@ +======================================================================== + WEB PAGE : WebControl Project Overview +======================================================================== + +AppWizard has created this WebControl project for you. + +This file contains a summary of what you will find in each of the files that +make up your WebControl application. + +WebControl.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +WebControlPage.cpp + This is the main web source file. + +WebControlPage.h + This header file contains the declarations of the Web Service. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + + +Web.Config + This file allows you to override the default configuration settings for your service. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter16/WebControl/Tables.aspx.cpp b/Chapter16/WebControl/Tables.aspx.cpp new file mode 100644 index 0000000..a34e5f0 --- /dev/null +++ b/Chapter16/WebControl/Tables.aspx.cpp @@ -0,0 +1,82 @@ +// Tables.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "Tables.aspx.h" + +namespace WebControl +{ + void Tables::Page_Load(Object ^sender, EventArgs ^e) + { + LiteralControl^ lit; + TableCell^ cell; + + array^ files = Directory::GetFiles(Server->MapPath(".")); + + for (int i = 0; i < files->Length; i++) + { + FileInfo^ finfo = gcnew FileInfo(files[i]); + + if (!finfo->Exists) + continue; + + // Create a TableRow (Step 2) + TableRow^ row = gcnew TableRow(); + + // Create a TableCell (Step 3) + cell = gcnew TableCell(); + + // Create a Web Form control (Step 4) + // Creating a hyperlink control + HyperLink^ link = gcnew HyperLink(); + link->Text = finfo->Name; + link->NavigateUrl = finfo->Name; + + // Place the control in the TableCell (Step 5) + cell->Controls->Add(link); + + // Place the TableCell in the TableRow (Step 6) + row->Cells->Add(cell); + + // Repeat steps 3 through 6 (Step 7) + // Creating a literal control + lit = gcnew LiteralControl( + String::Concat(finfo->CreationTime.ToShortDateString(), + " ", + finfo->CreationTime.ToLongTimeString())); + cell = gcnew TableCell(); + cell->Controls->Add(lit); + row->Cells->Add(cell); + + lit = gcnew LiteralControl(finfo->Length.ToString()); + cell = gcnew TableCell(); + cell->Controls->Add(lit); + row->Cells->Add(cell); + + lit = gcnew LiteralControl(finfo->Attributes.ToString()); + cell = gcnew TableCell(); + cell->Controls->Add(lit); + row->Cells->Add(cell); + + // Creating an image button control + ImageButton^ ibn = gcnew ImageButton(); + ibn->Command += gcnew CommandEventHandler(this, &Tables::btnHappy); + ibn->ImageUrl = "Images/Happy.gif"; + ibn->CommandArgument = finfo->Name; + cell = gcnew TableCell(); + cell->HorizontalAlign = HorizontalAlign::Center; + cell->Controls->Add(ibn); + row->Cells->Add(cell); + + // Place Row in Table (Step 8) + FilesTable->Rows->Add(row); + + // Repeat steps 2 through 8 (Step 9) + } + } + + void Tables::btnHappy(Object ^sender, CommandEventArgs ^e) + { + PageTitle->Text = "The file " + e->CommandArgument + " is now happy"; + } +} + diff --git a/Chapter16/WebControl/Tables.aspx.h b/Chapter16/WebControl/Tables.aspx.h new file mode 100644 index 0000000..f78c01f --- /dev/null +++ b/Chapter16/WebControl/Tables.aspx.h @@ -0,0 +1,22 @@ +// Tables.aspx.h + +#pragma once + +using namespace System; +using namespace System::IO; +using namespace System::Web::UI; +using namespace System::Web::UI::WebControls; +using namespace System::Web::UI::HtmlControls; + +namespace WebControl { + + public ref class Tables : public System::Web::UI::Page + { + protected: + Table^ FilesTable; + HtmlTitle^ PageTitle; + + void Page_Load(Object ^sender, EventArgs ^e); + void btnHappy(Object ^sender, CommandEventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/WebControl.aspx.cpp b/Chapter16/WebControl/WebControl.aspx.cpp new file mode 100644 index 0000000..7491887 --- /dev/null +++ b/Chapter16/WebControl/WebControl.aspx.cpp @@ -0,0 +1,17 @@ +// WebControl.aspx.cpp : main project file. + +#include "stdafx.h" +#include "WebControl.aspx.h" + +namespace WebControl { + + void _Default::Page_Load(Object ^sender, EventArgs ^e) + { + // + // TODO: Add the implementation of your Web Page here + // + Response->Write (L"

Hello World

"); + } + +} + diff --git a/Chapter16/WebControl/WebControl.aspx.h b/Chapter16/WebControl/WebControl.aspx.h new file mode 100644 index 0000000..88bd63e --- /dev/null +++ b/Chapter16/WebControl/WebControl.aspx.h @@ -0,0 +1,24 @@ +// WebControl.aspx.h + +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::Configuration; +using namespace System::Data; +using namespace System::Web; +using namespace System::Web::Security; +using namespace System::Web::UI; +using namespace System::Web::UI::HtmlControls; +using namespace System::Web::UI::WebControls; +using namespace System::Web::UI::WebControls::WebParts; +using namespace System::Xml; + +namespace WebControl { + + public ref class _Default : public System::Web::UI::Page + { + protected: + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/WebControl.vcproj b/Chapter16/WebControl/WebControl.vcproj new file mode 100644 index 0000000..cde3a08 --- /dev/null +++ b/Chapter16/WebControl/WebControl.vcproj @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter16/WebControl/myMaster.master.cpp b/Chapter16/WebControl/myMaster.master.cpp new file mode 100644 index 0000000..6503351 --- /dev/null +++ b/Chapter16/WebControl/myMaster.master.cpp @@ -0,0 +1,17 @@ +// myMaster.master.cpp : main project file. + +#include "StdAfx.h" +#include "myMaster.master.h" + +namespace WebControl +{ + void myMaster::PageLevel::set(String^ value) + { + myPageHeader1->Level = value; + } + + void myMaster::Page_Load(Object ^sender, EventArgs ^e) + { + } +} + diff --git a/Chapter16/WebControl/myMaster.master.h b/Chapter16/WebControl/myMaster.master.h new file mode 100644 index 0000000..38c676f --- /dev/null +++ b/Chapter16/WebControl/myMaster.master.h @@ -0,0 +1,25 @@ +// myMaster.master.h + +#pragma once + +#include "myPageHeader.ascx.h" + +using namespace System; +using namespace System::Web::UI; + +namespace WebControl +{ + public ref class myMaster : public System::Web::UI::MasterPage + { + public: + property String^ PageLevel + { + void set(String^ value); + } + + protected: + ::WebControl::uc::myPageHeader^ myPageHeader1; + + void Page_Load(Object ^sender, EventArgs ^e); + }; +} diff --git a/Chapter16/WebControl/myPageHeader.ascx.cpp b/Chapter16/WebControl/myPageHeader.ascx.cpp new file mode 100644 index 0000000..777e896 --- /dev/null +++ b/Chapter16/WebControl/myPageHeader.ascx.cpp @@ -0,0 +1,18 @@ +// myPageHeader.aspx.cpp : main project file. + +#include "StdAfx.h" +#include "myPageHeader.ascx.h" + + +namespace WebControl { + + namespace uc + { + void myPageHeader::Page_Load(Object ^sender, EventArgs ^e) + { + // Set the image based on passed header level + imgHeader->ImageUrl = String::Concat("Images/", Level, ".jpg"); + } + } +} + diff --git a/Chapter16/WebControl/myPageHeader.ascx.h b/Chapter16/WebControl/myPageHeader.ascx.h new file mode 100644 index 0000000..9df956c --- /dev/null +++ b/Chapter16/WebControl/myPageHeader.ascx.h @@ -0,0 +1,32 @@ +// myPageHeader.ascx.h + +#pragma once + +using namespace System; +using namespace System::Collections; +using namespace System::Configuration; +using namespace System::Data; +using namespace System::Web; +using namespace System::Web::Security; +using namespace System::Web::UI; +using namespace System::Web::UI::HtmlControls; +using namespace System::Web::UI::WebControls; +using namespace System::Web::UI::WebControls::WebParts; +using namespace System::Xml; + +namespace WebControl { + + namespace uc + { + public ref class myPageHeader abstract : public System::Web::UI::UserControl + { + public: + property String^ Level; // A trivial property + + protected: + Image^ imgHeader; + + void Page_Load(Object ^sender, EventArgs ^e); + }; + } +} diff --git a/Chapter16/WebControl/stdafx.cpp b/Chapter16/WebControl/stdafx.cpp new file mode 100644 index 0000000..958e0f8 --- /dev/null +++ b/Chapter16/WebControl/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// WebControl.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/Chapter16/WebControl/stdafx.h b/Chapter16/WebControl/stdafx.h new file mode 100644 index 0000000..e16d986 --- /dev/null +++ b/Chapter16/WebControl/stdafx.h @@ -0,0 +1,7 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + diff --git a/Chapter17/Author/AssemblyInfo.cpp b/Chapter17/Author/AssemblyInfo.cpp new file mode 100644 index 0000000..59ce918 --- /dev/null +++ b/Chapter17/Author/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("Author")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("Author")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter17/Author/Author.asmx.cpp b/Chapter17/Author/Author.asmx.cpp new file mode 100644 index 0000000..b22cd94 --- /dev/null +++ b/Chapter17/Author/Author.asmx.cpp @@ -0,0 +1,77 @@ +// Author.asmx.cpp : main project file. + +#include "stdafx.h" +#include "Author.asmx.h" + +namespace Author { + + + AuthorClass::AuthorClass() + { + this->sqlConnection = gcnew SqlConnection(); + + this->sqlConnection->ConnectionString = + ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString; + } + + AuthorClass::~AuthorClass() + { + // + //TODO: Add the destructor code here + // + } + + DataSet^ AuthorClass::GetAuthors() + { + SqlDataAdapter ^dAdapt; + DataSet ^dSet; + + dAdapt = gcnew SqlDataAdapter(); + dAdapt->MissingSchemaAction = MissingSchemaAction::AddWithKey; + + dAdapt->SelectCommand = + gcnew SqlCommand("SELECT AuthorID, LastName, FirstName FROM Authors", sqlConnection); + dSet = gcnew DataSet(); + dAdapt->Fill(dSet, "Authors"); + + return dSet; + } + + void AuthorClass::UpdateAuthors(DataSet ^dSet) + { + SqlDataAdapter ^dAdapt; + + dAdapt = gcnew SqlDataAdapter(); + dAdapt->MissingSchemaAction = MissingSchemaAction::AddWithKey; + + dAdapt->InsertCommand = + gcnew SqlCommand("INSERT INTO Authors (LastName, FirstName) " + "VALUES (@LastName, @FirstName)", + sqlConnection); + dAdapt->InsertCommand->Parameters->Add("@LastName", SqlDbType::VarChar, + 50, "LastName"); + dAdapt->InsertCommand->Parameters->Add("@FirstName", SqlDbType::VarChar, + 50, "FirstName"); + + dAdapt->UpdateCommand = + gcnew SqlCommand("UPDATE Authors SET LastName = @LastName," + "FirstName = @FirstName " + "WHERE AuthorID = @AuthorID", + sqlConnection); + dAdapt->UpdateCommand->Parameters->Add("@LastName", SqlDbType::VarChar, + 50, "LastName"); + dAdapt->UpdateCommand->Parameters->Add("@FirstName", SqlDbType::VarChar, + 50, "FirstName"); + dAdapt->UpdateCommand->Parameters->Add("@AuthorID", SqlDbType::Int, + 4, "AuthorID"); + + dAdapt->DeleteCommand = + gcnew SqlCommand("DELETE FROM Authors WHERE AuthorID = @AuthorID", + sqlConnection); + dAdapt->DeleteCommand->Parameters->Add("@AuthorID", SqlDbType::Int, + 4, "AuthorID"); + + dAdapt->Update(dSet, "Authors"); + } + +} diff --git a/Chapter17/Author/Author.asmx.h b/Chapter17/Author/Author.asmx.h new file mode 100644 index 0000000..c97aa76 --- /dev/null +++ b/Chapter17/Author/Author.asmx.h @@ -0,0 +1,40 @@ +// Author.asmx.h + +#pragma once + +using namespace System; +using namespace System::Configuration; +using namespace System::Data; +using namespace System::Data::SqlClient; +using namespace System::Web; +using namespace System::Web::Services; + +namespace Author { + + [WebServiceBinding(ConformsTo=WsiProfiles::BasicProfile1_1,EmitConformanceClaims = true)] + [WebService(Namespace="TODO: Enter Unique URL", Description = "TODO: Enter Description")] + public ref class AuthorClass : public System::Web::Services::WebService + { + private: + SqlConnection^ sqlConnection; + + public: + /// + /// Default Constructor + /// + AuthorClass(); + + protected: + /// + /// Clean up any resources being used. + /// + ~AuthorClass(); + + public: + [WebMethod(Description = "Method to retrieve All Authors from the database")] + DataSet ^GetAuthors(); + + [WebMethod(Description = "Method to Commit changed made on client with Server database")] + void UpdateAuthors(DataSet ^dSet); + }; +} diff --git a/Chapter17/Author/Author.vcproj b/Chapter17/Author/Author.vcproj new file mode 100644 index 0000000..0e98cd7 --- /dev/null +++ b/Chapter17/Author/Author.vcproj @@ -0,0 +1,260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter17/Author/Global.asax.cpp b/Chapter17/Author/Global.asax.cpp new file mode 100644 index 0000000..8a3717e --- /dev/null +++ b/Chapter17/Author/Global.asax.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "Global.asax.h" + +namespace Author { + + void Global::Application_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_BeginRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_EndRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_End(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_End(Object ^sender, EventArgs ^e) + { + + } +} diff --git a/Chapter17/Author/Global.asax.h b/Chapter17/Author/Global.asax.h new file mode 100644 index 0000000..319fb24 --- /dev/null +++ b/Chapter17/Author/Global.asax.h @@ -0,0 +1,25 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Web; +using namespace System::Collections; +using namespace System::ComponentModel; +using namespace System::Web::SessionState; + +namespace Author { + + /// + /// Summary description for Global. + /// + public ref class Global : public System::Web::HttpApplication + { + protected: + void Application_Start(Object ^sender, EventArgs ^e); + void Session_Start(Object ^sender, EventArgs ^e); + void Application_BeginRequest(Object ^sender, EventArgs ^e); + void Application_EndRequest(Object ^sender, EventArgs ^e); + void Session_End(Object ^sender, EventArgs ^e); + void Application_End(Object ^sender, EventArgs ^e); + }; +} + diff --git a/Chapter17/Author/ReadMe.txt b/Chapter17/Author/ReadMe.txt new file mode 100644 index 0000000..0642bac --- /dev/null +++ b/Chapter17/Author/ReadMe.txt @@ -0,0 +1,38 @@ +======================================================================== + WEB SERVICE : Author Project Overview +======================================================================== + +AppWizard has created this Author project for you. + +This file contains a summary of what you will find in each of the files that +make up your Author application. + +Author.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +AuthorClass.cpp + This is the main web source file. + +AuthorClass.h + This header file contains the declarations of the Web Service. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + + +Web.Config + This file allows you to override the default configuration settings for your service. + Web Services use the configuration file to allow customization and extensibility of the system. + You might supply a Web Service specific Web.Config file, for instance, if your Web Service + requires authentication and other Web Applications on the system do not. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter17/Author/stdafx.cpp b/Chapter17/Author/stdafx.cpp new file mode 100644 index 0000000..129d2e2 --- /dev/null +++ b/Chapter17/Author/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// Author.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/Chapter17/Author/stdafx.h b/Chapter17/Author/stdafx.h new file mode 100644 index 0000000..e16d986 --- /dev/null +++ b/Chapter17/Author/stdafx.h @@ -0,0 +1,7 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + diff --git a/Chapter17/Chapter17.sln b/Chapter17/Chapter17.sln new file mode 100644 index 0000000..bb623f1 --- /dev/null +++ b/Chapter17/Chapter17.sln @@ -0,0 +1,161 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "GetZip", "..\..\WebSites\GetZip", "{D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}" + ProjectSection(WebsiteProperties) = preProject + TargetFramework = "3.5" + Debug.AspNetCompiler.VirtualPath = "/GetZip" + Debug.AspNetCompiler.PhysicalPath = "..\..\WebSites\GetZip\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\GetZip\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/GetZip" + Release.AspNetCompiler.PhysicalPath = "..\..\WebSites\GetZip\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\GetZip\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + VWDPort = "50287" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZipCodeConsoleClient", "ZipCodeConsoleClient\ZipCodeConsoleClient.vcproj", "{09C33040-0F1B-4ACC-8297-383BFB7A4174}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaintAuthors", "MaintAuthors\MaintAuthors.vcproj", "{D1F2E95B-3B52-468E-97BD-9A28BAE79965}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FindZipCode", "FindZipCode\FindZipCode.vcproj", "{3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}" +EndProject +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "FindZipCodeWS", "http://localhost/FindZipCodeWS", "{94E11D02-1EB3-47D8-B7CC-1F62A7074194}" + ProjectSection(WebsiteProperties) = preProject + TargetFramework = "3.5" + ProjectReferences = "{3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}|FindZipCode.dll;" + Debug.AspNetCompiler.VirtualPath = "/FindZipCodeWS" + Debug.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\FindZipCodeWS\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\FindZipCodeWS\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/FindZipCodeWS" + Release.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\FindZipCodeWS\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\FindZipCodeWS\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + SlnRelativePath = "..\..\..\..\..\..\inetpub\wwwroot\FindZipCodeWS\" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Author", "Author\Author.vcproj", "{8D271C89-2C19-4868-8A28-A87FEE3261B6}" +EndProject +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "AuthorWS", "http://localhost/AuthorWS", "{5A4391FE-159A-4F8F-A09B-BAD1BF54539C}" + ProjectSection(WebsiteProperties) = preProject + TargetFramework = "3.5" + ProjectReferences = "{8D271C89-2C19-4868-8A28-A87FEE3261B6}|Author.dll;" + Debug.AspNetCompiler.VirtualPath = "/AuthorWS" + Debug.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\AuthorWS\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\AuthorWS\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/AuthorWS" + Release.AspNetCompiler.PhysicalPath = "..\..\..\..\..\..\inetpub\wwwroot\AuthorWS\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\AuthorWS\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + SlnRelativePath = "..\..\..\..\..\..\inetpub\wwwroot\AuthorWS\" + DefaultWebSiteLanguage = "Visual C#" + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|.NET = Debug|.NET + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|.NET = Release|.NET + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Debug|.NET.ActiveCfg = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Debug|.NET.Build.0 = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Debug|Mixed Platforms.Build.0 = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Debug|Win32.ActiveCfg = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Release|.NET.ActiveCfg = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Release|.NET.Build.0 = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Release|Mixed Platforms.ActiveCfg = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Release|Mixed Platforms.Build.0 = Debug|.NET + {D87A92FF-4C3D-4F25-BB7B-31C2E397BA75}.Release|Win32.ActiveCfg = Debug|.NET + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Debug|.NET.ActiveCfg = Debug|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Debug|Win32.ActiveCfg = Debug|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Debug|Win32.Build.0 = Debug|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Release|.NET.ActiveCfg = Release|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Release|Mixed Platforms.Build.0 = Release|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Release|Win32.ActiveCfg = Release|Win32 + {09C33040-0F1B-4ACC-8297-383BFB7A4174}.Release|Win32.Build.0 = Release|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Debug|.NET.ActiveCfg = Debug|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Debug|Win32.ActiveCfg = Debug|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Debug|Win32.Build.0 = Debug|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Release|.NET.ActiveCfg = Release|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Release|Mixed Platforms.Build.0 = Release|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Release|Win32.ActiveCfg = Release|Win32 + {D1F2E95B-3B52-468E-97BD-9A28BAE79965}.Release|Win32.Build.0 = Release|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Debug|.NET.ActiveCfg = Debug|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Debug|Win32.ActiveCfg = Debug|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Debug|Win32.Build.0 = Debug|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Release|.NET.ActiveCfg = Release|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Release|Mixed Platforms.Build.0 = Release|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Release|Win32.ActiveCfg = Release|Win32 + {3D52E83E-4C5E-4D9E-AB08-A81F96F74AD3}.Release|Win32.Build.0 = Release|Win32 + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Debug|.NET.ActiveCfg = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Debug|.NET.Build.0 = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Debug|Mixed Platforms.Build.0 = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Debug|Win32.ActiveCfg = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Release|.NET.ActiveCfg = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Release|.NET.Build.0 = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Release|Mixed Platforms.ActiveCfg = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Release|Mixed Platforms.Build.0 = Debug|.NET + {94E11D02-1EB3-47D8-B7CC-1F62A7074194}.Release|Win32.ActiveCfg = Debug|.NET + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Debug|.NET.ActiveCfg = Debug|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Debug|Win32.ActiveCfg = Debug|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Debug|Win32.Build.0 = Debug|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Release|.NET.ActiveCfg = Release|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Release|Mixed Platforms.Build.0 = Release|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Release|Win32.ActiveCfg = Release|Win32 + {8D271C89-2C19-4868-8A28-A87FEE3261B6}.Release|Win32.Build.0 = Release|Win32 + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Debug|.NET.ActiveCfg = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Debug|.NET.Build.0 = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Debug|Mixed Platforms.Build.0 = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Debug|Win32.ActiveCfg = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Release|.NET.ActiveCfg = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Release|.NET.Build.0 = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Release|Mixed Platforms.ActiveCfg = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Release|Mixed Platforms.Build.0 = Debug|.NET + {5A4391FE-159A-4F8F-A09B-BAD1BF54539C}.Release|Win32.ActiveCfg = Debug|.NET + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter17/Chapter17.suo b/Chapter17/Chapter17.suo new file mode 100644 index 0000000..8eea871 Binary files /dev/null and b/Chapter17/Chapter17.suo differ diff --git a/Chapter17/FindZipCode/AssemblyInfo.cpp b/Chapter17/FindZipCode/AssemblyInfo.cpp new file mode 100644 index 0000000..9dc10aa --- /dev/null +++ b/Chapter17/FindZipCode/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("FindZipCode")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("FindZipCode")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter17/FindZipCode/FindZipCode.asmx.cpp b/Chapter17/FindZipCode/FindZipCode.asmx.cpp new file mode 100644 index 0000000..52b0603 --- /dev/null +++ b/Chapter17/FindZipCode/FindZipCode.asmx.cpp @@ -0,0 +1,34 @@ +// FindZipCode.asmx.cpp : main project file. + +#include "stdafx.h" +#include "FindZipCode.asmx.h" + +namespace FindZipCode { + + + FindZipCodeClass::FindZipCodeClass() + { + // + //TODO: Add the constructor code here + // + } + + FindZipCodeClass::~FindZipCodeClass() + { + // + //TODO: Add the destructor code here + // + } + + int FindZipCodeClass::GetZip(String ^city, String ^state) + { + // Obviously very simplified + if (city->Equals("Louisville") && state->Equals("KY")) + return 40241; + else if (city->Equals("Irvine") && state->Equals("CA")) + return 92612; + else + throw gcnew Exception("Zip Code not found"); + } + +} diff --git a/Chapter17/FindZipCode/FindZipCode.asmx.h b/Chapter17/FindZipCode/FindZipCode.asmx.h new file mode 100644 index 0000000..1dd312c --- /dev/null +++ b/Chapter17/FindZipCode/FindZipCode.asmx.h @@ -0,0 +1,33 @@ +// FindZipCode.asmx.h + +#pragma once + +using namespace System; +using namespace System::Web; +using namespace System::Web::Services; + +namespace FindZipCode { + + [WebServiceBinding(ConformsTo=WsiProfiles::BasicProfile1_1,EmitConformanceClaims = true)] + [WebService(Namespace="http://procppcli.net", Description = "Zip code retrieval service")] + public ref class FindZipCodeClass : public System::Web::Services::WebService + { + public: + /// + /// Default Constructor + /// + FindZipCodeClass(); + + protected: + /// + /// Clean up any resources being used. + /// + ~FindZipCodeClass(); + + public: + [WebMethod(Description = "Get the zip code from city and state")] + int GetZip(String ^city, String ^state); + + // TODO: Add the methods of your Web Service here + }; +} diff --git a/Chapter17/FindZipCode/FindZipCode.vcproj b/Chapter17/FindZipCode/FindZipCode.vcproj new file mode 100644 index 0000000..1eeb01c --- /dev/null +++ b/Chapter17/FindZipCode/FindZipCode.vcproj @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter17/FindZipCode/Global.asax.cpp b/Chapter17/FindZipCode/Global.asax.cpp new file mode 100644 index 0000000..9d3b339 --- /dev/null +++ b/Chapter17/FindZipCode/Global.asax.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "Global.asax.h" + +namespace FindZipCode { + + void Global::Application_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_Start(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_BeginRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_EndRequest(Object ^sender, EventArgs ^e) + { + + } + + void Global::Session_End(Object ^sender, EventArgs ^e) + { + + } + + void Global::Application_End(Object ^sender, EventArgs ^e) + { + + } +} diff --git a/Chapter17/FindZipCode/Global.asax.h b/Chapter17/FindZipCode/Global.asax.h new file mode 100644 index 0000000..d666ef5 --- /dev/null +++ b/Chapter17/FindZipCode/Global.asax.h @@ -0,0 +1,25 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Web; +using namespace System::Collections; +using namespace System::ComponentModel; +using namespace System::Web::SessionState; + +namespace FindZipCode { + + /// + /// Summary description for Global. + /// + public ref class Global : public System::Web::HttpApplication + { + protected: + void Application_Start(Object ^sender, EventArgs ^e); + void Session_Start(Object ^sender, EventArgs ^e); + void Application_BeginRequest(Object ^sender, EventArgs ^e); + void Application_EndRequest(Object ^sender, EventArgs ^e); + void Session_End(Object ^sender, EventArgs ^e); + void Application_End(Object ^sender, EventArgs ^e); + }; +} + diff --git a/Chapter17/FindZipCode/ReadMe.txt b/Chapter17/FindZipCode/ReadMe.txt new file mode 100644 index 0000000..cb45905 --- /dev/null +++ b/Chapter17/FindZipCode/ReadMe.txt @@ -0,0 +1,38 @@ +======================================================================== + WEB SERVICE : FindZipCode Project Overview +======================================================================== + +AppWizard has created this FindZipCode project for you. + +This file contains a summary of what you will find in each of the files that +make up your FindZipCode application. + +FindZipCode.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +FindZipCodeClass.cpp + This is the main web source file. + +FindZipCodeClass.h + This header file contains the declarations of the Web Service. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + + +Web.Config + This file allows you to override the default configuration settings for your service. + Web Services use the configuration file to allow customization and extensibility of the system. + You might supply a Web Service specific Web.Config file, for instance, if your Web Service + requires authentication and other Web Applications on the system do not. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter17/FindZipCode/stdafx.cpp b/Chapter17/FindZipCode/stdafx.cpp new file mode 100644 index 0000000..8c0328c --- /dev/null +++ b/Chapter17/FindZipCode/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// FindZipCode.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/Chapter17/FindZipCode/stdafx.h b/Chapter17/FindZipCode/stdafx.h new file mode 100644 index 0000000..e16d986 --- /dev/null +++ b/Chapter17/FindZipCode/stdafx.h @@ -0,0 +1,7 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + diff --git a/Chapter17/MaintAuthors/AuthorWS.h b/Chapter17/MaintAuthors/AuthorWS.h new file mode 100644 index 0000000..865f926 --- /dev/null +++ b/Chapter17/MaintAuthors/AuthorWS.h @@ -0,0 +1,202 @@ +#pragma once + +#using +#using +#using +#using +#using +#using + +using namespace System::Security::Permissions; +[assembly:SecurityPermissionAttribute(SecurityAction::RequestMinimum, SkipVerification=false)]; +// +// This source code was auto-generated by wsdl, Version=2.0.50727.1432. +// +namespace AuthorWS { + using namespace System::Diagnostics; + using namespace System::Web::Services; + using namespace System::ComponentModel; + using namespace System::Web::Services::Protocols; + using namespace System; + using namespace System::Xml::Serialization; + using namespace System::Data; + using namespace System; + ref class AuthorClass; + ref class GetAuthorsCompletedEventArgs; + + + /// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.1432")] + public delegate System::Void GetAuthorsCompletedEventHandler(System::Object^ sender, AuthorWS::GetAuthorsCompletedEventArgs^ e); + + /// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.1432")] + public delegate System::Void UpdateAuthorsCompletedEventHandler(System::Object^ sender, System::ComponentModel::AsyncCompletedEventArgs^ e); + + /// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.1432"), + System::Diagnostics::DebuggerStepThroughAttribute, + System::ComponentModel::DesignerCategoryAttribute(L"code"), + System::Web::Services::WebServiceBindingAttribute(Name=L"AuthorClassSoap", Namespace=L"TODO: Enter Unique URL")] + public ref class AuthorClass : public System::Web::Services::Protocols::SoapHttpClientProtocol { + + private: System::Threading::SendOrPostCallback^ GetAuthorsOperationCompleted; + + private: System::Threading::SendOrPostCallback^ UpdateAuthorsOperationCompleted; + + /// + public: event AuthorWS::GetAuthorsCompletedEventHandler^ GetAuthorsCompleted; + + /// + public: event AuthorWS::UpdateAuthorsCompletedEventHandler^ UpdateAuthorsCompleted; + + /// + public: AuthorClass(); + /// + public: [System::Web::Services::Protocols::SoapDocumentMethodAttribute(L"TODO: Enter Unique URL/GetAuthors", RequestNamespace=L"TODO: Enter Unique URL", + ResponseNamespace=L"TODO: Enter Unique URL", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] + System::Data::DataSet^ GetAuthors(); + + /// + public: System::IAsyncResult^ BeginGetAuthors(System::AsyncCallback^ callback, System::Object^ asyncState); + + /// + public: System::Data::DataSet^ EndGetAuthors(System::IAsyncResult^ asyncResult); + + /// + public: System::Void GetAuthorsAsync(); + + /// + public: System::Void GetAuthorsAsync(System::Object^ userState); + + private: System::Void OnGetAuthorsOperationCompleted(System::Object^ arg); + + /// + public: [System::Web::Services::Protocols::SoapDocumentMethodAttribute(L"TODO: Enter Unique URL/UpdateAuthors", RequestNamespace=L"TODO: Enter Unique URL", + ResponseNamespace=L"TODO: Enter Unique URL", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] + System::Void UpdateAuthors(System::Data::DataSet^ dSet); + + /// + public: System::IAsyncResult^ BeginUpdateAuthors(System::Data::DataSet^ dSet, System::AsyncCallback^ callback, + System::Object^ asyncState); + + /// + public: System::Void EndUpdateAuthors(System::IAsyncResult^ asyncResult); + + /// + public: System::Void UpdateAuthorsAsync(System::Data::DataSet^ dSet); + + /// + public: System::Void UpdateAuthorsAsync(System::Data::DataSet^ dSet, System::Object^ userState); + + private: System::Void OnUpdateAuthorsOperationCompleted(System::Object^ arg); + + /// + public: System::Void CancelAsync(System::Object^ userState) new; + }; + + /// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.1432"), + System::Diagnostics::DebuggerStepThroughAttribute, + System::ComponentModel::DesignerCategoryAttribute(L"code")] + public ref class GetAuthorsCompletedEventArgs : public System::ComponentModel::AsyncCompletedEventArgs { + + private: cli::array< System::Object^ >^ results; + + internal: GetAuthorsCompletedEventArgs(cli::array< System::Object^ >^ results, System::Exception^ exception, System::Boolean cancelled, + System::Object^ userState); + /// + public: property System::Data::DataSet^ Result { + System::Data::DataSet^ get(); + } + }; +} +namespace AuthorWS { + + + inline AuthorClass::AuthorClass() { + this->Url = L"http://localhost/AuthorWS/Author.asmx"; + } + + inline System::Data::DataSet^ AuthorClass::GetAuthors() { + cli::array< System::Object^ >^ results = this->Invoke(L"GetAuthors", gcnew cli::array< System::Object^ >(0)); + return (cli::safe_cast(results[0])); + } + + inline System::IAsyncResult^ AuthorClass::BeginGetAuthors(System::AsyncCallback^ callback, System::Object^ asyncState) { + return this->BeginInvoke(L"GetAuthors", gcnew cli::array< System::Object^ >(0), callback, asyncState); + } + + inline System::Data::DataSet^ AuthorClass::EndGetAuthors(System::IAsyncResult^ asyncResult) { + cli::array< System::Object^ >^ results = this->EndInvoke(asyncResult); + return (cli::safe_cast(results[0])); + } + + inline System::Void AuthorClass::GetAuthorsAsync() { + this->GetAuthorsAsync(nullptr); + } + + inline System::Void AuthorClass::GetAuthorsAsync(System::Object^ userState) { + if (this->GetAuthorsOperationCompleted == nullptr) { + this->GetAuthorsOperationCompleted = gcnew System::Threading::SendOrPostCallback(this, &AuthorWS::AuthorClass::OnGetAuthorsOperationCompleted); + } + this->InvokeAsync(L"GetAuthors", gcnew cli::array< System::Object^ >(0), this->GetAuthorsOperationCompleted, userState); + } + + inline System::Void AuthorClass::OnGetAuthorsOperationCompleted(System::Object^ arg) { + { + System::Web::Services::Protocols::InvokeCompletedEventArgs^ invokeArgs = (cli::safe_cast(arg)); + this->GetAuthorsCompleted(this, (gcnew AuthorWS::GetAuthorsCompletedEventArgs(invokeArgs->Results, invokeArgs->Error, + invokeArgs->Cancelled, invokeArgs->UserState))); + } + } + + inline System::Void AuthorClass::UpdateAuthors(System::Data::DataSet^ dSet) { + this->Invoke(L"UpdateAuthors", gcnew cli::array< System::Object^ >(1) {dSet}); + } + + inline System::IAsyncResult^ AuthorClass::BeginUpdateAuthors(System::Data::DataSet^ dSet, System::AsyncCallback^ callback, + System::Object^ asyncState) { + return this->BeginInvoke(L"UpdateAuthors", gcnew cli::array< System::Object^ >(1) {dSet}, callback, asyncState); + } + + inline System::Void AuthorClass::EndUpdateAuthors(System::IAsyncResult^ asyncResult) { + this->EndInvoke(asyncResult); + } + + inline System::Void AuthorClass::UpdateAuthorsAsync(System::Data::DataSet^ dSet) { + this->UpdateAuthorsAsync(dSet, nullptr); + } + + inline System::Void AuthorClass::UpdateAuthorsAsync(System::Data::DataSet^ dSet, System::Object^ userState) { + if (this->UpdateAuthorsOperationCompleted == nullptr) { + this->UpdateAuthorsOperationCompleted = gcnew System::Threading::SendOrPostCallback(this, &AuthorWS::AuthorClass::OnUpdateAuthorsOperationCompleted); + } + this->InvokeAsync(L"UpdateAuthors", gcnew cli::array< System::Object^ >(1) {dSet}, this->UpdateAuthorsOperationCompleted, + userState); + } + + inline System::Void AuthorClass::OnUpdateAuthorsOperationCompleted(System::Object^ arg) { + { + System::Web::Services::Protocols::InvokeCompletedEventArgs^ invokeArgs = (cli::safe_cast(arg)); + this->UpdateAuthorsCompleted(this, (gcnew System::ComponentModel::AsyncCompletedEventArgs(invokeArgs->Error, invokeArgs->Cancelled, + invokeArgs->UserState))); + } + } + + inline System::Void AuthorClass::CancelAsync(System::Object^ userState) { + __super::CancelAsync(userState); + } + + + inline GetAuthorsCompletedEventArgs::GetAuthorsCompletedEventArgs(cli::array< System::Object^ >^ results, System::Exception^ exception, + System::Boolean cancelled, System::Object^ userState) : + System::ComponentModel::AsyncCompletedEventArgs(exception, cancelled, userState) { + this->results = results; + } + + inline System::Data::DataSet^ GetAuthorsCompletedEventArgs::Result::get() { + this->RaiseExceptionIfNecessary(); + return (cli::safe_cast(this->results[0])); + } +} diff --git a/Chapter17/MaintAuthors/AuthorWS.h.dll b/Chapter17/MaintAuthors/AuthorWS.h.dll new file mode 100644 index 0000000..c03c545 Binary files /dev/null and b/Chapter17/MaintAuthors/AuthorWS.h.dll differ diff --git a/Chapter17/MaintAuthors/AuthorWS.h.dll.manifest b/Chapter17/MaintAuthors/AuthorWS.h.dll.manifest new file mode 100644 index 0000000..7256947 --- /dev/null +++ b/Chapter17/MaintAuthors/AuthorWS.h.dll.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Chapter17/MaintAuthors/AuthorWS/Author.disco b/Chapter17/MaintAuthors/AuthorWS/Author.disco new file mode 100644 index 0000000..9b7c5d9 --- /dev/null +++ b/Chapter17/MaintAuthors/AuthorWS/Author.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Chapter17/MaintAuthors/AuthorWS/Author.wsdl b/Chapter17/MaintAuthors/AuthorWS/Author.wsdl new file mode 100644 index 0000000..00a12e0 --- /dev/null +++ b/Chapter17/MaintAuthors/AuthorWS/Author.wsdl @@ -0,0 +1,120 @@ + + + TODO: Enter Description + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Method to retrieve All Authors from the database + + + + + Method to Commit changed made on client with Server database + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TODO: Enter Description + + + + + + + + \ No newline at end of file diff --git a/Chapter17/MaintAuthors/AuthorWS/results.discomap b/Chapter17/MaintAuthors/AuthorWS/results.discomap new file mode 100644 index 0000000..664c009 --- /dev/null +++ b/Chapter17/MaintAuthors/AuthorWS/results.discomap @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter17/MaintAuthors/Debug.obj b/Chapter17/MaintAuthors/Debug.obj new file mode 100644 index 0000000..8437571 Binary files /dev/null and b/Chapter17/MaintAuthors/Debug.obj differ diff --git a/Chapter17/MaintAuthors/Form1.h b/Chapter17/MaintAuthors/Form1.h new file mode 100644 index 0000000..9223909 --- /dev/null +++ b/Chapter17/MaintAuthors/Form1.h @@ -0,0 +1,306 @@ +#pragma once + + +namespace MaintAuthors { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + authors = gcnew AuthorWS::AuthorClass(); + dSet = authors->GetAuthors(); + + DataTable ^dt = dSet->Tables["Authors"]; + + if (dt == nullptr) + throw gcnew Exception("No Authors Table"); + + for each (DataRow ^row in dt->Rows::get()) + { + lbAuthors->Items->Add(ListBoxItem(row)); + } + + CurrentAuthorID = -1; + } + + protected: + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Button^ bnRollback; + System::Windows::Forms::Button^ bnCommit; + System::Windows::Forms::Button^ bnDelete; + System::Windows::Forms::Button^ bnUpdate; + System::Windows::Forms::Button^ bnAdd; + System::Windows::Forms::ListBox^ lbAuthors; + System::Windows::Forms::TextBox^ tbLastName; + System::Windows::Forms::TextBox^ tbFirstName; + System::Windows::Forms::Label^ label2; + System::Windows::Forms::Label^ label1; + + System::ComponentModel::Container ^components; + + DataSet ^dSet; + int CurrentAuthorID; + AuthorWS::AuthorClass ^authors; + +#pragma region Windows Form Designer generated code + + void InitializeComponent(void) + { + this->bnRollback = (gcnew System::Windows::Forms::Button()); + this->bnCommit = (gcnew System::Windows::Forms::Button()); + this->bnDelete = (gcnew System::Windows::Forms::Button()); + this->bnUpdate = (gcnew System::Windows::Forms::Button()); + this->bnAdd = (gcnew System::Windows::Forms::Button()); + this->lbAuthors = (gcnew System::Windows::Forms::ListBox()); + this->tbLastName = (gcnew System::Windows::Forms::TextBox()); + this->tbFirstName = (gcnew System::Windows::Forms::TextBox()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->SuspendLayout(); + // + // bnRollback + // + this->bnRollback->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->bnRollback->Location = System::Drawing::Point(322, 168); + this->bnRollback->Name = L"bnRollback"; + this->bnRollback->Size = System::Drawing::Size(75, 23); + this->bnRollback->TabIndex = 29; + this->bnRollback->Text = L"Rollback"; + this->bnRollback->Click += gcnew System::EventHandler(this, &Form1::bnRollback_Click); + // + // bnCommit + // + this->bnCommit->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->bnCommit->Location = System::Drawing::Point(322, 138); + this->bnCommit->Margin = System::Windows::Forms::Padding(3, 0, 3, 3); + this->bnCommit->Name = L"bnCommit"; + this->bnCommit->Size = System::Drawing::Size(75, 23); + this->bnCommit->TabIndex = 28; + this->bnCommit->Text = L"Commit"; + this->bnCommit->Click += gcnew System::EventHandler(this, &Form1::bnCommit_Click); + // + // bnDelete + // + this->bnDelete->Location = System::Drawing::Point(322, 84); + this->bnDelete->Name = L"bnDelete"; + this->bnDelete->Size = System::Drawing::Size(75, 23); + this->bnDelete->TabIndex = 27; + this->bnDelete->Text = L"Delete"; + this->bnDelete->Click += gcnew System::EventHandler(this, &Form1::bnDelete_Click); + // + // bnUpdate + // + this->bnUpdate->Location = System::Drawing::Point(322, 52); + this->bnUpdate->Name = L"bnUpdate"; + this->bnUpdate->Size = System::Drawing::Size(75, 23); + this->bnUpdate->TabIndex = 26; + this->bnUpdate->Text = L"Update"; + this->bnUpdate->Click += gcnew System::EventHandler(this, &Form1::bnUpdate_Click); + // + // bnAdd + // + this->bnAdd->Location = System::Drawing::Point(322, 24); + this->bnAdd->Margin = System::Windows::Forms::Padding(3, 3, 3, 1); + this->bnAdd->Name = L"bnAdd"; + this->bnAdd->Size = System::Drawing::Size(75, 23); + this->bnAdd->TabIndex = 25; + this->bnAdd->Text = L"Add"; + this->bnAdd->Click += gcnew System::EventHandler(this, &Form1::bnAdd_Click); + // + // lbAuthors + // + this->lbAuthors->FormattingEnabled = true; + this->lbAuthors->Location = System::Drawing::Point(35, 101); + this->lbAuthors->Name = L"lbAuthors"; + this->lbAuthors->Size = System::Drawing::Size(257, 95); + this->lbAuthors->TabIndex = 24; + this->lbAuthors->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::lbAuthors_SelectedIndexChanged); + // + // tbLastName + // + this->tbLastName->Location = System::Drawing::Point(97, 57); + this->tbLastName->Margin = System::Windows::Forms::Padding(1, 3, 3, 3); + this->tbLastName->Name = L"tbLastName"; + this->tbLastName->Size = System::Drawing::Size(127, 20); + this->tbLastName->TabIndex = 23; + // + // tbFirstName + // + this->tbFirstName->Location = System::Drawing::Point(97, 30); + this->tbFirstName->Margin = System::Windows::Forms::Padding(1, 3, 3, 3); + this->tbFirstName->Name = L"tbFirstName"; + this->tbFirstName->Size = System::Drawing::Size(127, 20); + this->tbFirstName->TabIndex = 22; + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Location = System::Drawing::Point(35, 63); + this->label2->Margin = System::Windows::Forms::Padding(3, 3, 2, 3); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(58, 13); + this->label2->TabIndex = 21; + this->label2->Text = L"Last Name"; + // + // label1 + // + this->label1->AutoSize = true; + this->label1->Location = System::Drawing::Point(35, 33); + this->label1->Margin = System::Windows::Forms::Padding(3, 3, 2, 3); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(57, 13); + this->label1->TabIndex = 20; + this->label1->Text = L"First Name"; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(432, 220); + this->Controls->Add(this->bnRollback); + this->Controls->Add(this->bnCommit); + this->Controls->Add(this->bnDelete); + this->Controls->Add(this->bnUpdate); + this->Controls->Add(this->bnAdd); + this->Controls->Add(this->lbAuthors); + this->Controls->Add(this->tbLastName); + this->Controls->Add(this->tbFirstName); + this->Controls->Add(this->label2); + this->Controls->Add(this->label1); + this->Name = L"Form1"; + this->Text = L"Maintain Authors using a Web Service"; + this->ResumeLayout(false); + this->PerformLayout(); + } + +#pragma endregion + + private: + String ^ListBoxItem(DataRow ^row) + { + return String::Format("{0} {1} {2}", + row["AuthorID"], + row["FirstName"], + row["LastName"]); + } + + System::Void bnRollback_Click(System::Object^ sender, System::EventArgs^ e) + { + dSet->RejectChanges(); + + lbAuthors->Items->Clear(); + + DataTable ^dt = dSet->Tables["Authors"]; + + for each (DataRow^ row in dt->Rows::get()) + { + lbAuthors->Items->Add(ListBoxItem(row)); + } + CurrentAuthorID = -1; + } + + System::Void bnCommit_Click(System::Object^ sender, System::EventArgs^ e) + { + authors->UpdateAuthors(dSet->GetChanges()); + dSet->AcceptChanges(); + + lbAuthors->Items->Clear(); + + DataTable ^dt = dSet->Tables["Authors"]; + + for each (DataRow^ row in dt->Rows::get()) + { + lbAuthors->Items->Add(ListBoxItem(row)); + } + CurrentAuthorID = -1; + } + + System::Void bnDelete_Click(System::Object^ sender, System::EventArgs^ e) + { + if (CurrentAuthorID < 0) + return; + + DataTable ^dt = dSet->Tables["Authors"]; + array^ row = dt->Select(String::Format("AuthorID={0}", CurrentAuthorID)); + + row[0]->Delete(); + + lbAuthors->Items->RemoveAt(lbAuthors->SelectedIndex); + } + + System::Void bnUpdate_Click(System::Object^ sender, System::EventArgs^ e) + { + if (CurrentAuthorID < 0) + return; + + DataTable ^dt = dSet->Tables["Authors"]; + array^ row = dt->Select(String::Format("AuthorID={0}", CurrentAuthorID)); + + row[0]["FirstName"] = tbFirstName->Text; + row[0]["LastName"] = tbLastName->Text; + + lbAuthors->Items->Insert(lbAuthors->SelectedIndex, ListBoxItem(row[0])); + lbAuthors->Items->RemoveAt(lbAuthors->SelectedIndex); + } + + System::Void bnAdd_Click(System::Object^ sender, System::EventArgs^ e) + { + if (tbFirstName->Text->Trim()->Length == 0 || + tbLastName->Text->Trim()->Length == 0) + return; + + DataTable ^dt = dSet->Tables["Authors"]; + + DataRow ^row = dt->NewRow(); + + row["FirstName"] = tbFirstName->Text; + row["LastName"] = tbLastName->Text; + + dt->Rows->Add(row); + + lbAuthors->Items->Add(ListBoxItem(row)); + + tbFirstName->Text = ""; + tbLastName->Text = ""; + } + + System::Void lbAuthors_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) + { + array^ ASpace = gcnew array{' '}; + + if (lbAuthors->SelectedItem == nullptr) + { + CurrentAuthorID = -1; + tbFirstName->Text = ""; + tbLastName->Text = ""; + return; + } + array^ split = lbAuthors->SelectedItem->ToString()->Split(ASpace); + + CurrentAuthorID = Convert::ToInt32(split[0]); + tbFirstName->Text = split[1]; + tbLastName->Text = split[2]; + } + }; +} + diff --git a/Chapter17/MaintAuthors/Form1.resX b/Chapter17/MaintAuthors/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter17/MaintAuthors/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter17/MaintAuthors/MaintAuthors.cpp b/Chapter17/MaintAuthors/MaintAuthors.cpp new file mode 100644 index 0000000..39f735e --- /dev/null +++ b/Chapter17/MaintAuthors/MaintAuthors.cpp @@ -0,0 +1,18 @@ +// MaintAuthors.cpp : main project file. + +#include "WebService.h" +#include "Form1.h" + +using namespace MaintAuthors; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter17/MaintAuthors/MaintAuthors.vcproj b/Chapter17/MaintAuthors/MaintAuthors.vcproj new file mode 100644 index 0000000..2537947 --- /dev/null +++ b/Chapter17/MaintAuthors/MaintAuthors.vcproj @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter17/MaintAuthors/MaintAuthors.vcproj.vspscc b/Chapter17/MaintAuthors/MaintAuthors.vcproj.vspscc new file mode 100644 index 0000000..515391c --- /dev/null +++ b/Chapter17/MaintAuthors/MaintAuthors.vcproj.vspscc @@ -0,0 +1,11 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "1" +"EXCLUDED_FILE0" = "AuthorWS.h" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/Chapter17/MaintAuthors/WebService.h b/Chapter17/MaintAuthors/WebService.h new file mode 100644 index 0000000..cb77791 --- /dev/null +++ b/Chapter17/MaintAuthors/WebService.h @@ -0,0 +1,2 @@ +#include "AuthorWS.h" +#include "AuthorWS.h" diff --git a/Chapter17/MaintAuthors/temp/Author.disco b/Chapter17/MaintAuthors/temp/Author.disco new file mode 100644 index 0000000..9b7c5d9 --- /dev/null +++ b/Chapter17/MaintAuthors/temp/Author.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Chapter17/MaintAuthors/temp/Author.wsdl b/Chapter17/MaintAuthors/temp/Author.wsdl new file mode 100644 index 0000000..00a12e0 --- /dev/null +++ b/Chapter17/MaintAuthors/temp/Author.wsdl @@ -0,0 +1,120 @@ + + + TODO: Enter Description + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Method to retrieve All Authors from the database + + + + + Method to Commit changed made on client with Server database + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TODO: Enter Description + + + + + + + + \ No newline at end of file diff --git a/Chapter17/MaintAuthors/temp/results.discomap b/Chapter17/MaintAuthors/temp/results.discomap new file mode 100644 index 0000000..664c009 --- /dev/null +++ b/Chapter17/MaintAuthors/temp/results.discomap @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter17/ZipCodeConsoleClient/Debug.obj b/Chapter17/ZipCodeConsoleClient/Debug.obj new file mode 100644 index 0000000..d0afe23 Binary files /dev/null and b/Chapter17/ZipCodeConsoleClient/Debug.obj differ diff --git a/Chapter17/ZipCodeConsoleClient/FindZipCode.h b/Chapter17/ZipCodeConsoleClient/FindZipCode.h new file mode 100644 index 0000000..2d79c56 --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/FindZipCode.h @@ -0,0 +1,141 @@ +#pragma once + +#using +#using +#using +#using +#using + +using namespace System::Security::Permissions; +[assembly:SecurityPermissionAttribute(SecurityAction::RequestMinimum, SkipVerification=false)]; +// +// This source code was auto-generated by wsdl, Version=2.0.50727.1432. +// +namespace FindZipCode { + using namespace System::Diagnostics; + using namespace System::Web::Services; + using namespace System::ComponentModel; + using namespace System::Web::Services::Protocols; + using namespace System; + using namespace System::Xml::Serialization; + using namespace System; + ref class FindZipCodeClass; + ref class GetZipCompletedEventArgs; + + + /// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.1432")] + public delegate System::Void GetZipCompletedEventHandler(System::Object^ sender, FindZipCode::GetZipCompletedEventArgs^ e); + + /// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.1432"), + System::Diagnostics::DebuggerStepThroughAttribute, + System::ComponentModel::DesignerCategoryAttribute(L"code"), + System::Web::Services::WebServiceBindingAttribute(Name=L"FindZipCodeClassSoap", Namespace=L"http://procppcli.net")] + public ref class FindZipCodeClass : public System::Web::Services::Protocols::SoapHttpClientProtocol { + + private: System::Threading::SendOrPostCallback^ GetZipOperationCompleted; + + /// + public: event FindZipCode::GetZipCompletedEventHandler^ GetZipCompleted; + + /// + public: FindZipCodeClass(); + /// + public: [System::Web::Services::Protocols::SoapDocumentMethodAttribute(L"http://procppcli.net/GetZip", RequestNamespace=L"http://procppcli.net", + ResponseNamespace=L"http://procppcli.net", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)] + System::Int32 GetZip(System::String^ city, System::String^ state); + + /// + public: System::IAsyncResult^ BeginGetZip(System::String^ city, System::String^ state, System::AsyncCallback^ callback, + System::Object^ asyncState); + + /// + public: System::Int32 EndGetZip(System::IAsyncResult^ asyncResult); + + /// + public: System::Void GetZipAsync(System::String^ city, System::String^ state); + + /// + public: System::Void GetZipAsync(System::String^ city, System::String^ state, System::Object^ userState); + + private: System::Void OnGetZipOperationCompleted(System::Object^ arg); + + /// + public: System::Void CancelAsync(System::Object^ userState) new; + }; + + /// + [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.1432"), + System::Diagnostics::DebuggerStepThroughAttribute, + System::ComponentModel::DesignerCategoryAttribute(L"code")] + public ref class GetZipCompletedEventArgs : public System::ComponentModel::AsyncCompletedEventArgs { + + private: cli::array< System::Object^ >^ results; + + internal: GetZipCompletedEventArgs(cli::array< System::Object^ >^ results, System::Exception^ exception, System::Boolean cancelled, + System::Object^ userState); + /// + public: property System::Int32 Result { + System::Int32 get(); + } + }; +} +namespace FindZipCode { + + + inline FindZipCodeClass::FindZipCodeClass() { + this->Url = L"http://localhost/FindZipCodeWS/FindZipCode.asmx"; + } + + inline System::Int32 FindZipCodeClass::GetZip(System::String^ city, System::String^ state) { + cli::array< System::Object^ >^ results = this->Invoke(L"GetZip", gcnew cli::array< System::Object^ >(2) {city, + state}); + return (cli::safe_cast(results[0])); + } + + inline System::IAsyncResult^ FindZipCodeClass::BeginGetZip(System::String^ city, System::String^ state, System::AsyncCallback^ callback, + System::Object^ asyncState) { + return this->BeginInvoke(L"GetZip", gcnew cli::array< System::Object^ >(2) {city, state}, callback, asyncState); + } + + inline System::Int32 FindZipCodeClass::EndGetZip(System::IAsyncResult^ asyncResult) { + cli::array< System::Object^ >^ results = this->EndInvoke(asyncResult); + return (cli::safe_cast(results[0])); + } + + inline System::Void FindZipCodeClass::GetZipAsync(System::String^ city, System::String^ state) { + this->GetZipAsync(city, state, nullptr); + } + + inline System::Void FindZipCodeClass::GetZipAsync(System::String^ city, System::String^ state, System::Object^ userState) { + if (this->GetZipOperationCompleted == nullptr) { + this->GetZipOperationCompleted = gcnew System::Threading::SendOrPostCallback(this, &FindZipCode::FindZipCodeClass::OnGetZipOperationCompleted); + } + this->InvokeAsync(L"GetZip", gcnew cli::array< System::Object^ >(2) {city, state}, this->GetZipOperationCompleted, userState); + } + + inline System::Void FindZipCodeClass::OnGetZipOperationCompleted(System::Object^ arg) { + { + System::Web::Services::Protocols::InvokeCompletedEventArgs^ invokeArgs = (cli::safe_cast(arg)); + this->GetZipCompleted(this, (gcnew FindZipCode::GetZipCompletedEventArgs(invokeArgs->Results, invokeArgs->Error, + invokeArgs->Cancelled, invokeArgs->UserState))); + } + } + + inline System::Void FindZipCodeClass::CancelAsync(System::Object^ userState) { + __super::CancelAsync(userState); + } + + + inline GetZipCompletedEventArgs::GetZipCompletedEventArgs(cli::array< System::Object^ >^ results, System::Exception^ exception, + System::Boolean cancelled, System::Object^ userState) : + System::ComponentModel::AsyncCompletedEventArgs(exception, cancelled, userState) { + this->results = results; + } + + inline System::Int32 GetZipCompletedEventArgs::Result::get() { + this->RaiseExceptionIfNecessary(); + return (cli::safe_cast(this->results[0])); + } +} diff --git a/Chapter17/ZipCodeConsoleClient/FindZipCode.h.dll b/Chapter17/ZipCodeConsoleClient/FindZipCode.h.dll new file mode 100644 index 0000000..765dcd5 Binary files /dev/null and b/Chapter17/ZipCodeConsoleClient/FindZipCode.h.dll differ diff --git a/Chapter17/ZipCodeConsoleClient/FindZipCode.h.dll.manifest b/Chapter17/ZipCodeConsoleClient/FindZipCode.h.dll.manifest new file mode 100644 index 0000000..7256947 --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/FindZipCode.h.dll.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Chapter17/ZipCodeConsoleClient/FindZipCode/FindZipcode.disco b/Chapter17/ZipCodeConsoleClient/FindZipCode/FindZipcode.disco new file mode 100644 index 0000000..b72fd1b --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/FindZipCode/FindZipcode.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Chapter17/ZipCodeConsoleClient/FindZipCode/FindZipcode.wsdl b/Chapter17/ZipCodeConsoleClient/FindZipCode/FindZipcode.wsdl new file mode 100644 index 0000000..e218c9d --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/FindZipCode/FindZipcode.wsdl @@ -0,0 +1,72 @@ + + + Zip code retrieval service + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get the zip code from city and state + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Zip code retrieval service + + + + + + + + \ No newline at end of file diff --git a/Chapter17/ZipCodeConsoleClient/FindZipCode/results.discomap b/Chapter17/ZipCodeConsoleClient/FindZipCode/results.discomap new file mode 100644 index 0000000..96ba96a --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/FindZipCode/results.discomap @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter17/ZipCodeConsoleClient/WebService.h b/Chapter17/ZipCodeConsoleClient/WebService.h new file mode 100644 index 0000000..7125cf8 --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/WebService.h @@ -0,0 +1,2 @@ +#include "FindZipCode.h" +#include "FindZipCode.h" diff --git a/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.cpp b/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.cpp new file mode 100644 index 0000000..19fcef9 --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.cpp @@ -0,0 +1,20 @@ +#include "FindZipCode.h" + +using namespace System; + +void main() +{ + FindZipCode::FindZipCodeClass ^fzc = gcnew FindZipCode::FindZipCodeClass(); + + try + { + Console::WriteLine(fzc->GetZip("Louisville", "KY").ToString()); + Console::WriteLine(fzc->GetZip("Irvine", "CA").ToString()); + Console::WriteLine(fzc->GetZip("xx", "cc").ToString()); + } + + catch (Exception ^e) + { + Console::WriteLine(e->Message); + } +} diff --git a/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.vcproj b/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.vcproj new file mode 100644 index 0000000..ca84355 --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.vcproj @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.vcproj.vspscc b/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.vcproj.vspscc new file mode 100644 index 0000000..112c03a --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/ZipCodeConsoleClient.vcproj.vspscc @@ -0,0 +1,11 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "1" +"EXCLUDED_FILE0" = "FindZipCode.h" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/Chapter17/ZipCodeConsoleClient/temp/FindZipcode.disco b/Chapter17/ZipCodeConsoleClient/temp/FindZipcode.disco new file mode 100644 index 0000000..b72fd1b --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/temp/FindZipcode.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Chapter17/ZipCodeConsoleClient/temp/FindZipcode.wsdl b/Chapter17/ZipCodeConsoleClient/temp/FindZipcode.wsdl new file mode 100644 index 0000000..e218c9d --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/temp/FindZipcode.wsdl @@ -0,0 +1,72 @@ + + + Zip code retrieval service + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get the zip code from city and state + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Zip code retrieval service + + + + + + + + \ No newline at end of file diff --git a/Chapter17/ZipCodeConsoleClient/temp/results.discomap b/Chapter17/ZipCodeConsoleClient/temp/results.discomap new file mode 100644 index 0000000..96ba96a --- /dev/null +++ b/Chapter17/ZipCodeConsoleClient/temp/results.discomap @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Chapter18/AbortingThreads/AbortingThreads.cpp b/Chapter18/AbortingThreads/AbortingThreads.cpp new file mode 100644 index 0000000..e063daf --- /dev/null +++ b/Chapter18/AbortingThreads/AbortingThreads.cpp @@ -0,0 +1,57 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ +public: + static void ThreadFunc(Object ^Name); +}; + +void MyThread::ThreadFunc(Object ^Name) +{ + Thread ^thr = Thread::CurrentThread; + try + { + for (int i = 0; i < 100; i++) + { + Console::WriteLine("{0} {1}", Name, i.ToString()); + Thread::Sleep(1); + } + return; + } + catch (ThreadAbortException^) + { + Console::WriteLine("{0} Aborted", Name); + // Reset the abort so that the method will continue processing + // thr->ResetAbort(); + } +} + +void main() +{ + Console::WriteLine("Main Program Starts"); + + Thread ^thr1 = + gcnew Thread(gcnew ParameterizedThreadStart(&MyThread::ThreadFunc)); + Thread ^thr2 = + gcnew Thread(gcnew ParameterizedThreadStart(&MyThread::ThreadFunc)); + + thr1->Start("Thread1"); + thr2->Start("Thread2"); + + Thread::Sleep(2); + thr1->Abort(); + Thread::Sleep(4); + thr2->Abort(); + + + try + { + thr1->Start(); + } + catch (ThreadStateException ^tse) + { + Console::WriteLine(tse->ToString()); + } + Console::WriteLine("Main Program Ends"); +} diff --git a/Chapter18/AbortingThreads/AbortingThreads.vcproj b/Chapter18/AbortingThreads/AbortingThreads.vcproj new file mode 100644 index 0000000..d72436e --- /dev/null +++ b/Chapter18/AbortingThreads/AbortingThreads.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/Chapter18.sln b/Chapter18/Chapter18.sln new file mode 100644 index 0000000..b354d42 --- /dev/null +++ b/Chapter18/Chapter18.sln @@ -0,0 +1,86 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StartingThreads", "StartingThreads\StartingThreads.vcproj", "{A99CEE53-4434-4F68-9D60-BD5D38BBD505}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SleepingThreads", "SleepingThreads\SleepingThreads.vcproj", "{07803E35-27EB-4D4E-A95E-20CB9D135A7A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AbortingThreads", "AbortingThreads\AbortingThreads.vcproj", "{CAF6000F-0633-46A1-AD57-A45706705163}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JoiningThreads", "JoiningThreads\JoiningThreads.vcproj", "{548B55E0-2A30-45ED-8F2B-6796431A4274}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ISRingThreads", "ISRingThreads\ISRingThreads.vcproj", "{4EC08FA0-9371-45D8-BA1E-BF3540E0F2BE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ThreadPooling", "ThreadPooling\ThreadPooling.vcproj", "{AD461FFB-AB8D-4D2B-A013-6D569CCE6881}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ThreadStaticVars", "ThreadStaticVars\ThreadStaticVars.vcproj", "{B8882300-3C98-4C7A-AD87-3060DCFE6C96}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InterlockedVars", "InterlockedVars\InterlockedVars.vcproj", "{E665F1F9-E201-4995-A315-33B59707EB32}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SyncByMonitor", "SyncByMonitor\SyncByMonitor.vcproj", "{A39D45C8-AF6E-4E29-951C-FCA39ED899FD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MutexSpawn", "MutexSpawn\MutexSpawn.vcproj", "{F1DD4CB4-4854-4A42-8222-C341D5B7F476}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SyncByMutex", "SyncByMutex\SyncByMutex.vcproj", "{5D062155-556F-4AC3-BF1B-0F97051F6307}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SyncByRWLock", "SyncByRWLock\SyncByRWLock.vcproj", "{56B8C299-88B5-40B0-9C79-A25FD9A25F85}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A99CEE53-4434-4F68-9D60-BD5D38BBD505}.Debug|Win32.ActiveCfg = Debug|Win32 + {A99CEE53-4434-4F68-9D60-BD5D38BBD505}.Debug|Win32.Build.0 = Debug|Win32 + {A99CEE53-4434-4F68-9D60-BD5D38BBD505}.Release|Win32.ActiveCfg = Release|Win32 + {A99CEE53-4434-4F68-9D60-BD5D38BBD505}.Release|Win32.Build.0 = Release|Win32 + {07803E35-27EB-4D4E-A95E-20CB9D135A7A}.Debug|Win32.ActiveCfg = Debug|Win32 + {07803E35-27EB-4D4E-A95E-20CB9D135A7A}.Debug|Win32.Build.0 = Debug|Win32 + {07803E35-27EB-4D4E-A95E-20CB9D135A7A}.Release|Win32.ActiveCfg = Release|Win32 + {07803E35-27EB-4D4E-A95E-20CB9D135A7A}.Release|Win32.Build.0 = Release|Win32 + {CAF6000F-0633-46A1-AD57-A45706705163}.Debug|Win32.ActiveCfg = Debug|Win32 + {CAF6000F-0633-46A1-AD57-A45706705163}.Debug|Win32.Build.0 = Debug|Win32 + {CAF6000F-0633-46A1-AD57-A45706705163}.Release|Win32.ActiveCfg = Release|Win32 + {CAF6000F-0633-46A1-AD57-A45706705163}.Release|Win32.Build.0 = Release|Win32 + {548B55E0-2A30-45ED-8F2B-6796431A4274}.Debug|Win32.ActiveCfg = Debug|Win32 + {548B55E0-2A30-45ED-8F2B-6796431A4274}.Debug|Win32.Build.0 = Debug|Win32 + {548B55E0-2A30-45ED-8F2B-6796431A4274}.Release|Win32.ActiveCfg = Release|Win32 + {548B55E0-2A30-45ED-8F2B-6796431A4274}.Release|Win32.Build.0 = Release|Win32 + {4EC08FA0-9371-45D8-BA1E-BF3540E0F2BE}.Debug|Win32.ActiveCfg = Debug|Win32 + {4EC08FA0-9371-45D8-BA1E-BF3540E0F2BE}.Debug|Win32.Build.0 = Debug|Win32 + {4EC08FA0-9371-45D8-BA1E-BF3540E0F2BE}.Release|Win32.ActiveCfg = Release|Win32 + {4EC08FA0-9371-45D8-BA1E-BF3540E0F2BE}.Release|Win32.Build.0 = Release|Win32 + {AD461FFB-AB8D-4D2B-A013-6D569CCE6881}.Debug|Win32.ActiveCfg = Debug|Win32 + {AD461FFB-AB8D-4D2B-A013-6D569CCE6881}.Debug|Win32.Build.0 = Debug|Win32 + {AD461FFB-AB8D-4D2B-A013-6D569CCE6881}.Release|Win32.ActiveCfg = Release|Win32 + {AD461FFB-AB8D-4D2B-A013-6D569CCE6881}.Release|Win32.Build.0 = Release|Win32 + {B8882300-3C98-4C7A-AD87-3060DCFE6C96}.Debug|Win32.ActiveCfg = Debug|Win32 + {B8882300-3C98-4C7A-AD87-3060DCFE6C96}.Debug|Win32.Build.0 = Debug|Win32 + {B8882300-3C98-4C7A-AD87-3060DCFE6C96}.Release|Win32.ActiveCfg = Release|Win32 + {B8882300-3C98-4C7A-AD87-3060DCFE6C96}.Release|Win32.Build.0 = Release|Win32 + {E665F1F9-E201-4995-A315-33B59707EB32}.Debug|Win32.ActiveCfg = Debug|Win32 + {E665F1F9-E201-4995-A315-33B59707EB32}.Debug|Win32.Build.0 = Debug|Win32 + {E665F1F9-E201-4995-A315-33B59707EB32}.Release|Win32.ActiveCfg = Release|Win32 + {E665F1F9-E201-4995-A315-33B59707EB32}.Release|Win32.Build.0 = Release|Win32 + {A39D45C8-AF6E-4E29-951C-FCA39ED899FD}.Debug|Win32.ActiveCfg = Debug|Win32 + {A39D45C8-AF6E-4E29-951C-FCA39ED899FD}.Debug|Win32.Build.0 = Debug|Win32 + {A39D45C8-AF6E-4E29-951C-FCA39ED899FD}.Release|Win32.ActiveCfg = Release|Win32 + {A39D45C8-AF6E-4E29-951C-FCA39ED899FD}.Release|Win32.Build.0 = Release|Win32 + {F1DD4CB4-4854-4A42-8222-C341D5B7F476}.Debug|Win32.ActiveCfg = Debug|Win32 + {F1DD4CB4-4854-4A42-8222-C341D5B7F476}.Debug|Win32.Build.0 = Debug|Win32 + {F1DD4CB4-4854-4A42-8222-C341D5B7F476}.Release|Win32.ActiveCfg = Release|Win32 + {F1DD4CB4-4854-4A42-8222-C341D5B7F476}.Release|Win32.Build.0 = Release|Win32 + {5D062155-556F-4AC3-BF1B-0F97051F6307}.Debug|Win32.ActiveCfg = Debug|Win32 + {5D062155-556F-4AC3-BF1B-0F97051F6307}.Debug|Win32.Build.0 = Debug|Win32 + {5D062155-556F-4AC3-BF1B-0F97051F6307}.Release|Win32.ActiveCfg = Release|Win32 + {5D062155-556F-4AC3-BF1B-0F97051F6307}.Release|Win32.Build.0 = Release|Win32 + {56B8C299-88B5-40B0-9C79-A25FD9A25F85}.Debug|Win32.ActiveCfg = Debug|Win32 + {56B8C299-88B5-40B0-9C79-A25FD9A25F85}.Debug|Win32.Build.0 = Debug|Win32 + {56B8C299-88B5-40B0-9C79-A25FD9A25F85}.Release|Win32.ActiveCfg = Release|Win32 + {56B8C299-88B5-40B0-9C79-A25FD9A25F85}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter18/Chapter18.suo b/Chapter18/Chapter18.suo new file mode 100644 index 0000000..0f6395d Binary files /dev/null and b/Chapter18/Chapter18.suo differ diff --git a/Chapter18/ISRingThreads/ISRingThreads.cpp b/Chapter18/ISRingThreads/ISRingThreads.cpp new file mode 100644 index 0000000..f7c129c --- /dev/null +++ b/Chapter18/ISRingThreads/ISRingThreads.cpp @@ -0,0 +1,61 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ +public: + static void ThreadFunc1(); + static void ThreadFunc2(); +}; + +void MyThread::ThreadFunc1() +{ + Console::WriteLine("Before long sleep"); + try + { + Thread::Sleep(Timeout::Infinite); + } + catch(ThreadInterruptedException^){/*continue processing*/} + Console::WriteLine("After long sleep"); +} + +void MyThread::ThreadFunc2() +{ + for (int i = 0; i < 5; i++) + { + Console::WriteLine("Thread {0}",i.ToString()); + Thread::Sleep(2); + } +} + +void main() +{ + Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc1)); + Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc2)); + + Console::WriteLine("Sleep/interrupt thread"); + thr1->Start(); + + + Thread::Sleep(4); + for (int i = 0; i < 4; i++) + { + Console::WriteLine("**Main2 {0}", i.ToString()); + Thread::Sleep(2); + } + thr1->Interrupt(); + thr1->Join(); + + Console::WriteLine("\nSuspend/resume thread"); + thr2->Start(); + + Thread::Sleep(4); + thr2->Suspend(); + + for (int i = 0; i < 4; i++) + { + Console::WriteLine("**Main1 {0}", i.ToString()); + Thread::Sleep(2); + } + thr2->Resume(); +} diff --git a/Chapter18/ISRingThreads/ISRingThreads.vcproj b/Chapter18/ISRingThreads/ISRingThreads.vcproj new file mode 100644 index 0000000..ea9b227 --- /dev/null +++ b/Chapter18/ISRingThreads/ISRingThreads.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/InterlockedVars/InterlockedVars.cpp b/Chapter18/InterlockedVars/InterlockedVars.cpp new file mode 100644 index 0000000..14a2c91 --- /dev/null +++ b/Chapter18/InterlockedVars/InterlockedVars.cpp @@ -0,0 +1,44 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ + static int iVal; + +public: + + static MyThread() + { + iVal = 5; + } + + void ThreadFunc(); +}; + +void MyThread::ThreadFunc() +{ + while (Interlocked::Increment(iVal) < 15) + { + Thread ^thr = Thread::CurrentThread; + Console::WriteLine("{0} {1}", thr->Name, iVal); + Thread::Sleep(1); + } +} + + +void main() +{ + MyThread ^myThr1 = gcnew MyThread(); + + Thread ^thr1 = + gcnew Thread(gcnew ThreadStart(myThr1, &MyThread::ThreadFunc)); + Thread ^thr2 = + gcnew Thread(gcnew ThreadStart(myThr1, &MyThread::ThreadFunc)); + + + thr1->Name = "Thread1"; + thr2->Name = "Thread2"; + + thr1->Start(); + thr2->Start(); +} diff --git a/Chapter18/InterlockedVars/InterlockedVars.vcproj b/Chapter18/InterlockedVars/InterlockedVars.vcproj new file mode 100644 index 0000000..6404b54 --- /dev/null +++ b/Chapter18/InterlockedVars/InterlockedVars.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/JoiningThreads/JoiningThreads.cpp b/Chapter18/JoiningThreads/JoiningThreads.cpp new file mode 100644 index 0000000..da3911d --- /dev/null +++ b/Chapter18/JoiningThreads/JoiningThreads.cpp @@ -0,0 +1,34 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ +public: + static void ThreadFunc(Object ^Name); +}; + +void MyThread::ThreadFunc(Object ^Name) +{ + for (int i = 0; i < 5; i++) + { + Console::WriteLine("{0} {1}", Name, i.ToString()); + Thread::Sleep(1); + } +} + +void main() +{ + Console::WriteLine("Before starting thread"); + + Thread ^thr1 = + gcnew Thread(gcnew ParameterizedThreadStart(&MyThread::ThreadFunc)); + Thread ^thr2 = + gcnew Thread(gcnew ParameterizedThreadStart(&MyThread::ThreadFunc)); + + thr1->Start("Thread1"); + thr1->Join(); + + thr2->Start("Thread2"); + + Console::WriteLine("End of Main"); +} diff --git a/Chapter18/JoiningThreads/JoiningThreads.vcproj b/Chapter18/JoiningThreads/JoiningThreads.vcproj new file mode 100644 index 0000000..1e35ff3 --- /dev/null +++ b/Chapter18/JoiningThreads/JoiningThreads.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/MutexSpawn/MutexSpawn.cpp b/Chapter18/MutexSpawn/MutexSpawn.cpp new file mode 100644 index 0000000..93f1d63 --- /dev/null +++ b/Chapter18/MutexSpawn/MutexSpawn.cpp @@ -0,0 +1,23 @@ +using namespace System; +using namespace System::Diagnostics; +using namespace System::Threading; + + +void main() +{ + Process^ proc1 = gcnew Process(); + proc1->StartInfo->FileName = "../debug/SyncByMutex.exe"; + proc1->StartInfo->Arguments = "1"; + proc1->StartInfo->UseShellExecute = false; + proc1->StartInfo->RedirectStandardInput = true; + proc1->Start(); + + Process^ proc2 = gcnew Process(); + proc2->StartInfo->FileName = "../debug/SyncByMutex.exe"; + proc2->StartInfo->Arguments = "2"; + proc2->StartInfo->UseShellExecute = false; + proc2->StartInfo->RedirectStandardInput = true; + proc2->Start(); + + Thread::Sleep(5000); // Added just to clean up console display +} diff --git a/Chapter18/MutexSpawn/MutexSpawn.vcproj b/Chapter18/MutexSpawn/MutexSpawn.vcproj new file mode 100644 index 0000000..70aa943 --- /dev/null +++ b/Chapter18/MutexSpawn/MutexSpawn.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/SleepingThreads/SleepingThreads.cpp b/Chapter18/SleepingThreads/SleepingThreads.cpp new file mode 100644 index 0000000..13f0e1e --- /dev/null +++ b/Chapter18/SleepingThreads/SleepingThreads.cpp @@ -0,0 +1,41 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ +public: + static void ThreadFunc(); +}; + +void MyThread::ThreadFunc() +{ + String ^threadName = Thread::CurrentThread->Name; + for (int i = 0; i < 101; i++) + { + if (i % 10 == 0) + Console::WriteLine("{0} {1}", threadName, i.ToString()); + Thread::Sleep(10); + } +} + +void main() +{ + Console::WriteLine("Main Program Starts"); + + Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc)); + Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc)); + + thr1->Name = "Thread1"; + thr2->Name = "Thread2"; + + thr1->Start(); + thr2->Start(); + + int iHour = 0; + int iMin = 0; + int iSec = 1; + Thread::Sleep(TimeSpan(iHour, iMin, iSec)); + + Console::WriteLine("Main Program Ends"); +} + diff --git a/Chapter18/SleepingThreads/SleepingThreads.vcproj b/Chapter18/SleepingThreads/SleepingThreads.vcproj new file mode 100644 index 0000000..27046ec --- /dev/null +++ b/Chapter18/SleepingThreads/SleepingThreads.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/StartingThreads/StartingThreads.cpp b/Chapter18/StartingThreads/StartingThreads.cpp new file mode 100644 index 0000000..69731ab --- /dev/null +++ b/Chapter18/StartingThreads/StartingThreads.cpp @@ -0,0 +1,56 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ +public: + static void StaticThread(); + void NonStaticThread(Object ^name); +}; + +void MyThread::StaticThread() +{ + for (int i = 0; i < 50000001; i++) + { + if (i % 10000000 == 0) + Console::WriteLine("Static Thread {0}", i.ToString()); + } +} + +void MyThread::NonStaticThread(Object ^name) +{ + for (int i = 0; i < 50000001; i++) + { + + if (i % 10000000 == 0) + Console::WriteLine("Member {0} Thread {1}", + name, // Parameter passed + i.ToString()); + } +} + +void main() +{ + Console::WriteLine("Main Program Starts"); + + // Creating a thread start delegate for a static method + ThreadStart ^thrStart = gcnew ThreadStart(&MyThread::StaticThread); + // Use the ThreadStart to create a Thread handle Object + Thread ^thr1 = gcnew Thread(thrStart); + + MyThread ^myThr = gcnew MyThread(); + // Creating a Thread reference object in one line from a member method + Thread ^thr2 = gcnew Thread( + gcnew ParameterizedThreadStart(myThr, &MyThread::NonStaticThread)); + +// Uncomment for background vs foreground exploration +// thr1->IsBackground = true; +// thr2->IsBackground = true; + + // Actually starting the threads + thr1->Start(); + thr2->Start("Parameterized"); + + Console::WriteLine("Main Program Ends"); +} + diff --git a/Chapter18/StartingThreads/StartingThreads.vcproj b/Chapter18/StartingThreads/StartingThreads.vcproj new file mode 100644 index 0000000..e3185d7 --- /dev/null +++ b/Chapter18/StartingThreads/StartingThreads.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/SyncByMonitor/SyncByMonitor.cpp b/Chapter18/SyncByMonitor/SyncByMonitor.cpp new file mode 100644 index 0000000..93e2eb4 --- /dev/null +++ b/Chapter18/SyncByMonitor/SyncByMonitor.cpp @@ -0,0 +1,78 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ + static Object^ MonitorObject = gcnew Object(); + +public: + void TFuncOne(); + void TFuncTwo(); + void TFuncThree(); +}; + + +void MyThread::TFuncOne() +{ + Console::WriteLine("TFuncOne enters monitor"); + Monitor::Enter(MonitorObject); + for (Int32 i = 0; i < 3; i++) + { + Console::WriteLine("TFuncOne Waits {0}", i.ToString()); + Monitor::Wait(MonitorObject); + Console::WriteLine("TFuncOne Pulses {0}", i.ToString()); + Monitor::Pulse(MonitorObject); + Thread::Sleep(1); + } + Monitor::Exit(MonitorObject); + Console::WriteLine("TFuncOne exits monitor"); +} + +void MyThread::TFuncTwo() +{ + Console::WriteLine("TFuncTwo enters monitor"); + Monitor::Enter(MonitorObject); + for (Int32 i = 0; i < 3; i++) + { + Console::WriteLine("TFuncTwo Pulses {0}", i.ToString()); + Monitor::Pulse(MonitorObject); + Thread::Sleep(1); + Console::WriteLine("TFuncTwo Waits {0}", i.ToString()); + Monitor::Wait(MonitorObject); + } + Monitor::Exit(MonitorObject); + Console::WriteLine("TFuncTwo exits monitor"); +} + +void MyThread::TFuncThree() +{ + if (!Monitor::TryEnter(MonitorObject)) + { + Console::WriteLine("TFuncThree was not able to lock"); + return; + } + Console::WriteLine("TFuncThree got a lock"); + + Monitor::Exit(MonitorObject); + Console::WriteLine("TFuncThree exits monitor"); +} + + +void main() +{ + MyThread ^myThr1 = gcnew MyThread(); + + (gcnew Thread(gcnew ThreadStart(myThr1, &MyThread::TFuncOne)))->Start(); + Thread::Sleep(2); + + + (gcnew Thread(gcnew ThreadStart(myThr1, &MyThread::TFuncTwo)))->Start(); + Thread::Sleep(2); + + for (int i = 0; i < 2; i++) + { + (gcnew Thread( + gcnew ThreadStart(myThr1, &MyThread::TFuncThree)))->Start(); + Thread::Sleep(50); + } +} diff --git a/Chapter18/SyncByMonitor/SyncByMonitor.vcproj b/Chapter18/SyncByMonitor/SyncByMonitor.vcproj new file mode 100644 index 0000000..bdf9328 --- /dev/null +++ b/Chapter18/SyncByMonitor/SyncByMonitor.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/SyncByMutex/SyncByMutex.cpp b/Chapter18/SyncByMutex/SyncByMutex.cpp new file mode 100644 index 0000000..164bb4b --- /dev/null +++ b/Chapter18/SyncByMutex/SyncByMutex.cpp @@ -0,0 +1,45 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ + static Mutex ^m = gcnew Mutex(false, "SyncByMutex"); +public: + static void ThreadFunc(); +}; + +void MyThread::ThreadFunc() +{ + Random^ Rand = gcnew Random; + + Thread ^thr = Thread::CurrentThread; + + for (int i = 0; i < 4; i++) + { + m->WaitOne(); + + Console::WriteLine("{0} Enter - {1}", thr->Name, i); + Thread::Sleep(Rand->Next(20, 100)); // Simulate Work + Console::WriteLine("{0} Exit - {1}", thr->Name, i); + m->ReleaseMutex(); + + Thread::Sleep(Rand->Next(20, 100)); + } +} + +int main(int argc, char *argv[]) +{ + MyThread ^myThr = gcnew MyThread(); + + Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc)); + Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&MyThread::ThreadFunc)); + + thr1->Name = + String::Format("Process {0} - Thread 1", gcnew String(argv[1])); + thr2->Name = + String::Format("Process {0} - Thread 2", gcnew String(argv[1])); + + thr1->Start(); + Thread::Sleep(50); + thr2->Start(); +} diff --git a/Chapter18/SyncByMutex/SyncByMutex.vcproj b/Chapter18/SyncByMutex/SyncByMutex.vcproj new file mode 100644 index 0000000..d46ded2 --- /dev/null +++ b/Chapter18/SyncByMutex/SyncByMutex.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/SyncByRWLock/SyncByRWLock.cpp b/Chapter18/SyncByRWLock/SyncByRWLock.cpp new file mode 100644 index 0000000..a92cb64 --- /dev/null +++ b/Chapter18/SyncByRWLock/SyncByRWLock.cpp @@ -0,0 +1,68 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ + static ReaderWriterLock ^RWLock = gcnew ReaderWriterLock(); + static int iVal = 4; + +public: + static void ReaderThread(); + static void WriterThread(); +}; + +void MyThread::ReaderThread() +{ + String ^thrName = Thread::CurrentThread->Name; + while (true) + { + try + { + RWLock->AcquireReaderLock(2); + + Console::WriteLine("Reading in {0}. iVal is {1}", + thrName, iVal); + + RWLock->ReleaseReaderLock(); + Thread::Sleep(4); + } + catch (ApplicationException^) + { + Console::WriteLine("Reading in {0}. Timed out", thrName); + } + } +} + +void MyThread::WriterThread() +{ + while (iVal > 0) + { + RWLock->AcquireWriterLock(-1); + + Interlocked::Decrement(iVal); + Console::WriteLine("Writing iVal to {0}", iVal); + Thread::Sleep(7); + + RWLock->ReleaseWriterLock(); + } +} + +void main() +{ + Thread ^thr1 = gcnew Thread(gcnew ThreadStart(&MyThread::ReaderThread)); + Thread ^thr2 = gcnew Thread(gcnew ThreadStart(&MyThread::ReaderThread)); + Thread ^thr3 = gcnew Thread(gcnew ThreadStart(&MyThread::WriterThread)); + + thr1->Name = "Thread1"; + thr2->Name = "Thread2"; + + thr1->IsBackground = true; + thr2->IsBackground = true; + + thr1->Start(); + thr2->Start(); + thr3->Start(); + + thr3->Join(); + Thread::Sleep(2); +} diff --git a/Chapter18/SyncByRWLock/SyncByRWLock.vcproj b/Chapter18/SyncByRWLock/SyncByRWLock.vcproj new file mode 100644 index 0000000..87ac439 --- /dev/null +++ b/Chapter18/SyncByRWLock/SyncByRWLock.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/ThreadPooling/ThreadPooling.cpp b/Chapter18/ThreadPooling/ThreadPooling.cpp new file mode 100644 index 0000000..a24b6bf --- /dev/null +++ b/Chapter18/ThreadPooling/ThreadPooling.cpp @@ -0,0 +1,33 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ +public: + void ThreadFunc(Object^ stateInfo); +}; + +void MyThread::ThreadFunc(Object^ stateInfo) +{ + for (int i = 0; i < 10; i++) + { + Console::WriteLine("{0} {1}", stateInfo, i.ToString()); + Thread::Sleep(100); + } +} + + +void main() +{ + Console::WriteLine("Main Program Starts"); + + MyThread ^myThr1 = gcnew MyThread(); + + ThreadPool::QueueUserWorkItem( + gcnew WaitCallback(myThr1, &MyThread::ThreadFunc), "Thread1"); + ThreadPool::QueueUserWorkItem( + gcnew WaitCallback(myThr1, &MyThread::ThreadFunc), "Thread2"); + + Thread::Sleep(2000); + Console::WriteLine("Main Program Ends"); +} diff --git a/Chapter18/ThreadPooling/ThreadPooling.vcproj b/Chapter18/ThreadPooling/ThreadPooling.vcproj new file mode 100644 index 0000000..f3a5246 --- /dev/null +++ b/Chapter18/ThreadPooling/ThreadPooling.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter18/ThreadStaticVars/ThreadStaticVars.cpp b/Chapter18/ThreadStaticVars/ThreadStaticVars.cpp new file mode 100644 index 0000000..8fa072e --- /dev/null +++ b/Chapter18/ThreadStaticVars/ThreadStaticVars.cpp @@ -0,0 +1,62 @@ +using namespace System; +using namespace System::Threading; + +ref class MyThread +{ +public: + + [ThreadStatic] + static int ^iVal; + +public: + static MyThread() + { + iVal = gcnew int; + } + + void ThreadFunc(); + void SubThreadFunc(); +}; + +void MyThread::ThreadFunc() +{ + iVal = gcnew int; + iVal = 7; + + SubThreadFunc(); +} + +void MyThread::SubThreadFunc() +{ + int max = *iVal + 5; + + while (*iVal < max) + { + Thread ^thr = Thread::CurrentThread; + Console::WriteLine("{0} {1}", thr->Name, iVal->ToString()); + Thread::Sleep(1); + (*iVal)++; + } +} + +void main() +{ + Console::WriteLine("Before starting thread"); + + MyThread ^myThr1 = gcnew MyThread(); + + Thread ^thr1 = + gcnew Thread(gcnew ThreadStart(myThr1, &MyThread::ThreadFunc)); + Thread ^thr2 = + gcnew Thread(gcnew ThreadStart(myThr1, &MyThread::ThreadFunc)); + + Thread::CurrentThread->Name = "Main"; + thr1->Name = "Thread1"; + thr2->Name = "Thread2"; + + thr1->Start(); + thr2->Start(); + + myThr1->iVal = 5; + myThr1->SubThreadFunc(); +} diff --git a/Chapter18/ThreadStaticVars/ThreadStaticVars.vcproj b/Chapter18/ThreadStaticVars/ThreadStaticVars.vcproj new file mode 100644 index 0000000..b1e70f7 --- /dev/null +++ b/Chapter18/ThreadStaticVars/ThreadStaticVars.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/Chapter19.sln b/Chapter19/Chapter19.sln new file mode 100644 index 0000000..c0565cc --- /dev/null +++ b/Chapter19/Chapter19.sln @@ -0,0 +1,86 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TcpServer", "TcpServer\TcpServer.vcproj", "{894335C1-46D2-417D-A63D-460A40BDC510}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TcpClient", "TcpClient\TcpClient.vcproj", "{F096312A-1CD5-4A6D-8639-68C51212E706}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UdpServer", "UdpServer\UdpServer.vcproj", "{B5779AF4-8089-4696-8F9B-14E0F420F66B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UdpClient", "UdpClient\UdpClient.vcproj", "{B70DDDAE-7153-402F-94A3-C5D077396B29}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TcpServer_Listener", "TcpServer_Listener\TcpServer_Listener.vcproj", "{1C445626-EE0A-444D-BD2F-3A09FCB9E7E6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UdpClient_Connect", "UdpClient_Connect\UdpClient_Connect.vcproj", "{D700519B-9CBC-4AC2-892D-7449468D6147}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TcpServer_Stream", "TcpServer_Stream\TcpServer_Stream.vcproj", "{7C432E77-04B4-4197-9A9B-4E5BAD06FD98}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TcpClient_Stream", "TcpClient_Stream\TcpClient_Stream.vcproj", "{29DEDC2D-2C15-4544-9DDB-614E784BF3C7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UdpServer_Helper", "UdpServer_Helper\UdpServer_Helper.vcproj", "{90792D6C-8986-4CD2-823A-91CDBFF92E63}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UdpClient_Helper", "UdpClient_Helper\UdpClient_Helper.vcproj", "{E41EF41A-7BFB-42F6-A1FD-5B4D372096F1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UdpClient_Timeout", "UdpClient_Timeout\UdpClient_Timeout.vcproj", "{5B85B247-18E4-4C25-B946-C9215A0EB90A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TcpServer_Async", "TcpServer_Async\TcpServer_Async.vcproj", "{ECBB86F7-DECB-41F1-A3E4-24329E132D1E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {894335C1-46D2-417D-A63D-460A40BDC510}.Debug|Win32.ActiveCfg = Debug|Win32 + {894335C1-46D2-417D-A63D-460A40BDC510}.Debug|Win32.Build.0 = Debug|Win32 + {894335C1-46D2-417D-A63D-460A40BDC510}.Release|Win32.ActiveCfg = Release|Win32 + {894335C1-46D2-417D-A63D-460A40BDC510}.Release|Win32.Build.0 = Release|Win32 + {F096312A-1CD5-4A6D-8639-68C51212E706}.Debug|Win32.ActiveCfg = Debug|Win32 + {F096312A-1CD5-4A6D-8639-68C51212E706}.Debug|Win32.Build.0 = Debug|Win32 + {F096312A-1CD5-4A6D-8639-68C51212E706}.Release|Win32.ActiveCfg = Release|Win32 + {F096312A-1CD5-4A6D-8639-68C51212E706}.Release|Win32.Build.0 = Release|Win32 + {B5779AF4-8089-4696-8F9B-14E0F420F66B}.Debug|Win32.ActiveCfg = Debug|Win32 + {B5779AF4-8089-4696-8F9B-14E0F420F66B}.Debug|Win32.Build.0 = Debug|Win32 + {B5779AF4-8089-4696-8F9B-14E0F420F66B}.Release|Win32.ActiveCfg = Release|Win32 + {B5779AF4-8089-4696-8F9B-14E0F420F66B}.Release|Win32.Build.0 = Release|Win32 + {B70DDDAE-7153-402F-94A3-C5D077396B29}.Debug|Win32.ActiveCfg = Debug|Win32 + {B70DDDAE-7153-402F-94A3-C5D077396B29}.Debug|Win32.Build.0 = Debug|Win32 + {B70DDDAE-7153-402F-94A3-C5D077396B29}.Release|Win32.ActiveCfg = Release|Win32 + {B70DDDAE-7153-402F-94A3-C5D077396B29}.Release|Win32.Build.0 = Release|Win32 + {1C445626-EE0A-444D-BD2F-3A09FCB9E7E6}.Debug|Win32.ActiveCfg = Debug|Win32 + {1C445626-EE0A-444D-BD2F-3A09FCB9E7E6}.Debug|Win32.Build.0 = Debug|Win32 + {1C445626-EE0A-444D-BD2F-3A09FCB9E7E6}.Release|Win32.ActiveCfg = Release|Win32 + {1C445626-EE0A-444D-BD2F-3A09FCB9E7E6}.Release|Win32.Build.0 = Release|Win32 + {D700519B-9CBC-4AC2-892D-7449468D6147}.Debug|Win32.ActiveCfg = Debug|Win32 + {D700519B-9CBC-4AC2-892D-7449468D6147}.Debug|Win32.Build.0 = Debug|Win32 + {D700519B-9CBC-4AC2-892D-7449468D6147}.Release|Win32.ActiveCfg = Release|Win32 + {D700519B-9CBC-4AC2-892D-7449468D6147}.Release|Win32.Build.0 = Release|Win32 + {7C432E77-04B4-4197-9A9B-4E5BAD06FD98}.Debug|Win32.ActiveCfg = Debug|Win32 + {7C432E77-04B4-4197-9A9B-4E5BAD06FD98}.Debug|Win32.Build.0 = Debug|Win32 + {7C432E77-04B4-4197-9A9B-4E5BAD06FD98}.Release|Win32.ActiveCfg = Release|Win32 + {7C432E77-04B4-4197-9A9B-4E5BAD06FD98}.Release|Win32.Build.0 = Release|Win32 + {29DEDC2D-2C15-4544-9DDB-614E784BF3C7}.Debug|Win32.ActiveCfg = Debug|Win32 + {29DEDC2D-2C15-4544-9DDB-614E784BF3C7}.Debug|Win32.Build.0 = Debug|Win32 + {29DEDC2D-2C15-4544-9DDB-614E784BF3C7}.Release|Win32.ActiveCfg = Release|Win32 + {29DEDC2D-2C15-4544-9DDB-614E784BF3C7}.Release|Win32.Build.0 = Release|Win32 + {90792D6C-8986-4CD2-823A-91CDBFF92E63}.Debug|Win32.ActiveCfg = Debug|Win32 + {90792D6C-8986-4CD2-823A-91CDBFF92E63}.Debug|Win32.Build.0 = Debug|Win32 + {90792D6C-8986-4CD2-823A-91CDBFF92E63}.Release|Win32.ActiveCfg = Release|Win32 + {90792D6C-8986-4CD2-823A-91CDBFF92E63}.Release|Win32.Build.0 = Release|Win32 + {E41EF41A-7BFB-42F6-A1FD-5B4D372096F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {E41EF41A-7BFB-42F6-A1FD-5B4D372096F1}.Debug|Win32.Build.0 = Debug|Win32 + {E41EF41A-7BFB-42F6-A1FD-5B4D372096F1}.Release|Win32.ActiveCfg = Release|Win32 + {E41EF41A-7BFB-42F6-A1FD-5B4D372096F1}.Release|Win32.Build.0 = Release|Win32 + {5B85B247-18E4-4C25-B946-C9215A0EB90A}.Debug|Win32.ActiveCfg = Debug|Win32 + {5B85B247-18E4-4C25-B946-C9215A0EB90A}.Debug|Win32.Build.0 = Debug|Win32 + {5B85B247-18E4-4C25-B946-C9215A0EB90A}.Release|Win32.ActiveCfg = Release|Win32 + {5B85B247-18E4-4C25-B946-C9215A0EB90A}.Release|Win32.Build.0 = Release|Win32 + {ECBB86F7-DECB-41F1-A3E4-24329E132D1E}.Debug|Win32.ActiveCfg = Debug|Win32 + {ECBB86F7-DECB-41F1-A3E4-24329E132D1E}.Debug|Win32.Build.0 = Debug|Win32 + {ECBB86F7-DECB-41F1-A3E4-24329E132D1E}.Release|Win32.ActiveCfg = Release|Win32 + {ECBB86F7-DECB-41F1-A3E4-24329E132D1E}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter19/Chapter19.suo b/Chapter19/Chapter19.suo new file mode 100644 index 0000000..e4bd748 Binary files /dev/null and b/Chapter19/Chapter19.suo differ diff --git a/Chapter19/TcpClient/TcpClient.cpp b/Chapter19/TcpClient/TcpClient.cpp new file mode 100644 index 0000000..9be84f5 --- /dev/null +++ b/Chapter19/TcpClient/TcpClient.cpp @@ -0,0 +1,46 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Threading; +using namespace System::Text; + +void main() +{ + Socket^ server = gcnew Socket(AddressFamily::InterNetwork, + SocketType::Stream, ProtocolType::Tcp); + try + { + IPEndPoint^ iped = + gcnew IPEndPoint(IPAddress::Parse("127.0.0.1"), 12345); + server->Connect(iped); + } + catch (SocketException^ se) + { + Console::WriteLine("Connection Failed with error: {0}", se->Message); + return; + } + + array^ msg = gcnew array(1024); + int rcv = server->Receive(msg); + + Console::WriteLine(Encoding::ASCII->GetString(msg, 0, rcv)); + + while (true) + { + Console::Write("Message ('q' to quit): "); + String^ input = Console::ReadLine(); + + if (input->ToLower()->Equals("q")) + break; + + msg = Encoding::ASCII->GetBytes(input); + server->Send(msg, msg->Length, SocketFlags::None); + + msg = gcnew array(1024); + rcv = server->Receive(msg); + Console::WriteLine(Encoding::ASCII->GetString(msg, 0, rcv)); + } + Console::WriteLine("Ended connection with server."); + server->Shutdown(SocketShutdown::Both); + server->Close(); +} diff --git a/Chapter19/TcpClient/TcpClient.vcproj b/Chapter19/TcpClient/TcpClient.vcproj new file mode 100644 index 0000000..131a284 --- /dev/null +++ b/Chapter19/TcpClient/TcpClient.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/TcpClient_Stream/TcpClient_Stream.cpp b/Chapter19/TcpClient_Stream/TcpClient_Stream.cpp new file mode 100644 index 0000000..39b59fc --- /dev/null +++ b/Chapter19/TcpClient_Stream/TcpClient_Stream.cpp @@ -0,0 +1,54 @@ +using namespace System; +using namespace System::IO; +using namespace System::Net; +using namespace System::Net::Sockets; + +void main() +{ + TcpClient^ server; + StreamWriter^ writer; + StreamReader^ reader; + String^ msg; + + try + { + server = gcnew TcpClient("127.0.0.1", 12345); + + writer = gcnew StreamWriter(server->GetStream()); + reader = gcnew StreamReader(server->GetStream()); + } + catch (SocketException^ se) + { + Console::WriteLine("Connection to server failed with error: {0}", + se->Message); + return; + } + + msg = reader->ReadLine(); + Console::WriteLine(msg); + + while (true) + { + Console::Write("Message ('q' to quit): "); + msg = Console::ReadLine(); + + if (msg->ToLower()->Equals("q")) + break; + + try + { + writer->WriteLine(msg); + writer->Flush(); + + msg = reader->ReadLine(); + Console::WriteLine(msg); + } + + catch (IOException^) + { + break; // connection lost + } + } + Console::WriteLine("Ended connection with server."); + server->Close(); +} \ No newline at end of file diff --git a/Chapter19/TcpClient_Stream/TcpClient_Stream.vcproj b/Chapter19/TcpClient_Stream/TcpClient_Stream.vcproj new file mode 100644 index 0000000..724a71e --- /dev/null +++ b/Chapter19/TcpClient_Stream/TcpClient_Stream.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/TcpServer/TcpServer.cpp b/Chapter19/TcpServer/TcpServer.cpp new file mode 100644 index 0000000..c4a4f85 --- /dev/null +++ b/Chapter19/TcpServer/TcpServer.cpp @@ -0,0 +1,68 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Threading; +using namespace System::Text; + +ref class TcpServer +{ +public: + void ProcessThread(Object ^clientObj); +}; + +void TcpServer::ProcessThread(Object ^clientObj) +{ + Socket^ client = (Socket^)clientObj; + IPEndPoint^ clientEP = (IPEndPoint^)client->RemoteEndPoint; + + Console::WriteLine("Connected on IP: {0} Port: {1}", + clientEP->Address, clientEP->Port); + + array^ msg = Encoding::ASCII->GetBytes( + String::Format("Successful connection to the server on port {0}", + clientEP->Port)); + client->Send(msg); + + int rcv; + while (true) + { + msg = gcnew array(1024); + + if ((rcv = client->Receive(msg)) == 0) + break; + + Console::WriteLine("Port[{0}] {1}", + clientEP->Port, Encoding::ASCII->GetString(msg, 0, rcv)); + + client->Send(msg, rcv, SocketFlags::None); + } + client->Close(); + Console::WriteLine("Connection to IP: {0} Port {1} closed.", + clientEP->Address, clientEP->Port); +} + +void main() +{ + TcpServer^ server = gcnew TcpServer(); + + Socket^ tcpListener = gcnew Socket(AddressFamily::InterNetwork, + SocketType::Stream, ProtocolType::Tcp); + + + IPEndPoint^ iped = gcnew IPEndPoint(IPAddress::Any, 12345); + tcpListener->Bind(iped); + + tcpListener->Listen((int)SocketOptionName::MaxConnections); + + + while(true) + { + Console::WriteLine("Waiting for client connection."); + Socket^ client = tcpListener->Accept(); + + Thread ^thr = gcnew Thread( + gcnew ParameterizedThreadStart(server, &TcpServer::ProcessThread)); + thr->Start(client); + } +} + diff --git a/Chapter19/TcpServer/TcpServer.vcproj b/Chapter19/TcpServer/TcpServer.vcproj new file mode 100644 index 0000000..93590f4 --- /dev/null +++ b/Chapter19/TcpServer/TcpServer.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/TcpServer_Async/TcpServer_Async.cpp b/Chapter19/TcpServer_Async/TcpServer_Async.cpp new file mode 100644 index 0000000..a563cc3 --- /dev/null +++ b/Chapter19/TcpServer_Async/TcpServer_Async.cpp @@ -0,0 +1,106 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Threading; + +using namespace System::Text; + +ref class StateObject +{ +public: + property int bufSize; + property Socket ^workSocket; + property array^ message; + + StateObject(Socket^ sock, int bufsize) + { + workSocket = sock; + bufSize = bufsize; + message = gcnew array(bufsize); + } +}; + +ref class TcpServer +{ +public: + static void AcceptCB(IAsyncResult^ iar); + static void SendCB(IAsyncResult^ iar); + static void ReceiveCB(IAsyncResult^ iar); +}; + +void TcpServer::AcceptCB(IAsyncResult^ iar) +{ + TcpListener^ tcpListener = (TcpListener^)iar->AsyncState; + Socket^ client = tcpListener->EndAcceptSocket(iar); + + IPEndPoint^ clientEP = (IPEndPoint^)client->RemoteEndPoint; + + Console::WriteLine("Connected on IP: {0} Port: {1}", + clientEP->Address, clientEP->Port); + + // Send socket successful connection message + array^ msg = Encoding::ASCII->GetBytes( + String::Format("Successful connection to the server on port {0}", + clientEP->Port)); + client->BeginSend(msg, 0, msg->Length, SocketFlags::None, + gcnew AsyncCallback(&TcpServer::SendCB), client); + + // Get message from client + StateObject^ so = gcnew StateObject(client, 1024); + client->BeginReceive(so->message, 0, so->bufSize, + SocketFlags::None, gcnew AsyncCallback(&TcpServer::ReceiveCB), so); + + // Get the next socket connection + Console::WriteLine("Waiting for client connections. [Return to Exit]"); + tcpListener->BeginAcceptSocket(gcnew AsyncCallback(&TcpServer::AcceptCB), + tcpListener); +} + + +void TcpServer::SendCB(IAsyncResult^ iar) +{ + Socket^ client = (Socket^)iar->AsyncState; + client->EndSend(iar); +} + +void TcpServer::ReceiveCB(IAsyncResult^ iar) +{ + StateObject^ so = (StateObject^)iar->AsyncState; + Socket^ client = so->workSocket; + IPEndPoint^ clientEP = (IPEndPoint^)client->RemoteEndPoint; + + int rcv; + if ((rcv = client->EndReceive(iar)) > 0) // get message + { + Console::WriteLine("Port[{0}] {1}", + clientEP->Port, Encoding::ASCII->GetString(so->message, 0, rcv)); + + // echo message + client->BeginSend(so->message, 0, rcv, SocketFlags::None, + gcnew AsyncCallback(&TcpServer::SendCB), client); + + // set up for next receive + so = gcnew StateObject(client, 1024); + client->BeginReceive(so->message, 0, so->bufSize, + SocketFlags::None, gcnew AsyncCallback(&TcpServer::ReceiveCB), so); + } + else // connection closed + { + client->Close(); + Console::WriteLine("Connection to IP: {0} Port {1} closed.", + clientEP->Address, clientEP->Port); + } +} + +void main() +{ + TcpListener^ socket = gcnew TcpListener(IPAddress::Any, 12345); + socket->Start(); + + Console::WriteLine("Waiting for client connections. [Return to Exit]"); + socket->BeginAcceptSocket(gcnew AsyncCallback(&TcpServer::AcceptCB), + socket); + + // Exit on return key + Console::ReadLine(); +} diff --git a/Chapter19/TcpServer_Async/TcpServer_Async.vcproj b/Chapter19/TcpServer_Async/TcpServer_Async.vcproj new file mode 100644 index 0000000..42d3cf8 --- /dev/null +++ b/Chapter19/TcpServer_Async/TcpServer_Async.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/TcpServer_Listener/TcpServer_Listener.cpp b/Chapter19/TcpServer_Listener/TcpServer_Listener.cpp new file mode 100644 index 0000000..28ddf74 --- /dev/null +++ b/Chapter19/TcpServer_Listener/TcpServer_Listener.cpp @@ -0,0 +1,60 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Threading; +using namespace System::Text; + +ref class TcpServer +{ +public: + void ProcessThread(Object ^clientObj); +}; + +void TcpServer::ProcessThread(Object ^clientObj) +{ + Socket^ client = (Socket^)clientObj; + IPEndPoint^ clientEP = (IPEndPoint^)client->RemoteEndPoint; + + Console::WriteLine("Connected on IP: {0} Port: {1}", + clientEP->Address, clientEP->Port); + + array^ msg = Encoding::ASCII->GetBytes( + String::Format("Successful connection to the server on port {0}", + clientEP->Port)); + client->Send(msg); + + int rcv; + while (true) + { + msg = gcnew array(1024); + + if ((rcv = client->Receive(msg)) == 0) + break; + + Console::WriteLine("Port[{0}] {1}", + clientEP->Port, Encoding::ASCII->GetString(msg, 0, rcv)); + + client->Send(msg, rcv, SocketFlags::None); + } + client->Close(); + Console::WriteLine("Connection to IP: {0} Port {1} closed.", + clientEP->Address, clientEP->Port); +} + +void main() +{ + TcpServer^ server = gcnew TcpServer(); + + TcpListener^ socket = gcnew TcpListener(IPAddress::Any, 12345); + socket->Start(); + + while(true) + { + Console::WriteLine("Waiting for client connection."); + Socket^ client = socket->AcceptSocket(); + + Thread ^thr = gcnew Thread( + gcnew ParameterizedThreadStart(server, &TcpServer::ProcessThread)); + thr->Start(client); + } +} diff --git a/Chapter19/TcpServer_Listener/TcpServer_Listener.vcproj b/Chapter19/TcpServer_Listener/TcpServer_Listener.vcproj new file mode 100644 index 0000000..f45f7da --- /dev/null +++ b/Chapter19/TcpServer_Listener/TcpServer_Listener.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/TcpServer_Stream/TcpServer_Stream.cpp b/Chapter19/TcpServer_Stream/TcpServer_Stream.cpp new file mode 100644 index 0000000..b546eda --- /dev/null +++ b/Chapter19/TcpServer_Stream/TcpServer_Stream.cpp @@ -0,0 +1,68 @@ +using namespace System; +using namespace System::IO; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Threading; + +ref class TcpServer +{ +public: + void ProcessThread(Object ^clientObj); +}; + +void TcpServer::ProcessThread(Object ^clientObj) +{ + TcpClient^ client = (TcpClient^)clientObj; + + IPEndPoint^ clientEP = (IPEndPoint^)client->Client->RemoteEndPoint; + + Console::WriteLine("Connected on IP: {0} Port: {1}", + clientEP->Address, clientEP->Port); + + StreamWriter^ writer = gcnew StreamWriter(client->GetStream()); + StreamReader^ reader = gcnew StreamReader(client->GetStream()); + + + writer->WriteLine("Successful connection to the server on port {0}", + clientEP->Port); + writer->Flush(); + + String^ msg; + while (true) + { + try + { + msg = reader->ReadLine(); + Console::WriteLine("Port[{0}] {1}", clientEP->Port, msg); + + writer->WriteLine(msg); + writer->Flush(); + } + catch (IOException^) + { + break; // connection lost + } + } + client->Close(); + + Console::WriteLine("Connection to IP: {0} Port {1} closed.", + clientEP->Address, clientEP->Port); +} + +void main() +{ + TcpServer^ server = gcnew TcpServer(); + + TcpListener^ socket = gcnew TcpListener(IPAddress::Any, 12345); + socket->Start(); + + while(true) + { + Console::WriteLine("Waiting for client connection."); + TcpClient^ client = socket->AcceptTcpClient(); + + Thread ^thr = gcnew Thread( + gcnew ParameterizedThreadStart(server, &TcpServer::ProcessThread)); + thr->Start(client); + } +} diff --git a/Chapter19/TcpServer_Stream/TcpServer_Stream.vcproj b/Chapter19/TcpServer_Stream/TcpServer_Stream.vcproj new file mode 100644 index 0000000..52fc33e --- /dev/null +++ b/Chapter19/TcpServer_Stream/TcpServer_Stream.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/UdpClient/UdpClient.cpp b/Chapter19/UdpClient/UdpClient.cpp new file mode 100644 index 0000000..f3a91aa --- /dev/null +++ b/Chapter19/UdpClient/UdpClient.cpp @@ -0,0 +1,34 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Text; + +void main() +{ + Socket^ socket = gcnew Socket(AddressFamily::InterNetwork, + SocketType::Dgram, ProtocolType::Udp); + +// IPEndPoint^ ipep = gcnew IPEndPoint(IPAddress::Any, 54322); +// socket->Bind(ipep); + + EndPoint^ Remote = gcnew IPEndPoint(IPAddress::Parse("127.0.0.1"), + 54321); + + while (true) + { + Console::Write("Message ('q' to quit): "); + String^ input = Console::ReadLine(); + + if (input->ToLower()->Equals("q")) + break; + + array^ message = Encoding::ASCII->GetBytes(input); + socket->SendTo(message, Remote); + + message = gcnew array(1024); + int recv = socket->ReceiveFrom(message, Remote); + Console::WriteLine("[{0}] {1}", + Remote->ToString(), Encoding::ASCII->GetString(message, 0, recv)); + } +} + diff --git a/Chapter19/UdpClient/UdpClient.vcproj b/Chapter19/UdpClient/UdpClient.vcproj new file mode 100644 index 0000000..4fa28d6 --- /dev/null +++ b/Chapter19/UdpClient/UdpClient.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/UdpClient_Connect/UdpClient_Connect.cpp b/Chapter19/UdpClient_Connect/UdpClient_Connect.cpp new file mode 100644 index 0000000..6b93bcc --- /dev/null +++ b/Chapter19/UdpClient_Connect/UdpClient_Connect.cpp @@ -0,0 +1,32 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Text; + +void main() +{ + Socket^ socket = gcnew Socket(AddressFamily::InterNetwork, + SocketType::Dgram, ProtocolType::Udp); + + EndPoint^ Remote = gcnew IPEndPoint(IPAddress::Parse("127.0.0.1"), + 54321); + socket->Connect(Remote); + + while (true) + { + Console::Write("Message ('q' to quit): "); + String^ input = Console::ReadLine(); + + if (input->ToLower()->Equals("q")) + break; + + array^ message = Encoding::ASCII->GetBytes(input); + socket->Send(message); + + message = gcnew array(1024); + int recv = socket->Receive(message); + + Console::WriteLine("[{0}] {1}", + Remote->ToString(), Encoding::ASCII->GetString(message, 0, recv)); + } +} \ No newline at end of file diff --git a/Chapter19/UdpClient_Connect/UdpClient_Connect.vcproj b/Chapter19/UdpClient_Connect/UdpClient_Connect.vcproj new file mode 100644 index 0000000..b850a1f --- /dev/null +++ b/Chapter19/UdpClient_Connect/UdpClient_Connect.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/UdpClient_Helper/UdpClient_Helper.cpp b/Chapter19/UdpClient_Helper/UdpClient_Helper.cpp new file mode 100644 index 0000000..ff12f3e --- /dev/null +++ b/Chapter19/UdpClient_Helper/UdpClient_Helper.cpp @@ -0,0 +1,29 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Text; + +void main() +{ + UdpClient^ client = gcnew UdpClient(); + + IPEndPoint^ Remote = + gcnew IPEndPoint(IPAddress::Parse("127.0.0.1"), 54321); + + while (true) + { + Console::Write("Message ('q' to quit): "); + String^ input = Console::ReadLine(); + + if (input->ToLower()->Equals("q")) + break; + + array^ message = Encoding::ASCII->GetBytes(input); + client->Send(message, message->Length, Remote); + + message = client->Receive(Remote); + Console::WriteLine("[{0}] {1}", + Remote->ToString(), + Encoding::ASCII->GetString(message, 0, message->Length)); + } +} \ No newline at end of file diff --git a/Chapter19/UdpClient_Helper/UdpClient_Helper.vcproj b/Chapter19/UdpClient_Helper/UdpClient_Helper.vcproj new file mode 100644 index 0000000..43cc190 --- /dev/null +++ b/Chapter19/UdpClient_Helper/UdpClient_Helper.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/UdpClient_Timeout/UdpClient_Timeout.cpp b/Chapter19/UdpClient_Timeout/UdpClient_Timeout.cpp new file mode 100644 index 0000000..b85f7d1 --- /dev/null +++ b/Chapter19/UdpClient_Timeout/UdpClient_Timeout.cpp @@ -0,0 +1,46 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Text; + +void main() +{ + Socket^ socket = gcnew Socket(AddressFamily::InterNetwork, + SocketType::Dgram, ProtocolType::Udp); + + + EndPoint^ Remote = gcnew IPEndPoint(IPAddress::Parse("127.0.0.1"), + 54321); + + if ((int)socket->GetSocketOption(SocketOptionLevel::Socket, + SocketOptionName::ReceiveTimeout) < 5000) + { + socket->SetSocketOption(SocketOptionLevel::Socket, + SocketOptionName::ReceiveTimeout, 5000 ); + } + + while (true) + { + Console::Write("Message ('q' to quit): "); + String^ input = Console::ReadLine(); + + if (input->ToLower()->Equals("q")) + break; + + array^ message = Encoding::ASCII->GetBytes(input); + socket->SendTo(message, Remote); + + message = gcnew array(1024); + try + { + int recv = socket->ReceiveFrom(message, Remote); + Console::WriteLine("[{0}] {1}", + Remote->ToString(), Encoding::ASCII->GetString(message, 0, recv)); + } + catch (SocketException^) + { + Console::WriteLine("Receive failed with a time out."); + Console::WriteLine("Make sure server is running."); + } + } +} diff --git a/Chapter19/UdpClient_Timeout/UdpClient_Timeout.vcproj b/Chapter19/UdpClient_Timeout/UdpClient_Timeout.vcproj new file mode 100644 index 0000000..67328a9 --- /dev/null +++ b/Chapter19/UdpClient_Timeout/UdpClient_Timeout.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/UdpServer/UdpServer.cpp b/Chapter19/UdpServer/UdpServer.cpp new file mode 100644 index 0000000..a6ebafa --- /dev/null +++ b/Chapter19/UdpServer/UdpServer.cpp @@ -0,0 +1,28 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Text; + +void main() +{ + Socket^ socket = gcnew Socket(AddressFamily::InterNetwork, + SocketType::Dgram, ProtocolType::Udp); + IPEndPoint^ ipep = gcnew IPEndPoint(IPAddress::Any, 54321); + + socket->Bind(ipep); + + Console::WriteLine("Waiting for client connection."); + + while(true) + { + array^ message = gcnew array(1024); + EndPoint^ Remote = (EndPoint^) gcnew IPEndPoint(IPAddress::Any, 0); + + int recv = socket->ReceiveFrom(message, Remote); + + Console::WriteLine("[{0}] {1}", + Remote->ToString(), Encoding::ASCII->GetString(message, 0, recv)); + + socket->SendTo(message, recv, SocketFlags::None, Remote); + } +} diff --git a/Chapter19/UdpServer/UdpServer.vcproj b/Chapter19/UdpServer/UdpServer.vcproj new file mode 100644 index 0000000..06b2233 --- /dev/null +++ b/Chapter19/UdpServer/UdpServer.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter19/UdpServer_Helper/UdpServer_Helper.cpp b/Chapter19/UdpServer_Helper/UdpServer_Helper.cpp new file mode 100644 index 0000000..54764ce --- /dev/null +++ b/Chapter19/UdpServer_Helper/UdpServer_Helper.cpp @@ -0,0 +1,27 @@ +using namespace System; +using namespace System::Net; +using namespace System::Net::Sockets; +using namespace System::Text; + + +void main() +{ + IPEndPoint^ ipep = gcnew IPEndPoint(IPAddress::Any, 54321); + UdpClient^ server = gcnew UdpClient(ipep); + + Console::WriteLine("Waiting for client connection."); + + array^ message; + + while(true) + { + IPEndPoint^ Remote = gcnew IPEndPoint(IPAddress::Any, 0); + message = server->Receive(Remote); + + Console::WriteLine("[{0}] [{1}]", + Remote->ToString(), Encoding::ASCII->GetString(message, 0, + message->Length)); + + server->Send(message, message->Length, Remote); + } +} diff --git a/Chapter19/UdpServer_Helper/UdpServer_Helper.vcproj b/Chapter19/UdpServer_Helper/UdpServer_Helper.vcproj new file mode 100644 index 0000000..c433645 --- /dev/null +++ b/Chapter19/UdpServer_Helper/UdpServer_Helper.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/Chapter20.sln b/Chapter20/Chapter20.sln new file mode 100644 index 0000000..09f4450 --- /dev/null +++ b/Chapter20/Chapter20.sln @@ -0,0 +1,80 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Reflecting", "Reflecting\Reflecting.vcproj", "{DA11CE2A-0FC6-41AE-92EC-F0ADD643B89C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Invoking", "Invoking\Invoking.vcproj", "{1D5E4D0E-0E41-43FD-8A3C-97218BE475EA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Documentation", "Documentation\Documentation.vcproj", "{27D20CAD-2E4C-4AFD-A7A8-2C48EA3D3634}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocTestLib", "DocTestLib\DocTestLib.vcproj", "{4BBEBE8F-6D1D-414B-8131-AB847CC04BD3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocumentationWriter", "DocumentationWriter\DocumentationWriter.vcproj", "{EE8DA28B-A838-4FCE-B731-F29ED3CA0B3B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SharedAssemby", "SharedAssemby\SharedAssemby.vcproj", "{11797B4D-DFC1-429B-A146-1428ED0A6F6D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReferenceSharedAssembly", "ReferenceSharedAssembly\ReferenceSharedAssembly.vcproj", "{334AC402-8196-4C07-91C2-A91938A7E31E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EmbeddingResources", "EmbeddingResources\EmbeddingResources.vcproj", "{988C74B5-C145-4EE0-9811-C62C2B471272}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MulticulturalDates", "MulticulturalDates\MulticulturalDates.vcproj", "{96F1E314-B66B-4628-906D-F33525DA548F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MulticulturalApp", "MulticulturalApp\MulticulturalApp.vcproj", "{55557150-7AC0-45FA-A9FF-5F1AE3746EA3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MulticulturalConsole", "MulticulturalConsole\MulticulturalConsole.vcproj", "{A62E9469-D622-4799-87A8-93EE6887B138}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA11CE2A-0FC6-41AE-92EC-F0ADD643B89C}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA11CE2A-0FC6-41AE-92EC-F0ADD643B89C}.Debug|Win32.Build.0 = Debug|Win32 + {DA11CE2A-0FC6-41AE-92EC-F0ADD643B89C}.Release|Win32.ActiveCfg = Release|Win32 + {DA11CE2A-0FC6-41AE-92EC-F0ADD643B89C}.Release|Win32.Build.0 = Release|Win32 + {1D5E4D0E-0E41-43FD-8A3C-97218BE475EA}.Debug|Win32.ActiveCfg = Debug|Win32 + {1D5E4D0E-0E41-43FD-8A3C-97218BE475EA}.Debug|Win32.Build.0 = Debug|Win32 + {1D5E4D0E-0E41-43FD-8A3C-97218BE475EA}.Release|Win32.ActiveCfg = Release|Win32 + {1D5E4D0E-0E41-43FD-8A3C-97218BE475EA}.Release|Win32.Build.0 = Release|Win32 + {27D20CAD-2E4C-4AFD-A7A8-2C48EA3D3634}.Debug|Win32.ActiveCfg = Debug|Win32 + {27D20CAD-2E4C-4AFD-A7A8-2C48EA3D3634}.Debug|Win32.Build.0 = Debug|Win32 + {27D20CAD-2E4C-4AFD-A7A8-2C48EA3D3634}.Release|Win32.ActiveCfg = Release|Win32 + {27D20CAD-2E4C-4AFD-A7A8-2C48EA3D3634}.Release|Win32.Build.0 = Release|Win32 + {4BBEBE8F-6D1D-414B-8131-AB847CC04BD3}.Debug|Win32.ActiveCfg = Debug|Win32 + {4BBEBE8F-6D1D-414B-8131-AB847CC04BD3}.Debug|Win32.Build.0 = Debug|Win32 + {4BBEBE8F-6D1D-414B-8131-AB847CC04BD3}.Release|Win32.ActiveCfg = Release|Win32 + {4BBEBE8F-6D1D-414B-8131-AB847CC04BD3}.Release|Win32.Build.0 = Release|Win32 + {EE8DA28B-A838-4FCE-B731-F29ED3CA0B3B}.Debug|Win32.ActiveCfg = Debug|Win32 + {EE8DA28B-A838-4FCE-B731-F29ED3CA0B3B}.Debug|Win32.Build.0 = Debug|Win32 + {EE8DA28B-A838-4FCE-B731-F29ED3CA0B3B}.Release|Win32.ActiveCfg = Release|Win32 + {EE8DA28B-A838-4FCE-B731-F29ED3CA0B3B}.Release|Win32.Build.0 = Release|Win32 + {11797B4D-DFC1-429B-A146-1428ED0A6F6D}.Debug|Win32.ActiveCfg = Debug|Win32 + {11797B4D-DFC1-429B-A146-1428ED0A6F6D}.Debug|Win32.Build.0 = Debug|Win32 + {11797B4D-DFC1-429B-A146-1428ED0A6F6D}.Release|Win32.ActiveCfg = Release|Win32 + {11797B4D-DFC1-429B-A146-1428ED0A6F6D}.Release|Win32.Build.0 = Release|Win32 + {334AC402-8196-4C07-91C2-A91938A7E31E}.Debug|Win32.ActiveCfg = Debug|Win32 + {334AC402-8196-4C07-91C2-A91938A7E31E}.Debug|Win32.Build.0 = Debug|Win32 + {334AC402-8196-4C07-91C2-A91938A7E31E}.Release|Win32.ActiveCfg = Release|Win32 + {334AC402-8196-4C07-91C2-A91938A7E31E}.Release|Win32.Build.0 = Release|Win32 + {988C74B5-C145-4EE0-9811-C62C2B471272}.Debug|Win32.ActiveCfg = Debug|Win32 + {988C74B5-C145-4EE0-9811-C62C2B471272}.Debug|Win32.Build.0 = Debug|Win32 + {988C74B5-C145-4EE0-9811-C62C2B471272}.Release|Win32.ActiveCfg = Release|Win32 + {988C74B5-C145-4EE0-9811-C62C2B471272}.Release|Win32.Build.0 = Release|Win32 + {96F1E314-B66B-4628-906D-F33525DA548F}.Debug|Win32.ActiveCfg = Debug|Win32 + {96F1E314-B66B-4628-906D-F33525DA548F}.Debug|Win32.Build.0 = Debug|Win32 + {96F1E314-B66B-4628-906D-F33525DA548F}.Release|Win32.ActiveCfg = Release|Win32 + {96F1E314-B66B-4628-906D-F33525DA548F}.Release|Win32.Build.0 = Release|Win32 + {55557150-7AC0-45FA-A9FF-5F1AE3746EA3}.Debug|Win32.ActiveCfg = Debug|Win32 + {55557150-7AC0-45FA-A9FF-5F1AE3746EA3}.Debug|Win32.Build.0 = Debug|Win32 + {55557150-7AC0-45FA-A9FF-5F1AE3746EA3}.Release|Win32.ActiveCfg = Release|Win32 + {55557150-7AC0-45FA-A9FF-5F1AE3746EA3}.Release|Win32.Build.0 = Release|Win32 + {A62E9469-D622-4799-87A8-93EE6887B138}.Debug|Win32.ActiveCfg = Debug|Win32 + {A62E9469-D622-4799-87A8-93EE6887B138}.Debug|Win32.Build.0 = Debug|Win32 + {A62E9469-D622-4799-87A8-93EE6887B138}.Release|Win32.ActiveCfg = Release|Win32 + {A62E9469-D622-4799-87A8-93EE6887B138}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter20/Chapter20.suo b/Chapter20/Chapter20.suo new file mode 100644 index 0000000..d0a0c65 Binary files /dev/null and b/Chapter20/Chapter20.suo differ diff --git a/Chapter20/DocTestLib/AssemblyInfo.cpp b/Chapter20/DocTestLib/AssemblyInfo.cpp new file mode 100644 index 0000000..7868a14 --- /dev/null +++ b/Chapter20/DocTestLib/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("DocTestLib")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("DocTestLib")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter20/DocTestLib/DocTestLib.cpp b/Chapter20/DocTestLib/DocTestLib.cpp new file mode 100644 index 0000000..0f04414 --- /dev/null +++ b/Chapter20/DocTestLib/DocTestLib.cpp @@ -0,0 +1,4 @@ +// This is the main DLL file. + +#include "DocTestLib.h" + diff --git a/Chapter20/DocTestLib/DocTestLib.h b/Chapter20/DocTestLib/DocTestLib.h new file mode 100644 index 0000000..7105b15 --- /dev/null +++ b/Chapter20/DocTestLib/DocTestLib.h @@ -0,0 +1,33 @@ +// DocTestLib.h + +using namespace System; +using namespace Documentation; + +namespace DocTestLib +{ + [Description("Stephen Fraser", + "This is TestClass1 to test the documentation Attribute.")] + [History("Stephen Fraser", "Original Version.", ModifyDate="11/27/02")] + [History("Stephen Fraser", "Added DoesNothing Method to do nothing.")] + public ref class TestClass1 + { + public: + [Description("Stephen Fraser", + "This is default constructor for TextClass1.")] + TestClass1() {} + + [Description("Stephen Fraser", + "This is method does nothing for TestClass1.")] + void DoesNothing() {} + + [Description("Stephen Fraser", "Added Variable property.")] + [History("Stephen Fraser", "Removed extra CodeDoc Attribute")] + property String^ Variable; + }; + + [Description("Stephen Fraser", + "This is TestClass2 to test the documentation Attribute.")] + public ref class TestClass2 + { + }; +} diff --git a/Chapter20/DocTestLib/DocTestLib.vcproj b/Chapter20/DocTestLib/DocTestLib.vcproj new file mode 100644 index 0000000..38c8238 --- /dev/null +++ b/Chapter20/DocTestLib/DocTestLib.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/Documentation/AssemblyInfo.cpp b/Chapter20/Documentation/AssemblyInfo.cpp new file mode 100644 index 0000000..b8aece0 --- /dev/null +++ b/Chapter20/Documentation/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("Documentation")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("Documentation")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter20/Documentation/Documentation.cpp b/Chapter20/Documentation/Documentation.cpp new file mode 100644 index 0000000..0dc785f --- /dev/null +++ b/Chapter20/Documentation/Documentation.cpp @@ -0,0 +1,60 @@ +#include "Documentation.h" + +namespace Documentation +{ + // ------------- DescriptionAttribute ------------------- + + DescriptionAttribute::DescriptionAttribute(String ^Author, + String ^Description) + { + mAuthor = Author; + mDescription = Description; + mCompileDate = DateTime::Now; + } + + String^ DescriptionAttribute::Author::get() + { + return mAuthor; + } + + String^ DescriptionAttribute::Description::get() + { + return mDescription; + } + + String^ DescriptionAttribute::CompileDate::get() + { + return mCompileDate.ToShortDateString(); + } + + // ------------- HistoryAttribute ------------------- + + HistoryAttribute::HistoryAttribute(String ^Author, String ^Description) + { + mAuthor = Author; + mDescription = Description; + mModifyDate = DateTime::Now; + } + + String^ HistoryAttribute::Author::get() + { + return mAuthor; + } + + String^ HistoryAttribute::Description::get() + { + return mDescription; + } + + String^ HistoryAttribute::ModifyDate::get() + { + return mModifyDate.ToShortDateString(); + } + + + void HistoryAttribute::ModifyDate::set(String ^value) + { + mModifyDate = Convert::ToDateTime(value); + } +} + diff --git a/Chapter20/Documentation/Documentation.h b/Chapter20/Documentation/Documentation.h new file mode 100644 index 0000000..23aea18 --- /dev/null +++ b/Chapter20/Documentation/Documentation.h @@ -0,0 +1,41 @@ +#pragma once + +using namespace System; +using namespace System::Reflection; + +namespace Documentation +{ + [AttributeUsage(AttributeTargets::All, Inherited=true, AllowMultiple=false)] + public ref class DescriptionAttribute : public Attribute + { + String ^mAuthor; + DateTime mCompileDate; + String ^mDescription; + + public: + DescriptionAttribute(String ^Author, String ^Description); + + property String^ Author { String^ get(); } + property String^ Description { String^ get(); } + property String^ CompileDate { String^ get(); } + }; + + [AttributeUsage(AttributeTargets::All, Inherited=true, AllowMultiple=true)] + public ref class HistoryAttribute : public Attribute + { + String ^mAuthor; + DateTime mModifyDate; + String ^mDescription; + + public: + HistoryAttribute(String ^Author, String ^Description); + + property String^ Author { String^ get(); } + property String^ Description { String^ get(); } + property String^ ModifyDate + { + String^ get(); + void set(String^ value); + } + }; +} diff --git a/Chapter20/Documentation/Documentation.vcproj b/Chapter20/Documentation/Documentation.vcproj new file mode 100644 index 0000000..3791e3a --- /dev/null +++ b/Chapter20/Documentation/Documentation.vcproj @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/DocumentationWriter/DocumentationWriter.cpp b/Chapter20/DocumentationWriter/DocumentationWriter.cpp new file mode 100644 index 0000000..e23b5a4 --- /dev/null +++ b/Chapter20/DocumentationWriter/DocumentationWriter.cpp @@ -0,0 +1,89 @@ +using namespace System; +using namespace Reflection; +using namespace Documentation; + +void DisplayDescription(Attribute ^attr) +{ + if (attr != nullptr) + { + DescriptionAttribute ^cd = (DescriptionAttribute^)attr; + Console::WriteLine(" Author: {0} -- Compiled: {1}", + cd->Author, cd->CompileDate); + Console::WriteLine(" Description: {0}", cd->Description); + Console::WriteLine(" ---- Change History ----"); + } + else + Console::WriteLine(" No Documentation"); +} + +void DisplayHistory(array^ attr) +{ + if (attr->Length > 0) + { + for each (HistoryAttribute^ cd in attr) + { + Console::WriteLine(" Author: {0} -- Modified: {1}", + cd->Author, cd->ModifyDate); + Console::WriteLine(" Description: {0}", cd->Description); + } + } + else + Console::WriteLine(" No changes"); +} + +void DisplayAttributes(MemberInfo ^info) +{ + DisplayDescription(Attribute::GetCustomAttribute(info, + DescriptionAttribute::typeid)); + DisplayHistory(info->GetCustomAttributes(HistoryAttribute::typeid, true)); +} + +void PrintClassInfo(Type ^type) +{ + Console::WriteLine("Class: {0}", type->ToString()); + DisplayAttributes(type); + + array^ constructors = type->GetConstructors(); + for (int i = 0; i < constructors->Length; i++) + { + Console::WriteLine("Constructor: {0}", constructors[i]->ToString()); + DisplayAttributes(constructors[i]); + } + + + array ^ methods = type->GetMethods((BindingFlags) + (BindingFlags::Public|BindingFlags::Instance|BindingFlags::DeclaredOnly)); + for (int i = 0; i < methods->Length; i++) + { + Console::WriteLine("Method: {0}", methods[i]->ToString()); + DisplayAttributes(methods[i]); + } + + array^ properties = type->GetProperties((BindingFlags) + (BindingFlags::Public|BindingFlags::Instance|BindingFlags::DeclaredOnly)); + for (int i = 0; i < properties->Length; i++) + { + Console::WriteLine("Property: {0}", properties[i]->ToString()); + DisplayAttributes(properties[i]); + } +} + +int main(array ^args) +{ + try + { + Assembly ^assembly = Assembly::LoadFrom(args[0]); + + array^ types = assembly->GetTypes(); + + for (int i = 0; i < types->Length; i++) + { + PrintClassInfo(types[i]); + Console::WriteLine(); + } + } + catch(System::IO::FileNotFoundException^) + { + Console::WriteLine("Can't find assembly: {0}\n", args[0]); + } +} diff --git a/Chapter20/DocumentationWriter/DocumentationWriter.vcproj b/Chapter20/DocumentationWriter/DocumentationWriter.vcproj new file mode 100644 index 0000000..703ac27 --- /dev/null +++ b/Chapter20/DocumentationWriter/DocumentationWriter.vcproj @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/EmbeddingResources/Animal.resx b/Chapter20/EmbeddingResources/Animal.resx new file mode 100644 index 0000000..1005820 --- /dev/null +++ b/Chapter20/EmbeddingResources/Animal.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Dog + + + Cat + + + Horse + + + Cow + + \ No newline at end of file diff --git a/Chapter20/EmbeddingResources/Color.txt b/Chapter20/EmbeddingResources/Color.txt new file mode 100644 index 0000000..bb9e581 --- /dev/null +++ b/Chapter20/EmbeddingResources/Color.txt @@ -0,0 +1,4 @@ +Color1 = Blue +Color2 = Red +Color3 = Yellow +Color4 = Green diff --git a/Chapter20/EmbeddingResources/EmbeddingResources.cpp b/Chapter20/EmbeddingResources/EmbeddingResources.cpp new file mode 100644 index 0000000..331771b --- /dev/null +++ b/Chapter20/EmbeddingResources/EmbeddingResources.cpp @@ -0,0 +1,34 @@ +using namespace System; +using namespace System::Collections; +using namespace System::Reflection; +using namespace System::Resources; + +int main(array ^args) +{ + Console::WriteLine("*** ResourceReader ***"); + ResourceReader ^rreader = gcnew ResourceReader("Fruit.resources"); + IDictionaryEnumerator ^denum = rreader->GetEnumerator(); + while (denum->MoveNext()) + { + Console::WriteLine("{0} = {1}", denum->Key, denum->Value); + } + rreader->Close(); + + ResourceManager ^rmgr; + + Console::WriteLine("\n*** ResourceManager From File ***"); + rmgr = ResourceManager::CreateFileBasedResourceManager("Fruit", "", + nullptr); + Console::WriteLine(rmgr->GetString("Fruit1")); + Console::WriteLine(rmgr->GetString("Fruit2")); + Console::WriteLine(rmgr->GetString("Fruit3")); + Console::WriteLine(rmgr->GetString("Fruit4")); + + Console::WriteLine("\n*** ResourceManager From Assembly ***"); + Assembly ^assembly = Assembly::GetExecutingAssembly(); + rmgr = gcnew ResourceManager("Fruit", assembly); + Console::WriteLine(rmgr->GetObject("Fruit1")); + Console::WriteLine(rmgr->GetObject("Fruit2")); + Console::WriteLine(rmgr->GetObject("Fruit3")); + Console::WriteLine(rmgr->GetObject("Fruit4")); +} diff --git a/Chapter20/EmbeddingResources/EmbeddingResources.vcproj b/Chapter20/EmbeddingResources/EmbeddingResources.vcproj new file mode 100644 index 0000000..dbbe6cc --- /dev/null +++ b/Chapter20/EmbeddingResources/EmbeddingResources.vcproj @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/EmbeddingResources/fruit.resources b/Chapter20/EmbeddingResources/fruit.resources new file mode 100644 index 0000000..d64d266 Binary files /dev/null and b/Chapter20/EmbeddingResources/fruit.resources differ diff --git a/Chapter20/EmbeddingResources/fruit.txt b/Chapter20/EmbeddingResources/fruit.txt new file mode 100644 index 0000000..ec9acf3 --- /dev/null +++ b/Chapter20/EmbeddingResources/fruit.txt @@ -0,0 +1,4 @@ +Fruit1 = Apple +Fruit2 = Orange +Fruit3 = Grape +Fruit4 = Lemon diff --git a/Chapter20/Invoking/AssemblyInfo.cpp b/Chapter20/Invoking/AssemblyInfo.cpp new file mode 100644 index 0000000..d3863fc --- /dev/null +++ b/Chapter20/Invoking/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("Invoking")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("Invoking")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter20/Invoking/Form1.h b/Chapter20/Invoking/Form1.h new file mode 100644 index 0000000..0ba19df --- /dev/null +++ b/Chapter20/Invoking/Form1.h @@ -0,0 +1,162 @@ +#pragma once + + +namespace Invoking { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::Reflection; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + + System::Windows::Forms::Label^ lbColor; + System::Windows::Forms::ComboBox^ cbColor; + + array ^ colors; + + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->lbColor = (gcnew System::Windows::Forms::Label()); + this->cbColor = (gcnew System::Windows::Forms::ComboBox()); + this->SuspendLayout(); + // + // lbColor + // + this->lbColor->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; + this->lbColor->Location = System::Drawing::Point(14, 42); + this->lbColor->Name = L"lbColor"; + this->lbColor->Size = System::Drawing::Size(264, 62); + this->lbColor->TabIndex = 3; + this->lbColor->Text = L"None"; + this->lbColor->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // cbColor + // + this->cbColor->FormattingEnabled = true; + this->cbColor->Location = System::Drawing::Point(14, 14); + this->cbColor->Name = L"cbColor"; + this->cbColor->Size = System::Drawing::Size(264, 21); + this->cbColor->TabIndex = 2; + this->cbColor->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::cbColor_SelectedIndexChanged); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 118); + this->Controls->Add(this->lbColor); + this->Controls->Add(this->cbColor); + this->Name = L"Form1"; + this->Text = L"System Drawing Colors"; + this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); + this->ResumeLayout(false); + } + +#pragma endregion + private: + System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) + { + Type^ colorType = Color::typeid; + colors = colorType->GetProperties(); + + for (int i = 0; i < colors->Length; i++) + { + if (colors[i]->ToString()->IndexOf("System.Drawing.Color") >= 0) + cbColor->Items->Add(colors[i]->ToString()); + } + cbColor->SelectedIndex = 0; + } + + System::Void cbColor_SelectedIndexChanged(System::Object^ sender, + System::EventArgs^ e) + { + static bool alternateWrite = true; + PropertyInfo ^ColorProp = colors[cbColor->SelectedIndex]; + + MethodInfo ^PropMethod = ColorProp->GetGetMethod(); + + lbColor->BackColor = (Color)PropMethod->Invoke(nullptr,nullptr); + + Assembly ^assembly = Assembly::Load("Invoking"); + + Type ^type; + if (alternateWrite) + type = assembly->GetType("Invoking.Writer1"); + else + type = assembly->GetType("Invoking.Writer2"); + + alternateWrite = !alternateWrite; + + MethodInfo ^ColorMethod = type->GetMethod("aColor"); + + Object ^writerInst = Activator::CreateInstance(type); + + array ^ args = gcnew array (1); + args[0] = PropMethod->Invoke(nullptr,nullptr); + + lbColor->Text = (String^)ColorMethod->Invoke(writerInst, args); + } + }; + + ref class Writer1 + { + public: + String ^aColor(Color ^col) + { + return String::Format("[Writer 1] {0}", col->ToString()); + } + }; + + ref class Writer2 + { + public: + String ^aColor(Color ^col) + { + return String::Format("[Writer 2] {0}", col->ToString()); + } + }; +} + diff --git a/Chapter20/Invoking/Form1.resX b/Chapter20/Invoking/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter20/Invoking/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter20/Invoking/Invoking.cpp b/Chapter20/Invoking/Invoking.cpp new file mode 100644 index 0000000..fea2ebe --- /dev/null +++ b/Chapter20/Invoking/Invoking.cpp @@ -0,0 +1,18 @@ +// Invoking.cpp : main project file. + +#include "stdafx.h" +#include "Form1.h" + +using namespace Invoking; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter20/Invoking/Invoking.vcproj b/Chapter20/Invoking/Invoking.vcproj new file mode 100644 index 0000000..16fed54 --- /dev/null +++ b/Chapter20/Invoking/Invoking.vcproj @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/Invoking/ReadMe.txt b/Chapter20/Invoking/ReadMe.txt new file mode 100644 index 0000000..5e106c5 --- /dev/null +++ b/Chapter20/Invoking/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + APPLICATION : Invoking Project Overview +======================================================================== + +AppWizard has created this Invoking Application for you. + +This file contains a summary of what you will find in each of the files that +make up your Invoking application. + +Invoking.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +Invoking.cpp + This is the main application source file. + Contains the code to display the form. + +Form1.h + Contains the implementation of your form class and InitializeComponent() function. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named Invoking.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter20/Invoking/app.ico b/Chapter20/Invoking/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Chapter20/Invoking/app.ico differ diff --git a/Chapter20/Invoking/app.rc b/Chapter20/Invoking/app.rc new file mode 100644 index 0000000..807aa89 --- /dev/null +++ b/Chapter20/Invoking/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Chapter20/Invoking/resource.h b/Chapter20/Invoking/resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/Chapter20/Invoking/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/Chapter20/Invoking/stdafx.cpp b/Chapter20/Invoking/stdafx.cpp new file mode 100644 index 0000000..bbf6ea3 --- /dev/null +++ b/Chapter20/Invoking/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// Invoking.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter20/Invoking/stdafx.h b/Chapter20/Invoking/stdafx.h new file mode 100644 index 0000000..46bef73 --- /dev/null +++ b/Chapter20/Invoking/stdafx.h @@ -0,0 +1,6 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter20/MulticulturalApp/Form1.de-DE.resx b/Chapter20/MulticulturalApp/Form1.de-DE.resx new file mode 100644 index 0000000..5226b60 --- /dev/null +++ b/Chapter20/MulticulturalApp/Form1.de-DE.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + 113, 9 + + + 265, 23 + + + Hallo, ist mein Name Stephen + + + 390, 43 + + + Deutsch + + \ No newline at end of file diff --git a/Chapter20/MulticulturalApp/Form1.fr-FR.resx b/Chapter20/MulticulturalApp/Form1.fr-FR.resx new file mode 100644 index 0000000..352f62d --- /dev/null +++ b/Chapter20/MulticulturalApp/Form1.fr-FR.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + 247, 49 + + + Bonjour, mon nom est Stephen + + + 390, 67 + + + Français + + \ No newline at end of file diff --git a/Chapter20/MulticulturalApp/Form1.h b/Chapter20/MulticulturalApp/Form1.h new file mode 100644 index 0000000..9104b9a --- /dev/null +++ b/Chapter20/MulticulturalApp/Form1.h @@ -0,0 +1,93 @@ +#pragma once + + +namespace MulticulturalApp { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::Globalization; + using namespace System::Threading; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + Thread::CurrentThread->CurrentCulture = gcnew CultureInfo("fr-fr"); + Thread::CurrentThread->CurrentUICulture = Thread::CurrentThread->CurrentCulture; + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + private: System::Windows::Forms::Label^ lbHello; + protected: + + private: + /// + /// Required designer variable. + /// + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); + this->lbHello = (gcnew System::Windows::Forms::Label()); + this->SuspendLayout(); + // + // lbHello + // + this->lbHello->AccessibleDescription = nullptr; + this->lbHello->AccessibleName = nullptr; + resources->ApplyResources(this->lbHello, L"lbHello"); + this->lbHello->BackColor = System::Drawing::SystemColors::Control; + this->lbHello->Name = L"lbHello"; + // + // Form1 + // + this->AccessibleDescription = nullptr; + this->AccessibleName = nullptr; + resources->ApplyResources(this, L"$this"); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->BackgroundImage = nullptr; + this->Controls->Add(this->lbHello); + this->Font = nullptr; + this->Icon = nullptr; + this->Name = L"Form1"; + this->ResumeLayout(false); + + } +#pragma endregion + }; +} + diff --git a/Chapter20/MulticulturalApp/Form1.resX b/Chapter20/MulticulturalApp/Form1.resX new file mode 100644 index 0000000..1afe5be --- /dev/null +++ b/Chapter20/MulticulturalApp/Form1.resX @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + lbHello + + + $this + + + System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + 12, 9 + + + 390, 48 + + + 0 + + + 364, 23 + + + Hello, my name is Stephen + + + English + + + Microsoft Sans Serif, 12pt, style=Bold + + + + 0 + + + 6, 13 + + + Form1 + + + True + + + German (Germany) + + \ No newline at end of file diff --git a/Chapter20/MulticulturalApp/MulticulturalApp.cpp b/Chapter20/MulticulturalApp/MulticulturalApp.cpp new file mode 100644 index 0000000..766f8ca --- /dev/null +++ b/Chapter20/MulticulturalApp/MulticulturalApp.cpp @@ -0,0 +1,15 @@ +#include "Form1.h" + +using namespace MulticulturalApp; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter20/MulticulturalApp/MulticulturalApp.vcproj b/Chapter20/MulticulturalApp/MulticulturalApp.vcproj new file mode 100644 index 0000000..14836a9 --- /dev/null +++ b/Chapter20/MulticulturalApp/MulticulturalApp.vcproj @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/MulticulturalConsole/Colors.fr-fr.resx b/Chapter20/MulticulturalConsole/Colors.fr-fr.resx new file mode 100644 index 0000000..ca131b2 --- /dev/null +++ b/Chapter20/MulticulturalConsole/Colors.fr-fr.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Rouge + + + Vert + + + Jaune + + + Bleu + + \ No newline at end of file diff --git a/Chapter20/MulticulturalConsole/Colors.resx b/Chapter20/MulticulturalConsole/Colors.resx new file mode 100644 index 0000000..8395356 --- /dev/null +++ b/Chapter20/MulticulturalConsole/Colors.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Red + + + Blue + + + Yellow + + + Green + + \ No newline at end of file diff --git a/Chapter20/MulticulturalConsole/MulticulturalConsole.cpp b/Chapter20/MulticulturalConsole/MulticulturalConsole.cpp new file mode 100644 index 0000000..ee38130 --- /dev/null +++ b/Chapter20/MulticulturalConsole/MulticulturalConsole.cpp @@ -0,0 +1,25 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Resources; +using namespace System::Threading; +using namespace System::Globalization; + + +void main() +{ + Assembly ^assembly = Assembly::GetExecutingAssembly(); + ResourceManager ^rmgr = + gcnew ResourceManager("MulticulturalConsole.Colors", assembly); + + Console::WriteLine(rmgr->GetObject("Color1")); + Console::WriteLine(rmgr->GetObject("Color2")); + Console::WriteLine(rmgr->GetObject("Color3")); + Console::WriteLine(rmgr->GetObject("Color4")); + + Thread::CurrentThread->CurrentUICulture = gcnew CultureInfo("fr-fr"); + + Console::WriteLine(rmgr->GetObject("Color1")); + Console::WriteLine(rmgr->GetObject("Color2")); + Console::WriteLine(rmgr->GetObject("Color3")); + Console::WriteLine(rmgr->GetObject("Color4")); +} diff --git a/Chapter20/MulticulturalConsole/MulticulturalConsole.vcproj b/Chapter20/MulticulturalConsole/MulticulturalConsole.vcproj new file mode 100644 index 0000000..dc242f9 --- /dev/null +++ b/Chapter20/MulticulturalConsole/MulticulturalConsole.vcproj @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/MulticulturalDates/MulticulturalDates.cpp b/Chapter20/MulticulturalDates/MulticulturalDates.cpp new file mode 100644 index 0000000..47d15a7 --- /dev/null +++ b/Chapter20/MulticulturalDates/MulticulturalDates.cpp @@ -0,0 +1,12 @@ +using namespace System; +using namespace System::Globalization; + +void main() +{ + DateTime dt = DateTime::Now; + + Console::WriteLine("en-us {0}",dt.ToString("D",gcnew CultureInfo("en-us"))); + Console::WriteLine("en-gb {0}",dt.ToString("D",gcnew CultureInfo("en-gb"))); + Console::WriteLine("fr-fr {0}",dt.ToString("D",gcnew CultureInfo("fr-fr"))); + Console::WriteLine("de-de {0}",dt.ToString("D",gcnew CultureInfo("de-de"))); +} diff --git a/Chapter20/MulticulturalDates/MulticulturalDates.vcproj b/Chapter20/MulticulturalDates/MulticulturalDates.vcproj new file mode 100644 index 0000000..91bc9f5 --- /dev/null +++ b/Chapter20/MulticulturalDates/MulticulturalDates.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/ReferenceSharedAssembly/ReferenceSharedAssembly.cpp b/Chapter20/ReferenceSharedAssembly/ReferenceSharedAssembly.cpp new file mode 100644 index 0000000..b7e0da6 --- /dev/null +++ b/Chapter20/ReferenceSharedAssembly/ReferenceSharedAssembly.cpp @@ -0,0 +1,8 @@ +using namespace System; +using namespace SharedAssembly; + +void main() +{ + SharedClass ^sa = gcnew SharedClass(); + Console::WriteLine(sa->Version); +} diff --git a/Chapter20/ReferenceSharedAssembly/ReferenceSharedAssembly.vcproj b/Chapter20/ReferenceSharedAssembly/ReferenceSharedAssembly.vcproj new file mode 100644 index 0000000..3516302 --- /dev/null +++ b/Chapter20/ReferenceSharedAssembly/ReferenceSharedAssembly.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/Reflecting/Form1.h b/Chapter20/Reflecting/Form1.h new file mode 100644 index 0000000..3fc42e9 --- /dev/null +++ b/Chapter20/Reflecting/Form1.h @@ -0,0 +1,271 @@ +#pragma once + + +namespace Reflecting { + + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::Reflection; + + /// + /// Summary for Form1 + /// + /// WARNING: If you change the name of this class, you will need to change the + /// 'Resource File Name' property for the managed resource compiler tool + /// associated with all .resx files this class depends on. Otherwise, + /// the designers will not be able to interact properly with localized + /// resources associated with this form. + /// + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + // + //TODO: Add the constructor code here + // + } + + protected: + /// + /// Clean up any resources being used. + /// + ~Form1() + { + if (components) + { + delete components; + } + } + + private: + System::Windows::Forms::Label^ label3; + System::Windows::Forms::Label^ label4; + System::Windows::Forms::Label^ label5; + System::Windows::Forms::ListBox^ lbMethods; + System::Windows::Forms::ListBox^ lbProperties; + System::Windows::Forms::ListBox^ lbVariables; + System::Windows::Forms::GroupBox^ groupBox1; + System::Windows::Forms::ComboBox^ cbDataTypes; + System::Windows::Forms::ComboBox^ cbAssemblies; + System::Windows::Forms::Label^ label2; + System::Windows::Forms::Label^ label1; + + array^ types; + static array^ assemblies = + { + "System", + "System.Drawing", + "System.Xml", + "System.Windows.Forms", + "System.Data", + "mscorlib" + }; + + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->label3 = (gcnew System::Windows::Forms::Label()); + this->label4 = (gcnew System::Windows::Forms::Label()); + this->label5 = (gcnew System::Windows::Forms::Label()); + this->lbMethods = (gcnew System::Windows::Forms::ListBox()); + this->lbProperties = (gcnew System::Windows::Forms::ListBox()); + this->lbVariables = (gcnew System::Windows::Forms::ListBox()); + this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); + this->cbDataTypes = (gcnew System::Windows::Forms::ComboBox()); + this->cbAssemblies = (gcnew System::Windows::Forms::ComboBox()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->groupBox1->SuspendLayout(); + this->SuspendLayout(); + // + // label3 + // + this->label3->AutoSize = true; + this->label3->Location = System::Drawing::Point(15, 94); + this->label3->Name = L"label3"; + this->label3->Size = System::Drawing::Size(51, 13); + this->label3->TabIndex = 11; + this->label3->Text = L"Methods:"; + // + // label4 + // + this->label4->AutoSize = true; + this->label4->Location = System::Drawing::Point(320, 94); + this->label4->Name = L"label4"; + this->label4->Size = System::Drawing::Size(57, 13); + this->label4->TabIndex = 12; + this->label4->Text = L"Properties:"; + // + // label5 + // + this->label5->AutoSize = true; + this->label5->Location = System::Drawing::Point(585, 94); + this->label5->Name = L"label5"; + this->label5->Size = System::Drawing::Size(53, 13); + this->label5->TabIndex = 13; + this->label5->Text = L"Variables:"; + // + // lbMethods + // + this->lbMethods->FormattingEnabled = true; + this->lbMethods->Location = System::Drawing::Point(15, 114); + this->lbMethods->Name = L"lbMethods"; + this->lbMethods->Size = System::Drawing::Size(293, 251); + this->lbMethods->TabIndex = 14; + // + // lbProperties + // + this->lbProperties->FormattingEnabled = true; + this->lbProperties->Location = System::Drawing::Point(320, 114); + this->lbProperties->Name = L"lbProperties"; + this->lbProperties->Size = System::Drawing::Size(250, 251); + this->lbProperties->TabIndex = 15; + // + // lbVariables + // + this->lbVariables->FormattingEnabled = true; + this->lbVariables->Location = System::Drawing::Point(585, 114); + this->lbVariables->Name = L"lbVariables"; + this->lbVariables->Size = System::Drawing::Size(202, 251); + this->lbVariables->TabIndex = 16; + // + // groupBox1 + // + this->groupBox1->Controls->Add(this->cbDataTypes); + this->groupBox1->Controls->Add(this->cbAssemblies); + this->groupBox1->Controls->Add(this->label2); + this->groupBox1->Controls->Add(this->label1); + this->groupBox1->Location = System::Drawing::Point(14, 12); + this->groupBox1->Name = L"groupBox1"; + this->groupBox1->Size = System::Drawing::Size(443, 72); + this->groupBox1->TabIndex = 10; + this->groupBox1->TabStop = false; + // + // cbDataTypes + // + this->cbDataTypes->FormattingEnabled = true; + this->cbDataTypes->Location = System::Drawing::Point(120, 41); + this->cbDataTypes->Name = L"cbDataTypes"; + this->cbDataTypes->Size = System::Drawing::Size(287, 21); + this->cbDataTypes->TabIndex = 3; + this->cbDataTypes->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::cbDataTypes_SelectedIndexChanged); + // + // cbAssemblies + // + this->cbAssemblies->FormattingEnabled = true; + this->cbAssemblies->Location = System::Drawing::Point(120, 16); + this->cbAssemblies->Name = L"cbAssemblies"; + this->cbAssemblies->Size = System::Drawing::Size(287, 21); + this->cbAssemblies->TabIndex = 2; + this->cbAssemblies->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::cbAssemblies_SelectedIndexChanged); + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Location = System::Drawing::Point(24, 44); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(87, 13); + this->label2->TabIndex = 1; + this->label2->Text = L"Select data type:"; + // + // label1 + // + this->label1->AutoSize = true; + this->label1->Location = System::Drawing::Point(24, 19); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(86, 13); + this->label1->TabIndex = 0; + this->label1->Text = L"Select assembly:"; + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(801, 377); + this->Controls->Add(this->label3); + this->Controls->Add(this->label4); + this->Controls->Add(this->label5); + this->Controls->Add(this->lbMethods); + this->Controls->Add(this->lbProperties); + this->Controls->Add(this->lbVariables); + this->Controls->Add(this->groupBox1); + this->Name = L"Form1"; + this->Text = L"Assembly Viewer"; + this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); + this->groupBox1->ResumeLayout(false); + this->groupBox1->PerformLayout(); + this->ResumeLayout(false); + this->PerformLayout(); + } +#pragma endregion + private: + System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) + { + + for each (String ^assembly in assemblies) + { + cbAssemblies->Items->Add(assembly); + } + cbAssemblies->SelectedIndex = 0; + } + + private: + System::Void cbAssemblies_SelectedIndexChanged(System::Object^ sender, + System::EventArgs^ e) + { + Assembly^ assembly = Assembly::LoadWithPartialName( + assemblies[cbAssemblies->SelectedIndex]); + + types = assembly->GetTypes(); + + cbDataTypes->Items->Clear(); + + for (int i = 0; i < types->Length; i++) + { + cbDataTypes->Items->Add(types[i]->ToString()); + } + cbDataTypes->SelectedIndex = 0; + } + + private: + System::Void cbDataTypes_SelectedIndexChanged(System::Object^ sender, + System::EventArgs^ e) + { + Type ^type = types[cbDataTypes->SelectedIndex]; + + array ^ methods = type->GetMethods(); + lbMethods->Items->Clear(); + for (int i = 0; i < methods->Length; i++) + { + lbMethods->Items->Add(methods[i]->ToString()); + } + + array ^ properties = type->GetProperties(); + lbProperties->Items->Clear(); + for (int i = 0; i < properties->Length; i++) + { + lbProperties->Items->Add(properties[i]->ToString()); + } + + array ^ variables = type->GetFields(); + lbVariables->Items->Clear(); + for (int i = 0; i < variables->Length; i++) + { + lbVariables->Items->Add(variables[i]->ToString()); + } + } + }; +} + diff --git a/Chapter20/Reflecting/Form1.resX b/Chapter20/Reflecting/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter20/Reflecting/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter20/Reflecting/Reflecting.cpp b/Chapter20/Reflecting/Reflecting.cpp new file mode 100644 index 0000000..2ac6743 --- /dev/null +++ b/Chapter20/Reflecting/Reflecting.cpp @@ -0,0 +1,17 @@ +// Reflecting.cpp : main project file. + +#include "Form1.h" + +using namespace Reflecting; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter20/Reflecting/Reflecting.vcproj b/Chapter20/Reflecting/Reflecting.vcproj new file mode 100644 index 0000000..90a3fbc --- /dev/null +++ b/Chapter20/Reflecting/Reflecting.vcproj @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter20/SharedAssemby/AssemblyInfo.cpp b/Chapter20/SharedAssemby/AssemblyInfo.cpp new file mode 100644 index 0000000..51f8880 --- /dev/null +++ b/Chapter20/SharedAssemby/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("A Shared Assembly")]; +[assembly:AssemblyDescriptionAttribute("An assembly that knows its version")]; +[assembly:AssemblyConfigurationAttribute("Release Version")]; +[assembly:AssemblyCompanyAttribute("ProCppCLI")]; +[assembly:AssemblyProductAttribute("Pro C++/CLI Series")]; +[assembly:AssemblyCopyrightAttribute("Copyright (C) by Stephen Fraser 2008")]; +[assembly:AssemblyTrademarkAttribute("ProCppCLI is a Trademark of blah")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.0.0")]; + +[assembly:ComVisible(false)]; +[assembly:CLSCompliantAttribute(true)]; +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; + +[assembly:AssemblyDelaySignAttribute(false)]; +[assembly:AssemblyKeyFileAttribute("SharedAssembly.snk")]; +[assembly:AssemblyKeyNameAttribute("")]; diff --git a/Chapter20/SharedAssemby/SharedAssembly.snk b/Chapter20/SharedAssemby/SharedAssembly.snk new file mode 100644 index 0000000..c1e89a6 Binary files /dev/null and b/Chapter20/SharedAssemby/SharedAssembly.snk differ diff --git a/Chapter20/SharedAssemby/SharedAssemby.cpp b/Chapter20/SharedAssemby/SharedAssemby.cpp new file mode 100644 index 0000000..a5653b2 --- /dev/null +++ b/Chapter20/SharedAssemby/SharedAssemby.cpp @@ -0,0 +1,4 @@ +// This is the main DLL file. + +#include "SharedAssemby.h" + diff --git a/Chapter20/SharedAssemby/SharedAssemby.h b/Chapter20/SharedAssemby/SharedAssemby.h new file mode 100644 index 0000000..90bbca0 --- /dev/null +++ b/Chapter20/SharedAssemby/SharedAssemby.h @@ -0,0 +1,18 @@ +using namespace System; +using namespace System::Reflection; + +namespace SharedAssembly +{ + public ref class SharedClass + { + public: + property System::Version^ Version + { + System::Version^ get() + { + Assembly ^assembly = Assembly::GetExecutingAssembly(); + return assembly->GetName()->Version; + } + } + }; +} diff --git a/Chapter20/SharedAssemby/SharedAssemby.vcproj b/Chapter20/SharedAssemby/SharedAssemby.vcproj new file mode 100644 index 0000000..6e19a6b --- /dev/null +++ b/Chapter20/SharedAssemby/SharedAssemby.vcproj @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter21/AssertDenyPermit/AssertDenyPermit.cpp b/Chapter21/AssertDenyPermit/AssertDenyPermit.cpp new file mode 100644 index 0000000..41b6873 --- /dev/null +++ b/Chapter21/AssertDenyPermit/AssertDenyPermit.cpp @@ -0,0 +1,63 @@ +using namespace System; +using namespace System::IO; +using namespace System::Security; +using namespace System::Security::Permissions; + +void AssertRead() +{ + CodeAccessPermission ^permission = + gcnew FileIOPermission(FileIOPermissionAccess::Read, "C:\\Test"); + + permission->Assert(); + StreamReader ^sr = File::OpenText("C:\\Test\\TestFile.txt"); + String ^s = sr->ReadLine(); + sr->Close(); + permission->RevertAssert(); + Console::WriteLine("Successful Read"); +} + +void NoAssertRead() +{ + StreamReader ^sr = File::OpenText("C:\\Test\\TestFile.txt"); + String ^s = sr->ReadLine(); + sr->Close(); + Console::WriteLine("Successful Read"); +} + +void main() +{ + // Deny Reading C: + CodeAccessPermission ^permissionRead = + gcnew FileIOPermission(FileIOPermissionAccess::Read, "C:\\Test"); + + permissionRead->Deny(); + try + { + AssertRead(); + NoAssertRead(); + } + catch(SecurityException^) + { + Console::WriteLine("Failed To Read"); + } + permissionRead->RevertDeny(); + + // Only allow Writing to C: + CodeAccessPermission ^permissionWrite = + gcnew FileIOPermission(FileIOPermissionAccess::Write, "C:\\Test"); + + + permissionWrite->PermitOnly(); + try + { + AssertRead(); + NoAssertRead(); + } + catch(SecurityException^) + { + Console::WriteLine("Failed To Read"); + } + permissionWrite->RevertPermitOnly(); + + Console::WriteLine(""); +} diff --git a/Chapter21/AssertDenyPermit/AssertDenyPermit.vcproj b/Chapter21/AssertDenyPermit/AssertDenyPermit.vcproj new file mode 100644 index 0000000..9a6c350 --- /dev/null +++ b/Chapter21/AssertDenyPermit/AssertDenyPermit.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter21/CASSecurity/CASSecurity.cpp b/Chapter21/CASSecurity/CASSecurity.cpp new file mode 100644 index 0000000..a49e4dd --- /dev/null +++ b/Chapter21/CASSecurity/CASSecurity.cpp @@ -0,0 +1,17 @@ +// CASSecurity.cpp : main project file. + +#include "Form1.h" + +using namespace CASSecurity; + +[STAThreadAttribute] +int main(array ^args) +{ + // Enabling Windows XP visual effects before any controls are created + Application::EnableVisualStyles(); + Application::SetCompatibleTextRenderingDefault(false); + + // Create the main window and run it + Application::Run(gcnew Form1()); + return 0; +} diff --git a/Chapter21/CASSecurity/CASSecurity.vcproj b/Chapter21/CASSecurity/CASSecurity.vcproj new file mode 100644 index 0000000..e2cafff --- /dev/null +++ b/Chapter21/CASSecurity/CASSecurity.vcproj @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter21/CASSecurity/Form1.h b/Chapter21/CASSecurity/Form1.h new file mode 100644 index 0000000..d02ec31 --- /dev/null +++ b/Chapter21/CASSecurity/Form1.h @@ -0,0 +1,133 @@ +#pragma once + + +namespace CASSecurity +{ + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::IO; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + using namespace System::Security::Permissions; + + + public ref class Form1 : public System::Windows::Forms::Form + { + public: + Form1(void) + { + InitializeComponent(); + + try + { + (gcnew FileIOPermission(FileIOPermissionAccess::Read, "C:\\Test"))->Demand(); + } + catch(Exception^) + { + bnReadFile->Enabled = false; + } + + try + { + (gcnew FileIOPermission(FileIOPermissionAccess::Write, "C:\\Test"))->Demand(); + } + catch(Exception^) + { + bnWriteFile->Enabled = false; + } + } + + + protected: + ~Form1() + { + if (components) + { + delete components; + } + } + private: + System::Windows::Forms::Label^ lbOutput; + System::Windows::Forms::Button^ bnWriteFile; + System::Windows::Forms::Button^ bnReadFile; + System::ComponentModel::Container ^components; + +#pragma region Windows Form Designer generated code + + void InitializeComponent(void) + { + this->lbOutput = (gcnew System::Windows::Forms::Label()); + this->bnWriteFile = (gcnew System::Windows::Forms::Button()); + this->bnReadFile = (gcnew System::Windows::Forms::Button()); + this->SuspendLayout(); + // + // lbOutput + // + this->lbOutput->AutoSize = true; + this->lbOutput->Location = System::Drawing::Point(68, 71); + this->lbOutput->Name = L"lbOutput"; + this->lbOutput->Size = System::Drawing::Size(0, 13); + this->lbOutput->TabIndex = 5; + // + // bnWriteFile + // + this->bnWriteFile->Location = System::Drawing::Point(170, 30); + this->bnWriteFile->Name = L"bnWriteFile"; + this->bnWriteFile->Size = System::Drawing::Size(75, 23); + this->bnWriteFile->TabIndex = 4; + this->bnWriteFile->Text = L"Write File"; + this->bnWriteFile->UseVisualStyleBackColor = true; + this->bnWriteFile->Click += + gcnew System::EventHandler(this, &Form1::bnWriteFile_Click); + // + // bnReadFile + // + this->bnReadFile->Location = System::Drawing::Point(48, 30); + this->bnReadFile->Name = L"bnReadFile"; + this->bnReadFile->Size = System::Drawing::Size(75, 23); + this->bnReadFile->TabIndex = 3; + this->bnReadFile->Text = L"Read File"; + this->bnReadFile->UseVisualStyleBackColor = true; + this->bnReadFile->Click += + gcnew System::EventHandler(this, &Form1::bnReadFile_Click); + // + // Form1 + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(292, 110); + this->Controls->Add(this->lbOutput); + this->Controls->Add(this->bnWriteFile); + this->Controls->Add(this->bnReadFile); + this->Name = L"Form1"; + this->Text = L"CAS Security Test"; + this->ResumeLayout(false); + this->PerformLayout(); + + } +#pragma endregion + + private: + System::Void bnReadFile_Click(System::Object^ sender, + System::EventArgs^ e) + { + StreamReader ^sr = File::OpenText("C:\\Test\\TestFile.txt"); + String ^s = sr->ReadLine(); + sr->Close(); + lbOutput->Text = s; + } + + private: + System::Void bnWriteFile_Click(System::Object^ sender, + System::EventArgs^ e) + { + StreamWriter ^sw = File::CreateText("C:\\Test\\TestFile.txt"); + sw->WriteLine("This is a test. This is only a test."); + sw->Close(); + lbOutput->Text = "Wrote text to file."; + } + }; +} + diff --git a/Chapter21/CASSecurity/Form1.resX b/Chapter21/CASSecurity/Form1.resX new file mode 100644 index 0000000..de824e1 --- /dev/null +++ b/Chapter21/CASSecurity/Form1.resX @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Chapter21/Chapter21.sln b/Chapter21/Chapter21.sln new file mode 100644 index 0000000..ab90b7d --- /dev/null +++ b/Chapter21/Chapter21.sln @@ -0,0 +1,50 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrincipalIdentity", "PrincipalIdentity\PrincipalIdentity.vcproj", "{B02E94D0-0650-458D-81F6-D3F4492F88D8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RoleBasedSecurity", "RoleBasedSecurity\RoleBasedSecurity.vcproj", "{3CD82D49-795F-45C0-9608-A21076F5E6B3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SetSecurity", "SetSecurity\SetSecurity.vcproj", "{519D280F-A96D-4E76-A2A7-102C243E443E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RemoveSecurity", "RemoveSecurity\RemoveSecurity.vcproj", "{8ECFFF45-3212-44AA-9757-324812677AEF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CASSecurity", "CASSecurity\CASSecurity.vcproj", "{74477BF5-FB64-4836-9177-63B4EC62870C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssertDenyPermit", "AssertDenyPermit\AssertDenyPermit.vcproj", "{221E2F46-8988-4C61-A106-A09B95053C83}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B02E94D0-0650-458D-81F6-D3F4492F88D8}.Debug|Win32.ActiveCfg = Debug|Win32 + {B02E94D0-0650-458D-81F6-D3F4492F88D8}.Debug|Win32.Build.0 = Debug|Win32 + {B02E94D0-0650-458D-81F6-D3F4492F88D8}.Release|Win32.ActiveCfg = Release|Win32 + {B02E94D0-0650-458D-81F6-D3F4492F88D8}.Release|Win32.Build.0 = Release|Win32 + {3CD82D49-795F-45C0-9608-A21076F5E6B3}.Debug|Win32.ActiveCfg = Debug|Win32 + {3CD82D49-795F-45C0-9608-A21076F5E6B3}.Debug|Win32.Build.0 = Debug|Win32 + {3CD82D49-795F-45C0-9608-A21076F5E6B3}.Release|Win32.ActiveCfg = Release|Win32 + {3CD82D49-795F-45C0-9608-A21076F5E6B3}.Release|Win32.Build.0 = Release|Win32 + {519D280F-A96D-4E76-A2A7-102C243E443E}.Debug|Win32.ActiveCfg = Debug|Win32 + {519D280F-A96D-4E76-A2A7-102C243E443E}.Debug|Win32.Build.0 = Debug|Win32 + {519D280F-A96D-4E76-A2A7-102C243E443E}.Release|Win32.ActiveCfg = Release|Win32 + {519D280F-A96D-4E76-A2A7-102C243E443E}.Release|Win32.Build.0 = Release|Win32 + {8ECFFF45-3212-44AA-9757-324812677AEF}.Debug|Win32.ActiveCfg = Debug|Win32 + {8ECFFF45-3212-44AA-9757-324812677AEF}.Debug|Win32.Build.0 = Debug|Win32 + {8ECFFF45-3212-44AA-9757-324812677AEF}.Release|Win32.ActiveCfg = Release|Win32 + {8ECFFF45-3212-44AA-9757-324812677AEF}.Release|Win32.Build.0 = Release|Win32 + {74477BF5-FB64-4836-9177-63B4EC62870C}.Debug|Win32.ActiveCfg = Debug|Win32 + {74477BF5-FB64-4836-9177-63B4EC62870C}.Debug|Win32.Build.0 = Debug|Win32 + {74477BF5-FB64-4836-9177-63B4EC62870C}.Release|Win32.ActiveCfg = Release|Win32 + {74477BF5-FB64-4836-9177-63B4EC62870C}.Release|Win32.Build.0 = Release|Win32 + {221E2F46-8988-4C61-A106-A09B95053C83}.Debug|Win32.ActiveCfg = Debug|Win32 + {221E2F46-8988-4C61-A106-A09B95053C83}.Debug|Win32.Build.0 = Debug|Win32 + {221E2F46-8988-4C61-A106-A09B95053C83}.Release|Win32.ActiveCfg = Release|Win32 + {221E2F46-8988-4C61-A106-A09B95053C83}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter21/Chapter21.suo b/Chapter21/Chapter21.suo new file mode 100644 index 0000000..8327a87 Binary files /dev/null and b/Chapter21/Chapter21.suo differ diff --git a/Chapter21/PrincipalIdentity/PrincipalIdentity.cpp b/Chapter21/PrincipalIdentity/PrincipalIdentity.cpp new file mode 100644 index 0000000..7e871d7 --- /dev/null +++ b/Chapter21/PrincipalIdentity/PrincipalIdentity.cpp @@ -0,0 +1,52 @@ +using namespace System; +using namespace System::Security; +using namespace System::Security::Principal; +using namespace System::Threading; + +void main() +{ + // set policy from UnauthenticatedPrincipal to WindowsPrincipal + AppDomain::CurrentDomain->SetPrincipalPolicy( + PrincipalPolicy::WindowsPrincipal); + // ---------------------------------------------------------------------- + // Get Windows Principal and Identity + // ---------------------------------------------------------------------- + Console::WriteLine("Windows Principal & Identity"); + Console::WriteLine("----------------------------"); + + WindowsPrincipal ^wPrinc = (WindowsPrincipal^)Thread::CurrentPrincipal; + + Console::WriteLine("Is an Administrator?: {0}", + wPrinc->IsInRole(WindowsBuiltInRole::Administrator)); + Console::WriteLine("Is a Hacker?: {0}", wPrinc->IsInRole("Hacker")); + + WindowsIdentity ^wIdent = (WindowsIdentity^)wPrinc->Identity; + + Console::WriteLine("\nWindows Login Name: {0}", wIdent->Name); + Console::WriteLine("Authentication Type: {0}", wIdent->AuthenticationType); + Console::WriteLine("Is Authenticated: {0}", wIdent->IsAuthenticated); + Console::WriteLine("Is System Account: {0}", wIdent->IsSystem); + // ---------------------------------------------------------------------- + // Create (Hacker) Principal and Identity + // ---------------------------------------------------------------------- + Console::WriteLine("\n\nGeneric Principal & Identity"); + Console::WriteLine("----------------------------"); + + array^ rolesArray = {"Hacker"}; + + + // Set the principal to a new generic principal. + Thread::CurrentPrincipal = + gcnew GenericPrincipal(gcnew GenericIdentity("John Doe"), rolesArray); + + GenericPrincipal ^gPrinc = (GenericPrincipal^)Thread::CurrentPrincipal; + + Console::WriteLine("Is an Administrator?: {0}", + gPrinc->IsInRole("BUILTIN\\Administrator")); + Console::WriteLine("Is a Hacker?: {0}", gPrinc->IsInRole("Hacker")); + + GenericIdentity ^gIdent = (GenericIdentity^)gPrinc->Identity; + + Console::WriteLine("\nUser Name: {0}", gIdent->Name); + Console::WriteLine("Is Authenticated: {0}\n", gIdent->IsAuthenticated); +} diff --git a/Chapter21/PrincipalIdentity/PrincipalIdentity.vcproj b/Chapter21/PrincipalIdentity/PrincipalIdentity.vcproj new file mode 100644 index 0000000..2e5e501 --- /dev/null +++ b/Chapter21/PrincipalIdentity/PrincipalIdentity.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter21/RemoveSecurity/RemoveSecurity.cpp b/Chapter21/RemoveSecurity/RemoveSecurity.cpp new file mode 100644 index 0000000..77a6038 --- /dev/null +++ b/Chapter21/RemoveSecurity/RemoveSecurity.cpp @@ -0,0 +1,35 @@ +using namespace System; +using namespace System::Security; +using namespace System::Security::Permissions; +using namespace System::Security::Policy; + +void main() +{ + CodeGroup^ machine; + + // Iterate through policy hierarchy to get Machine Code group + System::Collections::IEnumerator^ ph = SecurityManager::PolicyHierarchy(); + while( ph->MoveNext() ) + { + PolicyLevel^ machinePolicyLevel = (PolicyLevel^)ph->Current; + if (machinePolicyLevel->Label == "Machine") + { + machine = machinePolicyLevel->RootCodeGroup; + break; + } + } + + // Iterate backwards removing all instances of "ReadOnly Secure Group" + for (int i = machine->Children->Count - 1; i >= 0; i--) + { + if(((CodeGroup^)machine->Children[i])->Name == "ReadOnly Secure Group") + { + machine->RemoveChild(((CodeGroup^)machine->Children[i])); + } + } + + // Save changes + SecurityManager::SavePolicy(); + + Console::WriteLine("Removed C:\\Test File ReadOnly Secure Group"); +} diff --git a/Chapter21/RemoveSecurity/RemoveSecurity.vcproj b/Chapter21/RemoveSecurity/RemoveSecurity.vcproj new file mode 100644 index 0000000..e0ef3ff --- /dev/null +++ b/Chapter21/RemoveSecurity/RemoveSecurity.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter21/RoleBasedSecurity/RoleBasedSecurity.cpp b/Chapter21/RoleBasedSecurity/RoleBasedSecurity.cpp new file mode 100644 index 0000000..8a944ff --- /dev/null +++ b/Chapter21/RoleBasedSecurity/RoleBasedSecurity.cpp @@ -0,0 +1,63 @@ +using namespace System; +using namespace System::Security; +using namespace System::Security::Principal; +using namespace System::Security::Permissions; +using namespace System::Threading; + +[PrincipalPermissionAttribute(SecurityAction::Demand, Role = "NotAHacker")] +void DeclarativeSecurity() +{ + Console::WriteLine("I'm in the Declarative Security Function"); +} + +void DemandSecurity() +{ + (gcnew PrincipalPermission(nullptr, "NotAHacker"))->Demand(); + + Console::WriteLine("I'm in the Demand Security Function\n"); +} + + +void main() +{ + try + { + DeclarativeSecurity(); + } + catch (SecurityException^) + { + Console::WriteLine("SECURITY ERROR in Declarative Security Function"); + } + + try + { + DemandSecurity(); + } + catch (SecurityException^) + { + Console::WriteLine("SECURITY ERROR in Demand Security Function\n"); + } + + Console::WriteLine("Set CurrentPrincipal to John with role of NotAHacker"); + array^ rolesArray = {"NotAHacker"}; + Thread::CurrentPrincipal = gcnew GenericPrincipal( + gcnew GenericIdentity( "John" ), + rolesArray ); + try + { + DeclarativeSecurity(); + } + catch (SecurityException^) + { + Console::WriteLine("SECURITY ERROR in Declarative Security Function"); + } + + try + { + DemandSecurity(); + } + catch (SecurityException^) + { + Console::WriteLine("SECURITY ERROR in Demand Security Function"); + } +} diff --git a/Chapter21/RoleBasedSecurity/RoleBasedSecurity.vcproj b/Chapter21/RoleBasedSecurity/RoleBasedSecurity.vcproj new file mode 100644 index 0000000..818e4dc --- /dev/null +++ b/Chapter21/RoleBasedSecurity/RoleBasedSecurity.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter21/SetSecurity/SetSecurity.cpp b/Chapter21/SetSecurity/SetSecurity.cpp new file mode 100644 index 0000000..4c0b5d7 --- /dev/null +++ b/Chapter21/SetSecurity/SetSecurity.cpp @@ -0,0 +1,48 @@ +using namespace System; +using namespace System::Security; +using namespace System::Security::Permissions; +using namespace System::Security::Policy; + +void main() +{ + // Create a new permission set + PermissionSet^ permSet = gcnew PermissionSet(PermissionState::None); + + // Add permissions to the permission set. + permSet->AddPermission( + gcnew SecurityPermission(PermissionState::Unrestricted)); + permSet->AddPermission(gcnew UIPermission(PermissionState::Unrestricted)); + permSet->AddPermission(gcnew FileIOPermission(FileIOPermissionAccess::Read, + "C:\\Test")); + + // Create Policy Statement + PolicyStatement^ policy = gcnew PolicyStatement(permSet); + + // Create Membership condition + IMembershipCondition^ membership = + gcnew UrlMembershipCondition("http://192.168.1.104/Chapter21/*"); + + // Create Code group + CodeGroup^ codeGroup = gcnew UnionCodeGroup(membership, policy); + codeGroup->Description = "C:\\Test ReadOnly permission for Application URL"; + codeGroup->Name = "ReadOnly Secure Group"; + + // Find the machine policy level + System::Collections::IEnumerator^ ph = SecurityManager::PolicyHierarchy(); + + while( ph->MoveNext() ) + { + PolicyLevel^ pl = (PolicyLevel^)ph->Current; + if( pl->Label == "Machine" ) + { + // Add code group to Machine policy + pl->RootCodeGroup->AddChild(codeGroup); + break; + } + } + + // Save changes + SecurityManager::SavePolicy(); + + Console::WriteLine("Added C:\\Test ReadOnly Secure Group"); +} diff --git a/Chapter21/SetSecurity/SetSecurity.vcproj b/Chapter21/SetSecurity/SetSecurity.vcproj new file mode 100644 index 0000000..237edc7 --- /dev/null +++ b/Chapter21/SetSecurity/SetSecurity.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/Chapter22.sln b/Chapter22/Chapter22.sln new file mode 100644 index 0000000..98aac94 --- /dev/null +++ b/Chapter22/Chapter22.sln @@ -0,0 +1,68 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IntPtrArith", "IntPtrArith\IntPtrArith.vcproj", "{8A3B5612-376E-4B94-B591-3A1A9006428D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IntPtr", "IntPtrMoving\IntPtrMoving.vcproj", "{AD1044A0-4AEC-46D1-B0CC-3B17AA534A0F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MixManUnman", "MixManUnman\MixManUnman.vcproj", "{8F7C524D-7538-4402-8958-5A3077DBAD46}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MixManUnmanClass", "MixManUnmanClass\MixManUnmanClass.vcproj", "{4CF1A97E-2016-46CA-B5DC-86F7C2F25FA9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MixManUnmanHello", "MixManUnmanHello\MixManUnmanHello.vcproj", "{B587D523-95B3-400A-A4A3-3DE4664F677B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PinIntPtr", "PinIntPtr\PinIntPtr.vcproj", "{1E5B45D2-4BCC-4BD8-8280-870C8052A422}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PinPtr", "PinPtr\PinPtr.vcproj", "{B914BACA-F360-4BA9-A138-4CDDA4C9AC2E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UMArray", "UMArray\UMArray.vcproj", "{673059DC-8799-42FA-8864-A150B1DC2CEC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ManIntoUnman", "ManIntoUnman\ManIntoUnman.vcproj", "{CBB5F58A-665D-4A1C-855B-81D9C7D00146}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8A3B5612-376E-4B94-B591-3A1A9006428D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8A3B5612-376E-4B94-B591-3A1A9006428D}.Debug|Win32.Build.0 = Debug|Win32 + {8A3B5612-376E-4B94-B591-3A1A9006428D}.Release|Win32.ActiveCfg = Release|Win32 + {8A3B5612-376E-4B94-B591-3A1A9006428D}.Release|Win32.Build.0 = Release|Win32 + {AD1044A0-4AEC-46D1-B0CC-3B17AA534A0F}.Debug|Win32.ActiveCfg = Debug|Win32 + {AD1044A0-4AEC-46D1-B0CC-3B17AA534A0F}.Debug|Win32.Build.0 = Debug|Win32 + {AD1044A0-4AEC-46D1-B0CC-3B17AA534A0F}.Release|Win32.ActiveCfg = Release|Win32 + {AD1044A0-4AEC-46D1-B0CC-3B17AA534A0F}.Release|Win32.Build.0 = Release|Win32 + {8F7C524D-7538-4402-8958-5A3077DBAD46}.Debug|Win32.ActiveCfg = Debug|Win32 + {8F7C524D-7538-4402-8958-5A3077DBAD46}.Debug|Win32.Build.0 = Debug|Win32 + {8F7C524D-7538-4402-8958-5A3077DBAD46}.Release|Win32.ActiveCfg = Release|Win32 + {8F7C524D-7538-4402-8958-5A3077DBAD46}.Release|Win32.Build.0 = Release|Win32 + {4CF1A97E-2016-46CA-B5DC-86F7C2F25FA9}.Debug|Win32.ActiveCfg = Debug|Win32 + {4CF1A97E-2016-46CA-B5DC-86F7C2F25FA9}.Debug|Win32.Build.0 = Debug|Win32 + {4CF1A97E-2016-46CA-B5DC-86F7C2F25FA9}.Release|Win32.ActiveCfg = Release|Win32 + {4CF1A97E-2016-46CA-B5DC-86F7C2F25FA9}.Release|Win32.Build.0 = Release|Win32 + {B587D523-95B3-400A-A4A3-3DE4664F677B}.Debug|Win32.ActiveCfg = Debug|Win32 + {B587D523-95B3-400A-A4A3-3DE4664F677B}.Debug|Win32.Build.0 = Debug|Win32 + {B587D523-95B3-400A-A4A3-3DE4664F677B}.Release|Win32.ActiveCfg = Release|Win32 + {B587D523-95B3-400A-A4A3-3DE4664F677B}.Release|Win32.Build.0 = Release|Win32 + {1E5B45D2-4BCC-4BD8-8280-870C8052A422}.Debug|Win32.ActiveCfg = Debug|Win32 + {1E5B45D2-4BCC-4BD8-8280-870C8052A422}.Debug|Win32.Build.0 = Debug|Win32 + {1E5B45D2-4BCC-4BD8-8280-870C8052A422}.Release|Win32.ActiveCfg = Release|Win32 + {1E5B45D2-4BCC-4BD8-8280-870C8052A422}.Release|Win32.Build.0 = Release|Win32 + {B914BACA-F360-4BA9-A138-4CDDA4C9AC2E}.Debug|Win32.ActiveCfg = Debug|Win32 + {B914BACA-F360-4BA9-A138-4CDDA4C9AC2E}.Debug|Win32.Build.0 = Debug|Win32 + {B914BACA-F360-4BA9-A138-4CDDA4C9AC2E}.Release|Win32.ActiveCfg = Release|Win32 + {B914BACA-F360-4BA9-A138-4CDDA4C9AC2E}.Release|Win32.Build.0 = Release|Win32 + {673059DC-8799-42FA-8864-A150B1DC2CEC}.Debug|Win32.ActiveCfg = Debug|Win32 + {673059DC-8799-42FA-8864-A150B1DC2CEC}.Debug|Win32.Build.0 = Debug|Win32 + {673059DC-8799-42FA-8864-A150B1DC2CEC}.Release|Win32.ActiveCfg = Release|Win32 + {673059DC-8799-42FA-8864-A150B1DC2CEC}.Release|Win32.Build.0 = Release|Win32 + {CBB5F58A-665D-4A1C-855B-81D9C7D00146}.Debug|Win32.ActiveCfg = Debug|Win32 + {CBB5F58A-665D-4A1C-855B-81D9C7D00146}.Debug|Win32.Build.0 = Debug|Win32 + {CBB5F58A-665D-4A1C-855B-81D9C7D00146}.Release|Win32.ActiveCfg = Release|Win32 + {CBB5F58A-665D-4A1C-855B-81D9C7D00146}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter22/Chapter22.suo b/Chapter22/Chapter22.suo new file mode 100644 index 0000000..718fdb1 Binary files /dev/null and b/Chapter22/Chapter22.suo differ diff --git a/Chapter22/IntPtrArith/IntPtrArith.cpp b/Chapter22/IntPtrArith/IntPtrArith.cpp new file mode 100644 index 0000000..b0d7cdd --- /dev/null +++ b/Chapter22/IntPtrArith/IntPtrArith.cpp @@ -0,0 +1,17 @@ +using namespace System; + +void main() +{ + array^ primes = gcnew array {1,2,3,5,7,11,13,17}; + + interior_ptr ip = &primes[0]; // Create the interior pointer + + int total = 0; + while(ip != &primes[0] + primes->Length) // Comparing pointers + { + total += *ip; + ip++; // Add size of int to ip not 1 + } + + Console::WriteLine("Sum of the first 8 prime numbers is {0}", total); +} diff --git a/Chapter22/IntPtrArith/IntPtrArith.vcproj b/Chapter22/IntPtrArith/IntPtrArith.vcproj new file mode 100644 index 0000000..ce2f4f8 --- /dev/null +++ b/Chapter22/IntPtrArith/IntPtrArith.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/IntPtrMoving/IntPtr.cpp b/Chapter22/IntPtrMoving/IntPtr.cpp new file mode 100644 index 0000000..3fea8aa --- /dev/null +++ b/Chapter22/IntPtrMoving/IntPtr.cpp @@ -0,0 +1,26 @@ +using namespace System; + +ref class Point +{ +public: + int X; +}; + +void main() +{ + Point ^p = gcnew Point(); + + interior_ptr ip1 = &p; // pointer to Point + + (*ip1)->X = 1; + + Console::WriteLine("(&ip1)={0:X}\tp->X={1}\t(*ip1)->X={2}", + (int)&ip1, p->X, (*ip1)->X); + + interior_ptr ip2 = &p->X; // pointer to Member variable X + + *ip2 += (*ip1)->X; + + Console::WriteLine("(&ip2)={0:X}\t*ip2={1}", + (int)&ip2, *ip2); +} diff --git a/Chapter22/IntPtrMoving/IntPtrMoving.vcproj b/Chapter22/IntPtrMoving/IntPtrMoving.vcproj new file mode 100644 index 0000000..05f4cd1 --- /dev/null +++ b/Chapter22/IntPtrMoving/IntPtrMoving.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/ManIntoUnman/ManIntoUnman.cpp b/Chapter22/ManIntoUnman/ManIntoUnman.cpp new file mode 100644 index 0000000..95d22ec --- /dev/null +++ b/Chapter22/ManIntoUnman/ManIntoUnman.cpp @@ -0,0 +1,46 @@ +#include "stdio.h" + +using namespace System; +using namespace System::Runtime::InteropServices; + +ref class MClass +{ +public: + int x; + ~MClass() { Console::WriteLine("MClass disposed"); } +protected: + !MClass() { Console::WriteLine("MClass finalized\n\n\n"); } +}; + +#pragma unmanaged // works with or without this line + +class UMClass +{ +public: + void* mclass; + + ~UMClass() { printf("UMClass deleted\n"); } +}; + +#pragma managed + +void main() +{ + UMClass *umc = new UMClass(); + + // Place ref class on unmanaged void* pointer + umc->mclass = GCHandle::ToIntPtr(GCHandle::Alloc(gcnew MClass())).ToPointer(); + + // access int variable x by typecasting void* + ((MClass^)GCHandle::FromIntPtr(System::IntPtr(umc->mclass)).Target)->x = 4; + + // Manage print int variable x + Console::WriteLine("Managed Print {0}", + ((MClass^)(GCHandle::FromIntPtr(System::IntPtr(umc->mclass))).Target)->x); + + // Unmanage print int variable x + printf("Unmanaged Print %d\n", + ((MClass^)(GCHandle::FromIntPtr(System::IntPtr(umc->mclass))).Target)->x); + + delete umc; +} diff --git a/Chapter22/ManIntoUnman/ManIntoUnman.vcproj b/Chapter22/ManIntoUnman/ManIntoUnman.vcproj new file mode 100644 index 0000000..ff2f31b --- /dev/null +++ b/Chapter22/ManIntoUnman/ManIntoUnman.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/MixManUnman/MixManUnman.cpp b/Chapter22/MixManUnman/MixManUnman.cpp new file mode 100644 index 0000000..4c6dde5 --- /dev/null +++ b/Chapter22/MixManUnman/MixManUnman.cpp @@ -0,0 +1,23 @@ +using namespace System; + +#pragma unmanaged + +int UMadd(int a, int b) +{ + return a + b; +} + +#pragma managed + + +int Madd(int a, int b) +{ + return a + b; +} + +void main() +{ + Console::WriteLine("Unmanaged Add 2 + 2: {0}", UMadd(2, 2)); + Console::WriteLine("Managed Add 3 + 3: {0}", Madd(3, 3)); +} + diff --git a/Chapter22/MixManUnman/MixManUnman.vcproj b/Chapter22/MixManUnman/MixManUnman.vcproj new file mode 100644 index 0000000..9b4fd5f --- /dev/null +++ b/Chapter22/MixManUnman/MixManUnman.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/MixManUnmanClass/MixManUnmanClass.cpp b/Chapter22/MixManUnmanClass/MixManUnmanClass.cpp new file mode 100644 index 0000000..b2ddf59 --- /dev/null +++ b/Chapter22/MixManUnmanClass/MixManUnmanClass.cpp @@ -0,0 +1,106 @@ +using namespace System; + +class ClassMember {}; +ref class RefClassMember {}; +value class ValueClassMember {}; + +class Class +{ +public: +// RefClassMember rc; // Can't embed instance ref class +// RefClassMember ^hrc; // Can't embed handle to ref class + ValueClassMember vc; +// ValueClassMember ^hvc; // Can't embed managed value class + ValueClassMember *pvc; + ClassMember c; + ClassMember *pc; + + int x; + void write() { Console::WriteLine("Class x: {0}", x); } +}; + +ref class RefClass +{ +public: + RefClassMember rc; + RefClassMember ^hrc; + ValueClassMember vc; + ValueClassMember ^hvc; + ValueClassMember *pvc; +// ClassMember c; // Can't embed instance of class + ClassMember *pc; + + int x; + void write() { Console::WriteLine("RefClass x: {0}", x); } +}; + +value class ValueClass +{ +public: +// RefClassMember rc; // Can't embed instance ref class + RefClassMember ^hrc; + ValueClassMember vc; + ValueClassMember ^hvc; + ValueClassMember *pvc; +// ClassMember c; // Can't embed instance of class + ClassMember *pc; + + int x; + void write() { Console::WriteLine("ValueClass x: {0}", x); } +}; + + +class ClassChildClassParent : public Class {}; // OK +//class ClassChildRefClassParent : public RefClass {}; // Error +//class ClassChildValueClassParent : public ValueClass {}; // Error + +//ref class RefClassChildClassParent : public Class {}; // Error +ref class RefClassChildRefClassParent : public RefClass {}; // OK +//ref class RefClassChildValueClassParent : public ValueClass {}; // Error + +//value class ValueClassChildClassParent : public Class {}; // Error +//value class ValueClassChildRefClassParent : public RefClass {}; // Error +//value class ValueClassChildValueClassParent : public ValueClass {}; // Error + +void main() +{ + // Stack + Class _class; + RefClass refclass; // Not really on the stack + ValueClass valueclass; + + // Handle +// Class ^hclass = gcnew Class(); // Not allowed + RefClass ^hrefclass = gcnew RefClass(); + ValueClass ^hvalueclass = gcnew ValueClass(); + + // Pointer + Class *pclass = new Class(); +// RefClass *prefclass = new RefClass(); // Not allowed + ValueClass *pvalueclass = & valueclass; + + // Reference + Class &rfclass = *new Class(); +// RefClass &rfrefclass = *gcnew RefClass(); // Not allowed + ValueClass &rfvalueclass = valueclass; + + _class.x = 1; + refclass.x = 2; + valueclass.x = 3; + hrefclass->x = 4; + hvalueclass->x = 5; + pclass->x = 6; + pvalueclass->x = 7; + rfclass.x = 8; + rfvalueclass.x = 9; + + _class.write(); // prints 1 + refclass.write(); // prints 2 + valueclass.write(); // prints 9 + hrefclass->write(); // prints 4 + hvalueclass->write(); // prints 5 + pclass->write(); // prints 6 + pvalueclass->write(); // prints 9 + rfclass.write(); // prints 8 + rfvalueclass.write(); // prints 9 +} diff --git a/Chapter22/MixManUnmanClass/MixManUnmanClass.vcproj b/Chapter22/MixManUnmanClass/MixManUnmanClass.vcproj new file mode 100644 index 0000000..6fe9798 --- /dev/null +++ b/Chapter22/MixManUnmanClass/MixManUnmanClass.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/MixManUnmanHello/MixManUnmanHello.cpp b/Chapter22/MixManUnmanHello/MixManUnmanHello.cpp new file mode 100644 index 0000000..868a594 --- /dev/null +++ b/Chapter22/MixManUnmanHello/MixManUnmanHello.cpp @@ -0,0 +1,13 @@ +#include "stdio.h" +#include + +using namespace System; + +void main() +{ + String ^hstr = "Hello World!"; + + pin_ptr pstr = PtrToStringChars(hstr); + + wprintf(pstr); +} diff --git a/Chapter22/MixManUnmanHello/MixManUnmanHello.vcproj b/Chapter22/MixManUnmanHello/MixManUnmanHello.vcproj new file mode 100644 index 0000000..c63343e --- /dev/null +++ b/Chapter22/MixManUnmanHello/MixManUnmanHello.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/PinIntPtr/PinIntPtr.cpp b/Chapter22/PinIntPtr/PinIntPtr.cpp new file mode 100644 index 0000000..4a7ec65 --- /dev/null +++ b/Chapter22/PinIntPtr/PinIntPtr.cpp @@ -0,0 +1,32 @@ +using namespace System; + +value class Test +{ +public: + int i; +}; + +#pragma unmanaged + +void incr (int *i) +{ + (*i) += 10; +} + +#pragma managed + +void main () +{ + Test ^test = gcnew Test(); + interior_ptr ip = &test->i; + (*ip) = 5; + +// incr( ip ); // invalid + + pin_ptr i = ip; // i is a pinned int pointer + + incr( i ); // pinned pointer to interior pointer passed to a + // native function call expecting a native pointer + + Console::WriteLine ( test->i ); +} diff --git a/Chapter22/PinIntPtr/PinIntPtr.vcproj b/Chapter22/PinIntPtr/PinIntPtr.vcproj new file mode 100644 index 0000000..84164a9 --- /dev/null +++ b/Chapter22/PinIntPtr/PinIntPtr.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/PinPtr/PinPtr.cpp b/Chapter22/PinPtr/PinPtr.cpp new file mode 100644 index 0000000..ea2e562 --- /dev/null +++ b/Chapter22/PinPtr/PinPtr.cpp @@ -0,0 +1,66 @@ +#include + +using namespace System; + +ref class RTest +{ +public: + int i; + RTest() + { + i = 0; + } +}; + +value class VTest +{ +public: + int i; +}; + +#pragma unmanaged + +void incr (int *i) +{ + (*i) += 10; +} + +#pragma managed + +void incr (VTest *t) +{ + t->i += 20; +} + +void main () +{ + RTest ^rtest = gcnew RTest(); // rtest is a reference type + + pin_ptr i = &(rtest->i); // i is a pinned int pointer + + incr( i ); // Pointer to managed data passed as + // parameter of unmanaged function call + + Console::WriteLine ( rtest->i ); + + VTest ^vtest = gcnew VTest; // vtest is a boxed value type + vtest->i = 0; + + pin_ptr ptest = &*vtest; // ptest is a pinned value type. + // The &* says give the address of the + // indirection of vtest + + incr( ptest ); // Pointer to value type passed as + // parameter of unmanaged function call + + Console::WriteLine ( vtest->i ); + + + array^ arr = gcnew array {'M', 'C', '+', '+'}; + + pin_ptr p = &arr[1]; // ENTIRE array is pinned + unsigned char *cp = p; + printf("%s\n", --cp); // cp bytes will not move during call + // notice the negative pointer arithmetic + // into the array. +} diff --git a/Chapter22/PinPtr/PinPtr.vcproj b/Chapter22/PinPtr/PinPtr.vcproj new file mode 100644 index 0000000..36f5b5b --- /dev/null +++ b/Chapter22/PinPtr/PinPtr.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter22/UMArray/UMArray.cpp b/Chapter22/UMArray/UMArray.cpp new file mode 100644 index 0000000..2ff739c --- /dev/null +++ b/Chapter22/UMArray/UMArray.cpp @@ -0,0 +1,12 @@ +using namespace System; + +void main() +{ + int UMarray[5] = {2, 3, 5, 7, 11}; + + for (int i = 0; i < 5; i++) + { + Console::Write("{0} ", UMarray[i]); + } + Console::WriteLine(" -- End of array"); +} diff --git a/Chapter22/UMArray/UMArray.vcproj b/Chapter22/UMArray/UMArray.vcproj new file mode 100644 index 0000000..4a10c5e --- /dev/null +++ b/Chapter22/UMArray/UMArray.vcproj @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/Chapter23.sln b/Chapter23/Chapter23.sln new file mode 100644 index 0000000..1abcdb9 --- /dev/null +++ b/Chapter23/Chapter23.sln @@ -0,0 +1,68 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DllOldWay", "DllOldWay\DllOldWay.vcproj", "{5A71BD5E-0D5B-4E71-BFFE-32D569FFEC83}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NativeCode", "NativeCode\NativeCode.vcproj", "{DC5E3BB1-8A27-479F-A0A3-BC9ABDE1AD3F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimplePInvoke", "SimplePInvoke\SimplePInvoke.vcproj", "{520A4064-D795-4658-AA50-CEF1C9088BDD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StaticMemberPInvoke", "StaticMemberPInvoke\StaticMemberPInvoke.vcproj", "{41E62FC5-5145-4670-92F6-E0A7AD130137}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InOutString", "InOutString\InOutString.vcproj", "{B3AC1C76-79D0-4E28-998D-0A49F0787B35}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ClassMarshal", "ClassMarshal\ClassMarshal.vcproj", "{CED76714-587B-4148-9B00-7CB64E08642A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCOM", "TestCOM\TestCOM.vcproj", "{AAA45069-D403-4CAA-B2F3-ADE3F331BB31}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InvokeTestCOM", "InvokeTestCOM\InvokeTestCOM.vcproj", "{BCAD877D-DDE0-4C93-90B5-CEBD8198B0F6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LateBindTestCOM", "LateBindTestCOM\LateBindTestCOM.vcproj", "{B05AB45E-2A06-4F8F-8451-D17F33868E65}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5A71BD5E-0D5B-4E71-BFFE-32D569FFEC83}.Debug|Win32.ActiveCfg = Debug|Win32 + {5A71BD5E-0D5B-4E71-BFFE-32D569FFEC83}.Debug|Win32.Build.0 = Debug|Win32 + {5A71BD5E-0D5B-4E71-BFFE-32D569FFEC83}.Release|Win32.ActiveCfg = Release|Win32 + {5A71BD5E-0D5B-4E71-BFFE-32D569FFEC83}.Release|Win32.Build.0 = Release|Win32 + {DC5E3BB1-8A27-479F-A0A3-BC9ABDE1AD3F}.Debug|Win32.ActiveCfg = Debug|Win32 + {DC5E3BB1-8A27-479F-A0A3-BC9ABDE1AD3F}.Debug|Win32.Build.0 = Debug|Win32 + {DC5E3BB1-8A27-479F-A0A3-BC9ABDE1AD3F}.Release|Win32.ActiveCfg = Release|Win32 + {DC5E3BB1-8A27-479F-A0A3-BC9ABDE1AD3F}.Release|Win32.Build.0 = Release|Win32 + {520A4064-D795-4658-AA50-CEF1C9088BDD}.Debug|Win32.ActiveCfg = Debug|Win32 + {520A4064-D795-4658-AA50-CEF1C9088BDD}.Debug|Win32.Build.0 = Debug|Win32 + {520A4064-D795-4658-AA50-CEF1C9088BDD}.Release|Win32.ActiveCfg = Release|Win32 + {520A4064-D795-4658-AA50-CEF1C9088BDD}.Release|Win32.Build.0 = Release|Win32 + {41E62FC5-5145-4670-92F6-E0A7AD130137}.Debug|Win32.ActiveCfg = Debug|Win32 + {41E62FC5-5145-4670-92F6-E0A7AD130137}.Debug|Win32.Build.0 = Debug|Win32 + {41E62FC5-5145-4670-92F6-E0A7AD130137}.Release|Win32.ActiveCfg = Release|Win32 + {41E62FC5-5145-4670-92F6-E0A7AD130137}.Release|Win32.Build.0 = Release|Win32 + {B3AC1C76-79D0-4E28-998D-0A49F0787B35}.Debug|Win32.ActiveCfg = Debug|Win32 + {B3AC1C76-79D0-4E28-998D-0A49F0787B35}.Debug|Win32.Build.0 = Debug|Win32 + {B3AC1C76-79D0-4E28-998D-0A49F0787B35}.Release|Win32.ActiveCfg = Release|Win32 + {B3AC1C76-79D0-4E28-998D-0A49F0787B35}.Release|Win32.Build.0 = Release|Win32 + {CED76714-587B-4148-9B00-7CB64E08642A}.Debug|Win32.ActiveCfg = Debug|Win32 + {CED76714-587B-4148-9B00-7CB64E08642A}.Debug|Win32.Build.0 = Debug|Win32 + {CED76714-587B-4148-9B00-7CB64E08642A}.Release|Win32.ActiveCfg = Release|Win32 + {CED76714-587B-4148-9B00-7CB64E08642A}.Release|Win32.Build.0 = Release|Win32 + {AAA45069-D403-4CAA-B2F3-ADE3F331BB31}.Debug|Win32.ActiveCfg = Debug|Win32 + {AAA45069-D403-4CAA-B2F3-ADE3F331BB31}.Debug|Win32.Build.0 = Debug|Win32 + {AAA45069-D403-4CAA-B2F3-ADE3F331BB31}.Release|Win32.ActiveCfg = Release|Win32 + {AAA45069-D403-4CAA-B2F3-ADE3F331BB31}.Release|Win32.Build.0 = Release|Win32 + {BCAD877D-DDE0-4C93-90B5-CEBD8198B0F6}.Debug|Win32.ActiveCfg = Debug|Win32 + {BCAD877D-DDE0-4C93-90B5-CEBD8198B0F6}.Debug|Win32.Build.0 = Debug|Win32 + {BCAD877D-DDE0-4C93-90B5-CEBD8198B0F6}.Release|Win32.ActiveCfg = Release|Win32 + {BCAD877D-DDE0-4C93-90B5-CEBD8198B0F6}.Release|Win32.Build.0 = Release|Win32 + {B05AB45E-2A06-4F8F-8451-D17F33868E65}.Debug|Win32.ActiveCfg = Debug|Win32 + {B05AB45E-2A06-4F8F-8451-D17F33868E65}.Debug|Win32.Build.0 = Debug|Win32 + {B05AB45E-2A06-4F8F-8451-D17F33868E65}.Release|Win32.ActiveCfg = Release|Win32 + {B05AB45E-2A06-4F8F-8451-D17F33868E65}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter23/Chapter23.suo b/Chapter23/Chapter23.suo new file mode 100644 index 0000000..f6d5865 Binary files /dev/null and b/Chapter23/Chapter23.suo differ diff --git a/Chapter23/ClassMarshal/ClassMarshal.cpp b/Chapter23/ClassMarshal/ClassMarshal.cpp new file mode 100644 index 0000000..fdb52f7 --- /dev/null +++ b/Chapter23/ClassMarshal/ClassMarshal.cpp @@ -0,0 +1,52 @@ +using namespace System; +using namespace System::Runtime::InteropServices; + +[StructLayout(LayoutKind::Sequential)] +value class vRec +{ +public: + int width; + int height; + + + vRec(int iwidth, int iheight) + { + width = iwidth; + height = iheight; + } +}; + +[StructLayout(LayoutKind::Sequential)] +ref class rRec +{ +public: + int width; + int height; + + rRec(int iwidth, int iheight) + { + width = iwidth; + height = iheight; + } +}; + +// By value +[DllImportAttribute("NativeCode.dll")] +extern "C" bool vIsSquare(vRec rec); + +// by reference +[DllImportAttribute("NativeCode.dll")] +extern "C" bool rIsSquare(rRec^ rec); + +void main() +{ + // By Value + vRec vrec(2,3); + Console::WriteLine("value class rec a square? {0}", vIsSquare(vrec)); + + // By Reference + rRec ^rrec = gcnew rRec(3,3); + Console::WriteLine("ref class rec a square? {0}", rIsSquare(rrec)); + + Console::WriteLine("\n\n"); +} diff --git a/Chapter23/ClassMarshal/ClassMarshal.vcproj b/Chapter23/ClassMarshal/ClassMarshal.vcproj new file mode 100644 index 0000000..fc072ab --- /dev/null +++ b/Chapter23/ClassMarshal/ClassMarshal.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/DllOldWay/DllOldWay.cpp b/Chapter23/DllOldWay/DllOldWay.cpp new file mode 100644 index 0000000..082a07b --- /dev/null +++ b/Chapter23/DllOldWay/DllOldWay.cpp @@ -0,0 +1,20 @@ +// DllOldWay.cpp : main project file. + +#include "stdafx.h" +#include "windows.h" + +extern "C" __declspec(dllimport) long square(long value); + +using namespace System; + +int main(array ^args) +{ + long Squareof4 = square(4); + + Console::WriteLine(L"The square of 4 is {0}", Squareof4); + + MessageBox(0, L"Hello World!", L"A Message Box", 0); + + return 0; +} + diff --git a/Chapter23/DllOldWay/DllOldWay.vcproj b/Chapter23/DllOldWay/DllOldWay.vcproj new file mode 100644 index 0000000..8201c63 --- /dev/null +++ b/Chapter23/DllOldWay/DllOldWay.vcproj @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/DllOldWay/stdafx.cpp b/Chapter23/DllOldWay/stdafx.cpp new file mode 100644 index 0000000..8386c43 --- /dev/null +++ b/Chapter23/DllOldWay/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// DllOldWay.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/Chapter23/DllOldWay/stdafx.h b/Chapter23/DllOldWay/stdafx.h new file mode 100644 index 0000000..39986bd --- /dev/null +++ b/Chapter23/DllOldWay/stdafx.h @@ -0,0 +1,8 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +// TODO: reference additional headers your program requires here diff --git a/Chapter23/InOutString/InOutString.cpp b/Chapter23/InOutString/InOutString.cpp new file mode 100644 index 0000000..7ecee4a --- /dev/null +++ b/Chapter23/InOutString/InOutString.cpp @@ -0,0 +1,16 @@ +using namespace System; +using namespace System::Text; +using namespace System::Runtime::InteropServices; + +[DllImport("msvcrt", CharSet=CharSet::Ansi)] +extern "C" int strcpy([MarshalAs(UnmanagedType::LPStr)] StringBuilder^ dest, + [MarshalAs(UnmanagedType::LPStr)] String^ source); + +void main() +{ + StringBuilder^ dest = gcnew StringBuilder(); + String^ source = "Hello"; + + strcpy(dest, source); + Console::WriteLine(dest); +} diff --git a/Chapter23/InOutString/InOutString.vcproj b/Chapter23/InOutString/InOutString.vcproj new file mode 100644 index 0000000..cb79ef6 --- /dev/null +++ b/Chapter23/InOutString/InOutString.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/InvokeTestCOM/Interop/Interop.TestCOM.1.0.dll b/Chapter23/InvokeTestCOM/Interop/Interop.TestCOM.1.0.dll new file mode 100644 index 0000000..ae833b5 Binary files /dev/null and b/Chapter23/InvokeTestCOM/Interop/Interop.TestCOM.1.0.dll differ diff --git a/Chapter23/InvokeTestCOM/InvokeTestCOM.cpp b/Chapter23/InvokeTestCOM/InvokeTestCOM.cpp new file mode 100644 index 0000000..31a863e --- /dev/null +++ b/Chapter23/InvokeTestCOM/InvokeTestCOM.cpp @@ -0,0 +1,24 @@ +// #using // Add if you are not referencing using VS .NET + +using namespace System; +using namespace TestCOM; + +int main(array ^args) +{ + CTestCOMClass^ test = gcnew CTestCOMClass(); + + long ret = test->Square(4); + + Console::WriteLine("The Square of 4 is {0}", ret); + + try + { + long ret = test->Square(0x10000); + } + catch (Exception^ ex) + { + Console::WriteLine("Oops an exception occurred: {0}", ex->Message); + } + + return 0; +} diff --git a/Chapter23/InvokeTestCOM/InvokeTestCOM.vcproj b/Chapter23/InvokeTestCOM/InvokeTestCOM.vcproj new file mode 100644 index 0000000..93ae13f --- /dev/null +++ b/Chapter23/InvokeTestCOM/InvokeTestCOM.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/LateBindTestCOM/LateBindTestCOM.cpp b/Chapter23/LateBindTestCOM/LateBindTestCOM.cpp new file mode 100644 index 0000000..0c5e5bf --- /dev/null +++ b/Chapter23/LateBindTestCOM/LateBindTestCOM.cpp @@ -0,0 +1,36 @@ +using namespace System; +using namespace System::Reflection; + +int main(array ^args) +{ + Type ^typeTestCom = Type::GetTypeFromProgID(L"CTestCOM.CTestCOM"); + + + if (typeTestCom == nullptr) + { + Console::WriteLine("Getting CTestCOM.CTestCOM failed"); + return -1; + } + + try + { + Object ^TestComLBnd = Activator::CreateInstance(typeTestCom); + + array^ param = gcnew array { 4 }; + + Object ^ret = typeTestCom->InvokeMember( + L"Square", + Reflection::BindingFlags::InvokeMethod, + nullptr, + TestComLBnd, + param); + + Console::WriteLine("Square of 4 is {0}", ret); + } + catch (Exception ^ex) + { + Console::WriteLine("Error when invoking Square method: {0}", + ex->Message); + } + return 0; +} diff --git a/Chapter23/LateBindTestCOM/LateBindTestCOM.vcproj b/Chapter23/LateBindTestCOM/LateBindTestCOM.vcproj new file mode 100644 index 0000000..bd7ef0b --- /dev/null +++ b/Chapter23/LateBindTestCOM/LateBindTestCOM.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/NativeCode/NativeCode.cpp b/Chapter23/NativeCode/NativeCode.cpp new file mode 100644 index 0000000..e1e23c9 --- /dev/null +++ b/Chapter23/NativeCode/NativeCode.cpp @@ -0,0 +1,33 @@ +// NativeCode.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" +#include + +extern "C" __declspec(dllexport) long square(long value) +{ + return value * value; +} + +extern "C" +{ + struct Rec + { + int width; + int height; + }; + + // By reference + __declspec(dllexport) bool rIsSquare(Rec *rec) + { + return rec->width == rec->height; + } + + // By value + __declspec(dllexport) bool vIsSquare(Rec rec) + { + return rec.width == rec.height; + } +} + + diff --git a/Chapter23/NativeCode/NativeCode.vcproj b/Chapter23/NativeCode/NativeCode.vcproj new file mode 100644 index 0000000..7dbe65f --- /dev/null +++ b/Chapter23/NativeCode/NativeCode.vcproj @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/NativeCode/ReadMe.txt b/Chapter23/NativeCode/ReadMe.txt new file mode 100644 index 0000000..0bc3cc3 --- /dev/null +++ b/Chapter23/NativeCode/ReadMe.txt @@ -0,0 +1,41 @@ +======================================================================== + DYNAMIC LINK LIBRARY : NativeCode Project Overview +======================================================================== + +AppWizard has created this NativeCode DLL for you. + +This file contains a summary of what you will find in each of the files that +make up your NativeCode application. + + +NativeCode.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +NativeCode.cpp + This is the main DLL source file. + + When created, this DLL does not export any symbols. As a result, it + will not produce a .lib file when it is built. If you wish this project + to be a project dependency of some other project, you will either need to + add code to export some symbols from the DLL so that an export library + will be produced, or you can set the Ignore Input Library property to Yes + on the General propert page of the Linker folder in the project's Property + Pages dialog box. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named NativeCode.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Chapter23/NativeCode/dllmain.cpp b/Chapter23/NativeCode/dllmain.cpp new file mode 100644 index 0000000..69b5891 --- /dev/null +++ b/Chapter23/NativeCode/dllmain.cpp @@ -0,0 +1,19 @@ +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/Chapter23/NativeCode/stdafx.cpp b/Chapter23/NativeCode/stdafx.cpp new file mode 100644 index 0000000..a812c10 --- /dev/null +++ b/Chapter23/NativeCode/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// NativeCode.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/Chapter23/NativeCode/stdafx.h b/Chapter23/NativeCode/stdafx.h new file mode 100644 index 0000000..f3a0737 --- /dev/null +++ b/Chapter23/NativeCode/stdafx.h @@ -0,0 +1,16 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + + + +// TODO: reference additional headers your program requires here diff --git a/Chapter23/NativeCode/targetver.h b/Chapter23/NativeCode/targetver.h new file mode 100644 index 0000000..203dfbc --- /dev/null +++ b/Chapter23/NativeCode/targetver.h @@ -0,0 +1,24 @@ +#pragma once + +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. +#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. +#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. +#endif diff --git a/Chapter23/SimplePInvoke/SimplePInvoke.cpp b/Chapter23/SimplePInvoke/SimplePInvoke.cpp new file mode 100644 index 0000000..4b255cc --- /dev/null +++ b/Chapter23/SimplePInvoke/SimplePInvoke.cpp @@ -0,0 +1,23 @@ +using namespace System; +using namespace System::Runtime::InteropServices; + +[DllImportAttribute("..\\Debug\\NativeCode.dll", + CallingConvention=CallingConvention::StdCall)] +extern "C" long square(long value); + + +[DllImport("User32.dll", CharSet=CharSet::Auto, + CallingConvention=CallingConvention::StdCall)] +extern "C" int MessageBox(int hWnd, String^ text, String^ caption, + unsigned int type); + +int main(array ^args) +{ + long Squareof4 = square(4); + + Console::WriteLine(L"The square of 4 is {0}", Squareof4); + + MessageBox(0, L"Hello World!", L"A Message Box", 0); + + return 0; +} diff --git a/Chapter23/SimplePInvoke/SimplePInvoke.vcproj b/Chapter23/SimplePInvoke/SimplePInvoke.vcproj new file mode 100644 index 0000000..434262c --- /dev/null +++ b/Chapter23/SimplePInvoke/SimplePInvoke.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/StaticMemberPInvoke/StaticMemberPInvoke.cpp b/Chapter23/StaticMemberPInvoke/StaticMemberPInvoke.cpp new file mode 100644 index 0000000..0593d06 --- /dev/null +++ b/Chapter23/StaticMemberPInvoke/StaticMemberPInvoke.cpp @@ -0,0 +1,24 @@ +using namespace System; +using namespace System::Runtime::InteropServices; + +ref class SimpleClass +{ +public: + [DllImport("NativeCode")] + static long square(long value); + + [DllImport("User32", CharSet=CharSet::Auto)] + static int MessageBox(int hWnd, String^ text, String^ caption, + unsigned int type); +}; + +int main(array ^args) +{ + long Squareof4 = SimpleClass::square(4); + + Console::WriteLine(L"The square of 4 is {0}", Squareof4); + + SimpleClass::MessageBox(0, L"Hello World!", L"A Message Box", 0); + + return 0; +} diff --git a/Chapter23/StaticMemberPInvoke/StaticMemberPInvoke.vcproj b/Chapter23/StaticMemberPInvoke/StaticMemberPInvoke.vcproj new file mode 100644 index 0000000..ab22ec3 --- /dev/null +++ b/Chapter23/StaticMemberPInvoke/StaticMemberPInvoke.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/TestCOM/TestCOM.cpp b/Chapter23/TestCOM/TestCOM.cpp new file mode 100644 index 0000000..9b05beb --- /dev/null +++ b/Chapter23/TestCOM/TestCOM.cpp @@ -0,0 +1,36 @@ +// Compile from command line using +// cl /LD TestCOM.cpp +// regsvr32 TestCOM.dll + +#define _ATL_ATTRIBUTES +#include +#include + +[module(name="TestCOM",type=dll)]; + +// ITestCOM interface with Square method +[dual] +__interface ITestCOM : IDispatch +{ + [id(0x01)] HRESULT Square([in]LONG Value, [out,retval]LONG* Result); +}; + +// coclass CTestCOM implements the ITestCOM interface +[coclass, threading=both] +class CTestCOM : public ITestCOM +{ + HRESULT Square(LONG Value, LONG* Result) + { + if (Value > 0x0ffff) + { + *Result = -1; + return E_INVALIDARG; + } + else + { + *Result = Value * Value; + return S_OK; + } + } +}; + diff --git a/Chapter23/TestCOM/TestCOM.dll b/Chapter23/TestCOM/TestCOM.dll new file mode 100644 index 0000000..8748d79 Binary files /dev/null and b/Chapter23/TestCOM/TestCOM.dll differ diff --git a/Chapter23/TestCOM/TestCOM.exp b/Chapter23/TestCOM/TestCOM.exp new file mode 100644 index 0000000..c8862a8 Binary files /dev/null and b/Chapter23/TestCOM/TestCOM.exp differ diff --git a/Chapter23/TestCOM/TestCOM.lib b/Chapter23/TestCOM/TestCOM.lib new file mode 100644 index 0000000..9941fe8 Binary files /dev/null and b/Chapter23/TestCOM/TestCOM.lib differ diff --git a/Chapter23/TestCOM/TestCOM.obj b/Chapter23/TestCOM/TestCOM.obj new file mode 100644 index 0000000..d7947e3 Binary files /dev/null and b/Chapter23/TestCOM/TestCOM.obj differ diff --git a/Chapter23/TestCOM/TestCOM.vcproj b/Chapter23/TestCOM/TestCOM.vcproj new file mode 100644 index 0000000..fe3d53d --- /dev/null +++ b/Chapter23/TestCOM/TestCOM.vcproj @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter23/TestCOM/dlldata.c b/Chapter23/TestCOM/dlldata.c new file mode 100644 index 0000000..2027429 --- /dev/null +++ b/Chapter23/TestCOM/dlldata.c @@ -0,0 +1,38 @@ +/********************************************************* + DllData file -- generated by MIDL compiler + + DO NOT ALTER THIS FILE + + This file is regenerated by MIDL on every IDL file compile. + + To completely reconstruct this file, delete it and rerun MIDL + on all the IDL files in this DLL, specifying this file for the + /dlldata command line option + +*********************************************************/ + +#define PROXY_DELEGATION + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +EXTERN_PROXY_FILE( vc90 ) + + +PROXYFILE_LIST_START +/* Start of list */ + REFERENCE_PROXY_FILE( vc90 ), +/* End of list */ +PROXYFILE_LIST_END + + +DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID ) + +#ifdef __cplusplus +} /*extern "C" */ +#endif + +/* end of generated dlldata file */ diff --git a/Chapter23/TestCOM/vc90.h b/Chapter23/TestCOM/vc90.h new file mode 100644 index 0000000..06486b0 --- /dev/null +++ b/Chapter23/TestCOM/vc90.h @@ -0,0 +1,226 @@ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0500 */ +/* at Thu Oct 16 23:43:55 2008 + */ +/* Compiler settings for vc90.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __vc90_h__ +#define __vc90_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __ITestCOM_FWD_DEFINED__ +#define __ITestCOM_FWD_DEFINED__ +typedef interface ITestCOM ITestCOM; +#endif /* __ITestCOM_FWD_DEFINED__ */ + + +#ifndef __CTestCOM_FWD_DEFINED__ +#define __CTestCOM_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class CTestCOM CTestCOM; +#else +typedef struct CTestCOM CTestCOM; +#endif /* __cplusplus */ + +#endif /* __CTestCOM_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "docobj.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __ITestCOM_INTERFACE_DEFINED__ +#define __ITestCOM_INTERFACE_DEFINED__ + +/* interface ITestCOM */ +/* [object][dual][uuid] */ + + +EXTERN_C const IID IID_ITestCOM; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("F0FD23AE-CAC9-3485-95DC-E5B53A6FB09F") + ITestCOM : public IDispatch + { + public: + virtual /* [id] */ HRESULT STDMETHODCALLTYPE Square( + /* [in] */ LONG Value, + /* [retval][out] */ LONG *Result) = 0; + + }; + +#else /* C style interface */ + + typedef struct ITestCOMVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ITestCOM * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ITestCOM * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ITestCOM * This); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( + ITestCOM * This, + /* [out] */ UINT *pctinfo); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( + ITestCOM * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo **ppTInfo); + + HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( + ITestCOM * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ LPOLESTR *rgszNames, + /* [range][in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID *rgDispId); + + /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( + ITestCOM * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS *pDispParams, + /* [out] */ VARIANT *pVarResult, + /* [out] */ EXCEPINFO *pExcepInfo, + /* [out] */ UINT *puArgErr); + + /* [id] */ HRESULT ( STDMETHODCALLTYPE *Square )( + ITestCOM * This, + /* [in] */ LONG Value, + /* [retval][out] */ LONG *Result); + + END_INTERFACE + } ITestCOMVtbl; + + interface ITestCOM + { + CONST_VTBL struct ITestCOMVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ITestCOM_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ITestCOM_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ITestCOM_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ITestCOM_GetTypeInfoCount(This,pctinfo) \ + ( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) ) + +#define ITestCOM_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + ( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) ) + +#define ITestCOM_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + ( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) ) + +#define ITestCOM_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) ) + + +#define ITestCOM_Square(This,Value,Result) \ + ( (This)->lpVtbl -> Square(This,Value,Result) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ITestCOM_INTERFACE_DEFINED__ */ + + + +#ifndef __TestCOM_LIBRARY_DEFINED__ +#define __TestCOM_LIBRARY_DEFINED__ + +/* library TestCOM */ +/* [uuid][version] */ + + +EXTERN_C const IID LIBID_TestCOM; + +EXTERN_C const CLSID CLSID_CTestCOM; + +#ifdef __cplusplus + +class DECLSPEC_UUID("876C33E0-4A52-3769-A61A-5E01E4B82579") +CTestCOM; +#endif +#endif /* __TestCOM_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/Chapter23/TestCOM/vc90.idl b/Chapter23/TestCOM/vc90.idl new file mode 100644 index 0000000..e816a85 --- /dev/null +++ b/Chapter23/TestCOM/vc90.idl @@ -0,0 +1,30 @@ +import "docobj.idl"; + +[ + uuid(F0FD23AE-CAC9-3485-95DC-E5B53A6FB09F), + dual +] +#line 13 "c:\\users\\administrator\\documents\\visual studio 2008\\projects\\chapter23\\testcom\\testcom.cpp" +interface ITestCOM : IDispatch { +#line 15 "c:\\users\\administrator\\documents\\visual studio 2008\\projects\\chapter23\\testcom\\testcom.cpp" + [id(1)] HRESULT Square([in] LONG Value, [out,retval] LONG *Result); +}; + + +[ version(1.0), uuid(23db553b-27e4-3e6c-9661-645501e82507) ] +library TestCOM +{ + importlib("stdole2.tlb"); + importlib("olepro32.dll"); + + [ + uuid(876C33E0-4A52-3769-A61A-5E01E4B82579), + version(1.0) + ] +#line 20 "c:\\users\\administrator\\documents\\visual studio 2008\\projects\\chapter23\\testcom\\testcom.cpp" + coclass CTestCOM { + interface ITestCOM; + }; + +} + diff --git a/Chapter23/TestCOM/vc90.tlb b/Chapter23/TestCOM/vc90.tlb new file mode 100644 index 0000000..0e50f41 Binary files /dev/null and b/Chapter23/TestCOM/vc90.tlb differ diff --git a/Chapter23/TestCOM/vc90_i.c b/Chapter23/TestCOM/vc90_i.c new file mode 100644 index 0000000..5b6d828 --- /dev/null +++ b/Chapter23/TestCOM/vc90_i.c @@ -0,0 +1,85 @@ + + +/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */ + +/* link this file in with the server and any clients */ + + + /* File created by MIDL compiler version 7.00.0500 */ +/* at Thu Oct 16 23:43:55 2008 + */ +/* Compiler settings for vc90.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +#ifdef __cplusplus +extern "C"{ +#endif + + +#include +#include + +#ifdef _MIDL_USE_GUIDDEF_ + +#ifndef INITGUID +#define INITGUID +#include +#undef INITGUID +#else +#include +#endif + +#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ + DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) + +#else // !_MIDL_USE_GUIDDEF_ + +#ifndef __IID_DEFINED__ +#define __IID_DEFINED__ + +typedef struct _IID +{ + unsigned long x; + unsigned short s1; + unsigned short s2; + unsigned char c[8]; +} IID; + +#endif // __IID_DEFINED__ + +#ifndef CLSID_DEFINED +#define CLSID_DEFINED +typedef IID CLSID; +#endif // CLSID_DEFINED + +#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ + const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} + +#endif !_MIDL_USE_GUIDDEF_ + +MIDL_DEFINE_GUID(IID, IID_ITestCOM,0xF0FD23AE,0xCAC9,0x3485,0x95,0xDC,0xE5,0xB5,0x3A,0x6F,0xB0,0x9F); + + +MIDL_DEFINE_GUID(IID, LIBID_TestCOM,0x23db553b,0x27e4,0x3e6c,0x96,0x61,0x64,0x55,0x01,0xe8,0x25,0x07); + + +MIDL_DEFINE_GUID(CLSID, CLSID_CTestCOM,0x876C33E0,0x4A52,0x3769,0xA6,0x1A,0x5E,0x01,0xE4,0xB8,0x25,0x79); + +#undef MIDL_DEFINE_GUID + +#ifdef __cplusplus +} +#endif + + + diff --git a/Chapter23/TestCOM/vc90_p.c b/Chapter23/TestCOM/vc90_p.c new file mode 100644 index 0000000..a58acb1 --- /dev/null +++ b/Chapter23/TestCOM/vc90_p.c @@ -0,0 +1,327 @@ + + +/* this ALWAYS GENERATED file contains the proxy stub code */ + + + /* File created by MIDL compiler version 7.00.0500 */ +/* at Thu Oct 16 23:43:55 2008 + */ +/* Compiler settings for vc90.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#if !defined(_M_IA64) && !defined(_M_AMD64) + + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif + +#pragma warning( disable: 4211 ) /* redefine extern to static */ +#pragma warning( disable: 4232 ) /* dllimport identity*/ +#pragma warning( disable: 4024 ) /* array to pointer mapping*/ +#pragma warning( disable: 4152 ) /* function/data pointer conversion in expression */ +#pragma warning( disable: 4100 ) /* unreferenced arguments in x86 call */ + +#pragma optimize("", off ) + +#define USE_STUBLESS_PROXY + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REDQ_RPCPROXY_H_VERSION__ +#define __REQUIRED_RPCPROXY_H_VERSION__ 475 +#endif + + +#include "rpcproxy.h" +#ifndef __RPCPROXY_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCPROXY_H_VERSION__ + + +#include "vc90.h" + +#define TYPE_FORMAT_STRING_SIZE 7 +#define PROC_FORMAT_STRING_SIZE 43 +#define EXPR_FORMAT_STRING_SIZE 1 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _vc90_MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } vc90_MIDL_TYPE_FORMAT_STRING; + +typedef struct _vc90_MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } vc90_MIDL_PROC_FORMAT_STRING; + +typedef struct _vc90_MIDL_EXPR_FORMAT_STRING + { + long Pad; + unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; + } vc90_MIDL_EXPR_FORMAT_STRING; + + +static RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = +{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; + + +extern const vc90_MIDL_TYPE_FORMAT_STRING vc90__MIDL_TypeFormatString; +extern const vc90_MIDL_PROC_FORMAT_STRING vc90__MIDL_ProcFormatString; +extern const vc90_MIDL_EXPR_FORMAT_STRING vc90__MIDL_ExprFormatString; + + +extern const MIDL_STUB_DESC Object_StubDesc; + + +extern const MIDL_SERVER_INFO ITestCOM_ServerInfo; +extern const MIDL_STUBLESS_PROXY_INFO ITestCOM_ProxyInfo; + + + +#if !defined(__RPC_WIN32__) +#error Invalid build platform for this stub. +#endif + +#if !(TARGET_IS_NT50_OR_LATER) +#error You need a Windows 2000 or later to run this stub because it uses these features: +#error /robust command line switch. +#error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems. +#error This app will fail with the RPC_X_WRONG_STUB_VERSION error. +#endif + + +static const vc90_MIDL_PROC_FORMAT_STRING vc90__MIDL_ProcFormatString = + { + 0, + { + + /* Procedure Square */ + + 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x7 ), /* 7 */ +/* 8 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ +/* 10 */ NdrFcShort( 0x8 ), /* 8 */ +/* 12 */ NdrFcShort( 0x24 ), /* 36 */ +/* 14 */ 0x44, /* Oi2 Flags: has return, has ext, */ + 0x3, /* 3 */ +/* 16 */ 0x8, /* 8 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 18 */ NdrFcShort( 0x0 ), /* 0 */ +/* 20 */ NdrFcShort( 0x0 ), /* 0 */ +/* 22 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter Value */ + +/* 24 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 26 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 28 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Parameter Result */ + +/* 30 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ +/* 32 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 34 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Return value */ + +/* 36 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 38 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 40 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const vc90_MIDL_TYPE_FORMAT_STRING vc90__MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0xc, /* FC_RP [alloced_on_stack] [simple_pointer] */ +/* 4 */ 0x8, /* FC_LONG */ + 0x5c, /* FC_PAD */ + + 0x0 + } + }; + + +/* Object interface: IUnknown, ver. 0.0, + GUID={0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */ + + +/* Object interface: IDispatch, ver. 0.0, + GUID={0x00020400,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}} */ + + +/* Object interface: ITestCOM, ver. 0.0, + GUID={0xF0FD23AE,0xCAC9,0x3485,{0x95,0xDC,0xE5,0xB5,0x3A,0x6F,0xB0,0x9F}} */ + +#pragma code_seg(".orpc") +static const unsigned short ITestCOM_FormatStringOffsetTable[] = + { + (unsigned short) -1, + (unsigned short) -1, + (unsigned short) -1, + (unsigned short) -1, + 0 + }; + +static const MIDL_STUBLESS_PROXY_INFO ITestCOM_ProxyInfo = + { + &Object_StubDesc, + vc90__MIDL_ProcFormatString.Format, + &ITestCOM_FormatStringOffsetTable[-3], + 0, + 0, + 0 + }; + + +static const MIDL_SERVER_INFO ITestCOM_ServerInfo = + { + &Object_StubDesc, + 0, + vc90__MIDL_ProcFormatString.Format, + &ITestCOM_FormatStringOffsetTable[-3], + 0, + 0, + 0, + 0}; +CINTERFACE_PROXY_VTABLE(8) _ITestCOMProxyVtbl = +{ + &ITestCOM_ProxyInfo, + &IID_ITestCOM, + IUnknown_QueryInterface_Proxy, + IUnknown_AddRef_Proxy, + IUnknown_Release_Proxy , + 0 /* (void *) (INT_PTR) -1 /* IDispatch::GetTypeInfoCount */ , + 0 /* (void *) (INT_PTR) -1 /* IDispatch::GetTypeInfo */ , + 0 /* (void *) (INT_PTR) -1 /* IDispatch::GetIDsOfNames */ , + 0 /* IDispatch_Invoke_Proxy */ , + (void *) (INT_PTR) -1 /* ITestCOM::Square */ +}; + + +static const PRPC_STUB_FUNCTION ITestCOM_table[] = +{ + STUB_FORWARDING_FUNCTION, + STUB_FORWARDING_FUNCTION, + STUB_FORWARDING_FUNCTION, + STUB_FORWARDING_FUNCTION, + NdrStubCall2 +}; + +CInterfaceStubVtbl _ITestCOMStubVtbl = +{ + &IID_ITestCOM, + &ITestCOM_ServerInfo, + 8, + &ITestCOM_table[-3], + CStdStubBuffer_DELEGATING_METHODS +}; + +static const MIDL_STUB_DESC Object_StubDesc = + { + 0, + NdrOleAllocate, + NdrOleFree, + 0, + 0, + 0, + 0, + 0, + vc90__MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x50002, /* Ndr library version */ + 0, + 0x70001f4, /* MIDL Version 7.0.500 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* cs routines */ + 0, /* proxy/server info */ + 0 + }; + +const CInterfaceProxyVtbl * _vc90_ProxyVtblList[] = +{ + ( CInterfaceProxyVtbl *) &_ITestCOMProxyVtbl, + 0 +}; + +const CInterfaceStubVtbl * _vc90_StubVtblList[] = +{ + ( CInterfaceStubVtbl *) &_ITestCOMStubVtbl, + 0 +}; + +PCInterfaceName const _vc90_InterfaceNamesList[] = +{ + "ITestCOM", + 0 +}; + +const IID * _vc90_BaseIIDList[] = +{ + &IID_IDispatch, + 0 +}; + + +#define _vc90_CHECK_IID(n) IID_GENERIC_CHECK_IID( _vc90, pIID, n) + +int __stdcall _vc90_IID_Lookup( const IID * pIID, int * pIndex ) +{ + + if(!_vc90_CHECK_IID(0)) + { + *pIndex = 0; + return 1; + } + + return 0; +} + +const ExtendedProxyFileInfo vc90_ProxyFileInfo = +{ + (PCInterfaceProxyVtblList *) & _vc90_ProxyVtblList, + (PCInterfaceStubVtblList *) & _vc90_StubVtblList, + (const PCInterfaceName * ) & _vc90_InterfaceNamesList, + (const IID ** ) & _vc90_BaseIIDList, + & _vc90_IID_Lookup, + 1, + 2, + 0, /* table of [async_uuid] interfaces */ + 0, /* Filler1 */ + 0, /* Filler2 */ + 0 /* Filler3 */ +}; +#pragma optimize("", on ) +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + + +#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/ + diff --git a/Chapter24/AutoHandleEx/AutoHandleEx.cpp b/Chapter24/AutoHandleEx/AutoHandleEx.cpp new file mode 100644 index 0000000..0bd8b93 --- /dev/null +++ b/Chapter24/AutoHandleEx/AutoHandleEx.cpp @@ -0,0 +1,56 @@ +// AutoHandleEx.cpp : main project file. + +#include + +using namespace System; +using namespace msclr; + +ref class DeleteMe : public IDisposable +{ +private: + String^ Name; +public: + DeleteMe(String^ name) : Name(name) + { + Console::WriteLine("Constructor - {0}", Name); + } + + ~DeleteMe() + { + Console::WriteLine("Destructor - {0}", Name); + Name = nullptr; + } +protected: + !DeleteMe() + { + Console::WriteLine("Finalize - {0}", Name); + Name = nullptr; + } +}; + + +int main(array ^args) +{ + // Falling out of scope without delete + { + DeleteMe^ NonAuto = gcnew DeleteMe("Non Auto no finally"); + } + + // Falling out of scope with finally delete + DeleteMe^ NonAutoWFinally; + try + { + NonAutoWFinally = gcnew DeleteMe("Non Auto with finally"); + } + finally + { + delete NonAutoWFinally; + } + + // using auto_handle + { + auto_handle Auto = gcnew DeleteMe("Auto"); + } + + return 0; +} diff --git a/Chapter24/AutoHandleEx/AutoHandleEx.vcproj b/Chapter24/AutoHandleEx/AutoHandleEx.vcproj new file mode 100644 index 0000000..0ef04de --- /dev/null +++ b/Chapter24/AutoHandleEx/AutoHandleEx.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter24/Chapter24.sln b/Chapter24/Chapter24.sln new file mode 100644 index 0000000..31f5827 --- /dev/null +++ b/Chapter24/Chapter24.sln @@ -0,0 +1,56 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutoHandleEx", "AutoHandleEx\AutoHandleEx.vcproj", "{B3D288A0-C549-4329-9309-4178A1077595}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gcrootsEx", "gcrootsEx\gcrootsEx.vcproj", "{7ABFCB4C-7A75-4A26-B241-5F4E65EDC036}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "auto_gcrootEx", "auto_gcrootEx\auto_gcrootEx.vcproj", "{9338B0E0-105B-456E-9E97-80DBE5FF9E70}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "comptrEx", "comptrEx\comptrEx.vcproj", "{ABF6A079-CBCF-49A5-A6E8-3FC710BB826E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "safe_boolEx", "safe_boolEx\safe_boolEx.vcproj", "{11319B9C-B8A8-4673-AC81-DD0456B26B47}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lockEx", "lockEx\lockEx.vcproj", "{131250DC-CD88-404F-BE32-54695DBDED4A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MarshalEx", "MarshalEx\MarshalEx.vcproj", "{BB930FFA-28C6-4DF6-AE22-7981E2E27AA8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B3D288A0-C549-4329-9309-4178A1077595}.Debug|Win32.ActiveCfg = Debug|Win32 + {B3D288A0-C549-4329-9309-4178A1077595}.Debug|Win32.Build.0 = Debug|Win32 + {B3D288A0-C549-4329-9309-4178A1077595}.Release|Win32.ActiveCfg = Release|Win32 + {B3D288A0-C549-4329-9309-4178A1077595}.Release|Win32.Build.0 = Release|Win32 + {7ABFCB4C-7A75-4A26-B241-5F4E65EDC036}.Debug|Win32.ActiveCfg = Debug|Win32 + {7ABFCB4C-7A75-4A26-B241-5F4E65EDC036}.Debug|Win32.Build.0 = Debug|Win32 + {7ABFCB4C-7A75-4A26-B241-5F4E65EDC036}.Release|Win32.ActiveCfg = Release|Win32 + {7ABFCB4C-7A75-4A26-B241-5F4E65EDC036}.Release|Win32.Build.0 = Release|Win32 + {9338B0E0-105B-456E-9E97-80DBE5FF9E70}.Debug|Win32.ActiveCfg = Debug|Win32 + {9338B0E0-105B-456E-9E97-80DBE5FF9E70}.Debug|Win32.Build.0 = Debug|Win32 + {9338B0E0-105B-456E-9E97-80DBE5FF9E70}.Release|Win32.ActiveCfg = Release|Win32 + {9338B0E0-105B-456E-9E97-80DBE5FF9E70}.Release|Win32.Build.0 = Release|Win32 + {ABF6A079-CBCF-49A5-A6E8-3FC710BB826E}.Debug|Win32.ActiveCfg = Debug|Win32 + {ABF6A079-CBCF-49A5-A6E8-3FC710BB826E}.Debug|Win32.Build.0 = Debug|Win32 + {ABF6A079-CBCF-49A5-A6E8-3FC710BB826E}.Release|Win32.ActiveCfg = Release|Win32 + {ABF6A079-CBCF-49A5-A6E8-3FC710BB826E}.Release|Win32.Build.0 = Release|Win32 + {11319B9C-B8A8-4673-AC81-DD0456B26B47}.Debug|Win32.ActiveCfg = Debug|Win32 + {11319B9C-B8A8-4673-AC81-DD0456B26B47}.Debug|Win32.Build.0 = Debug|Win32 + {11319B9C-B8A8-4673-AC81-DD0456B26B47}.Release|Win32.ActiveCfg = Release|Win32 + {11319B9C-B8A8-4673-AC81-DD0456B26B47}.Release|Win32.Build.0 = Release|Win32 + {131250DC-CD88-404F-BE32-54695DBDED4A}.Debug|Win32.ActiveCfg = Debug|Win32 + {131250DC-CD88-404F-BE32-54695DBDED4A}.Debug|Win32.Build.0 = Debug|Win32 + {131250DC-CD88-404F-BE32-54695DBDED4A}.Release|Win32.ActiveCfg = Release|Win32 + {131250DC-CD88-404F-BE32-54695DBDED4A}.Release|Win32.Build.0 = Release|Win32 + {BB930FFA-28C6-4DF6-AE22-7981E2E27AA8}.Debug|Win32.ActiveCfg = Debug|Win32 + {BB930FFA-28C6-4DF6-AE22-7981E2E27AA8}.Debug|Win32.Build.0 = Debug|Win32 + {BB930FFA-28C6-4DF6-AE22-7981E2E27AA8}.Release|Win32.ActiveCfg = Release|Win32 + {BB930FFA-28C6-4DF6-AE22-7981E2E27AA8}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Chapter24/Chapter24.suo b/Chapter24/Chapter24.suo new file mode 100644 index 0000000..8c7ef21 Binary files /dev/null and b/Chapter24/Chapter24.suo differ diff --git a/Chapter24/MarshalEx/MarshalEx.cpp b/Chapter24/MarshalEx/MarshalEx.cpp new file mode 100644 index 0000000..029bd44 --- /dev/null +++ b/Chapter24/MarshalEx/MarshalEx.cpp @@ -0,0 +1,19 @@ +#include "stdio.h" +#include "msclr\marshal.h" + +using namespace System; +using namespace msclr::interop; + +void main() +{ + String ^hstr = gcnew String("Marshaling String^ to wchar_t*"); + + marshal_context^ context = gcnew marshal_context(); + const wchar_t* pstr = context->marshal_as(hstr); + + wprintf(L"%s\n", pstr); + delete context; // from here on pstr is invalid + + const char* message = "Marshaling const char* to String^"; + Console::WriteLine(marshal_as(message) + "\n\n\n"); +} diff --git a/Chapter24/MarshalEx/MarshalEx.vcproj b/Chapter24/MarshalEx/MarshalEx.vcproj new file mode 100644 index 0000000..6308364 --- /dev/null +++ b/Chapter24/MarshalEx/MarshalEx.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter24/Marshaling/Marshaling.cpp b/Chapter24/Marshaling/Marshaling.cpp new file mode 100644 index 0000000..85f1b57 --- /dev/null +++ b/Chapter24/Marshaling/Marshaling.cpp @@ -0,0 +1,20 @@ +#include "stdio.h" +#include "msclr\marshal.h" + +using namespace System; +using namespace msclr::interop; + +void main() +{ + String ^hstr = gcnew String("Marshaling String^ to wchar_t*"); + + marshal_context^ context = gcnew marshal_context(); + const wchar_t* pstr = context->marshal_as(hstr); + + wprintf(L"%s\n", pstr); + delete context; // from here on pstr is invalid + + const char* message = "Marshaling const char* to String^"; + Console::WriteLine(marshal_as(message)); +} + diff --git a/Chapter24/Marshaling/Marshaling.vcproj b/Chapter24/Marshaling/Marshaling.vcproj new file mode 100644 index 0000000..0d14865 --- /dev/null +++ b/Chapter24/Marshaling/Marshaling.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter24/auto_gcrootEx/auto_gcrootEx.cpp b/Chapter24/auto_gcrootEx/auto_gcrootEx.cpp new file mode 100644 index 0000000..98c14fb --- /dev/null +++ b/Chapter24/auto_gcrootEx/auto_gcrootEx.cpp @@ -0,0 +1,37 @@ +#include "stdio.h" +#include + +using namespace System; +using namespace msclr; + +ref class MClass +{ +public: + int x; + ~MClass() { Console::WriteLine("MClass disposed"); } +protected: + !MClass() { Console::WriteLine("MClass finalized"); } +}; + +#pragma unmanaged + +class UMClass +{ +public: + auto_gcroot mclass; + ~UMClass() { printf("UMClass deleted\n"); } +}; + +#pragma managed + +void main() +{ + UMClass *umc = new UMClass(); + umc->mclass = gcnew MClass(); + + umc->mclass->x = 4; + Console::WriteLine("Managed Print {0}", umc->mclass->x); + printf("Unmanaged Print %d\n", umc->mclass->x); + + delete umc; +} diff --git a/Chapter24/auto_gcrootEx/auto_gcrootEx.vcproj b/Chapter24/auto_gcrootEx/auto_gcrootEx.vcproj new file mode 100644 index 0000000..82bc74b --- /dev/null +++ b/Chapter24/auto_gcrootEx/auto_gcrootEx.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter24/comptrEx/Interop/Interop.TestCOM.1.0.dll b/Chapter24/comptrEx/Interop/Interop.TestCOM.1.0.dll new file mode 100644 index 0000000..d178c37 Binary files /dev/null and b/Chapter24/comptrEx/Interop/Interop.TestCOM.1.0.dll differ diff --git a/Chapter24/comptrEx/TestCOM.dll b/Chapter24/comptrEx/TestCOM.dll new file mode 100644 index 0000000..692dbfb Binary files /dev/null and b/Chapter24/comptrEx/TestCOM.dll differ diff --git a/Chapter24/comptrEx/TestCOM.h b/Chapter24/comptrEx/TestCOM.h new file mode 100644 index 0000000..9059089 --- /dev/null +++ b/Chapter24/comptrEx/TestCOM.h @@ -0,0 +1,226 @@ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 7.00.0500 */ +/* at Sun Sep 21 22:04:27 2008 + */ +/* Compiler settings for vc90.idl: + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif // __RPCNDR_H_VERSION__ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __vc90_h__ +#define __vc90_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifndef __ITestCOM_FWD_DEFINED__ +#define __ITestCOM_FWD_DEFINED__ +typedef interface ITestCOM ITestCOM; +#endif /* __ITestCOM_FWD_DEFINED__ */ + + +#ifndef __CTestCOM_FWD_DEFINED__ +#define __CTestCOM_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class CTestCOM CTestCOM; +#else +typedef struct CTestCOM CTestCOM; +#endif /* __cplusplus */ + +#endif /* __CTestCOM_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "docobj.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __ITestCOM_INTERFACE_DEFINED__ +#define __ITestCOM_INTERFACE_DEFINED__ + +/* interface ITestCOM */ +/* [object][dual][uuid] */ + + +EXTERN_C const IID IID_ITestCOM; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("F0FD23AE-CAC9-3485-95DC-E5B53A6FB09F") + ITestCOM : public IDispatch + { + public: + virtual /* [id] */ HRESULT STDMETHODCALLTYPE Square( + /* [in] */ LONG Value, + /* [retval][out] */ LONG *Result) = 0; + + }; + +#else /* C style interface */ + + typedef struct ITestCOMVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ITestCOM * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ + __RPC__deref_out void **ppvObject); + + ULONG ( STDMETHODCALLTYPE *AddRef )( + ITestCOM * This); + + ULONG ( STDMETHODCALLTYPE *Release )( + ITestCOM * This); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( + ITestCOM * This, + /* [out] */ UINT *pctinfo); + + HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( + ITestCOM * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo **ppTInfo); + + HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( + ITestCOM * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ LPOLESTR *rgszNames, + /* [range][in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID *rgDispId); + + /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( + ITestCOM * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS *pDispParams, + /* [out] */ VARIANT *pVarResult, + /* [out] */ EXCEPINFO *pExcepInfo, + /* [out] */ UINT *puArgErr); + + /* [id] */ HRESULT ( STDMETHODCALLTYPE *Square )( + ITestCOM * This, + /* [in] */ LONG Value, + /* [retval][out] */ LONG *Result); + + END_INTERFACE + } ITestCOMVtbl; + + interface ITestCOM + { + CONST_VTBL struct ITestCOMVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ITestCOM_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ITestCOM_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ITestCOM_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ITestCOM_GetTypeInfoCount(This,pctinfo) \ + ( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) ) + +#define ITestCOM_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + ( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) ) + +#define ITestCOM_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + ( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) ) + +#define ITestCOM_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) ) + + +#define ITestCOM_Square(This,Value,Result) \ + ( (This)->lpVtbl -> Square(This,Value,Result) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ITestCOM_INTERFACE_DEFINED__ */ + + + +#ifndef __TestCOM_LIBRARY_DEFINED__ +#define __TestCOM_LIBRARY_DEFINED__ + +/* library TestCOM */ +/* [uuid][version] */ + + +EXTERN_C const IID LIBID_TestCOM; + +EXTERN_C const CLSID CLSID_CTestCOM; + +#ifdef __cplusplus + +class DECLSPEC_UUID("876C33E0-4A52-3769-A61A-5E01E4B82579") +CTestCOM; +#endif +#endif /* __TestCOM_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/Chapter24/comptrEx/TestCOM.tlb b/Chapter24/comptrEx/TestCOM.tlb new file mode 100644 index 0000000..ca9e2bf Binary files /dev/null and b/Chapter24/comptrEx/TestCOM.tlb differ diff --git a/Chapter24/comptrEx/comptrEx.cpp b/Chapter24/comptrEx/comptrEx.cpp new file mode 100644 index 0000000..4aada96 --- /dev/null +++ b/Chapter24/comptrEx/comptrEx.cpp @@ -0,0 +1,41 @@ +#include "TestCOM.h" +#include + +#import "TestCOM.dll" raw_interfaces_only + +using namespace System; +using namespace msclr; + +ref class rcTestCOM +{ +private: + com::ptr test; +public: + rcTestCOM() + { +// test.CreateInstance(L"CTestCOM.CTestCOM"); +// or + test.CreateInstance(__uuidof(CTestCOM)); + } + + long Square(int val) + { + long ret; + HRESULT hr = test->Square(val, &ret); + return ret; + } +}; + +int main(array ^args) +{ + rcTestCOM^ test = gcnew rcTestCOM(); + + long ret = test->Square(4); + + Console::WriteLine("The Square of 4 is {0}", ret); + + Console::WriteLine("\n\n\n"); + + return 0; +} + diff --git a/Chapter24/comptrEx/comptrEx.vcproj b/Chapter24/comptrEx/comptrEx.vcproj new file mode 100644 index 0000000..b3deb42 --- /dev/null +++ b/Chapter24/comptrEx/comptrEx.vcproj @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter24/gcrootsEx/AssemblyInfo.cpp b/Chapter24/gcrootsEx/AssemblyInfo.cpp new file mode 100644 index 0000000..eb6c9c2 --- /dev/null +++ b/Chapter24/gcrootsEx/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("gcrootsEx")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("gcrootsEx")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2008")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/Chapter24/gcrootsEx/gcrootsEx.cpp b/Chapter24/gcrootsEx/gcrootsEx.cpp new file mode 100644 index 0000000..26cdfc0 --- /dev/null +++ b/Chapter24/gcrootsEx/gcrootsEx.cpp @@ -0,0 +1,43 @@ +#include "stdio.h" +#include + +using namespace System; +using namespace msclr; + +ref class MClass +{ +public: + int x; + ~MClass() { Console::WriteLine("MClass disposed"); } +protected: + !MClass() { Console::WriteLine("MClass finalized"); } +}; + +#pragma unmanaged + +class UMClass +{ +public: + gcroot mclass; + ~UMClass() + { + // delete mclass; /* cannot call a funtion with __clrcall calling */ + /* convention from native code */ + + printf("UMClass deleted\n"); + } +}; + +#pragma managed + +void main() +{ + UMClass *umc = new UMClass(); + umc->mclass = gcnew MClass(); + + umc->mclass->x = 4; + Console::WriteLine("Managed Print {0}", umc->mclass->x); + printf("Unmanaged Print %d\n", umc->mclass->x); + + delete umc; +} diff --git a/Chapter24/gcrootsEx/gcrootsEx.vcproj b/Chapter24/gcrootsEx/gcrootsEx.vcproj new file mode 100644 index 0000000..9a78ae3 --- /dev/null +++ b/Chapter24/gcrootsEx/gcrootsEx.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter24/lockEx/lockEx.cpp b/Chapter24/lockEx/lockEx.cpp new file mode 100644 index 0000000..d35d2c4 --- /dev/null +++ b/Chapter24/lockEx/lockEx.cpp @@ -0,0 +1,67 @@ +#include + +using namespace System; +using namespace System::Collections; +using namespace System::Threading; +using namespace msclr; + +ref class App +{ +private: + ArrayList^ myArray; + +public: + App() { myArray = gcnew ArrayList(); } + + void Thread1() + { + while (true) + { + try + { + lock l1 (myArray->SyncRoot, 500); + Console::WriteLine(L"In Thread 1 Lock"); + Thread::Sleep(1000); + } + catch(...) + { + Console::WriteLine(L"Failed to get sync in Thread 1"); + } + } + } + + void Thread2() + { + lock l2(myArray->SyncRoot, lock_later); + while (true) + { + if (l2.try_acquire(500)) + { + Console::WriteLine(L"In Thread 2 lock"); + Thread::Sleep(1000); + l2.release(); + } + else + { + Console::WriteLine(L"Failed to get sync in Thread 2"); + } + } + } +}; + +int main(array ^args) +{ + App^ app = gcnew App(); + + Thread ^th1 = gcnew Thread(gcnew ThreadStart(app, &App::Thread1)); + Thread ^th2 = gcnew Thread(gcnew ThreadStart(app, &App::Thread2)); + + th1->IsBackground = true; + th2->IsBackground = true; + + th1->Start(); + th2->Start(); + + Console::ReadLine(); + return 0; +} diff --git a/Chapter24/lockEx/lockEx.vcproj b/Chapter24/lockEx/lockEx.vcproj new file mode 100644 index 0000000..c7d7ab6 --- /dev/null +++ b/Chapter24/lockEx/lockEx.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter24/safe_boolEx/safe_boolEx.cpp b/Chapter24/safe_boolEx/safe_boolEx.cpp new file mode 100644 index 0000000..7b89387 --- /dev/null +++ b/Chapter24/safe_boolEx/safe_boolEx.cpp @@ -0,0 +1,66 @@ +//#define UseSafeBool + +#include + +using namespace System; +using namespace msclr; + +ref class myClass +{ +private: + bool IsInitialized; + +public: + myClass() + { + IsInitialized = false; + } + + void Initialize() + { + IsInitialized = true; + } + +#ifdef UseSafeBool + + // Check to see if this class has been initialized + operator _detail_class::_safe_bool() + { + return IsInitialized ? _detail_class::_safe_true + : _detail_class::_safe_false; + } +#else + + operator bool() + { + return IsInitialized; + } +#endif +}; + + +void main() +{ + myClass^ mc = gcnew myClass(); + +#ifndef UseSafeBool // works without _safe_bool + int i = (mc + 2) << 1; + double d = mc * 3.2; + Console::WriteLine("b=[{0}] d=[{1}]", i.ToString(), d.ToString()); +#endif + + if (mc) + Console::WriteLine("Is Initialized"); + else + Console::WriteLine("Is Not Initialized"); + + mc->Initialize(); + + Console::WriteLine(mc ? "Is Initialized" : "Is Not Initialized"); + +#ifndef UseSafeBool // works without _safe_bool + i = (mc + 2) << 1; + d = mc * 3.2; + Console::WriteLine("b=[{0}] d=[{1}]\n\n\n", i.ToString(), d.ToString()); +#endif +} diff --git a/Chapter24/safe_boolEx/safe_boolEx.vcproj b/Chapter24/safe_boolEx/safe_boolEx.vcproj new file mode 100644 index 0000000..608e2c1 --- /dev/null +++ b/Chapter24/safe_boolEx/safe_boolEx.vcproj @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..76128f0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2009 Stephen R.G. Fraser + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..f823750 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Pro Visual C++/CLI and the .NET 3.5 Platform*](http://www.apress.com/9781430210535) by Stephen R.G. Fraser (Apress, 2009). + +![Cover image](9781430210535.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..50c9bda --- /dev/null +++ b/README.txt @@ -0,0 +1,11 @@ +Source code for Pro Visual C++/CLI and the .NET 3.5 Platform (978-1-4302-1053-5) by Stephen R. G. Fraser. + +There are 3 pieces to this file: + +1) All the Chapter source code directories. These you can copy anywhere you want. But I recommend the + the "My Documents/Visual Studio 200x/Projects directory" where "x" is your version of Visual Studio. + +2) The wwwroot directory. You will copy to your wwwroot directory. + +3) The Web Templates.zip file which contains templates to build Web Applications and Web Services. + The instructions to install these templates is found within the zip file. \ No newline at end of file diff --git a/Web Templates.zip b/Web Templates.zip new file mode 100644 index 0000000..1bf512c Binary files /dev/null and b/Web Templates.zip differ diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file diff --git a/wwwroot/AuthorWS/Author.asmx b/wwwroot/AuthorWS/Author.asmx new file mode 100644 index 0000000..4f113c4 --- /dev/null +++ b/wwwroot/AuthorWS/Author.asmx @@ -0,0 +1,2 @@ +<%@ WebService Class="Author.AuthorClass" %> + diff --git a/wwwroot/AuthorWS/Bin/Author.dll b/wwwroot/AuthorWS/Bin/Author.dll new file mode 100644 index 0000000..eb5df52 Binary files /dev/null and b/wwwroot/AuthorWS/Bin/Author.dll differ diff --git a/wwwroot/AuthorWS/Bin/Author.pdb b/wwwroot/AuthorWS/Bin/Author.pdb new file mode 100644 index 0000000..f7bf709 Binary files /dev/null and b/wwwroot/AuthorWS/Bin/Author.pdb differ diff --git a/wwwroot/AuthorWS/Global.asax b/wwwroot/AuthorWS/Global.asax new file mode 100644 index 0000000..134ff16 --- /dev/null +++ b/wwwroot/AuthorWS/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.h" Inherits="Author.Global" %> diff --git a/wwwroot/AuthorWS/Web.config b/wwwroot/AuthorWS/Web.config new file mode 100644 index 0000000..3082c84 --- /dev/null +++ b/wwwroot/AuthorWS/Web.config @@ -0,0 +1,123 @@ + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/Chapter21/CASSecurity.exe b/wwwroot/Chapter21/CASSecurity.exe new file mode 100644 index 0000000..34c3f1c Binary files /dev/null and b/wwwroot/Chapter21/CASSecurity.exe differ diff --git a/wwwroot/FindZipCodeWS/Bin/FindZipCode.dll b/wwwroot/FindZipCodeWS/Bin/FindZipCode.dll new file mode 100644 index 0000000..656edf1 Binary files /dev/null and b/wwwroot/FindZipCodeWS/Bin/FindZipCode.dll differ diff --git a/wwwroot/FindZipCodeWS/Bin/FindZipCode.pdb b/wwwroot/FindZipCodeWS/Bin/FindZipCode.pdb new file mode 100644 index 0000000..3105e78 Binary files /dev/null and b/wwwroot/FindZipCodeWS/Bin/FindZipCode.pdb differ diff --git a/wwwroot/FindZipCodeWS/FindZipCode.asmx b/wwwroot/FindZipCodeWS/FindZipCode.asmx new file mode 100644 index 0000000..d312876 --- /dev/null +++ b/wwwroot/FindZipCodeWS/FindZipCode.asmx @@ -0,0 +1,2 @@ +<%@ WebService Class="FindZipCode.FindZipCodeClass" %> + diff --git a/wwwroot/FindZipCodeWS/Global.asax b/wwwroot/FindZipCodeWS/Global.asax new file mode 100644 index 0000000..28d16bc --- /dev/null +++ b/wwwroot/FindZipCodeWS/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.h" Inherits="FindZipCode.Global" %> diff --git a/wwwroot/FindZipCodeWS/Web.config b/wwwroot/FindZipCodeWS/Web.config new file mode 100644 index 0000000..3a74d6a --- /dev/null +++ b/wwwroot/FindZipCodeWS/Web.config @@ -0,0 +1,140 @@ + + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/HelloWorldSite/Bin/HelloWorld.dll b/wwwroot/HelloWorldSite/Bin/HelloWorld.dll new file mode 100644 index 0000000..517f491 Binary files /dev/null and b/wwwroot/HelloWorldSite/Bin/HelloWorld.dll differ diff --git a/wwwroot/HelloWorldSite/Bin/HelloWorld.pdb b/wwwroot/HelloWorldSite/Bin/HelloWorld.pdb new file mode 100644 index 0000000..f105e51 Binary files /dev/null and b/wwwroot/HelloWorldSite/Bin/HelloWorld.pdb differ diff --git a/wwwroot/HelloWorldSite/Global.asax b/wwwroot/HelloWorldSite/Global.asax new file mode 100644 index 0000000..c919edc --- /dev/null +++ b/wwwroot/HelloWorldSite/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.h" Inherits="HelloWorld.Global" %> diff --git a/wwwroot/HelloWorldSite/HelloWorld.aspx b/wwwroot/HelloWorldSite/HelloWorld.aspx new file mode 100644 index 0000000..2cbd834 --- /dev/null +++ b/wwwroot/HelloWorldSite/HelloWorld.aspx @@ -0,0 +1,17 @@ +<%@ Page Inherits="HelloWorld._Default" %> + + + + + + Untitled Page + + +
+
+ +
+
+ + + diff --git a/wwwroot/HelloWorldSite/Web.config b/wwwroot/HelloWorldSite/Web.config new file mode 100644 index 0000000..38d9cea --- /dev/null +++ b/wwwroot/HelloWorldSite/Web.config @@ -0,0 +1,120 @@ + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/WebControlSite/Bin/WebControl.dll b/wwwroot/WebControlSite/Bin/WebControl.dll new file mode 100644 index 0000000..d3b29b5 Binary files /dev/null and b/wwwroot/WebControlSite/Bin/WebControl.dll differ diff --git a/wwwroot/WebControlSite/Bin/WebControl.pdb b/wwwroot/WebControlSite/Bin/WebControl.pdb new file mode 100644 index 0000000..fca9760 Binary files /dev/null and b/wwwroot/WebControlSite/Bin/WebControl.pdb differ diff --git a/wwwroot/WebControlSite/Blank1.aspx b/wwwroot/WebControlSite/Blank1.aspx new file mode 100644 index 0000000..bb51b93 --- /dev/null +++ b/wwwroot/WebControlSite/Blank1.aspx @@ -0,0 +1,21 @@ +<%@ Page Inherits="WebControl.Blank1" %> + +<%@ Register src="myPageHeader.ascx" tagname="myPageHeader" tagprefix="uc1" %> + + + + + + Blank1 + + +
+
+ + + +
+
+ + + diff --git a/wwwroot/WebControlSite/Blank2.aspx b/wwwroot/WebControlSite/Blank2.aspx new file mode 100644 index 0000000..a45ebc8 --- /dev/null +++ b/wwwroot/WebControlSite/Blank2.aspx @@ -0,0 +1,21 @@ +<%@ Page Inherits="WebControl.Blank2" %> + +<%@ Register src="myPageHeader.ascx" tagname="myPageHeader" tagprefix="uc1" %> + + + + + + Blank2 + + +
+
+ + + +
+
+ + + diff --git a/wwwroot/WebControlSite/Buttons.aspx b/wwwroot/WebControlSite/Buttons.aspx new file mode 100644 index 0000000..5b7ba4a --- /dev/null +++ b/wwwroot/WebControlSite/Buttons.aspx @@ -0,0 +1,95 @@ +<%@ Page Inherits="WebControl.Buttons" %> + + + + + + Buttons + + +
+
+ + + + + + + + + +
+ + +

+ + +

+ + +

+ + +

+ + +

+ + +

+ + +

+ + +

+ + +

+ + +

+ + Colorful + +

+ + Happy Face + +

+ + TextBox Color + +

+
+
+ + diff --git a/wwwroot/WebControlSite/ChangeColor.aspx b/wwwroot/WebControlSite/ChangeColor.aspx new file mode 100644 index 0000000..280e977 --- /dev/null +++ b/wwwroot/WebControlSite/ChangeColor.aspx @@ -0,0 +1,19 @@ +<%@ Page Inherits="WebControl.ChangeColor" %> + + + + + + Change Color + + +
+
+ +
+
+ + + diff --git a/wwwroot/WebControlSite/Colorful.aspx b/wwwroot/WebControlSite/Colorful.aspx new file mode 100644 index 0000000..f571362 --- /dev/null +++ b/wwwroot/WebControlSite/Colorful.aspx @@ -0,0 +1,21 @@ +<%@ Page Inherits="WebControl.Colorful" %> + + + + + + Colorful + + + +
+
+ + + +
+
+ + + diff --git a/wwwroot/WebControlSite/DomainPage.aspx b/wwwroot/WebControlSite/DomainPage.aspx new file mode 100644 index 0000000..4473b41 --- /dev/null +++ b/wwwroot/WebControlSite/DomainPage.aspx @@ -0,0 +1,10 @@ +<%@ Page MasterPageFile="~/myMaster.master" Inherits="WebControl.DomainPage" Title="Domain Page" %> + + + + + + To Home Page + + + diff --git a/wwwroot/WebControlSite/Global.asax b/wwwroot/WebControlSite/Global.asax new file mode 100644 index 0000000..77cdffc --- /dev/null +++ b/wwwroot/WebControlSite/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.h" Inherits="WebControl.Global" %> diff --git a/wwwroot/WebControlSite/Happy.aspx b/wwwroot/WebControlSite/Happy.aspx new file mode 100644 index 0000000..35d0068 --- /dev/null +++ b/wwwroot/WebControlSite/Happy.aspx @@ -0,0 +1,21 @@ +<%@ Page Inherits="WebControl.Happy" %> + + + + + + Happy Face + + +
+
+ +
+
+ + + + diff --git a/wwwroot/WebControlSite/HomePage.aspx b/wwwroot/WebControlSite/HomePage.aspx new file mode 100644 index 0000000..832ca12 --- /dev/null +++ b/wwwroot/WebControlSite/HomePage.aspx @@ -0,0 +1,8 @@ +<%@ Page MasterPageFile="~/myMaster.master" Inherits="WebControl.HomePage" Title="Home Page" %> + + + + To Domain Page + + + diff --git a/wwwroot/WebControlSite/Images/Happy.GIF b/wwwroot/WebControlSite/Images/Happy.GIF new file mode 100644 index 0000000..9a57e25 Binary files /dev/null and b/wwwroot/WebControlSite/Images/Happy.GIF differ diff --git a/wwwroot/WebControlSite/Images/domain.jpg b/wwwroot/WebControlSite/Images/domain.jpg new file mode 100644 index 0000000..2e65553 Binary files /dev/null and b/wwwroot/WebControlSite/Images/domain.jpg differ diff --git a/wwwroot/WebControlSite/Images/home.jpg b/wwwroot/WebControlSite/Images/home.jpg new file mode 100644 index 0000000..433db82 Binary files /dev/null and b/wwwroot/WebControlSite/Images/home.jpg differ diff --git a/wwwroot/WebControlSite/Images/story.jpg b/wwwroot/WebControlSite/Images/story.jpg new file mode 100644 index 0000000..ace2ba0 Binary files /dev/null and b/wwwroot/WebControlSite/Images/story.jpg differ diff --git a/wwwroot/WebControlSite/Lists.aspx b/wwwroot/WebControlSite/Lists.aspx new file mode 100644 index 0000000..bbe58bb --- /dev/null +++ b/wwwroot/WebControlSite/Lists.aspx @@ -0,0 +1,27 @@ +<%@ Page Inherits="WebControl.Lists" %> + + + + + + Lists + + +
+
+ + +
+ + +
+ + Select Background Color + +
+
+ + + diff --git a/wwwroot/WebControlSite/ManyHeadings.aspx b/wwwroot/WebControlSite/ManyHeadings.aspx new file mode 100644 index 0000000..5a28651 --- /dev/null +++ b/wwwroot/WebControlSite/ManyHeadings.aspx @@ -0,0 +1,23 @@ +<%@ Page Inherits="WebControl.ManyHeadings" %> + + + + + + Many Headings + + +
+
+ + + + + + +
+
+ + + diff --git a/wwwroot/WebControlSite/Tables.aspx b/wwwroot/WebControlSite/Tables.aspx new file mode 100644 index 0000000..ea1f86b --- /dev/null +++ b/wwwroot/WebControlSite/Tables.aspx @@ -0,0 +1,26 @@ +<%@ Page Inherits="WebControl.Tables" %> + + + + + + Nobody is happy right now + + +
+
+ + + + + + + + + + +
+
+ + diff --git a/wwwroot/WebControlSite/Web.config b/wwwroot/WebControlSite/Web.config new file mode 100644 index 0000000..4bad2ac --- /dev/null +++ b/wwwroot/WebControlSite/Web.config @@ -0,0 +1,122 @@ + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/WebControlSite/myMaster.master b/wwwroot/WebControlSite/myMaster.master new file mode 100644 index 0000000..ee2d033 --- /dev/null +++ b/wwwroot/WebControlSite/myMaster.master @@ -0,0 +1,24 @@ +<%@ Master Inherits="WebControl.myMaster" %> + +<%@ Register src="myPageHeader.ascx" tagname="myPageHeader" tagprefix="uc1" %> + + + + + + Master Page + + + + +
+
+ + + +
+
+ + + diff --git a/wwwroot/WebControlSite/myPageHeader.ascx b/wwwroot/WebControlSite/myPageHeader.ascx new file mode 100644 index 0000000..03a7b93 --- /dev/null +++ b/wwwroot/WebControlSite/myPageHeader.ascx @@ -0,0 +1,5 @@ +<%@ Control Inherits="WebControl.uc.myPageHeader" %> + + +
+
diff --git a/wwwroot/iisstart.htm b/wwwroot/iisstart.htm new file mode 100644 index 0000000..6cbe736 --- /dev/null +++ b/wwwroot/iisstart.htm @@ -0,0 +1,32 @@ + + + + +IIS7 + + + +
+IIS7 +
+ + \ No newline at end of file diff --git a/wwwroot/welcome.png b/wwwroot/welcome.png new file mode 100644 index 0000000..5be29f7 Binary files /dev/null and b/wwwroot/welcome.png differ