Ruby and CoCreateInstance

  • Thread starter Thomas Thomassen
  • Start date
T

Thomas Thomassen

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)
 
R

Ryan Davis

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.
 
T

Thomas Thomassen

Ryan said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top