Its not crashing, its just that the main loop is blocking the windows form from monitoring events sent to it.. i have this same problem.
If someone knew of a way to force a winform to monitor events from within a loop that would should solve the problem... kinda
[EDIT!]
Ok so i figured out how to get it setup properly, and working with winforms also its better to start with an empty project when you do this instead of starting a winforms project.
heres the code i have:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace SFML_Application
{
class Window : Form
{
public Window()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.SuspendLayout();
//
// Window
//
this.ClientSize = new System.Drawing.Size(784, 562);
this.Name = "Window";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SFML Application";
this.ResumeLayout(false);
}
}
class SFMLApp
{
static void Main(string[] args)
{
Window Wnd = new Window();
SFML.Graphics.RenderWindow Scene = new SFML.Graphics.RenderWindow(Wnd.Handle);
SFML.Graphics.Shape Rect = SFML.Graphics.Shape.Rectangle(new SFML.Graphics.Vector2(0, 0),
new SFML.Graphics.Vector2(200, 100),
new SFML.Graphics.Color(255, 40, 40));
Wnd.Show();
while (Wnd.Created)
{
Application.DoEvents();
Scene.Clear();
Scene.Draw(Rect);
Scene.Display();
}
}
}
}
If you want to edit your winform, right click on the class that inherits from Form (Window i think) and select view designer.
There.
PS: it was Application.DoEvents( ) that allowed me to monitor events inside a loop.