![Avatar of ST3VO](https://filedb.experts-exchange.com/files/public/2013/11/18/aa647e42-1104-4856-b843-e6e730bd2cef.png)
URGENT 500 Points - Form Hide and Show Problems
I am having a problem with hidding and showing the main form.
This is want i'm trying to do:
Try
Form1.hide;
Form2.Show; //This form displays a message saying "PLEASE WAIT LOADING"
ExecuteAndWait; //Executes and external application
Finally
Form2.close; //Close the Please wait form
Form1.Show; //Restore the main form
etc...
PROBLEM: The Main form is hiding and the Please Wait form is not coming up and also Form1 is not Showing after calling Form1.Show
Here is the execute and wait procedure just in case it helps too... (This works fine)
Procedure ExecuteAndWait;
var
SEI:TShellExecuteInfo;
begin
FillChar(SEI,SizeOf(SEI),0 );
with SEI do begin
cbSize:=SizeOf(SEI);
lpVerb:='open';
lpFile:=Lnk1; //const here
nShow:=SW_SHOW;
fMask:=SEE_MASK_NOCLOSEPRO CESS;
end;
ShellExecuteEx(@SEI);
WaitForSingleObject(SEI.hP rocess, INFINITE);
CloseHandle(SEI.hProcess); //Only one handle to close
//ShowMessage('done');
//ShellExecute(Form1.Handl e, nil, pchar('externalApp.exe'), nil, pchar (ExtractFilePath(Applicati on.ExeName )), SW_SHOWNORMAL);
end;
Hope you see what I'm trying to do here....
It's urgent so I'm giving 500 points for the solution
Thanks
This is want i'm trying to do:
Try
Form1.hide;
Form2.Show; //This form displays a message saying "PLEASE WAIT LOADING"
ExecuteAndWait; //Executes and external application
Finally
Form2.close; //Close the Please wait form
Form1.Show; //Restore the main form
etc...
PROBLEM: The Main form is hiding and the Please Wait form is not coming up and also Form1 is not Showing after calling Form1.Show
Here is the execute and wait procedure just in case it helps too... (This works fine)
Procedure ExecuteAndWait;
var
SEI:TShellExecuteInfo;
begin
FillChar(SEI,SizeOf(SEI),0
with SEI do begin
cbSize:=SizeOf(SEI);
lpVerb:='open';
lpFile:=Lnk1; //const here
nShow:=SW_SHOW;
fMask:=SEE_MASK_NOCLOSEPRO
end;
ShellExecuteEx(@SEI);
WaitForSingleObject(SEI.hP
CloseHandle(SEI.hProcess);
//ShowMessage('done');
//ShellExecute(Form1.Handl
end;
Hope you see what I'm trying to do here....
It's urgent so I'm giving 500 points for the solution
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
![Avatar of mokule](https://filedb.experts-exchange.com/files/public/2013/11/18/f99241b6-e1e3-4f6d-9457-f7ac185f4e32.png)
I have no idea.
Try exactly what i have pasted. (Form1 is the main form)
Then replace notepad with Your external app.
Try exactly what i have pasted. (Form1 is the main form)
Then replace notepad with Your external app.
![Avatar of ST3VO](https://filedb.experts-exchange.com/files/public/2013/11/18/aa647e42-1104-4856-b843-e6e730bd2cef.png)
ASKER
That's exactly what I've done but neither Form2 shows up or Form1 comes back :o/
![Avatar of mokule](https://filedb.experts-exchange.com/files/public/2013/11/18/f99241b6-e1e3-4f6d-9457-f7ac185f4e32.png)
Have You created a new app from scratch now? With two new forms?
Or If You used Your old forms maybe You've got some code in events like OnShow or OnHide?
Or If You used Your old forms maybe You've got some code in events like OnShow or OnHide?
![Avatar of ST3VO](https://filedb.experts-exchange.com/files/public/2013/11/18/aa647e42-1104-4856-b843-e6e730bd2cef.png)
ASKER
Just got the on OnShow Event
SetForegroundWindow(Handle );
SetForegroundWindow(Handle
![Avatar of ST3VO](https://filedb.experts-exchange.com/files/public/2013/11/18/aa647e42-1104-4856-b843-e6e730bd2cef.png)
ASKER
Why isn't the form showing here...
Procedure ExecuteAndWait;
var
SEI:TShellExecuteInfo;
begin
FillChar(SEI,SizeOf(SEI),0 );
with SEI do begin
cbSize:=SizeOf(SEI);
lpVerb:='open';
lpFile:=Lnk1; //constant
nShow:=SW_SHOW;
fMask:=SEE_MASK_NOCLOSEPRO CESS;
end;
ShellExecuteEx(@SEI);
WaitForSingleObject(SEI.hP rocess, INFINITE);
CloseHandle(SEI.hProcess); //Only one handle to close
Form1.Show; // NEW -
end;
Procedure ExecuteAndWait;
var
SEI:TShellExecuteInfo;
begin
FillChar(SEI,SizeOf(SEI),0
with SEI do begin
cbSize:=SizeOf(SEI);
lpVerb:='open';
lpFile:=Lnk1; //constant
nShow:=SW_SHOW;
fMask:=SEE_MASK_NOCLOSEPRO
end;
ShellExecuteEx(@SEI);
WaitForSingleObject(SEI.hP
CloseHandle(SEI.hProcess);
Form1.Show; // NEW -
end;
![Avatar of ST3VO](https://filedb.experts-exchange.com/files/public/2013/11/18/aa647e42-1104-4856-b843-e6e730bd2cef.png)
ASKER
I'm also trying the following...not working properly either:
begin
try
sngWalk:=-40;
CanRender:=False;
Form2.Showmodal;
Form2.FormStyle := fsStayOnTop; // if You like this
Form1.Hide;
ExecuteAndWait;
Finally
sngWalk:=sngWalk-3;
Form2.Close;
end
end
begin
try
sngWalk:=-40;
CanRender:=False;
Form2.Showmodal;
Form2.FormStyle := fsStayOnTop; // if You like this
Form1.Hide;
ExecuteAndWait;
Finally
sngWalk:=sngWalk-3;
Form2.Close;
end
end
![Avatar of mokule](https://filedb.experts-exchange.com/files/public/2013/11/18/f99241b6-e1e3-4f6d-9457-f7ac185f4e32.png)
It shows for me here with no problem.
You must have set some form's properties (or events) to not default values, which i don't know, so it's hardly to say.
You must have set some form's properties (or events) to not default values, which i don't know, so it's hardly to say.
![Avatar of ST3VO](https://filedb.experts-exchange.com/files/public/2013/11/18/aa647e42-1104-4856-b843-e6e730bd2cef.png)
ASKER
Hmmm...I wonder what the problem could be :(
![Avatar of dinilud](https://filedb.experts-exchange.com/files/public/2013/11/18/d2969551-af0c-47a6-856a-2ecf4722d2c2.png)
Is your main form is MID Form
![Avatar of ST3VO](https://filedb.experts-exchange.com/files/public/2013/11/18/aa647e42-1104-4856-b843-e6e730bd2cef.png)
ASKER
No it's not!
ASKER