File Exchange

image thumbnail

getHWnd - retrieve the underlying Windows handle for Matlab figure(s)

version 1.1 (2.71 KB) by

Enable C++ GUI integration by retrieving the HWnd handle of matlab figure(s)

4 Downloads

Updated

View License

Syntax:
hWnd = gethwnd(hFig)

Description:
HWnd = GETHWND retrieves the current figure (gcf)'s underlying Windows handle, thus enabling integration of Matlab GUI in C/C++/C# programs.

HWnd = GETHWND(hFig) retrieves a specific figure's underlying Windows handle. hFig is a Matlab handle, or a list of handles (not necessarily figure handle(s) - the handles' containing figure is used).

Limitations:
Windows-only (duh!); Java must be enabled

Warning:
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

Comments and Ratings (2)

Alexander H

Pablo Tacconi

Yair,

Is it possible to interact with a Window Handle (HWnd) directly from Matlab.
  get(HWnd) does not return anything, as Matlab is not recognizing HWnd as an object.

This would be very useful in several cases like when trying to control an external application using the COM interfaces. A good case is controlling the Google Earth Window (see http://www.mathworks.com/matlabcentral/fileexchange/20031-google-earth-com-api-example)

Paul

Updates

1.1

Fix for R2011b

MATLAB Release
MATLAB 7.4 (R2007a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video