Share via


xlGetHwnd

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

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

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

Parameters

This function has no arguments.

Property Value/Return Value

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

Remarks

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. In Microsoft Office 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.

See Also

Reference

xlGetInst

Concepts

C API Functions That Can Be Called Only from a DLL or XLL