 |
| 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
|
|
|
|

June 26th, 2008, 08:16 AM
|
|
Registered User
|
|
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 26th, 2008, 09:33 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
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.
|
|

June 26th, 2008, 11:13 AM
|
|
Registered User
|
|
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 27th, 2008, 10:34 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
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...
|
|
 |