 |
|
|
 |
|
 |
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..
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
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.....
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
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!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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.... 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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!
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
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!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
... 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.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
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 {
public enum Flags : uint { PROGDLG_NORMAL = 0x00000000, PROGDLG_MODAL = 0x00000001, PROGDLG_AUTOTIME = 0x00000002, PROGDLG_NOTIME = 0x00000004, PROGDLG_NOMINIMIZE = 0x00000008, PROGDLG_NOPROGRESSBAR = 0x00000010 }
public const uint PDTIMER_RESET = 0x00000001;
}
[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 );
}
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
[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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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... 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
...as in:
IntPtr phndl = LoadLibraryEx( "shell32.dll\0", null, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE ); ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Similar, though i'm a little more obcessive about translating api calls.
The enum:
[Flags] public enum LoadLibraryExFlags : uint { DontResolveDllReferences = 0x00000001, LoadLibraryAsDatafile = 0x00000002, LoadWithAlteredSearchPath = 0x00000008, LoadIgnoreCodeAuthzLevel = 0x00000010, }
The declaration:
[DllImport("kernel32",CharSet=CharSet.Auto,SetLastError=true)] public static extern IntPtr LoadLibraryEx( [In,MarshalAs(UnmanagedType.LPTStr)] string lpFileName, [In] IntPtr hFile, [In] LoadLibraryExFlags dwFlags );
The call:
this.hinstance = Kernel32.LoadLibraryEx(path,IntPtr.Zero,LoadLibraryExFlags.LoadLibraryAsDatafile|LoadLibraryExFlags.DontResolveDllReferences);
I also wrapped the filename and handle parameters in a Library class which will return the same handle for the same path if it already holds that handle and ensures that the handle is released properly using IDisposable. Its a bit long to post here and simple enough to replicate.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I did imply import of winapi's ...and of course 2nd arg is IntPtr.Zero not null.
reckon its time for you and me to post an "IProgressDialog .NET" article here?     
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |