Pointers, Handles and References

Modern C++ programs should almost always use vectors and iteriators in preference to the lower-level arrays and pointers, and strings to replace C-style array based character strings. Well designed programs use arrays and pointers only in the internals of class implementations where speed is essential. As well as being less powerful, C-style strings are the […]

Read More

Namespace General

Every name defined in a given scope must be unique within that scope. This can be difficult for large complex applications as name collisions become an issue. Namespaces may be defined at global scope or inside another namespace. They may not be defined inside a function or a class. The entities defined inside a namespace […]

Read More

Graphics General

GDI+ is the graphical library used in the .NET Framework. Good Resources http://www.functionx.com/vccli/index.htm How To Draw Graphics On A Form Include the namespace: System::Drawing Add the following to the forms constructor bmpDrawingArea = gcnew Bitmap(Width, Height); graphDrawingArea = Graphics::FromImage(bmpDrawingArea); Then Create the forms paint event (select form > select the properties lighting bolt icon > […]

Read More

Copying Files When Building

Goto project properties -> configuration properties -> build events -> post build event and change the command line with: copy “$(ProjectDir)MyFileToCopy.xml” “$(TargetDir)MyFileToCopy.xml” Notes: You can have lots of lines of events, just click the ‘…’ button and enter each command on a new line The quotation marks are used as a space signifies the break […]

Read More

.Classes (& Struct) General

Objects represent the people, places and things in your program. For example individual invoices sent and invoices received are invoices. Classes are the units of code you write to make objects come to life in your program. You write classes but you think in terms of objects (its why its called object orientated programming). Think […]

Read More

Adding new class to a form

Form designer won’t allow you to add new classes before the main form class. In fact you can place a class before the forms main class no problem for the compiler – its just the form editor that won’t have it (you can’t view the form in design view) To solve this you need to […]

Read More

Forward Declarations Of A Class

When you use references to a class in another classes header file (e.g. becuase the class uses the other class objects in function calls or as objects for its own use) then instead of including the other classes header file in the .h file, use the following forward class declaration instead: ref class OtherClassName; (Typically […]

Read More

Creating Basic Class / Struct

ref class and ref struct are the same thing. You could replace class with struct below, but no-one uses struct. Define a structure public ref class DOCINFO { public: String ^DocumentName; String ^OutputFile; int ^TheValue; }; If You Need A Constructor //—– CONSTRUCTOR —– public: DOCINFO::DOCINFO() { DocumentName = “”; OutputFile = “”; } Use […]

Read More

Structures/Class Of Our Own Data Types

Often with a class you want the application to use structures or variables that can be passed to the classes functions to be read or written with data. There is no real difference between a class or structure in c++.NET so create the structure as a class. In the header file of a class create […]

Read More

Other System Applications

Other Applications / Processes Running This is a C# example of finding all processes that are running with something particular in their name (include System.Diagnostics namespace):- var Processses = from p in Process.GetProcesses() where p.ProcessName.Contains(“x”) select p;

Read More