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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting the child-forms in VB6 1

Status
Not open for further replies.

Flupke

Programmer
Jun 26, 2002
94
BE
Hi everyone!

In a VB6 application, I want to disable the menu-item "Close form" when there are no child-forms left to close. How can I do that? I thought by counting the open child forms and when the result is 1 or zero, then set the menu-item.disabled to true.
Can you help me with a routine to count the number of active child forms?

Many thanks and greetings from Brugge (Bruges - Belgium),

Michel
 
Boy, you're on a roll, strongm. I had no idea this would work, and would have gone running through the forms collection looking for open MDI Child forms.

I think I get this part of why this works: doevents keeps a count of the number of events that it processes in the event queue, and can optionally return that number to the caller. (Therefore, doevents is overloaded.)

I'm not so sure about this part: In a given wait state there is always at least one event per form in the event queue. To hazard a guess, it's the GotFocus event, but the logic behind that guess is built on very shaky premises.

Perhaps you can expand on this a little?

Bob
 
Hello,

"and would have gone running through the forms collection looking for open MDI Child forms..."

Can you please explain to me in more detail how you can achieve this with VB6 code?

Many thanks and greetings from Brugge (Bruges - Belgium),

Michel
 
Well, you can run through the forms collection looking for open MDI Child forms, and I could explain how to do that, but I would recommend using strongm's one little line of code instead, which is elegant and concise. Is there a reason that that doesn't work for you?

Bob
 
>Perhaps you can expand on this a little?


Wish I could. The (undocumented) overloading of DoEvents is a Microsoft mystery. Can't for the life of me remeber where I picked up the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top