Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using menus to navigate forms with scrollbars

Status
Not open for further replies.

aiden

Programmer
Apr 23, 2001
27
CA
Hi,

I am using a menu designer created menu to navigate through my forms.
ie
File
Form1
Form2
Form3

I open the selected form using 'Do Form' and then use the following code to close any other open forms. This works fine until I put scrollbars on my forms. It seems as though VFP6 is treating scrollbars as another form and closes them too - which closes the form I just opened. Can anyone suggest other code or a fix to mine to avoid this issue.

I only want one form open at a time.

Thanks in advance for any help.


x = _SCREEN.FORMCOUNT
DO WHILE _SCREEN.FORMCOUNT > 1
x = _SCREEN.FORMCOUNT
IF _SCREEN.FORMS(x).NAME <> TMPFORM &&tmpform = form just opened
_SCREEN.FORMS(x).RELEASE
x =_SCREEN.FORMCOUNT - 1
ENDIF

ENDDO
 
Aiden,
You are correct, before VFP 7.0, any form with Scrollbars actually shows up twice in the _SCREEN.FORMS() collection. The other thing you should know is that the collection index (as well as the formcount) is dynamically changed when you release or add a form. So normally, if I'm releasing them all, I will step backward through the list. i.e.
Code:
LOCAL lnFormCount
FOR lnFormCount = _SCREEN.FormCount TO 1 STEP -1
   IF TYPE(&quot;_SCREEN.Forms[lnFormCount]&quot;) = &quot;O&quot;
      _SCREEN.Forms[lnFormCount].Release()	
   ENDIF
   * optional * DOEVENTS && leave a little breathing room
ENDFOR
I'd do this before creating the new form, so you don't have to skip around the new one. Or if you know whether it has scrollbars, then start one or two less than _SCREEN.FormCount, because it'll always be at the end of the list.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top