Hello good morning everyone, has any colleague managed to do this?
I already searched a lot on google and didn't find anything that worked, and maybe the more experienced colleagues have already done it, I think it's similar.
I would like to create a Showmodal form that is Local and doesn't block my entire system but to do that I need a way to pause the code and go back, several situations like "messagedlg" would be very useful for my system.
All my attempts have failed
In the code below if I run Form2 and after Form3 the code flow is retained on Form3 I wanted a way to be able to return the code flow on Form2 when I close it because in the current form I will always have to close the last open form to run code after Assigned
attached a small project for colleagues to take a look at
If you can help me I will be immensely grateful.
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2 := TForm2.Create(Nil);
Form2.Show;
while Assigned(Form2) do
Application.HandleMessage; // or Application.ProcessMessages Failed
Showmessage('End Form2');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form3 := TForm3.Create(Nil);
Form3.Show;
while Assigned(Form3) do
Application.HandleMessage; // or Application.ProcessMessages Failed
Showmessage('End Form3');
end;
How to pause a code and return later ?
How to pause a code and return later ?
- Attachments
-
- Exemplo 4 madExcept.zip
- (2.79 KiB) Not downloaded yet
Re: How to pause a code and return later ?
Hello,
TBH with you this is a very ugly thing to do and a lot can go wrong. If you're wanting to do something like return to code that needs to be executed then you might be able to get away with this using a 'label' and 'goto' statement. In theory it should work unless I didn't fully understand your post. You'd need to combine both button click events though into a single procedure to handle this.
e.g:
--Iconic
TBH with you this is a very ugly thing to do and a lot can go wrong. If you're wanting to do something like return to code that needs to be executed then you might be able to get away with this using a 'label' and 'goto' statement. In theory it should work unless I didn't fully understand your post. You'd need to combine both button click events though into a single procedure to handle this.
e.g:
Code: Select all
Procedure Blah();
label ReRun;
begin
ReRun:
DoSomething();
if not (condition) then
goto ReRun;
end;
Re: How to pause a code and return later ?
Yes I understand it's an ugly thingby iconic » Sat Jul 09, 2022 9:05 pm
Hello,
TBH with you this is a very ugly thing to do and a lot can go wrong. If you're wanting to do something like return to code that needs to be executed then you might be able to get away with this using a 'label' and 'goto' statement. In theory it should work unless I didn't fully understand your post. You'd need to combine both button click events though into a single procedure to handle this.
what I need is a way to create Showmodal Forms that doesn't block the whole system and for that the only idea I had.
Would the colleague have any ideas for me to be able to create a FormShow Modal that does not block the whole system?
I would like to pause the code and then return.
The code you gave me works but for that I will have to program all my ShowModal and MessageBox screens
I would like a code that is Global that works for the whole system, how can I adapt your code inside a Function ?
Re: How to pause a code and return later ?
Hello,
--Iconic
Yes, you're 100% correct about this as each instance would need to have code added. However, why not just create a thin wrapper around (e.g: ShowModal or MessageBox) and have the code in a label/goto handle this for you? Now all instances of those ShowModal/MessageBox calls act accordngly. That's really all you can do in this case TBH, I am sure Madshi would agree with me here.The code you gave me works but for that I will have to program all my ShowModal and MessageBox screens
--Iconic