Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
| Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 26th, 2008, 08:16 AM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cascading forms, form start locations

I have a form for maintaining vendor information. Users can open multiple copies of this form, which I'm still not sure is a good idea. Nonetheless, I notice that when a new vendor form is opened, it "cascades" slightly down and to the right of the prior instance whether the prior instance is opened or was closed.

How do I get a new vendor form to open at (0,0) if there is no other open vendor form and otherwise cascade like it is currently doing? In other words, the only behavior I want to change is to have it reset the open location each time the last open vendor form is closed.

Thanks,

Pigparent
Raleigh, North Carolina

Pigparent
Raleigh, North Carolina
USA
  #2 (permalink)  
Old June 26th, 2008, 09:33 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Load the form, set its Left and Top, then show it.
You can do this with any form, irrespective of how many instances of it are already open.
  #3 (permalink)  
Old June 26th, 2008, 11:13 AM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, and you're right, that's easy, but that's not what I'm trying to do. I'm trying to get the form to set at (0,0) only if it is the only open instance, otherwise it should cascade. Setting the point in code makes the new form overlap the old one. I would like for it to cascade like the default action. But, it needs to reset each time there is only one instance of the form class open.

Please let me know if I'm not making sense.

Thanks,

Pigparent
Raleigh, North Carolina

Pigparent
Raleigh, North Carolina
USA
  #4 (permalink)  
Old June 27th, 2008, 10:34 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Create a public variable for counting. Every time you open an instance of this form, increment the counter. Everytime you unload one, decrement it.

You could put the incrementation in the instantiation code of the form, so that it would increment that Var as soon as it was granted life, rather than putting it in the process the opens the form...


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make my main form start up invisibly? dylanbutler Visual Studio 2005 1 May 16th, 2008 08:47 AM
One Location to Many Locations sudipkumar Biztalk 0 April 15th, 2005 08:13 AM
how to start new form q8z Beginning VB 6 2 October 26th, 2004 05:40 AM
Cascading combo lists in continuous forms rjd97c Access 1 June 30th, 2004 02:51 PM
Default file locations selbybrock Excel VBA 0 March 9th, 2004 12:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.