Link to home
Start Free TrialLog in
Avatar of ST3VO
ST3VOFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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_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


ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ST3VO

ASKER

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

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

ASKER

That's exactly what I've done but neither Form2 shows up or Form1 comes back :o/
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?
Avatar of ST3VO

ASKER

Just got the on OnShow Event

SetForegroundWindow(Handle);
Avatar of ST3VO

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


end;
Avatar of ST3VO

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
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.
Avatar of ST3VO

ASKER

Hmmm...I wonder what the problem could be :(
Avatar of dinilud
Is your main form is MID Form
Avatar of ST3VO

ASKER

No it's not!