Jump to content

  • Log In with Google      Sign In   
  • Create Account


Trouble when attaching Handle to Managed DLL HWND.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 SIC Games   Members   -  Reputation: 614

Like
0Likes
Like

Posted 18 July 2012 - 08:51 PM

I took Kunos advice and started to create a Managed DLL file to put in C#. This is just a level editor, so seemed a better ideal. I did some research and a IntPtr is Handle for a windows form control. So, I'm trying to put the DirectX inside a Panel control. I tested out a test out DLL of just returning a string in the Managed DLL and it worked well in C#.

On additional notes, I tried to have it the OutputWindow as a IntPtr in C++ but insisted it has to be a HWND.

It may just be simple and I've over looked something.

Here's the Managed DLL compiled as Old Syntax CLI.

HWND InitD3D(HWND h)
{
_h = h;
    // create a struct to hold information about the swap chain
    DXGI_SWAP_CHAIN_DESC scd;
    // clear out the struct for use
    ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));
    // fill the swap chain description struct
    scd.BufferCount = 1;								    // one back buffer
    scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;	 // use 32-bit color
    scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;	  // how swap chain is to be used
    scd.OutputWindow = _h;							    // the window to be used
    scd.SampleDesc.Count = 1;							   // how many multisamples
    scd.SampleDesc.Quality = 0;							 // multisample quality level
    scd.Windowed = TRUE;								    // windowed/full-screen mode

inside the private function I have the HWND _h;

I was thinking, well okay maybe it needs to return the handle. So perhaps, it needs to set it which I thought it was doing it.

Inside the C# Form1_Load I have this snipplet.

SICGames.Engine SE = new SICGames.Engine();
		    IntPtr _DXView = panel1.Handle;
		    SE.InitD3D(_DXView);

I know that the Overloaded Method Match is because the arguments don't match. If there is a work around or possible a small tiny mistake I'm doign that can pointed out that would be awesome. A IntPtr should be fine with HWND, right? Thanks everyone!

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


Sponsor:

#2 SIC Games   Members   -  Reputation: 614

Like
0Likes
Like

Posted 18 July 2012 - 10:00 PM

With more tackling it - I finally got it! I'll have a preview of what the editor looks like soon.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS