Game Development Community

Get HWND?

by Adam Beer · in Torque 3D Professional · 11/04/2010 (4:30 am) · 3 replies

How do I get the HWND of the Torque window? The way I am trying to get it doesn't seem to be working:

Win32Window* w = (Win32Window*) PlatformWindowManager::get()->getFirstWindow();
	Win32Window *win = dynamic_cast<Win32Window*>(w);
	result = win->getHWND() ;

When I am debugging, 'w' and 'win' are both NULL so something is wrong. Also, this code is getting called last in StandardMainLoop::init() so is there a chance that the window doesn't exist at that point causing it to fail and crash? Or am I going about this the wrong way?

#2
11/18/2010 (5:30 pm)
GuiCanvas* canvas = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
Win32Window *pWindow = canvas ? dynamic_cast<Win32Window*>(canvas->getPlatformWindow()) : NULL;
if(pWindow)
   result = pWindow->getHWND();

P.S. Don't forget to add needed includes, like so:
.. at the top of file
#include "gui/core/guiCanvas.h"
#3
11/30/2010 (11:18 pm)
Thank you very much Bank!