Quote:
Originally Posted by Xav
You shouldn't need DirectX just to display a form! Use a simple Form object, and change its BackColor to Color.Blue, like so:
Code:
Dim f As New Form()
f.BackColor = Color.Blue
f.Show()
You can change any extra properties of the 'f' object before showing it, to make it look just the way you want it to.
|
It is that simple? Here is the command line that I am having problems with below:
REM Create the Direct3D device
device = New Direct3D.Device(adapterNumber, Direct3D.DeviceType.Hardware, Me, flags, params)
Here is the program below:
Imports Microsoft.DirectX
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Dim device As Microsoft.DirectX.Direct3D.Device
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Size = New Size(800, 600)
Me.Text = "DirectX Initialization Demo"
Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True)
REM the above statements resize the window of the form
REM set up the presentation parameters
Dim params As New Direct3D.PresentParameters
params.Windowed = True
params.SwapEffect = Direct3D.SwapEffect.Discard
params.AutoDepthStencilFormat = Direct3D.DepthFormat.D16
params.EnableAutoDepthStencil = True
params.BackBufferCount = 1
params.BackBufferCount = 800
params.BackBufferCount = 600
REM Check video card capabilities
Dim adapterNumber As Integer = Direct3D.Manager.Adapters.Default.Adapter
Dim flags As Direct3D.CreateFlags
flags = Direct3D.CreateFlags.HardwareVertexProcessing
flags += Direct3D.CreateFlags.PureDevice
Dim caps As Direct3D.Caps
caps = Direct3D.Manager.GetDeviceCaps(adapterNumber, Direct3D.DeviceType.Hardware)
If caps.DeviceCaps.SupportsHardwareTransformAndLight = False Or caps.DeviceCaps.SupportsPureDevice = False Then
MessageBox.Show("Your video card is obsolete.", "Hardware Problem")
End
End If
REM Create the Direct3D device
device = New Direct3D.Device(adapterNumber, Direct3D.DeviceType.Hardware, Me, flags, params)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
device.Clear(Direct3D.ClearFlags.Target + Direct3D.ClearFlags.ZBuffer, Color.Blue, 1.0, 0)
device.BeginScene()
device.EndScene()
device.Present()
Me.Invalidate()
End Sub
End Class
It is suppose to bring up a window and make the window blue.