Recent

Author Topic: InputBox and other sub-forms don't close  (Read 5695 times)

Iede

  • Newbie
  • Posts: 3
InputBox and other sub-forms don't close
« on: May 16, 2011, 06:06:02 pm »
I have a program in which I'm using inputboxes. When the inputbox opens, I'm able to key in a value, but after clicking Ok or Cancel the inputbox doesn't close and the program doesn't react to anything anymore: it has to be killed from the task list. Part of the code is:

var rstr: String;
begin
  rstr:= InputBox('Simulation', 'Reference-car', IntToStr(ReferenceCar));
  try
    ReferenceCar := StrToInt(rstr);
    if (ReferenceCar < 1) or (ReferenceCar > nVehicles) then
      ReferenceCar := 1;
    MyIniFile.WriteInteger('Settings', 'ReferenceCar', ReferenceCar)
  except
    on E: EConvertError do
      ShowMessage(E.ClassName + CRLF + E.Message)
  end
end;


The same happens also for other forms which are opened inside the main form.

Any idea what's wrong?

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: InputBox and other sub-forms don't close
« Reply #1 on: May 16, 2011, 06:44:20 pm »
Part of the code is:

Part of the answer: it all works OK for me.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Iede

  • Newbie
  • Posts: 3
Re: InputBox and other sub-forms don't close
« Reply #2 on: May 16, 2011, 07:59:25 pm »
That's the "funny" thing, I have programs (most trivial ones) where the above works fine, and some (non-trivial) programs where it doesn't. Could it be a compiler setting and if so, how could I check this?

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: InputBox and other sub-forms don't close
« Reply #3 on: May 16, 2011, 09:33:22 pm »
What I meant to say was: there is nothing wrong with the isolated code fragment so that is not the problem (I hope, or else there might be a problem with Lazarus or FPC).
The problem most likely lies somewhere else.

My crystal ball came up with: are you using threads? Any (form) code in dll's? Other events like timers that interrupt the normal message flow?
etc.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Iede

  • Newbie
  • Posts: 3
Re: InputBox and other sub-forms don't close
« Reply #4 on: May 16, 2011, 11:11:15 pm »
No, nothing of these...

Oops  %) there was a timer running and not disabled while opening the inputbox. I disabled it before the inputbox and now it works ok. Thanks a lot!!!
« Last Edit: May 17, 2011, 08:45:18 pm by Iede »

 

TinyPortal © 2005-2018