Export (0) Print
Expand All

xlGetHwnd

Last modified: July 01, 2011

Applies to: Excel 2013 | Office 2013 | Visual Studio

Returns the window handle of the top-level Microsoft Excel window.


Excel4(xlGetHwnd, LPXLOPER pxRes, 0); /* returns low part only */
Excel12(xlGetHwnd, LPXLOPER12 pxRes, 0); /* returns full handle */

This function has no arguments.

Contains the window handle (xltypeInt) in the val.w field.

This function is useful for writing Windows API code.

When you call this function using Excel4 or Excel4v, the returned XLOPER integer variable is a signed 16-bit short int. This is only capable of containing the low 16 bits of the 32-bit Windows handle. To find the high part, your code must iterate through all open windows looking for a match with the low part. Starting in Excel 2007, the integer variable of the XLOPER12 is a signed 32-bit int and therefore contains the entire handle, removing the need to iterate all open windows.

Example

See the code for the fShowDialog function in SAMPLES\GENERIC\GENERIC.C.

Show:
© 2014 Microsoft