Wrox Programmer Forums
|
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
 
Old February 24th, 2009, 01:22 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Forms losing focus

I have created a dialog type form which i need to be the top most form and it musn't lose focus, so obviously (or not so . . ) i set the topmost property to true, but the form can still lose focus . . . any thoughts?
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old February 24th, 2009, 03:01 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Well it depends on what you mean by 'focus'. Are you talking about a 'window' popping up in side of a browser window that contains your form that, when displayed, disables everything else on the page or are you asking how to spawn a new window and keep it as the top most window?

In the case of the former you can use a standard CSS Modal effect where the user clicks on something, a hidden div appears and overlays the entire page with a semi-transparent png thus making the form in the div the only thing that can be acted upon. You could also look into the ModalExtender control in the AJAX Toolkit.

In the case of the latter, this can be achieved with JavaScript but it is pretty annoying and I would recommed it.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old February 24th, 2009, 03:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Just to clarify, are you looking for that in web or in a form based enviroment???

(Doug, this is the vb2005, could be any case!)
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old February 25th, 2009, 07:14 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

This is in vb2005, not web based!
I'm looking to make the form that pops up to be the top most form and can't be navigated away from until its closed.
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old February 25th, 2009, 07:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Ok. Did you search google?? there are a lot of examples around there...

try for example ".net form always on top"

This is not a trivial mather, since you have to catch windows events to make it work (and also, you could lost focus, there is no way that you can remain focus, unless, maybe with a crazy idea, that you built a transparent form under your form that catch the entire desktop, with bars and everything).
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old February 25th, 2009, 09:37 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

It can be done easily, i think it is trivial.
For example, open up windows movie maker
Tools -> Options
Then try and click the main movie maker window, it doesn't let you unless you close the options dialog box.
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old March 2nd, 2009, 05:32 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default The proper answer to this thread

Effectivily what i was trying to do was to make a dialog out of a form, so when i call the form to show instead of using form.show which gives standard results ii should of used form.showdialog(me) which gives the form all the properties of a dialog form such as; waiting till the user inputs data and the form is closed before carrying out the next line of code - which is not true when .show method is used because once it's shown the parent form goes to next line of code, and focus on that form cannot be lost to the parent form so achieving always on top.

So the code is:

Code:
Dim dialogForm As New Form1
dialogForm.showdialog(me)
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old August 10th, 2009, 05:36 AM
Authorized User
 
Join Date: Aug 2009
Posts: 18
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Add some code on that forms.
Private Sub Form1_load(...)
Form1.Focus()
End Sub
 
Old August 20th, 2009, 08:36 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Quote:
Originally Posted by Lupus81 View Post
Add some code on that forms.
Private Sub Form1_load(...)
Form1.Focus()
End Sub
No point the question has been answered, that wouldnt work though because it wouldn't stop the form that called that event carrying on processing the rest of the subs code, the thing with showdialog is that it haults the caller until an answer has been given or the dialog has been closed!
__________________
Apocolypse2005, I'm a programmer - of sorts.





Similar Threads
Thread Thread Starter Forum Replies Last Post
DAP losing connection.... kalebson Access 4 July 10th, 2006 09:05 AM
Multiple Forms and the Return Key Focus rit01 ASP.NET 2.0 Basics 4 June 20th, 2006 01:44 PM
Losing variables bluemat XSLT 2 October 16th, 2004 01:59 AM
Switch Focus between 2 Forms lxu Access 1 March 11th, 2004 09:49 AM





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