So, I need to make a program that draws a finite automata from the input data.
I had some experience with the graphics.h header but as far as I know it's a Borland only header and VC++ doesn't support it. So I was wondering, is there a way to draw some simple shapes and lines on VC++, besides using OpenGL?
Caveat is the examples are in C# and VB.NET, but the usual dot used for namespace in C# changes to C++ :: ,and dot used for member method in C# changes to -> (if the variable in question is a pointer) will apply. Look on MSDN to confirm the syntax if need be.
I did some more research on the web and found this topic about shapes in Microsoft's MSDN Library "Shapes and Basic Drawing in WPF Overview". It seems that the only way to draw in a window is by using .Net and XAML. Typical for Microsoft, always making things more complicated than they aleready are.
If someone knows another way of drawing on a Form please respond, I would really apreciate'it.
You don't need to do it in WPF (using that with C++ is one of those things that's theoretically possible, but not really doable anyway), the GDI+ stuff works in C++/CLI. I'll try to throw together a sample at some point.
Here's a sample that moves a circle around the window when you press the button.
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
//get this event from the right hand side of the screen in the form design
// window, click on the the lightening bolt and double click the cell next to
Graphics ^ g = e->Graphics; //get the graphics handle from the form
Random ^ rand = gcnew Random(); //random number generator
->Next(0,ClientRectangle.Width),10,10)); //make a circle in a 10x10 box at some
//point over the window (box has upper left hand corner coordinate specified).
//Sometimes it overlaps off the screen, but you get the idea
//this normally requires a handle to a RectangleF (a rectangle with float coords), but this is an overload.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
Invalidate(); //forces Paint() event to be called
(the lines are too long so it looks like hell, but you get the idea).
See if that gets you started in the right direction and you can start translating the Bob Powell tutorial (or one of your choosing) into C++. That graphics object holds all of the methods (drawellipse, fillellipse,etc.). The graphics object only comes from the Paint method, so you'll have to use Invalidate() in your other methods to control it.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...