Code covered by the BSD License  

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

5.0

5.0 | 1 rating Rate this file 7 Downloads (last 30 days) File Size: 2.71 KB File ID: #16743

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

by Yair Altman

 

07 Oct 2007 (Updated 13 Oct 2011)

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

| Watch this File

File Information
Description

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)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
GetJFrame - Retrieves a figure's underlying Java frame

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Windows-only (duh!); Java should be enabled
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
13 Apr 2011 Paul Andrews

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

Please login to add a comment or rating.
Updates
13 Oct 2011

Fix for R2011b

Tag Activity for this File
Tag Applied By Date/Time
gui tools Yair Altman 22 Oct 2008 09:30:27
example Yair Altman 22 Oct 2008 09:30:27
java Yair Altman 22 Oct 2008 09:30:27
window Yair Altman 22 Oct 2008 09:30:28
hwnd Yair Altman 22 Oct 2008 09:30:28
example laurent 28 Dec 2008 14:19:44
window a 26 Oct 2009 14:08:55

Contact us at files@mathworks.com