I need to be able to get the window handle of my Irrlicht app but there does not seem to be any method for doing this in Irrlicht.NET.
Is there any way to do this?
Thanks for any assistance.
How to get the handle of an Irrlicht window?
This will only work if you are running Irrlicht inside a .NET form which is not the case here. I am getting Irrlicht to create its own window rather than creating a .NET window and getting Irrlicht to run inside it so I need to be able to get the handle back from the window that Irrlicht has created.matiae wrote:hi, in .NET every control (and form) has the .Handle property that gets the IntPtr.. it's not a method
haa, I see.. I don't know if there is a better way to do it in .NET but you could use window api functions, e.g.
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using Irrlicht;
using Irrlicht.Core;
using System.Runtime.InteropServices;
namespace Project1
{
class Class1
{
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
public static void Main(string[] args)
{
IrrlichtDevice device = new IrrlichtDevice(
Irrlicht.Video.DriverType.DIRECT3D9, new Dimension2D(640, 480), 16, false, false, false);
device.WindowCaption = "Irrlict window!!";
IntPtr WindowHandle = FindWindow(null, "Irrlict window!!");
while(device.Run())
{
// loop
}
}
}
}