Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 July 14th, 2003, 08:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default making Shortcut keys

Hi there:
I wanted to make shortcut keys for my Win App. for example [left_arrow] for next next record & [right_arrow] for previuos record.
how can I do it?! ill be thankful for any of ur ideas & codes.

Always:),
Hovik Melkomian.
__________________
Always,
Hovik Melkomian.
 
Old July 15th, 2003, 02:55 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

in your Control keyup event put something like that:

if( e.KeyCode == Keys.Right )
{
MoveNext();//function for next record
}

else if( e.KeyCode == Keys.Left)
{
MovePrevious();//function for previous record
}

..........


 
Old July 15th, 2003, 02:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Hi Hovik

You can catch various key events for windows forms.
This code is a Key_Up event handler for a window form.

private void ClientForm_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
    if( e.KeyCode == Keys.Left )
        MessageBox.Show("ClientForm_KeyDown");
}

The message box gets displayed as soon as the left arrow
key is pressed and left.

For the key even handlers to wrok, you have to make
sure that the keypreview property of you form is true.

Write back if there is anything else you wanna ask me.

Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
 
Old July 15th, 2003, 04:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Tnx dear friends for ur replay:)
 
Old April 8th, 2005, 03:03 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI,,
I have a Windows user control ,which contains child user controls again. The parent user control is inside a browser. Now where do you write the code for setting the shortcut keys. Is it in client side javascript or inside the parent window user control or Child user controls .

thanks in advance
Bali Reddy

 
Old April 9th, 2005, 10:36 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

you don't have a windows user control,you have a web user control,

in a web control there is no Key_Up event or ...

the client of a web control is a explore just knows HTML and JavaScript!

the client of a windows control is windows operating system!

_____________
Mehdi.
software student.
 
Old April 9th, 2005, 11:48 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

another approach,

you can implement IMessageFilter,
Code:
    class Filter:System.Windows.Forms.IMessageFilter
    {
        const int WM_KEYDOWN=0x100;
        const int Left_Arrow=37;
        public event System.EventHandler theEvent;
        public bool PreFilterMessage(ref Message m)
        {
            if(m.Msg==WM_KEYDOWN && m.WParam.ToInt32()==Left_Arrow)
            {this.theEvent(this,new System.EventArgs());return true;}
            return false;
        }
    }
//then in your form use it
    public class Form1 : System.Windows.Forms.Form
    {
        Filter filter=new Filter();
                //....
        public Form1()
        {
            InitializeComponent();
            filter.theEvent+=new EventHandler(this.Imessagefilter);
            Application.AddMessageFilter(filter);
        }
                //....
        private void Imessagefilter(object o,System.EventArgs e)
        {
            //LeftArrow Pressed;
        }
    }

also you can make other events in Filter class for right arrow key or other message handlings.

_____________
Mehdi.
software student.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut keys don't work at runtime stuart.steedman VB.NET 10 May 9th, 2008 11:24 AM
shortcut keys and pop up dipankar.aich Windows Presentation Foundation 0 April 5th, 2007 07:43 AM
use Shortcut keys slokhande C# 1 July 21st, 2006 09:45 AM
Shortcut keys! Dharam80 Access 2 August 18th, 2005 08:23 AM
Shortcut keys DARSIN General .NET 1 November 22nd, 2004 10:29 AM





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