473,387 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VC++.NET 2002 and VC++.NET 2003 Co-Exist Side-by-Side Probblems

SHC
Hi all,
1) I have used VC++.NET 2002 (v7.0) for a while. Recently I just installed
VC++.NET 2003 (v7.1) - I saw the message "Settings were not migrated from
Visual Studio.NET 2002 to Visual Studio,NET 2003" during the installation.
Do I have to do the migration of the "Settings" if I want to use the both
versions of VC++.NET in the Side-by-Side fashion?
2) I ran the "Build" of the example 'Chapter5_Example1' of 'Beginning
DirectX 9' by W. Jones and I got the fatal error C1083: Cannot open include
file: 'd3d9.hc\BeginningDirectX9\Chapter5\example1\winma in.cpp.'
But the #include <d3d9.h> is in the library - see the attached file. What
causes this prblem? Did I launch the program in the wrong path/folder? How
can I execute the program right?
Please help and advise.
Thanks in advance,
shc
/////--Chapter5_Example1\winmain.cpp---/////
#include <windows.h>
#include <mmsystem.h>
#include <d3d9.h>
#include <d3dx9tex.h>
#include <string>
using namespace std;

HINSTANCE hInst; // holds the instance for this app
HWND wndHandle; // global window handle

LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; // Buffer to hold vertices

// A structure for our custom vertex type
struct CUSTOMVERTEX
{
FLOAT x, y, z, rhw; // The untransformed, 3D position for the vertex
DWORD color; // The vertex color
};

// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)

LPDIRECT3D9 pD3D;
LPDIRECT3DDEVICE9 pd3dDevice;

////////////////////////////////////////////// forward declarations
bool initWindow(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

// direct3D functions
HRESULT SetupVB();
bool initDirect3D(HWND hwnd);
void shutdown(void);
LPDIRECT3DVERTEXBUFFER9 createVertexBuffer(int size, DWORD usage);
void drawVB(LPDIRECT3DVERTEXBUFFER9 buffer);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR
lpCmdLine, int nCmdShow)
{
// call our function to init and create our window
if (!initWindow(hInstance))
{
MessageBox(NULL, "Unable to create window", "ERROR", MB_OK);
return false;
}

// init direct3d
initDirect3D(wndHandle);

// setup the vertex buffer and add the triangle to it.
SetupVB();

// Main message loop:
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
// check for messages
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
// this is called when no messages are pending
else
{
// call our render function
pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f,
0 );

pd3dDevice->BeginScene();

// draw the contents of the vertex buffer
drawVB(g_pVB);

pd3dDevice->EndScene();

pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
}

// shutdown the directx manager
shutdown();

return (int) msg.wParam;
}

HRESULT SetupVB()
{
HRESULT hr;

// Initialize three vertices for rendering a triangle
CUSTOMVERTEX g_Vertices[] =
{
{ 320.0f, 50.0f, 0.5f, 1.0f, D3DCOLOR_ARGB(0,255,0,0), }, // x, y,
z, rhw, color
{ 250.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_ARGB(0,0,255,0), },
{ 50.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_ARGB(0,0,0,255), },
};

// Create the vertex buffer
g_pVB = createVertexBuffer(3*sizeof(CUSTOMVERTEX), D3DFVF_CUSTOMVERTEX);

// Fill the vertex buffer.
VOID* pVertices;

hr = g_pVB->Lock( 0, sizeof(g_Vertices), (void**)&pVertices, 0 );
if FAILED (hr)
return E_FAIL;

// copy the vertices into the buffer
memcpy( pVertices, g_Vertices, sizeof(g_Vertices) );

// unlock the vertex buffer
g_pVB->Unlock();

return S_OK;
}

bool initDirect3D(HWND hwnd)
{
HRESULT hr;

if( NULL == ( pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
return false;
}

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferWidth = 640;
d3dpp.hDeviceWindow = hwnd;

hr = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &pd3dDevice );
if FAILED (hr)
{
return false;
}

return true;
}

LPDIRECT3DVERTEXBUFFER9 createVertexBuffer(int size, DWORD usage)
{
HRESULT hr;
LPDIRECT3DVERTEXBUFFER9 buffer;

// Create the vertex buffer.
hr = pd3dDevice->CreateVertexBuffer( size,
0,
usage,
D3DPOOL_DEFAULT,
&buffer,
NULL );
if FAILED ( hr)
return NULL;

return buffer;
}

void drawVB(LPDIRECT3DVERTEXBUFFER9 buffer)
{
pd3dDevice->SetStreamSource( 0, buffer, 0, sizeof(CUSTOMVERTEX) );
pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );
}

void shutdown(void)
{
if( pd3dDevice != NULL)
{
pd3dDevice->Release();
pd3dDevice = NULL;
}
if( pD3D != NULL)
{
pD3D->Release();
pD3D = NULL;
}
}

bool initWindow(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "DirectXExample";
wcex.hIconSm = 0;
RegisterClassEx(&wcex);

wndHandle = CreateWindow("DirectXExample",
"DirectXExample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
NULL,
NULL,
hInstance,
NULL);
if (!wndHandle)
return false;

ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);

return true;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
SHC
Nov 17 '05 #1
3 1572
SHC wrote:
Hi all,
1) I have used VC++.NET 2002 (v7.0) for a while. Recently I just
installed VC++.NET 2003 (v7.1) - I saw the message "Settings were not
migrated from Visual Studio.NET 2002 to Visual Studio,NET 2003"
during the installation. Do I have to do the migration of the
"Settings" if I want to use the both versions of VC++.NET in the
Side-by-Side fashion? 2) I ran the "Build" of the example
'Chapter5_Example1' of 'Beginning DirectX 9' by W. Jones and I got
the fatal error C1083: Cannot open include file:
'd3d9.hc\BeginningDirectX9\Chapter5\example1\winma in.cpp.'
But the #include <d3d9.h> is in the library - see the attached file.
What causes this prblem? Did I launch the program in the wrong
path/folder? How can I execute the program right?


What do you mean by "<d3d9.h> is in the library"?

Make sure that the Direct-X SDK include directory is in the list of include
directories for Visual Studio 2003. Go to Tools|Options|Projects|C++
Directories|Include files from the menu. If the include directory isn't
there (which it apparently isn't), you probably also need to add the
corresponding d3d LIB directory to the libraries path (located nearby).

-cd
Nov 17 '05 #2
SHC
Hi Carl, Thank you very much for your valuable response and tips.
I did what you said and added C:\DX90SDK\Include, C:\DX90SDK\lib and
C:\DX90SDK\Utilities to the Tools|Options|Projects|C++ Directory.
If I clicked on the examples of the Jones' book on my C:\Drive, the VC++
..NET 2003, the "Build" and "Start Without Debugging" worked fine and I got
the right results.
If I created a new project called "WJCh4Ex1" from the scratch, and clicked
on "Build", I got the following errors:

WJCh4Ex1 error LNK2001: unresolved external symbol "struct IDirect3D9 *
__stdcall Direct3DCreate9(unsigned int)"
(?Direct3DCreate9@@$$J14YGPAUIDirect3D9@@I@Z)
WJCh4Ex1 fatal error LNK1120: 1 unresolved externals

I have no ideas what the errors are and how to correct them.
Please help again and tell me what I should do to get my created "WJCh4Ex1"
project working right.

Thanks,
SHC

//////--WJCh4Ex1____WinMain,cpp----/////
#include <windows.h>
#include <mmsystem.h>
#include <d3d9.h>
#include <d3dx9tex.h>
#include <string>
using namespace std;

HINSTANCE hInst; // holds the instance for this app
HWND wndHandle; // global window handle

LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; // Buffer to hold vertices

// A structure for our custom vertex type
struct CUSTOMVERTEX
{
FLOAT x, y, z, rhw; // The untransformed, 3D position for the vertex
DWORD color; // The vertex color
};

// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)

LPDIRECT3D9 pD3D;
LPDIRECT3DDEVICE9 pd3dDevice;

////////////////////////////////////////////// forward declarations
bool initWindow(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

// direct3D functions
HRESULT SetupVB();
bool initDirect3D(HWND hwnd);
void shutdown(void);
LPDIRECT3DVERTEXBUFFER9 createVertexBuffer(int size, DWORD usage);
void drawVB(LPDIRECT3DVERTEXBUFFER9 buffer);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR
lpCmdLine, int nCmdShow)
{
// call our function to init and create our window
if (!initWindow(hInstance))
{
MessageBox(NULL, "Unable to create window", "ERROR", MB_OK);
return false;
}

// init direct3d
initDirect3D(wndHandle);

// setup the vertex buffer and add the triangle to it.
SetupVB();

// Main message loop:
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
// check for messages
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
// this is called when no messages are pending
else
{
// call our render function
pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f,
0 );

pd3dDevice->BeginScene();

// draw the contents of the vertex buffer
drawVB(g_pVB);

pd3dDevice->EndScene();

pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
}

// shutdown the directx manager
shutdown();

return (int) msg.wParam;
}

HRESULT SetupVB()
{
HRESULT hr;

// Initialize three vertices for rendering a triangle
CUSTOMVERTEX g_Vertices[] =
{
{ 320.0f, 50.0f, 0.5f, 1.0f, D3DCOLOR_ARGB(0,255,0,0), }, // x, y,
z, rhw, color
{ 250.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_ARGB(0,0,255,0), },
{ 50.0f, 400.0f, 0.5f, 1.0f, D3DCOLOR_ARGB(0,0,0,255), },
};

// Create the vertex buffer
g_pVB = createVertexBuffer(3*sizeof(CUSTOMVERTEX), D3DFVF_CUSTOMVERTEX);

// Fill the vertex buffer.
VOID* pVertices;

hr = g_pVB->Lock( 0, sizeof(g_Vertices), (void**)&pVertices, 0 );
if FAILED (hr)
return E_FAIL;

// copy the vertices into the buffer
memcpy( pVertices, g_Vertices, sizeof(g_Vertices) );

// unlock the vertex buffer
g_pVB->Unlock();

return S_OK;
}

bool initDirect3D(HWND hwnd)
{
HRESULT hr;

if( NULL == ( pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
return false;
}

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferWidth = 640;
d3dpp.hDeviceWindow = hwnd;

hr = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &pd3dDevice );
if FAILED (hr)
{
return false;
}

return true;
}

LPDIRECT3DVERTEXBUFFER9 createVertexBuffer(int size, DWORD usage)
{
HRESULT hr;
LPDIRECT3DVERTEXBUFFER9 buffer;

// Create the vertex buffer.
hr = pd3dDevice->CreateVertexBuffer( size,
0,
usage,
D3DPOOL_DEFAULT,
&buffer,
NULL );
if FAILED ( hr)
return NULL;

return buffer;
}

void drawVB(LPDIRECT3DVERTEXBUFFER9 buffer)
{
pd3dDevice->SetStreamSource( 0, buffer, 0, sizeof(CUSTOMVERTEX) );
pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );
}

void shutdown(void)
{
if( pd3dDevice != NULL)
{
pd3dDevice->Release();
pd3dDevice = NULL;
}
if( pD3D != NULL)
{
pD3D->Release();
pD3D = NULL;
}
}

bool initWindow(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "DirectXExample";
wcex.hIconSm = 0;
RegisterClassEx(&wcex);

wndHandle = CreateWindow("DirectXExample",
"DirectXExample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
NULL,
NULL,
hInstance,
NULL);
if (!wndHandle)
return false;

ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);

return true;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}


Nov 17 '05 #3
SHC wrote:
Hi Carl, Thank you very much for your valuable response and tips.
I did what you said and added C:\DX90SDK\Include, C:\DX90SDK\lib and
C:\DX90SDK\Utilities to the Tools|Options|Projects|C++ Directory.
If I clicked on the examples of the Jones' book on my C:\Drive, the
VC++ .NET 2003, the "Build" and "Start Without Debugging" worked fine
and I got the right results.
If I created a new project called "WJCh4Ex1" from the scratch, and
clicked on "Build", I got the following errors:

WJCh4Ex1 error LNK2001: unresolved external symbol "struct IDirect3D9
* __stdcall Direct3DCreate9(unsigned int)"
(?Direct3DCreate9@@$$J14YGPAUIDirect3D9@@I@Z)
WJCh4Ex1 fatal error LNK1120: 1 unresolved externals

I have no ideas what the errors are and how to correct them.
Please help again and tell me what I should do to get my created
"WJCh4Ex1" project working right.


You need to add d3d9.lib to the "additional dependencies" section of the
Linker properties for your new project. (Project|Properties|Linker|Input
from the menu).

-cd
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve | last post by:
Hi I want to write a GUI type MIDI Windows App. using the VC#.NET 2002 Standard I have already purchased. What DirectX SDK version should I use This is just a part of my learning process, so...
2
by: John Harrison | last post by:
Hi, I have a copy of Visual Studio 2002 Professional. What is the best way to get hold of the new VC++ 7.1 compiler? I could upgrade to VS 2003 Pro, but expensive. Could I buy VC++ 2003...
36
by: Tim | last post by:
Is there a way to upgrade from Visual C++ Net 2002 to Visual C++ Net 2003? The 2002 version does not provide a Windows Forms Designer. I can't find any upgrade package on Microsoft's website. ...
3
by: Ryan | last post by:
My project uses the /ORDER specifier to order functions as specified in file containing the decorated names of packaged functions (COMDATs). I am in the process of upgrading from VC6 to VC.NET 2003....
10
by: msnews.microsoft.com | last post by:
Hi, How do I add a reference in VC++.NET? In VB.NET and VC#.NET, there's an option in "Project" menu called "Add Reference". This will add a .NET DLL reference to the current project. After I...
3
by: Binary | last post by:
VC++ .NET 2003: Access violation with /O2 compiler switch; no AV with /O Hi I'm in the process of narrowing down a problem, and I have reduced the code involved to the following If someone could...
1
by: Matt S | last post by:
Does the liscense for the VC++.Net 2003 allow the user to purchase a downgrade to VC++.NET 2002? DO I need to buy a standard version of VC++.NET to downgrade? I need to get VC++ 2002, but I can't...
1
by: Johan Nilsson | last post by:
Hi, is there a browser toolkit available for VC.NET 2003 (VC7.1)? I found downloadable toolkits for virtually all other versions at microsoft.com, but none specifically marked as compatible with...
4
by: Hyo-Han Kim | last post by:
Hi.. someone built app. with VC++.NET .. But It cause error on Windows 98 SE .. No one can correct the error. So I would like to downgrade the app to VC++ 6.0 .. The application should...
7
by: Mihajlo Cvetanović | last post by:
Hi all, I've been trying to find some info on Visual C++ 2005 Standard on Microsoft's site, but wasn't able to find any. There's only VC++ 2005 Express Edition, and Visual Studio 2005 Standard,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.