For my C plugin, I want to display a progress bar while it exports. To do that, I need to get the HWND of the main sketchup window. Is there a best way to do that?
The APIs have never had a method / function to get SketchUp’s application window (despite requests.)
So we’ve had to make Windows system calls using various Ruby libraries (currently Fiddle.)
But on the C side you can load a system DLL (User32.DLL) and make direct system calls.
One way might be …
- Get the current SketchUp process ID. (Ruby’s
Process::pidmodule method will return it.)
- Enumerate the toplevel windows.
- Check each Window’s process ID against what you know is SketchUp’s process ID.
- When found keep the handle and return falsely from your EnumWindowsProc.
You might also filter by windows containing “SketchUp” in the caption, but users can have more than 1 instance of SketchUp running.
Others have used the handle of what they know is a child window (perhaps they created it as an empty HtmlDialog offscreen with a unique caption,) used
FindWindow using the unique name, and then
GetAncestorWindow function looking for the root owner.