Recent

Author Topic: Popup window crashing after new tab added to form  (Read 4077 times)

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Popup window crashing after new tab added to form
« on: September 01, 2010, 06:21:54 pm »
I'm using a showmodal option to pop up a form to use as a default settings entry screen.  Everything was working fine until I decided to add another tabsheet to the mix, now when I access the screen for the first time it works fine but closing it and reopening it causes a crash if the second tabsheet is left up.  First I get a window with a EInvalidOperati exception and if I tell it to continue I get a popup saying cannot focus a disabled or invisible window.  Seems like something is not getting reset the second time through.  Also if I leave the second tab up on the edit window and compile and run the program I get the same errors right away instead of getting the first tabsheet.  I guess I'm missing something either on the second sheet or a setting that would set the first tabsheet as the default.  I tried to setfocus on the first tabsheet with the formshow event but I still get a crash.

What am I missing.

Bill

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Popup window crashing after new tab added to form
« Reply #1 on: September 01, 2010, 08:27:41 pm »
I figured out the problem but I'm not sure what I use to fix it.  What is happening is that I added a setfocus to the one listbox on the first tabsheet in the showform event for the form and if the second sheet is in front then the system panics because it cannot find the object to set focus to.  All I have to do is something in the showform event that will force a specific tabsheet to the top.  Can anyone tell me which property or function of a TPageControl will let me set this?

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Popup window crashing after new tab added to form
« Reply #2 on: September 01, 2010, 08:48:20 pm »
Finally figured it out, setting ActivePage of the PageControl to the tabsheet 'name' that I wanted to be default has it always starting with that tab.  I think I tried that once before but might have had it in the wrong event so it wasn't being called.

This is the 10th or 20th thing I've learned today so I guess it isn't a bad day after all  ;D

 

TinyPortal © 2005-2018