Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference 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 October 4th, 2007, 12:33 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default Focusless Control

Hi, im creating a new control through inherit a treeview. but i want to make the control being accessable through mouse and not keyboard (The control should not be in focus anyway). Im using the tabstop property false but i was unable to set the canselect/canfocus properties. How can i make a focusless control.

Regards

 
Old October 4th, 2007, 08:31 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I think this will be a bit tricky. The TreeView has a lot of code to deal with the keyboard so if you inherit from it you'll need to disable all of that. Your best best may be to override its WndProc and discard keyboard events.

Rod
RodStephens@vb-helper.com

Check out my book:
"Expert One-on-One Visual Basic 2005 Design and Development"
http://www.vb-helper.com/one_on_one.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old October 5th, 2007, 11:51 PM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

hi, i can discard the keyboard through WndProc, but i want to ensure that there sould be no focus on my control (like label control). if i use ur suggestion, the keys are not work but the focus remains on my control.


 
Old October 5th, 2007, 11:55 PM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Rod, i have a C# solution, and he recommend that

Subclass the control and SetStyle(ControlStyles.Selectable, false);

but how can i do this in vb

 
Old October 6th, 2007, 09:40 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I think you may need to use a combination of the two techniques. When I try the SetStyle method, it prevents the user from tabbing to the control but if I click on it I can then use the mouse to move through its nodes. So perhaps you can do that to prevent tabbing onto the control and then use WndProc to ignore keyboard events.

To set the style, add this constructor to your derived class:

    Public Sub New()
        MyBase.New()

        Me.SetStyle(ControlStyles.Selectable, False)
        Me.UpdateStyles()
    End Sub

Rod
RodStephens@vb-helper.com

Check out my book:
"Expert One-on-One Visual Basic 2005 Design and Development"
http://www.vb-helper.com/one_on_one.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to put a button control in a GridView control ryan.webb ASP.NET 2.0 Basics 2 December 28th, 2007 05:26 AM
Can't move focus to control <control scptech Access VBA 8 October 26th, 2007 12:16 PM
Calendar Control with Tab Control Slicemahn Access 1 June 12th, 2006 10:35 PM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM
Help with control initialization in user control mike_remember ASP.NET 1.0 and 1.1 Professional 7 December 19th, 2005 11:08 AM





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