473,800 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make application buttons assign to keys up, down, left, right...

9 New Member
Need help to create an windows mobile application with a few buttons that when they are pressed/clicked they assign keys, like up, down, left, right.

It is just like to create a "virtual d-pad", or "software emulated d-pad".

I'm newbie in programming, and I'm using Visual Studio 2008.
Some one can help me with that?

Tanks.

My effort for it only result in this simple code lines:

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
  4.  
  5.         'Bye!
  6.  
  7.         Application.Exit()
  8.  
  9.     End Sub
  10.  
  11.     Private Sub UpButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpButton.Click
  12.  
  13.         'Up
  14.  
  15.   *****my tries:      System.Windows.Forms.SendKeys.Send("{UP}") \\\\\\\\\ LeftButton_Click(Keys.Down, Keys.Down)     *******
  16.  
  17.     End Sub
  18.  
  19.     Private Sub LeftButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LeftButton.Click
  20.  
  21.         'Left
  22.  
  23.  
  24.  
  25.     End Sub
  26.  
  27.     Private Sub DownButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownButton.Click
  28.  
  29.         'Down
  30.  
  31.  
  32.  
  33.     End Sub
  34.  
  35.     Private Sub RightButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RightButton.Click
  36.  
  37.         'Right
  38.  
  39.  
  40.  
  41.     End Sub
  42. End Class
Oct 9 '08 #1
16 4104
markmcgookin
648 Recognized Expert Contributor
Hi,

Welcome to Bytes! Can I just clarify what you are after here?

So you have a device/emulator and you want 4 buttons on the screen to emulate what the "dpad" directional buttons already do? or do you simply want to create four buttons from scratch?

Either way in VS2008 this is nice and easy. Just drag four buttons onto the form, then click properties on each button, then if you already have an action on the "dpad" or softkeys as we call them you can just click the little lightning symbol at the top and find the on click event and use the drop down menu to select the same action that your soft key has... so binding the "on press" event to the same thing.

Otherwise if you just want this to be a function in it's own right, just double click on the button, and enter your code.

I'm not sure if this is what you are after, but if you have any more questions, please be a bit more specific.

Thanks,

Mark
Oct 9 '08 #2
ImpactMan
9 New Member
Hi,

Welcome to Bytes! Can I just clarify what you are after here?

So you have a device/emulator and you want 4 buttons on the screen to emulate what the "dpad" directional buttons already do? or do you simply want to create four buttons from scratch?

Either way in VS2008 this is nice and easy. Just drag four buttons onto the form, then click properties on each button, then if you already have an action on the "dpad" or softkeys as we call them you can just click the little lightning symbol at the top and find the on click event and use the drop down menu to select the same action that your soft key has... so binding the "on press" event to the same thing.

Otherwise if you just want this to be a function in it's own right, just double click on the button, and enter your code.

I'm not sure if this is what you are after, but if you have any more questions, please be a bit more specific.

Thanks,

Mark


Hello.

Tanks for the answer and sorry about my english, maybe not much specific. I'm Portuguese.

I try to explain specifically what I want.

I have a Pocket PC device each don't have a dpad.

So, I'm trying to emulate/replicate the normal pocket pc dpad hardware.

I want to do one application with 4 buttons on the screen to emulate what the "dpad" directional buttons do.

I've already create those buttons with visual studio (I've placed 4 images to work as buttons. I think this is possible.)

Now, my problem is to assign functions/acctions to this buttons each makes the same as the dpad. Not getting any results. :(

If you can tell me some tips or If you can show me an example for one button, I will be tankful.

Kind regards.
Oct 9 '08 #3
markmcgookin
648 Recognized Expert Contributor
Hello.

Tanks for the answer and sorry about my english, maybe not much specific. I'm Portuguese.

I try to explain specifically what I want.

I have a Pocket PC device each don't have a dpad.

So, I'm trying to emulate/replicate the normal pocket pc dpad hardware.

I want to do one application with 4 buttons on the screen to emulate what the "dpad" directional buttons do.

I've already create those buttons with visual studio (I've placed 4 images to work as buttons. I think this is possible.)

Now, my problem is to assign functions/acctions to this buttons each makes the same as the dpad. Not getting any results. :(

If you can tell me some tips or If you can show me an example for one button, I will be tankful.

Kind regards.
Right, so you have dragged a .Net Picture box onto the form?

Unfortunatley I dont think there is any automatic way to replace all the functions of the soft keys, but you can code them yourself (to move inbetween items, it's selecteditemind ex ++ or -- etc. Have you managed to get anything to happen when you click the image? or is that your problem? or is your problem that you have it doing things, you just can't replicate the functions of the soft keys?

To make an image clickable, you need to select it, right click > properties > click on the little lightning icon in the properties tab > then double click in the box beside "Click" and this will create an event handler (and should take you to it in the code) for the click event on the button.

Mark
Oct 10 '08 #4
ImpactMan
9 New Member
Right, so you have dragged a .Net Picture box onto the form?

Unfortunatley I dont think there is any automatic way to replace all the functions of the soft keys, but you can code them yourself (to move inbetween items, it's selecteditemind ex ++ or -- etc. Have you managed to get anything to happen when you click the image? or is that your problem? or is your problem that you have it doing things, you just can't replicate the functions of the soft keys?

To make an image clickable, you need to select it, right click > properties > click on the little lightning icon in the properties tab > then double click in the box beside "Click" and this will create an event handler (and should take you to it in the code) for the click event on the button.

Mark

Tanks.
I think I've already make images clickable.
But, maybe it will get me some more troubles. Do you think is better to start with simple buttons?

Doing this with simple buttons, the same way, I can't add an action to button that replicates/simulates the dpad (keys up, down....).

"Unfortunat ley I dont think there is any automatic way to replace all the functions of the soft keys, but you can code them yourself (to move inbetween items, it's selecteditemind ex ++ or -- etc."

I would like to try it now, but I'm on my PC with VS only Monday.
Anyway, if you can show-me some code lines example to do this, it will make me understanding the program structure and the basics for doing that.

Tanks for all your availability.

Best regardes.

Filipe



Kind regards.
Oct 10 '08 #5
ImpactMan
9 New Member
Hi!

I've been trying to make this work, but, not getting any results. :(

I don't know more what to do or how to proceed!

The only button (which is an image) that I can make work is the one to close the application. Not a progress at all!

I tink I have to see some examples do perform my program.

If you have time, and if you can, you could show me some code lines.
I will appreciate that.

Tanks.

Filipe
Oct 13 '08 #6
I dont think there is any automatic way to replace all the functions of the soft keys, but you can code them yourself (to move inbetween items, it's selecteditemind ex ++ or -- etc. Have you managed to get anything to happen when you click the image? or is that your problem? or is your problem that you have it doing things, you just can't replicate the functions of the soft keys?
Oct 16 '08 #7
rahulsengar
6 New Member
hey already explained you dude i think it will help you out
Oct 31 '08 #8
markmcgookin
648 Recognized Expert Contributor
Rahul Says:

You can do something like this to make it work.

Add the dll - System.runtime. IneropServices
then add this code where you initialize all the global variables
[DllImport("Core dll.dll", SetLastError = true)]
static extern int keybd_event(byt e b, byte b1, int dwflags, int dwExtraInfo);

1) On menuclick1-
add this set of code when u want the display to move up
keybd_event(38, 0, 0, 0); //
keybd_event(38, 0, 2, 0); //this code Works similarly when u press up
2) On menuclick2 -
add this set of code when u want the display to move down
keybd_event(40, 0, 0, 0);
keybd_event(40, 0, 2, 0);
I have posted the above quote as it was in another thread... IMPACTMAN ... You have been warned before about this DO NOT DOUBLE POST, this is your last warning.

I will remove the other thread.

Mark
Oct 31 '08 #9
ImpactMan
9 New Member
I have posted the above quote as it was in another thread... IMPACTMAN ... You have been warned before about this DO NOT DOUBLE POST, this is your last warning.

I will remove the other thread.

Mark

Hi there!

Sorry about it. I don't was't seen this post, and today I make the same mistake!! Posting again other topic with the same subject.
If you can remove it to me, I will be glad. Tanks for the info and for the help.

Regards.

Filipe
Oct 31 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
8115
by: Darren Oakey | last post by:
ok - the problem - I made a simple breakout game out of a form, just painting the background - and using keydown for left and right arrow keys to control the bat - worked fine. I then moved all the code into a user control, put it on the form. Now I don't get keydown events when I press an arrow key - on either the form or the usercontrol ?!!!? I suspect somehow the container fucntionality has decided that they are was of migrating...
4
15221
by: pixel | last post by:
hi i just discovered something strange when i use in ProcessCmdKey this construction switch(keyData) { case Keys.Left: {
5
4843
by: iwdu15 | last post by:
hi, im making a program that makes a picturebox move according to key presses...but what if the user pushes say down and right at the same time. the keypress event only responds to once key pressed...how can i respond to two keys pressed at once so my picturebox will move diagonally? thanks -- -iwdu15
7
3323
by: aviad | last post by:
I am writing a Form application I need it to fit both resolution of 1600*1200 and 800*600 (and any other resolution that might jump in) the application is meant for regular PCs another question is what the difference between the Dock and Anchor properties? i tried to use them (mutual exclusive of course) but with no success
1
2646
by: ansc1 | last post by:
Hello, I'm new to using php coding. I need help with the following: 1. There is a submit button on the form and is saves information to my database. After clicking on "Save Measurement" it redirects me to another page in my site. What I would like to do is change what page directs it to. Currently the submit button redirects me to page /measure/men_measure. I would like to be able to change this. Please see below my page below:...
0
8777
Denburt
by: Denburt | last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set up with this code and the way I set it up the first button is my search toggle button no submenu (this prevents a submenu from displaying when the form is first opened) TabIndex set to 0 (I like using the keyboard) the second toggle button is called...
2
1240
by: ra88it | last post by:
I'm working on some javascript games, and I encountered what appears to be a bug specific to Firefox on Linux (I'm using several recent versions of Ubuntu). I'd love to get some help verifying that it is a bug as well as possibly devising a workaround. Here's the situation: in my game, you control a space ship with the arrow keys. You move the ship by pressing the arrow keys, and often you will press both the up key and the left or right...
1
47492
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
2
1732
by: DavidPr | last post by:
I've downloaded an Open Source Maze game and the keys that makes the thingy move through the maze isn't very intuitive and I'd like to change them to the arrow keys. Here's the current setup: /* Set the default keys. (left, right, up, down, pause, solve, hint, save, header, reload) */ var keys = new Array('j','l','i','k','q','s','h','y','c','r'); How can I set the left, right, up and down arrow keys in the var keys array instead of...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.