# cannot convert parameter 2 from HRESULT

This topic is 4612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

You can view the source code here: www.kryolinth.com/all2_1.rtf That's a Rich Text Document. Open in wordpad. IMPORTANT: all recently written code is in green, which greatly narrows down where the problems can possibly arise from. line 88: error C2664: 'MessageBoxA' : cannot convert parameter 2 from 'HRESULT' to 'LPCSTR'. Convertion from integral type to pointer type requires reinterpret_cast, C-style cast, or function-style cast. line 190: warning C4305 'return' : truncation from 'HRESULT' to 'bool' line 219: warning C4305 'return' : truncation from 'HRESULT' to 'bool' The line 88 error is within the InitGeometry function. I'm trying to learn DirectX and have thoroughly studied the code to create a window, initialize the Direct3D object and device, and source in a background image to display on screen. This next step in the code was to attempt to load a .x mesh and display it. I'm actually surprised I don't have more errors than this. And remember, all code dealing with loading the .x file, interpreting the mesh data, etc is in GREEN. thanks for any help

##### Share on other sites
Quote:
 Original post by infernosnowYou can view the source code here:www.kryolinth.com/all2_1.rtfThat's a Rich Text Document. Open in wordpad.IMPORTANT: all recently written code is in green, which greatly narrows down where the problems can possibly arise from.line 88: error C2664: 'MessageBoxA' : cannot convert parameter 2 from 'HRESULT' to 'LPCSTR'. Convertion from integral type to pointer type requires reinterpret_cast, C-style cast, or function-style cast.line 190: warning C4305 'return' : truncation from 'HRESULT' to 'bool'line 219: warning C4305 'return' : truncation from 'HRESULT' to 'bool'The line 88 error is within the InitGeometry function.I'm trying to learn DirectX and have thoroughly studied the code to create a window, initialize the Direct3D object and device, and source in a background image to display on screen. This next step in the code was to attempt to load a .x mesh and display it. I'm actually surprised I don't have more errors than this. And remember, all code dealing with loading the .x file, interpreting the mesh data, etc is in GREEN.thanks for any help

HRESULT is typedef as a long, not a boolean. Most DirectX interface methods return this type and are used like this.

IDirect3DTexture9 pMyTexture = NULL ;HRESULT hr = 0 ;hr = D3DXCreateTexture( pMyDevice, pMyTexture ) ; // This is a real function but it's used incorrectly for simplicity.if( FAILED(hr) )  MessageBox( NULL, "Cannot create texture!", "Title Here", MB_OK | MB_ICONERROR ) ;pMyDevice->Release() ;

##### Share on other sites
Also, if you do want to use the HRESULT in a message box, you can use the DXGetErrorString9 function as shown here. Make sure you include dxerr9.h and link dxerr9.lib.

-Jeff

##### Share on other sites
gah... I've been trying to work with this for a while now and still can't get it. I just don't know DirectX well enough yet. This is really agravating me. I understand the basics of what's happening in the code and why, but I don't understand the specifics well enough.

Would any of you be so kind as to impliment your code directly into the rest of the code that I have and color it in red or some other color so I can study exactly what's going on? I tried to put it in myself, but I guess I just didn't do it right. I hate when I can't figure stuff out on my own.

##### Share on other sites
see, the code you gave me is different than what I have... that's the problem maybe.

IDirect3DTexture9 pMyTexture = NULL ;
HRESULT hr = 0 ;

hr = D3DXCreateTexture( pMyDevice, pMyTexture ) ;

but I don't use IDirect3DTexture9 to define pMyTexture

my code uses D3DXMATERIAL* d3dxMaterials then sets it = to (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer();

which might as well be Chinese to me. I don't understand all that yet.

So I feel like if I use IDirect3DTexture9 pMyTexture = NULL ; then it will mess something up because there must be a reason my code uses D3DXMATERIAL*

• 10
• 17
• 9
• 14
• 41
• ### Forum Statistics

• Total Topics
631067
• Total Posts
2997734
×