 |
|
 |
There is one strange thing I encountered. I have small test project with simple loop and I simulate long work with Sleep(2000).
If I move the dialog window, it will freeze for about 2 seconds after I release the mouse button (doesn't respond to any input, animation is also frozen). This shouldn't happen, but it does, both in debug and release builds.
Any insights or clues are appreciated.
|
|
|
|
 |
|
 |
Hi,
Thanks for the article.
I have a problem under W7 I don't know if it is the same on its predecessors or not. After calling the StartProgressDialog, the dialog does not appear immediately when the function returns. It causes a problem, when I display a messagebox with a question right away. My message appears first (file overwrite warning), then the Progress dialog pops up and hides it.
If I add a Sleep(2000) after the StartProgressDialog it works okay.
Is there any workaround to wait until the progress dialog gets displayed? I wasn't able to hunt down the window handle either.
Thanks!
|
|
|
|
 |
|
 |
The trick is to query the IProgressDialog for IOleWindow interface. Then you get HWND with IOleWindow->GetWindow() and use ShowWindow() to show it immediately. Do it just after StartProgressDialog.
|
|
|
|
 |
|
 |
Thank you for the prompt answer. After calling the ShowWindow, the progress dialog still bring itself to the front after about two seconds. But now, using the window handle, I was able to wait until it gets visible. Problem solved! Cheers!
|
|
|
|
 |
|
 |
thanks for putting this out there.
|
|
|
|
 |
|
 |
How to get the handle of this progress dialog?
What to do when I want to HIDE the dialog for some time and again show this dialog after some interval.
Its urgent please..
|
|
|
|
 |
|
 |
After the hotfix KB928365 downloaded and installed by Automatically update, the error will occur. It will work well if you uninstall the hotfix or reinstall .NET Framework 2.0, could you please test it and solve this problem? thank you.
|
|
|
|
 |
|
 |
Main window loses the focus after the completion.
Is there any method to aviod this.
Please help :(
|
|
|
|
 |
|
 |
Same problem for me ... is there anyone who knows a solution?
Thanks
|
|
|
|
 |
|
 |
Is there any method to position the "progressDialog" in the center of the screen. Right now it is coming near the Upper left corner of the form.
I am not finding any way to position it in centerscreen
Thanks in advance.....
|
|
|
|
 |
|
 |
I'm developing a winform application in ASP.NET, in which I have to display a pop-up similar to the one you developed. In my case the directory to be copied might have several sub-directories and files. In your project where is the 'Time Remaining' coming from? Your help is appreciated. Thanks.
Winform
|
|
|
|
 |
|
 |
How should i call the handler in order to use it in a C# Web app ?
|
|
|
|
 |
|
 |
Hello,
I dont think this is possible as Asp.net does not use windows or Winforms.
This would basically assume that the .net framework or the asp.net framework has access to the underlying windows api that calls this function, which is most instances, would not be the case.
This is the same for MessageBox.Show().
Regards
|
|
|
|
 |
|
 |
Hello,
When invoked the code(objProgressDialog.Dispose) and the Progress Dialog disappeared after done, the main window also will lose focus automatically, how to fix the problem?
Thank you!
|
|
|
|
 |
|
 |
Hello,
I am having the same problem but I think it is solved now.
You can try Form.activate method after objProgressDialog.Dispose.
Good luck ..
Cheers....
|
|
|
|
 |
|
 |
Hello,
When invoked the code(objProgressDialog.Dispose) and the Progress Dialog disappeared after done, the main window also will lose focus automatically, how to fix the problem?
Thank you!
|
|
|
|
 |
|
 |
Hello,
When invoked the code(objProgressDialog.Dispose) and the Progress Dialog disappeared after done, the main window also will lose focus automatically, how to fix the problem?
Thank you!
|
|
|
|
 |
|
 |
... if you implement it directly in code instead of using the tlb which based on relfection seems to generate a lot of unnecasary classes and interfaces.
If you imply write the interface and class definitions yourself it pops up in roughly a second and doesn't rely on an external assembly or tlb file of which the providence is not explained.
|
|
|
|
 |
|
 |
I actually attempted doing exactly that and I've reasonably successded, tho I'm having *real* troubles marshaling bool in and out (HasUserCancelled() and in SetLine()).
I've tried marshalling as UnmanagedType.Bool and UnmanagedType.I4 and UnmanagedType.I1 without any success.
Anyone can suggest a fix?
[ComImport, Guid("F8383852-FCD3-11d1-A6B9-006097DF5BD4")]
public class ProgressDialog {
[ComImport]
[Guid("EBBC7C04-315E-11d2-B62F-006097DF5BD4")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IProgressDialog {
void StartProgressDialog(
IntPtr hwndParent,
[MarshalAs(UnmanagedType.IUnknown)]
object punkEnableModless,
uint dwFlags,
IntPtr pvResevered
);
void StopProgressDialog();
void SetTitle(
[MarshalAs(UnmanagedType.LPWStr)]
string pwzTitle
);
void SetAnimation(
IntPtr hInstAnimation,
ushort idAnimation
);
[return: MarshalAs(UnmanagedType.Bool)]
bool HasUserCancelled();
void SetProgress(
uint dwCompleted,
uint dwTotal
);
void SetProgress64(
ulong ullCompleted,
ulong ullTotal
);
void SetLine(
uint dwLineNum,
[MarshalAs(UnmanagedType.LPWStr)]
string pwzString,
[MarshalAs(UnmanagedType.Bool)]
bool fCompactPath,
IntPtr pvResevered
);
void SetCancelMsg(
[MarshalAs(UnmanagedType.LPWStr)]
string pwzCancelMsg,
object pvResevered
);
void Timer(
uint dwTimerAction,
object pvResevered
);
}
|
|
|
|
 |
|
 |
[PreserveSig]
[return: MarshalAs(UnmanagedType.Bool)]
bool HasUserCanceled();
The Com interface returns Hresults which .net auto translated to ComExceptions, you don't want it mangling the return type on that method because it doesn't actually return an hresult so you have to mark it with PreserveSigAttribute.
It took me hours to work out how to create the ProgressDialog class so i could acually get an object that implemented the interface, its childishly simple as it turns out but i was expecting so much complexity that i totally missed it.
Also it really doesn't like it if you ever try to operate on it from windows other than the one you pass the handle of into StartProgressDialog, if you do so you get InvalidCastException on every call so be careful because if the dialog is open and that error occurs there is no way to close the dialog cleanly.
|
|
|
|
 |
|
 |
heh, I've see [PreserveSig], but as you said it's meant for HRESULT returns and I actually never got to try it tho thought of it...
I'll give it a go when have time
I've got the idea about the implementation from MSDN[^] - you may find it useful :->
another 2 points of interest
1. I'm not sure if GC releases COM object or I need to take care of it myself
2. is loading shell32.dll the best possible solution for getting animation?
[UPDATE]
Your suggestion worked! Thaks a bunch! For HasUserCancelled() at least. Still can't get correct shortened path to work correctly but...
|
|
|
|
 |
|
 |
That page was useful, but only when i'd disassembled the interop assembly and read what was in there so i understood some of the more obscure stuff. For the shortened path just import the path compaction function from shlwapi, i'm already using it before my text gets to the dialog so i've not had that problem.
From my reading and understanding the .net object represents a rcw around the com object, .net handled the IUnknown/IDispatch interface so when you create the object it'll get addref-ed and then its collected the collector will cause it to be removeref-ed. This all happens inside the runtime so only the docs will tell you accurately and i find them non too clear in places.
I've not go to the animantions yet though i'm looking at LoadLibrary and LoadLibraryEx to do so, i'm not sure what flags are needed but i think bypassing DllMain could be advantageous. Since shell32 might already be loaded the performance hit could be very small using loadlibary. I'l need to do some testing to be sure
|
|
|
|
 |
|
 |
heh same here =)
looks like we jogging along on neighbouring lanes
|
|
|
|
 |
|
 |
Using LoadLibraryEx with the no dll main and dataonly flags set works for the standard shell32.dll which implies the that implementation of ProgressDialog in the system uses only LoadResource, helpful to know.
|
|
|
|
 |
|
 |
...as in:
IntPtr phndl = LoadLibraryEx(
"shell32.dll\0",
null,
DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE
); ?
|
|
|
|
 |