Need help in C#.NET 2005 beta 2
-
using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace XSkate { public partial class MainForm : Form { Device device = null; // Our rendering device public MainForm() { InitializeComponent(); } public bool InitializeGraphics() { try { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, presentParams); return true; } catch (DirectXException) { DisplayError("Could not initialize Direct3D, now exiting.", true); return false; } } private void Render() { if (device == null) { return; } device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); device.BeginScene(); // Rendering of scene objects can happen here device.EndScene(); device.Present(); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { this.Render(); } protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) { if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) { this.Close(); } } static void Main() { using (MainForm frm = new MainForm()) { if (!frm.InitializeGraphics()) { return; } frm.Show(); while (frm.Created) { frm.Render(); Application.DoEvents(); } } } private void DisplayError(string Message, bool Fatal) { if (Fatal) { MessageBox.Show(Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { MessageBox.Show(Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } }
It works but I don't know why the console window pops up along with the form, I don't want it to but what am I doing wrong? I am using Visual C#.NET 2005 beta 2, plz help, this is all the code I have in the project, except for the form code which is probably unnecessary for this problem, again plz help. :(:confused::confused: IM PROUD TO BE A GMAIL; -
using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace XSkate { public partial class MainForm : Form { Device device = null; // Our rendering device public MainForm() { InitializeComponent(); } public bool InitializeGraphics() { try { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, presentParams); return true; } catch (DirectXException) { DisplayError("Could not initialize Direct3D, now exiting.", true); return false; } } private void Render() { if (device == null) { return; } device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); device.BeginScene(); // Rendering of scene objects can happen here device.EndScene(); device.Present(); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { this.Render(); } protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) { if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) { this.Close(); } } static void Main() { using (MainForm frm = new MainForm()) { if (!frm.InitializeGraphics()) { return; } frm.Show(); while (frm.Created) { frm.Render(); Application.DoEvents(); } } } private void DisplayError(string Message, bool Fatal) { if (Fatal) { MessageBox.Show(Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { MessageBox.Show(Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } }
It works but I don't know why the console window pops up along with the form, I don't want it to but what am I doing wrong? I am using Visual C#.NET 2005 beta 2, plz help, this is all the code I have in the project, except for the form code which is probably unnecessary for this problem, again plz help. :(:confused::confused: IM PROUD TO BE A GMAIL;Is your project's Output Type specified as Console application? Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Is your project's Output Type specified as Console application? Regards Senthil _____________________________ My Blog | My Articles | WinMacro
I thought of that, but he has a mainform, surely the wizard added that ? Christian Graus - Microsoft MVP - C++
-
I thought of that, but he has a mainform, surely the wizard added that ? Christian Graus - Microsoft MVP - C++
-
Is your project's Output Type specified as Console application? Regards Senthil _____________________________ My Blog | My Articles | WinMacro