ghiboz's picture

[GameWindow] Retrieve window handle

Project:The Open Toolkit library
Version:0.9.x-dev
Component:Code
Category:support request
Priority:critical
Assigned:Unassigned
Status:closed
Description

Hi! how can I retrieve the window handle of my game window??
thanks


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

The window handle is not exposed, as it is an implementation detail. Even if it were part of the public API, you'd still need the display connection, device context or a number of other platform-specific parameters, which would still not be exposed.

OpenTK itself relies on IWindowInfo instances that contain all the necessary parameters. GameWindow provides a WindowInfo property that can be used with other OpenTK APIs (e.g. the GraphicsContext constructor).

Of course, this doesn't help if you need the handle for a non-OpenTK API. To that end, I must ask: what do you need the handle for?

ghiboz's picture

#2

Status:open» closed

thanks, I tried to send a message to change the icon (my other post), but I think that the solution is to set the icon in a clean way and not with the sendmessage

thanks

ghiboz's picture

#3

I found how to retrieve the window handle...
if someone needs this:

IWindowInfo ii = ((OpenTK.NativeWindow)this).WindowInfo;
object inf = ((OpenTK.NativeWindow)this).WindowInfo;
PropertyInfo pi = (inf.GetType()).GetProperty("WindowHandle");
IntPtr hnd = ((IntPtr)pi.GetValue(ii, null));