Thread: Getting HWND from non-win32 API...

  1. #1
    Not stupid, just stupider yaya's Avatar
    Join Date
    May 2007
    Location
    Earthland
    Posts
    204

    Thumbs up Getting HWND from non-win32 API...

    I'd like to use an API that is much simpler than Win32 or MFC, but I want be able to get the HWND of a window so that I can put my Direct3D stuff in it. I've tried FLTK and Qt, they were both great, though I couldn't find a way to extract a HWND from a window. Does anyone know how to do this for any API (C++) that isn't Win32 or MFC?

    Thanks.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    There has to be a way since any library using windows inside Win32 must have an HWND.

    Here is one solution for GTK:
    http://osdir.com/ml/video.gimp.windo.../msg00018.html

    This looks promising for QTWidget:
    http://doc.qt.nokia.com/4.6/qwidget.html#winId

    Specifically:
    WId QWidget::winId () const
    Returns the window system identifier of the widget.

    Portable in principle, but if you use it you are probably about to do something non-portable. Be careful.

    If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle.

    On Mac OS X, the type returned depends on which framework Qt was linked against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt is using Cocoa, {WId} is a pointer to an NSView.

    This value may change at run-time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier.

    See also find().
    Last edited by VirtualAce; 12-21-2009 at 11:18 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. My first "real" windows app
    By JoshR in forum Windows Programming
    Replies: 2
    Last Post: 07-28-2005, 07:40 AM
  3. Win32 API or Win32 SDK?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-20-2005, 03:26 PM
  4. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM