I have written (with a pointer from you lot here - thanks) a visualisation program in unmanaged C++ DirectX. Everything works fine, however I need to be able to change and edit parameters of the model with the usual text input boxes and track bar, as well as haveing a menu with different options. I have written a little windows form program that does this but wihout the directx stuff.
I would like to add my DirectX work into a window in the form but I have no idea about devices and that side of things (I just used the tutorials to set that end of things up).
Any help would be greatly appreciated, thanks.

Unmanaged directX and .net windows form
Shoaib Aleem
Compiling...
test.cpp
Linking...
test.obj : error LNK2028: unresolved token (0A00001C) "extern "C" struct D3DXMATRIX * __stdcall D3DXMatrixPerspectiveLH(struct D3DXMATRIX *,float,float,float,float)" ( D3DXMatrixPerspectiveLH@@$$J220YGPAUD3DXMATRIX@@PAU1@MMMM@Z) referenced in function "public: int __clrcall D3DGraphics::CreateDevice(struct HWND__ *)" ( CreateDevice@D3DGraphics@@$$FQAMHPAUHWND__@@@Z)
test.obj : error LNK2028: unresolved token (0A00001D) "extern "C" int __stdcall GetClientRect(struct HWND__ *,struct tagRECT *)" ( GetClientRect@@$$J18YGHPAUHWND__@@PAUtagRECT@@@Z) referenced in function "public: int __clrcall D3DGraphics::CreateDevice(struct HWND__ *)" ( CreateDevice@D3DGraphics@@$$FQAMHPAUHWND__@@@Z)
test.obj : error LNK2028: unresolved token (0A00001F) "extern "C" struct IDirect3D9 * __stdcall Direct3DCreate9(unsigned int)" ( Direct3DCreate9@@$$J14YGPAUIDirect3D9@@I@Z) referenced in function "public: int __clrcall D3DGraphics::InitD3D(void)" ( InitD3D@D3DGraphics@@$$FQAMHXZ)
test.obj : error LNK2019: unresolved external symbol "extern "C" struct D3DXMATRIX * __stdcall D3DXMatrixPerspectiveLH(struct D3DXMATRIX *,float,float,float,float)" ( D3DXMatrixPerspectiveLH@@$$J220YGPAUD3DXMATRIX@@PAU1@MMMM@Z) referenced in function "public: int __clrcall D3DGraphics::CreateDevice(struct HWND__ *)" ( CreateDevice@D3DGraphics@@$$FQAMHPAUHWND__@@@Z)
test.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetClientRect(struct HWND__ *,struct tagRECT *)" ( GetClientRect@@$$J18YGHPAUHWND__@@PAUtagRECT@@@Z) referenced in function "public: int __clrcall D3DGraphics::CreateDevice(struct HWND__ *)" ( CreateDevice@D3DGraphics@@$$FQAMHPAUHWND__@@@Z)
test.obj : error LNK2019: unresolved external symbol "extern "C" struct IDirect3D9 * __stdcall Direct3DCreate9(unsigned int)" ( Direct3DCreate9@@$$J14YGPAUIDirect3D9@@I@Z) referenced in function "public: int __clrcall D3DGraphics::InitD3D(void)" ( InitD3D@D3DGraphics@@$$FQAMHXZ)
C:\Documents and Settings\R. Andersson\My Documents\LITH\Modellering och Animering\test\Debug\test.exe : fatal error LNK1120: 6 unresolved externals
Build log was saved at "file://c:\Documents and Settings\R. Andersson\My Documents\LITH\Modellering och Animering\test\test\Debug\BuildLog.htm"
test - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Seabhcan
// test.cpp : main project file.
#include
"stdafx.h"#include
"Form1.h"using
namespace D3DFormTest;[STAThreadAttribute]
int
main(array<System::String ^> ^args){
// Enabling Windows XP visual effects before any controls are createdApplication::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(
false); // Create the main window and run itApplication::Run(
gcnew Form1()); return 0;}
// Form1.h : the form header
#include
"D3DGraphics.h"namespace
D3DFormTest{
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form{
public:Form1(
void){
InitializeComponent();
this->SetStyle(static_cast<ControlStyles>(ControlStyles::AllPaintingInWmPaint | ControlStyles::Opaque),
true);m_Graphics =
new D3DGraphics;m_Graphics->InitD3D();
}
protected: /// <summary> /// Clean up any resources being used. /// </summary>~Form1()
{
m_Graphics->Shutdown();
delete m_Graphics; if (components){
delete components;}
}
private:System::ComponentModel::Container^ components;
void InitializeComponent(void){
this->components = gcnew System::ComponentModel::Container(); this->Size = System::Drawing::Size(300,300); this->Text = "Form1";}
protected:D3DGraphics* m_Graphics;
virtual void OnHandleCreated(System::EventArgs^ e){
__super::OnHandleCreated(e);HWND hWnd =
reinterpret_cast<HWND>(this->Handle.ToPointer());m_Graphics->CreateDevice(hWnd);
}
virtual void OnPaint(PaintEventArgs^ e){
if(m_Graphics->CanRender() == FALSE) return;m_Graphics->Render();
this->Invalidate();}
};
}
This give me the following two headers, how do I fix it
ompiling...
test.cpp
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(48) : error C4485: 'D3DFormTest::Form1::OnHandleCreated' : matches base ref class method 'System::Windows::Forms::Form::OnHandleCreated', but is not marked 'new' or 'override'; 'new' (and 'virtual') is assumed
c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : see declaration of 'System::Windows::Forms::Form::OnHandleCreated'
Specify 'override' (and 'virtual') to override the ref class virtual method
Specify 'new' (and 'virtual') to hide the ref class virtual method with a new virtual method
Position for 'new' and 'override' keywords is after method parameter list
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(54) : error C4485: 'D3DFormTest::Form1::OnPaint' : matches base ref class method 'System::Windows::Forms::Form::OnPaint', but is not marked 'new' or 'override'; 'new' (and 'virtual') is assumed
c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : see declaration of 'System::Windows::Forms::Form::OnPaint'
Specify 'override' (and 'virtual') to override the ref class virtual method
Specify 'new' (and 'virtual') to hide the ref class virtual method with a new virtual method
Position for 'new' and 'override' keywords is after method parameter list
Build log was saved at "file://c:\Documents and Settings\R. Andersson\My Documents\LITH\Modellering och Animering\test\test\Debug\BuildLog.htm"
test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
GeorgeIT
notnal
I have something up and running, and I need to get it ready for a presestation on monday, so I will have a look at this extra stuff next week.
Thanks for all the help.
Nandagopal
I take it that you mean using your unmanaged code in a managed environment. I’m using VS2003 so that’s what this is based on.
Your unmanaged types declared in a managed class have to be pointers.
You have to set the style to avoid flickering, basically you’re telling windows that you will be doing the painting in the OnPaint event.
this->SetStyle(static_cast<ControlStyles>(ControlStyles::AllPaintingInWmPaint | ControlStyles::Opaque), true);
Then override OnPaint
virtual void OnPaint(PaintEventArgs* args)
{
if(readyToRender)
myEngine->Render();
this->Invalidate();
}
You need to get the handle to the form to create the device, if its like an example program you can always do this in the OnHandleCreated handler
virtual void OnHandleCreated(System::EventArgs* args)
{
// Make sure the handle is created
__super::OnHandleCreated(args);
// Get the handle
void* phWnd = this->Handle.ToPointer();
// You might get a conflict if you cast to HWND so it
// might be better to cast the void* in the Init method
myEngine->Init(phWnd);
}
Use the Marshal class for converting strings
using namespace System::Runtime::InteropServices;
// Convert C style string to a managed string
System::String* managed_str = Marshal::PtrToStringAnsi(System::IntPtr((void*)txt));
// Convert managed string to C style string
char* txt= (char*)(Marshal::StringToHGlobalAnsi(managed_str)).ToPointer();
// But you have to release the C style string afterwards because its based on
// something managed
Marshal::FreeHGlobal(System::IntPtr((void*)txt));
Get something going first then play around with this stuff, you can toggle the style, release and re-create the handle.
Also check out the Application class, it has things like the Idle event where you can put things like PeekMessage and other things you would do in idle time.
Jondr
Another way would be to create you own custom control so you can toggle its style and maybe add some other stuff, it’s fun to play about with these things, plus since the style is set differently it might cause problems with buttons and the like redrawing if they inherit from the form. You can always use the controls Paint, Size and other events, plus they always have access to a Handle property. Also since DInput takes a handle to the window it might just apply to that control.
What I’ll do is start you off with something to work with, you can then do some research for a deeper understanding, you'll find there are different ways of doing this.
Start a “Class library” project, call it CustomControls or something and paste this sample code:
// CustomControls.h
#pragma once
// add these references to the default ones:
// System.Windows.Forms
// System.Drawing
// System.Design
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;
namespace CustomControls
{
/// <summary>
/// GraphicsScreenDesigner class
/// </summary>
private __gc class GraphicsScreenDesigner : public ControlDesigner
{
protected:
void PostFilterProperties(System::Collections::IDictionary* properties)
{
// Remove "Text" from the properties
properties->Remove(S"Text");
}
};
/// <summary>
/// GameRenderPanel class
/// </summary>
[Designer(__typeof(GraphicsScreenDesigner))]
public __gc class GraphicsScreen : public System::Windows::Forms::Control
{
private:
/// <summary>
/// flag render mode
/// </summary>
bool graphicsMode;
public:
/// <summary>
/// GraphicsMode property
/// Use to toggle the render mode
/// </summary>
[DefaultValue(false)] // Default value in properties dialog
[Category("Custom")] // Category in properties dialog
__property bool get_GraphicsMode()
{
return graphicsMode;
}
__property void set_GraphicsMode(bool value)
{
if(value == true && graphicsMode == false)
{
this->SetStyle(static_cast<ControlStyles>(
ControlStyles::AllPaintingInWmPaint | ControlStyles::Opaque), true);
graphicsMode = true;
}
else if(value == false && graphicsMode == true)
{
this->SetStyle(static_cast<ControlStyles>(
ControlStyles::AllPaintingInWmPaint | ControlStyles::Opaque), false);
graphicsMode = false;
}
}
};
}
When you’ve finished with it open up your toolbox, right click on the General tab and select “Add/Remove Items…”, in the dialog box select Browse and locate the dll somewhere in your project.
Every time you change it do a full rebuild and reset it in the toolbox.
Also becareful when reference is added to a different project, sometimes it set lower case.
Tea
It’s just a syntax thing.
The example I gave was based on VC 2003, which used things like "__gc" to define a managed class and "new __gc" to allocate a managed type, with VC 2005 you should replace __gc with "ref" when defining a managed class and use "gcnew" to allocate a managed type. Dispose was used in 2003 instead of a destructor, but that’s changed too by the look of it. Managed pointers in 2003 used "*" but in 2005 you use "^".
So you’ll have to tweak it a bit to use it for 2005.
The important thing is to get the handle to the control via its "Handle" property.
You can also mimic the "PeekMessage" part by declaring a message handle for the Application Idle event like:
using namespace System::Runtime::InteropServices;
private:
[StructLayout(LayoutKind::Sequential)]
ref class Message
{
public:
IntPtr hWnd;
unsigned int msg;
IntPtr wParam;
IntPtr lParam;
unsigned long time;
System::Drawing::Point p;
};
[System::Security::SuppressUnmanagedCodeSecurity]
[DllImportAttribute("User32.dll", CharSet=CharSet::Auto)]
static bool PeekMessage(Message ^msg,
IntPtr hWnd,
unsigned int messageFilterMin,
unsigned int messageFilterMax,
unsigned int flags);
private:
System::Void OnApplicationIdle(System::Object^ sender, System::EventArgs^ e)
{
Message^ Msg = gcnew Message();
while(!PeekMessage(Msg, IntPtr::Zero, 0, 0, 0))
{
// Render stuff...
}
}
private:
System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
// Initialise DX
InitDX(panel1->Handle);
// Hook the handler
Application::Idle += gcnew System::EventHandler(
this, &Form1::OnApplicationIdle);
}
Sanjay659
Hi Jen!
You don't want to create another window, the form is the one you'll use, a little example, use it to help update your code:
// stdafx.h
#include
<windows.h>#include
<d3d9.h>#include
<d3dx9.h>//
D3DGraphics.hclass
D3DGraphics{
public
:D3DGraphics(
void): m_pD3D(NULL)
, m_pD3DDevice(NULL)
, m_CanRender(FALSE)
{
}
~D3DGraphics(
void){
Shutdown();
}
BOOL InitD3D()
{
Shutdown();
m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
return m_pD3D != 0;}
void Shutdown(){
DestroyDevice();
if(m_pD3D != NULL){
m_pD3D->Release();
m_pD3D = NULL;
}
}
BOOL CreateDevice(HWND hWnd)
{
if(m_pD3D == NULL) return FALSE;DestroyDevice();
if((m_hWnd = hWnd) == NULL) return FALSE;m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &m_d3ddm);
ZeroMemory(&m_d3dpp,
sizeof(D3DPRESENT_PARAMETERS));RECT ClientRect;
::GetClientRect(m_hWnd, &ClientRect);
m_d3dpp.Windowed = TRUE;
m_d3dpp.BackBufferWidth = ClientRect.right;
m_d3dpp.BackBufferHeight = ClientRect.bottom;
m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_d3dpp.BackBufferFormat = m_d3ddm.Format;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
m_d3dpp.EnableAutoDepthStencil = TRUE;
m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
if(FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,m_hWnd, D3DCREATE_MIXED_VERTEXPROCESSING, &m_d3dpp, &m_pD3DDevice)))
{
return FALSE;}
D3DXMATRIX matProjection;
D3DXMatrixPerspectiveLH(&matProjection,
D3DX_PI / 4,
(
float)ClientRect.right / (float)ClientRect.bottom,1.0f,
10000.0f);
m_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProjection);
m_CanRender = TRUE;
return TRUE;}
void DestroyDevice(){
m_CanRender = FALSE;
if(m_pD3DDevice != NULL){
m_pD3DDevice->Release();
m_pD3DDevice = NULL;
}
m_hWnd = NULL;
}
BOOL CanRender()
{
if(m_CanRender == TRUE) return TRUE;HRESULT hr = m_pD3DDevice->TestCooperativeLevel();
if(hr == D3DERR_DEVICELOST){
// Dispose of disposable resources return FALSE;}
if(hr == D3DERR_DEVICENOTRESET){
m_pD3DDevice->Reset(&m_d3dpp);
// Reset resourcesm_CanRender = TRUE;
return TRUE;}
// Something serious happened, exit application return FALSE;}
void Render(){
m_pD3DDevice->Clear(
0, NULL,
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_RGBA(0,64,128,255),
1.0f, 0);
if(SUCCEEDED(m_pD3DDevice->BeginScene())){
m_pD3DDevice->EndScene();
}
m_CanRender = SUCCEEDED(m_pD3DDevice->Present(NULL,NULL,NULL,NULL));
}
private
:HWND m_hWnd;
IDirect3D9* m_pD3D;
IDirect3DDevice9* m_pD3DDevice;
D3DPRESENT_PARAMETERS m_d3dpp;
D3DDISPLAYMODE m_d3ddm;
BOOL m_CanRender;
};
//
Form.h#include
"D3DGraphics.h"namespace
D3DFormTest{
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public __gc class Form1 : public System::Windows::Forms::Form{
public:Form1(
void){
InitializeComponent();
this->SetStyle(static_cast<ControlStyles>(ControlStyles::AllPaintingInWmPaint | ControlStyles::Opaque),
true);m_Graphics =
new D3DGraphics;m_Graphics->InitD3D();
}
protected: void Dispose(Boolean disposing){
m_Graphics->Shutdown();
delete m_Graphics; if (disposing && components){
components->Dispose();
}
__super::Dispose(disposing);}
private:System::ComponentModel::Container * components;
void InitializeComponent(void){
this->components = new System::ComponentModel::Container(); this->Size = System::Drawing::Size(300,300); this->Text = S"Form1";}
protected:D3DGraphics* m_Graphics;
virtual void OnHandleCreated(System::EventArgs* e){
__super::OnHandleCreated(e);HWND hWnd =
reinterpret_cast<HWND>(this->Handle.ToPointer());m_Graphics->CreateDevice(hWnd);
}
virtual void OnPaint(PaintEventArgs* e){
if(m_Graphics->CanRender() == FALSE) return;m_Graphics->Render();
this->Invalidate();}
};
}
E. Richards
Kunj
I have implemented this, and I have the direct X in the form, but this make the whole of the window a direct x window. I want a square about the size of 2/3 the window to be direct X
like this (hope this appears ok):
_____________________________
|_____________________ |
|| | |
|| | form |
|| DX WIN | |
|| | |
||_____________________| |
|____________________________|
should I just make the whole thing direct x and only draw my direct x to a small portion of my direct x window. I would have to figure out a scale, and also tell the mouse pointer only to process a directx click as apposed to a form click when clicked within the specified rectangle.
cheers,
Jen
SVadali7881
I have made a windows form with the details given to me:
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
virtual void OnHandleCreated(System::EventArgs* args)
{
// Make sure the handle is created
__super::OnHandleCreated(args);
// Get the handle
// I used the toPointer Method but phWnd kept coming back as <void>
void* phWnd = &(this->Handle);
myEngine->Initialize( hInstance, 640, 480, true, phWnd );
}
virtual void OnPaint(PaintEventArgs* args)
{
__super::OnPaint(args);
if(readyToRender) myEngine->Run();
this->Invalidate();
}
//intialise for form I have sent it the HINSTANCE from main as the directX needs it
Form1(HINSTANCE h)
{
hInstance = h;
this->SetStyle(static_cast<ControlStyles>(ControlStyles::AllPaintingInWmPaint | ControlStyles::Opaque), true);
InitializeComponent();
}
Then we also have my DirectX stuff which is based on the tutorials about for using directx C++
BOOL CEngine::Initialize(HINSTANCE hInstance, int width, int height, BOOL windowed, void* phWndVoid )
{
m_hInstance = hInstance;
m_windowWidth = width;
m_windowHeight = height;
// Define the window
WNDCLASSEX wcex;
wcex.cbSize = sizeof( WNDCLASSEX );
wcex.style = CS_DBLCLKS;
wcex.lpfnWndProc = (WNDPROC)CFramework::StaticWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_CUNIT ) );
wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
wcex.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wcex.lpszMenuName = NULL;
wcex.lpszClassName = title;
wcex.hIconSm = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_CUNIT ) );
// Register the window
RegisterClassEx( &wcex );
HWND* phWnd = (HWND*)phWndVoid;
// Create the window
// let it know it is a child to the windows form,
m_hWnd = CreateWindow( title, title, WS_CHILD , 5,
5, width, height, *phWnd , NULL, hInstance, this );
// Adjust to desired size
// not sure if this is needed
RECT rect = { 0, 0, width, height };
AdjustWindowRect( &rect, GetWindowLong( m_hWnd, GWL_STYLE ), FALSE );
SetWindowPos( m_hWnd, *phWnd , 0, 0, rect.right - rect.left, rect.bottom - rect.top,
SWP_NOMOVE );
ShowWindow( m_hWnd, SW_SHOW );
UpdateWindow( m_hWnd );
// Save current location/size
ZeroMemory( &m_wp, sizeof( WINDOWPLACEMENT ) );
m_wp.length = sizeof( WINDOWPLACEMENT );
GetWindowPlacement( m_hWnd, &m_wp );
// Initialize Direct3D stuff
Also when I try to set the input device cooperative level it fails:
// Set the cooperative level where hWnd is the handle to the directX window
if( FAILED( m_pDevice->SetCooperativeLevel( hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE ) ) )
{
SHOWERROR( "Unable to set input cooperative level.", __FILE__, __LINE__ );
return FALSE;
}
I know this is quite hard to help on, as I have probably not given all the information on what variables are what, but I have tried to help make it transparent.
Any help would be really appreciated,
Jen.
PerryMowbray
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(19) : error C4980: '__gc' : use of this keyword requires /clr:oldSyntax command line option
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(46) : error C2605: 'Dispose' : this method is reserved within a managed class
did you intend to define a destructor
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(67) : error C3699: '*' : cannot use this indirection on type 'System::ComponentModel::Container'
compiler replacing '*' with '^' to continue parsing
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(77) : error C3921: Use of S-prefixed strings requires /clr:oldSyntax command line option
When compiling with /clr, an implicit conversion exists from string literal type to System::String^. If necessary to avoid ambiguity, cast to System::String^
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(85) : error C3699: '*' : cannot use this indirection on type 'System::EventArgs'
compiler replacing '*' with '^' to continue parsing
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(97) : error C3699: '*' : cannot use this indirection on type 'System::Windows::Forms::PaintEventArgs'
compiler replacing '*' with '^' to continue parsing
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(85) : error C4485: 'D3DFormTest::Form1::OnHandleCreated' : matches base ref class method 'System::Windows::Forms::Form::OnHandleCreated', but is not marked 'new' or 'override'; 'new' (and 'virtual') is assumed
c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : see declaration of 'System::Windows::Forms::Form::OnHandleCreated'
Specify 'override' (and 'virtual') to override the ref class virtual method
Specify 'new' (and 'virtual') to hide the ref class virtual method with a new virtual method
Position for 'new' and 'override' keywords is after method parameter list
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(97) : error C4485: 'D3DFormTest::Form1::OnPaint' : matches base ref class method 'System::Windows::Forms::Form::OnPaint', but is not marked 'new' or 'override'; 'new' (and 'virtual') is assumed
c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : see declaration of 'System::Windows::Forms::Form::OnPaint'
Specify 'override' (and 'virtual') to override the ref class virtual method
Specify 'new' (and 'virtual') to hide the ref class virtual method with a new virtual method
Position for 'new' and 'override' keywords is after method parameter list
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(56) : error C2039: 'Dispose' : is not a member of 'System::ComponentModel::Container'
c:\windows\microsoft.net\framework\v2.0.50727\system.dll : see declaration of 'System::ComponentModel::Container'
You should invoke the destructor, '~Container' instead
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(60) : error C2794: 'Dispose' : is not a member of any direct or indirect base class of 'D3DFormTest::Form1'
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(73) : error C2750: 'System::ComponentModel::Container' : cannot use 'new' on the reference type; use 'gcnew' instead
c:\documents and settings\r. andersson\my documents\lith\modellering och animering\test\test\Form1.h(73) : error C2440: '=' : cannot convert from 'System::ComponentModel::Container *' to 'System::ComponentModel::Container ^'
No user-defined-conversion operator available, or
Cannot convert an unmanaged type to a managed type
.\test.cpp(6) : error C2871: 'test' : a namespace with this name does not exist
.\test.cpp(8) : error C2337: 'STAThreadAttribute' : attribute not found
.\test.cpp(12) : error C2653: 'Application' : is not a class or namespace name
.\test.cpp(12) : error C3861: 'EnableVisualStyles': identifier not found
.\test.cpp(13) : error C2653: 'Application' : is not a class or namespace name
.\test.cpp(13) : error C3861: 'SetCompatibleTextRenderingDefault': identifier not found
.\test.cpp(16) : error C2653: 'Application' : is not a class or namespace name
.\test.cpp(16) : error C2061: syntax error : identifier 'Form1'
.\test.cpp(16) : error C3861: 'Run': identifier not found
Build log was saved at "file://c:\Documents and Settings\R. Andersson\My Documents\LITH\Modellering och Animering\test\test\Debug\BuildLog.htm"
test - 21 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Dukebaby
these are linker errors.
did you remember to add
dinput8.lib dxerr9.lib dxguid.lib d3dx9d.lib d3d9.lib winmm.lib comctl32.lib
under you project properties->linker->input.
Shane Colin
Hi,
I will have to leave the answer about the message queue to Bad Habit . But I Think I can solve your errors.
try replacing
virtual void OnHandleCreated(System::EventArgs^ e)
with
virtual void OnHandleCreated(System::EventArgs^ e) override
and
virtual void OnPaint(PaintEventArgs^ e)with
virtual void OnPaint(PaintEventArgs^ e) override
That should sort out the errors.
The problem I am having is that the whole program only runs at about 1%, so the direct x is very laggy.
Jen