Does Form.hide allow code to continue "beyond" a Form.Show Modal in vb6? - vb6

I'm doing a Form.Show Modal to force code execution until the user closes the shown form.
This form gets shown over again, so I'm thinking I'll just HIDE it. This seems to work OK, but wanted to confirm.
So:
frmMessage.Show MODAL
user clicks OK and frmMessage.Hide
code continues

You can either close or hide the modal form to allow the calling code to continue executing. At some point before your application closes you should make sure you unload any hidden forms though. I've had issues in my application with the application not always shutting down correctly when forms are still loaded and hidden. Might just depend on what resources your hidden forms are using.

Related

How to refresh page after dialog has completed?

I'm running a dialog (the workflow-ish one, not a custom, modal window) on Customer and during the process, an instance of a related entity Project is created. All the related instances of Project are displayed in a subgrid on the Contact form.
The problem is that the most recently added instance of Project isn't view until a refresh of the page which confuses the users. How can I force the form to refresh when a dialog has run?
I've googled the issue but the only resolution I've found are to a modal dialog frames à la JavaScript. The abundance of these drowns any relevant hits, as far I can see (if there are any, that is).
I think you'll find refreshing the page after a dialog closes in CRM Online impossible in the way you describe. As such my only recommendations are to flag up to the user before the dialog closes that they will need to refresh the page or to do something custom via a ribbon button.

My application disappears from the task bar as soon as I move away from the main form

Below is my code for the clicking of a button on the main form.
procedure TfrmLoginSelect.btnStudentLoginClick(Sender: TObject);
var
FilePAthFile:TextFile;
begin
assignFile(filepathfile,FilePathLocation);
reset(filepathfile);
readln(filepathfile,FilePath);
closeFile(filepathfile);
frmLoginSelect.visible:=False;
frmStudentLogin.visible:=True;
end;
Whenever this is clicked, however, the Delphi application is removed from the task bar. What am I doing wrong and how do I prevent this?
The problem is here:
frmLoginSelect.Visible := False;
The frmLoginSelect form is the main form. That is defined to be the first form created by a call to Application.CreateForm. The main form is the form associated with the taskbar button. Taskbar buttons only show when their associated window is visible. By hiding the main form you are also hiding the taskbar button.
It's difficult to give advice on how to resolve this. We cannot see enough of your program to say for sure what the right solution is. It's likely that you don't want frmLoginSelect to be the main form. But I cannot tell which form should be the main form.
It looks like you have a series of login forms that have to be navigated before the real main form can be used. I would handle that by showing the main form at startup, but then show the login forms as modal dialogs. Only if the user succeeds in navigating through the login forms does the main form become usable. Of course, I'm speculating wildly on what your application is really doing.
My broad advice in this area is to call Application.CreateForm once and once only during the lifetime of your program. For all other form creation call the form's constructor. Remove global form variables. All this goes against what the IDE wants you to do. But the IDE was designed when Borland were luring VB devs to Delphi. Don't let that drive your code architecture.

Ordering issue in modal window

I have a problem with a component that loads in to a modal window. I am using the Alpha User Points system and it has a component that gives you a full list of yous site's users. It also gives you the ability to order by username, by points etc. If I use it outside of modal window it works fine. If I use it in to modal window, ordering don't work!!! When I put my mouse over table's headers, outside of modal window gives this...javascript:tableOrdering('aup.referreid','asc','');In to modal window I see this...javascript:tableOrdering('aup.referreid','asc','');?ml=1 Using Firebug, I remove this ?ml=1 and it works into modal also!!! So the question is, why in to modal window gives this ?ml=1, what is this? And how will I remove it?
Well here is the answer... I use the Modalizer extension of nonumber.nl. I was loading my component through modalizer's modal box, this is why I had this issue. So, if anyone use Modalizer to popup components and have the same problem with me, just go to modalizer's Plugin Manager, find the option Convert Links inside Window and disable it!!! But, after this, if you want to add link in to modal window and you don't want to show-up the whole front page but only the component or what ever this is, you have to add at the end of the link this &ml=1.

Loading inline content from an iframe

First of all, I had all my buttons which opened the Colorbox using the "ajax" class. That class however caused me many problems:
1-When I open one window, it will appear, when I close it and re-click the same button, it will be loaded twice (so I need to click twice to close)
Is there a fix for this?
What I have done for the moment:
Use iframes; my only problem now is I cant load the other colorboxes that are linked in that iframe. I am using the inline class.
Let me re-phrase that: I click on button "generate" it opens first colorbox with the iframe class. Inside that iframe I have a "generate_2" button which has inline content. Once I click that second button nothing happens. This used to work when I had the first button set to ajax.
What can I do?
thanks!
I had the same problem before. Since JavaScript cannot affect iframes, you must add the JavaScript code inside a script tag in the iframe page itself.
when I close it and re-click the same button, it will be loaded twice (so I need to click twice to close) Is there a fix for this?
I'd wager you are using ajax to open a complete HTML document, aren't you? You shouldn't be doing that. It's not valid HTML to nest one HTML document inside another, and you are causing the scripts from both to be applied to the original document. Each time you load that content, those scripts are being loaded and executed all over again.

Firefox back button vs iframes

In Firefox if the window.location of an iframe is changed, this gets populated to the history of the top level window.
If the user now clicks the browser back button, the contents of the iframe will change rather than the browser going back to the previous HTML page.
This is totally wrong for some architectures.
Is there any way with JavaScript to prevent Firefox (3.x) from doing this?
(Please stick to just this question, not why/when/how iframes versus other techniques should be used.)
Use .location.replace
I have the same issue and was researching possible ways around it when I read this. I don't know if you solved the problem, but I think I'm going to use the unload event in the IFrame'd window to notify the parent window when it's unloaded.
If the iframe is closed by a 'valid' method, a variable is set at the parent to say the iframe is expected to unload
If the parent reloads / changes the src of the iframe a variable is set to say the unload is expected
If an unexpected unload happens in the iframe I assume it was the back button and update the parent page accordingly (e.g. jump another step back in the parent's history, or do something else).
The only ugly case here is if the parent page is unloaded and the iframe also throws unload - depending on how quickly the parent page changes you might get a race condition where the parent's iframe unload handler is or isn't fired.

Resources