Ruby and CoCreateInstance

I am writing plugins for Google SketchUp using their Ruby API. One of
the common problems we (SketchUp scripters) have is that when a script
is performing intensive operations it locks up the SketchUp UI and there
is no way to see the progress of the current process.

What I would like to do is call the new Taskbar API in Windows7 in a
hope that it will allow for a reactive progress indication.

I found this MSDN article:
http://msdn.microsoft.com/en-us/magazine/dd942846.aspx

The simplest example appear to be:

ITaskbarList3* ptl;
VERIFY(CoCreateInstance(
CLSID_TaskbarList, NULL, CLSCTX_ALL,
IID_ITaskbarList3, (void**)&ptl));

HWND hmainwnd;//Application main window
ITaskbarList3* ptl;//Created earlier

DWORD WINAPI DoWork(LPVOID) {
ptl->SetProgressState(hmainwnd, TBPF_NORMAL);
for (int i = 0; i < WorkToDo; ++i) {
DoSomePartOfTheWork(i);
ptl->SetProgressValue(hmainwnd, i, WorkToDo);
}
ptl->SetProgressState(hmainwnd, TBPF_PAUSED);
return 0;
}

I have briefly toyed with some simple Win32API calls from Ruby - but
this one I am unable to translate.

I am able to get the window handle of the SketchUp window, but how do I
initiate these taskbar progressbar calls?

(SketchUp uses Ruby 1.8)

On Oct 3, 2010, at 13:15 , Thomas T. wrote:

What I would like to do is call the new Taskbar API in Windows7 in a
hope that it will allow for a reactive progress indication.

Bad idea unless your plugin is supposed to run on only windoze (which
would make us sad)… What you should do is see if google sketchup API
has their own progress API. If not, you should petition them for it.

Ryan D. wrote:

On Oct 3, 2010, at 13:15 , Thomas T. wrote:

What I would like to do is call the new Taskbar API in Windows7 in a
hope that it will allow for a reactive progress indication.

Bad idea unless your plugin is supposed to run on only windoze (which
would make us sad)… What you should do is see if google sketchup API
has their own progress API. If not, you should petition them for it.

It hasn’t. And we have petitioned this for years - literally.
I know it’ll only be available for limited amount of users, but I’d like
to try it out anyway. I don’t have the know-how to create a Win+OSX
compatible custom progressbar implementation.
At least I could offer an enhancement for some users.

From what I understand the CoCreateInstance is connecting to a COM
object - which one in Ruby can do with Win32OLE.

WIN32OLE.new(CLSID_TaskbarList3)

However, I get error message that the No such interface supported.
When I look at the examples for a progressbar it appear that they are
creating a Taskbar object with an ITaskbarList3 interface - but when I
look at the Ruby source code the object it creates is hardcoded to
IDispatch.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs