URGENT 500 Points - Form Hide and Show Problems

ST3VO
ST3VO used Ask the Experts™
on
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_NOCLOSEPROCESS;
  end;
  ShellExecuteEx(@SEI);
  WaitForSingleObject(SEI.hProcess, INFINITE);
 
  CloseHandle(SEI.hProcess); //Only one handle to close
  //ShowMessage('done');

  //ShellExecute(Form1.Handle, nil, pchar('externalApp.exe'), nil, pchar (ExtractFilePath(Application.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


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
This works ok for me.

Procedure ExecuteAndWait;
var
  SEI:TShellExecuteInfo;
begin
  FillChar(SEI,SizeOf(SEI),0);
  with SEI do begin
    cbSize:=SizeOf(SEI);
    lpVerb:='open';
    lpFile:= 'notepad.exe'; //const here

    nShow:=SW_SHOW;
    fMask:=SEE_MASK_NOCLOSEPROCESS;
  end;
  ShellExecuteEx(@SEI);
  WaitForSingleObject(SEI.hProcess, INFINITE);

  CloseHandle(SEI.hProcess); //Only one handle to close
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
  Form2.FormStyle := fsStayOnTop;     // if You like this
  Form1.Hide;
  ExecuteAndWait;
  Form1.Show;
  Form2.Close;
end;

Author

Commented:
Hmmm....Form1 is not reappearing...any ideas why?

Commented:
I have no idea.
Try exactly what i have pasted. (Form1 is the main form)
Then replace notepad with Your external app.
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Author

Commented:
That's exactly what I've done but neither Form2 shows up or Form1 comes back :o/

Commented:
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?

Author

Commented:
Just got the on OnShow Event

SetForegroundWindow(Handle);

Author

Commented:
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_NOCLOSEPROCESS;
  end;
  ShellExecuteEx(@SEI);
  WaitForSingleObject(SEI.hProcess, INFINITE);
 
  CloseHandle(SEI.hProcess); //Only one handle to close
 
  Form1.Show; // NEW -


end;

Author

Commented:
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

Commented:
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.

Author

Commented:
Hmmm...I wonder what the problem could be :(
Top Expert 2007

Commented:
Is your main form is MID Form

Author

Commented:
No it's not!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial