Using the Windows7 Taskbar Progressbar?
-
I'm wondering - seeing how the windows UI appear to be much more responsive even though the application isn't in Windows7 - could we call the new taskbar API to have a progressbar that will actually work while SU's own UI is dead?
http://msdn.microsoft.com/en-us/magazine/dd942846.aspx
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; }
From what I understand that's the API calls needed. Can anyone with some better C++ understanding than mine port this into Ruby maing Win32 calls?
Another link - more code:
http://windowsteamblog.com/blogs/developers/archive/2009/07/28/windows-7-taskbar-dynamic-overlay-icons-and-progress-bars.aspx -
I think something like this should work:
def self.test_progress( max = 10000 ) @taskbar ||= WIN32OLE.new(CLSID_TaskbarList3) # http://rubyonwindows.blogspot.com/2007/04/ruby-win32ole-inspecting-objects.html p @taskbar.ole_methods.collect!{ |e| e.to_s }.sort hmainwnd = self.su_window_handle @taskbar.SetProgressState( hmainwnd, TBPF_NORMAL ) (0...max).each { |i| @taskbar.SetProgressValue( hmainwnd, i, max ) } @taskbar.SetProgressState( hmainwnd, TBPF_PAUSED ) end
However, I'm having problems getting the CLSID for the OLE object...
Searching I find some GUIDs here:
http://msdn.microsoft.com/en-us/library/dd378460%28VS.85%29.aspx
There's a reference toEA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF
in the comment on that page. But that gives me an error:WIN32OLE.new('{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}') Error; #<WIN32OLERuntimeError; (eval);51;in `initialize'; failed to create WIN32OLE object from `{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}' HRESULT error code;0x80040154 Class not registered>
Then, here I find another snippet:
http://www.autohotkey.com/forum/topic50817.html
Referencing{56FDF344-FD6D-11d0-958A-006097C9A090}
Which gives me a different error:WIN32OLE.new('{56FDF344-FD6D-11d0-958A-006097C9A090}') Error; #<WIN32OLERuntimeError; (eval);51;in `initialize'; failed to create WIN32OLE object from `{56FDF344-FD6D-11d0-958A-006097C9A090}' HRESULT error code;0x80004002 No such interface supported>
The comment says:
COM_Init() ; Create a TaskbarList object with ITaskbarList3 interface; if DllCall("ole32\CoCreateInstance", "uint", COM_GUID4String(CLSID,"{56FDF344-FD6D-11d0-958A-006097C9A090}"), "uint", 0, "uint", 21, "uint", COM_GUID4String(IID,"{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}"), "uint*", tbl) != 0
It uses both the GUIDs I had earlier. But I can't work out their meanings.
I wonder ifTaskbarList3
requires the object to inherit fromTaskbarList
(the first version).
I'm very confused... -
hmm....
here as well:
http://old.nabble.com/Windows-7-taskbar-api-td25595307.html=cc.CreateObject("{56FDF344-FD6D-11d0-958A-006097C9A090}",interface=ITaskbarList3)
Seems that the objects need to be implemented with some Interface... But how do you do that win Ruby Win32OLE?
-
I know nothing about Win7 and its progress bar and Win32, but I have done one using WxSU and I export model while having the progress bar alive. The only thin is to give it an update from time to time to keep it 'active'. WxSU gives also an option of Cancel button.
It has this advantage over your solution that it works on Mac & lower Win version as well. Disadvantageous is installation\addition of WxSU library.
Advertisement