View Full Version : StatusDlg
sside
06-22-2004, 07:02 AM
Hallo everybody
I was having some troubles with built-in StatusDlg and i thought to drop by and ask.
If i want to use the built-in StatusDlg in order to let a user know that some files are being copied, if at the end of copying i let show the cancel button on the StatusDlg with the purpose to terminate the process it doesn't work, it doesn't do anything although i use a few simple commands to close the StatusDlg with the cancel button. The code that i use looks something like this;
StatusDlg.Show(MB_ICONNONE, false);
-- do smth here --
StatusDlg.ShowCancelButton(true, "Cancel");
result = StatusDlg.IsCancelled();
if result == true then
StatusDlg.Hide();
end
Does anybody know what is wrong with this code?
Thanks in advance
Lorne
06-22-2004, 09:24 AM
What's in the "-- do smth here --" part?
sside
06-22-2004, 09:32 AM
Hello Lorne
The idea is to copy some files from one location to another and StatusDlg is handy. So one can realise that something is going on (files are being copied) and when the copying it's finished the by clicking the cancel button (Finish) wich shows up at StatusDlg you hide StatusDlg.
Thanks
TJ_Tigger
06-22-2004, 09:40 AM
I believe what you want to do is more something like this.
StatusDlg.ShowCancelButton(true, "Cancel");
StatusDlg.Show(MB_ICONNONE, false);
-- do smth here --
result = StatusDlg.IsCancelled();
if result == true then
StatusDlg.Hide();
end
You want to have the cancel function before the do something here that will actually give you something to cancel. Otherwise the code that checks to see if result == true happens before you can press the cancel button. Or as another thought, you could start a timer and put your if/then statement on the timer to check and see if the cancel button has been pressed.
Tigg
Desmond
06-22-2004, 09:50 AM
Hello,
The way I read your post, you want the status Dialog up when you are copying files WITHOUT any type of button on it. Then, when the copying is finished, you want to display a "Finish" button, similar to buttons at the very end of setups.
Assuming that's correct, let's go!
The reason your code is not working the way you want it to is due to the way in which "IsCancelled" works. At the moment that action is run, it checks to see if the button has been pressed. Since the user couldn't possibly press the button before the action is run, result will always == false. The action checks if the button is pressed, it doesn't wait for the button to be pressed.
There are a couple of ways to accomplish your goal.
The easiest in terms of implimentation is this:
StatusDlg.Show();
-- Do something here
StatusDlg.Hide();
Dialog.Message("Copy Complete", "Copy Complete, press 'OK' to continue");
If you are heart-set on having a finish button, you'll have to use the page's timer to continuously check if the cancel button was pressed.
Put this where your code is right now (where you want the copy to happen):
StatusDlg.Show(MB_ICONNONE, false);
-- do smth here --
StatusDlg.ShowCancelButton(true, "Cancel");
-- adjust the below value as needed
Page.StartTimer(100);
Then, put this code on the On Timer event:
result = StatusDlg.IsCancelled();
if result == true then
StatusDlg.Hide();
Page.StopTimer();
end
Hope that gets the ball rolling! Good luck.
sside
06-22-2004, 11:39 AM
Hallo everybody
I thank everybody's advise
This is one example;
-----------------------------------------------------------------------
select_folder = Dialog.FolderBrowse("Please select a folder:", "AutoPlay\\Docs");
if select_folder == "CANCEL" then
result = Dialog.Message("Notice", "Canceled by user", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
StatusDlg.Show(MB_ICONNONE, false);
File.Copy("AutoPlay\\Docs\\*.*", select_folder, true, true, false, true, nil);
get_error = Application.GetLastError();
StatusDlg.Hide();
if get_error == 0 then
result = Dialog.Message("Notice", "Copying successful", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Notice", "Copying failed", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
end
-----------------------------------------------------------------------
My point is that since i could attach a cancel button at StatusDlg i thought it was lot easier to program that cancel button to close the copy procedure, but at that time i didn't know how. That's why i asked. It seems meaningless to attach a cancel button at StatusDlg for 2 reasons;
1-during the copy procedure the StatusDlg expand itself. It adopts itself (the length) to the changing of the link in it (from: etc etc etc, to: etc etc etc) That means that one side of StatusDlg is in the middle of the screen the other side is way out in the right side of the screen. So there is no way somebody can click that button since it is all the time on the move (even worse out of the screen)
2-even if by some wonders i can click that cancel button it won't do any good since it can not be (easy) programmed.
So this is how i wondered if there was some way to
1-have this StatusDlg under control (the length)
2-program that cancel button
3-put my own text on StatusDlg
I know that there are some options to put your own title, message etc but to me didn't work out. Anyway...
thanks a lot
Desmond
06-22-2004, 11:45 AM
Hello,
You will definitely want to check out the callback function in the copy action.
This function is called every time (i believe) a new file is being copied. The help file has excellent documentation on this.
Then, you could just not output the path, or only the filename (using String.SplitPath), or whatever you want! the possibilities are endless.
This way, you could display a cancel button if you want . . . and put an IsCancelled action there, and an ifstatement that returns a value if cancel was pressed.
Take a peak, experiment. AutoPlay is definitely an extremely powerful tool with a bazillion options.
Disclaimer: The above 'bazillion' statement was intended to make desmond sound smarter than he is . . . it in no way reflects the actual number of features in AutoPlay Media Studio. :)
Lorne
06-22-2004, 11:57 AM
No need to quality that statement, Des. With the ability to call DLLs and plugin support, AutoPlay really does give you a bazillion options. :)
TJ_Tigger
06-22-2004, 12:06 PM
AutoPlay is definitely an extremely powerful tool with a bazillion options.
Disclaimer: The above 'bazillion' statement was intended to make desmond sound smarter than he is . . . it in no way reflects the actual number of features in AutoPlay Media Studio. :)
A bazillion, that's a lot huh? Reminds me of the movie Get Shorty.
Mr Escobar: You gave him the money.
Bo: I gave him a key to a locker that had the money in it.
Mr Escobar: Now why would you do that, put the money in a locker.
Bo: Because there were a zillion DEA guys hanging around the Terminal.
Mr Escobar: A zillion, that's a lot, huh?
Tigg
sside
06-22-2004, 12:07 PM
Hi there
No doubt. The possibilities are unlimited with ams5. Just wondering how somethings can be done with less.
The shortest way to connect two points is a straight line.
sside
06-22-2004, 12:10 PM
I thought he said gazillion... :D
Just kidding :yes
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.