• After more than 30 years running websites and forums I am retiring.

    I have made many friends through the years. I will cherish my time getting to know you. I wish you all the best. This was not an easy decision to make. The cost to keep the communities running has gotten to the point where it's just too expensive. Security certificates, hosting cost, software renewals and everything else has increased threefold. While costs are up ad revenue is down. It's no longer viable to keep things running.

    All sites will be turned off on Thursday 30 November 2023. If you are interested in acquiring any of the websites I own you can Email Schwarz Network.

Form not displaying

SleepingTroll

Newcomer
Joined
Feb 14, 2012
(sorry about the repost, just realized the original was in the wrong place)
I create a form and it displays fine, however as soon as I create my directX device the form stops displaying!

Here is my code, please note that I can eliminate all of the DirectX code and the form displays, however just the line 'private Device device = null;' will prevent my form from displaying.


Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace Model
{
	public partial class MainForm : Form
	{
		private Device device = null;
		public MainForm()
		{
			InitializeComponent();
			InitializeDevice();
		}
		
		private void InitializeDevice()
		{
			PresentParameters pp = new PresentParameters();
			pp.Windowed = true;
			pp.SwapEffect = SwapEffect.Discard;
			
			device = new Device(0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, pp);
		}
		
		protected override void OnPaint(PaintEventArgs e)
		{
			device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1);
			device.Present();
		}

	}
}
I am new at directX and will likely stay that way if I can't get by this!
 

snarfblam

Ultimate Contributor
Joined
Jun 10, 2003
Location
USA
Is there a reason why you are creating a reference device? I can't how this could cause a problem, but it seems unusual.

The problem might be related to the fact that you are creating the device before your form creates its handle. Try calling the InitializeDevice method from the OnLoad event method rather than the constructor.
 

SleepingTroll

Newcomer
Joined
Feb 14, 2012
I do have more info, although it is not encouraging... It would seem that the compiler is having a problem with the DirectX framework, when it references it, it goes into limbo! I am redownloading the framework, somehow though... I don't expect that this is a solution, any ideas greatly appreciated!

AHA! When searching for the DirectX download I was directed(no pun intended) to DirectX 11! Downloading Version 9 now... I can't imagine all the trouble this is going to cause for nubes like myself...
 
Last edited:

SleepingTroll

Newcomer
Joined
Feb 14, 2012
I found my solution! app.cfg needs to read like this...
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
 
Top Bottom