I am trying to code an application that will move a image around the screen
depending on what arrow keys the user presses. If the user presses the up
key, the graphic will move up a few positions, and so on. I was wondering
how I would move the image though, it seems that when I try to change the X
and Y values in the position property, nothing happenes. I must be changing
the wrong property, but I don't know where to find the one that needs to
change. Thanks 5 1163
"Jay" <Ja*@discussions.microsoft.com> schrieb: I am trying to code an application that will move a image around the screen depending on what arrow keys the user presses. If the user presses the up key, the graphic will move up a few positions, and so on. I was wondering how I would move the image though, it seems that when I try to change the X and Y values in the position property, nothing happenes. I must be changing the wrong property, but I don't know where to find the one that needs to change.
If you want to move a form around, check its 'Left', 'Top', and 'Location'
properties.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
I wasn't really looking to move the form though, I just wanted to move the
image that is located on the form, not the entire form itself. Thanks
"Herfried K. Wagner [MVP]" wrote: "Jay" <Ja*@discussions.microsoft.com> schrieb:I am trying to code an application that will move a image around the screen depending on what arrow keys the user presses. If the user presses the up key, the graphic will move up a few positions, and so on. I was wondering how I would move the image though, it seems that when I try to change the X and Y values in the position property, nothing happenes. I must be changing the wrong property, but I don't know where to find the one that needs to change.
If you want to move a form around, check its 'Left', 'Top', and 'Location' properties.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
"Jay" <Ja*@discussions.microsoft.com> schrieb: I wasn't really looking to move the form though, I just wanted to move the image that is located on the form, not the entire form itself.
Even controls have these properties.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jay,
Image.Position is a structure you need to change the entire structure.
Something like:
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
Select Case keyData
Case Keys.Left, Keys.Right, Keys.Up, Keys.Down
Return False
Case Else
Return MyBase.IsInputKey(keyData)
End Select
End Function
Protected Overrides Function ProcessDialogKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
Dim offset As Point
Select Case keyData
Case Keys.Left
offset = New Point(-1, 0)
Case Keys.Right
offset = New Point(1, 0)
Case Keys.Up
offset = New Point(0, -1)
Case Keys.Down
offset = New Point(0, 1)
Case Else
Return MyBase.ProcessDialogKey(keyData)
End Select
Me.PictureBox1.Location = New Point(Me.PictureBox1.Location.X +
offset.X, Me.PictureBox1.Location.Y + offset.Y)
End Function
The above was tested in a Form with KeyPreview=True. I would also expect the
above to work within a custom control itself.
NOTE: Left, Right, Up, & Down are normally not input keys, so the IsInputKey
override is not specifically needed...
Hope this helps
Jay
"Jay" <Ja*@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
|I am trying to code an application that will move a image around the screen
| depending on what arrow keys the user presses. If the user presses the up
| key, the graphic will move up a few positions, and so on. I was wondering
| how I would move the image though, it seems that when I try to change the
X
| and Y values in the position property, nothing happenes. I must be
changing
| the wrong property, but I don't know where to find the one that needs to
| change. Thanks
Doh!
ProcessDialogKey should return a True if it processed the key.
| Protected Overrides Function ProcessDialogKey(ByVal keyData As
| System.Windows.Forms.Keys) As Boolean
| Dim offset As Point
| Select Case keyData
| Case Keys.Left
| offset = New Point(-1, 0)
| Case Keys.Right
| offset = New Point(1, 0)
| Case Keys.Up
| offset = New Point(0, -1)
| Case Keys.Down
| offset = New Point(0, 1)
| Case Else
| Return MyBase.ProcessDialogKey(keyData)
| End Select
| Me.PictureBox1.Location = New Point(Me.PictureBox1.Location.X +
| offset.X, Me.PictureBox1.Location.Y + offset.Y)
Return True
| End Function
Jay
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:et**************@TK2MSFTNGP14.phx.gbl...
| Jay,
| Image.Position is a structure you need to change the entire structure.
|
| Something like:
|
| Protected Overrides Function IsInputKey(ByVal keyData As
| System.Windows.Forms.Keys) As Boolean
| Select Case keyData
| Case Keys.Left, Keys.Right, Keys.Up, Keys.Down
| Return False
| Case Else
| Return MyBase.IsInputKey(keyData)
| End Select
| End Function
|
| Protected Overrides Function ProcessDialogKey(ByVal keyData As
| System.Windows.Forms.Keys) As Boolean
| Dim offset As Point
| Select Case keyData
| Case Keys.Left
| offset = New Point(-1, 0)
| Case Keys.Right
| offset = New Point(1, 0)
| Case Keys.Up
| offset = New Point(0, -1)
| Case Keys.Down
| offset = New Point(0, 1)
| Case Else
| Return MyBase.ProcessDialogKey(keyData)
| End Select
| Me.PictureBox1.Location = New Point(Me.PictureBox1.Location.X +
| offset.X, Me.PictureBox1.Location.Y + offset.Y)
| End Function
|
| The above was tested in a Form with KeyPreview=True. I would also expect
the
| above to work within a custom control itself.
|
| NOTE: Left, Right, Up, & Down are normally not input keys, so the
IsInputKey
| override is not specifically needed...
|
| Hope this helps
| Jay
|
| "Jay" <Ja*@discussions.microsoft.com> wrote in message
| news:0E**********************************@microsof t.com...
||I am trying to code an application that will move a image around the
screen
|| depending on what arrow keys the user presses. If the user presses the
up
|| key, the graphic will move up a few positions, and so on. I was
wondering
|| how I would move the image though, it seems that when I try to change the
| X
|| and Y values in the position property, nothing happenes. I must be
| changing
|| the wrong property, but I don't know where to find the one that needs to
|| change. Thanks
|
| This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Falc2199 |
last post by:
Hi all,
I am using the "Poistion" attribute to correctly align a column
of images that I have on a table. The code looks like so....
<TD valign="top" class="listinglight" align="left">
<A...
|
by: CMAR |
last post by:
I have been having a problem styling a page, which you can see live at my
test site:
Designer Page (http://home.ne.rr.com/thespar/)
(Ignore the missing pictures, which have not been uploaded.)...
|
by: Jaime Rios |
last post by:
Hi,
I created a COM AddIn for Word that performs the functions
that it needs to, but I needed to add the ability for the
toolbar created by the COM AddIn to remember it's last
position and...
|
by: akunamatata |
last post by:
Hello everyone,
I contact this discussiongroup because I encountered a little
problem with XSL. Let me explain it:
I have following file "position.xml":
<?xml version="1.0"?>...
|
by: Edward |
last post by:
I used to do this all the time in HTML-table layouting. How do I do
this in CSS?
--------------------------------------------------
<table width="400px">
<tr>
<td bgcolor="beige">one line of...
|
by: Roderik |
last post by:
Hi,
My logo images are positioned some more to the right in IE6 than in
FF1.5. I like them to be as shown in FF1.5. Does anyone have a clue,
why they are positioned differently in IE?
Problem...
|
by: petermichaux |
last post by:
Hi,
It seems like determining element position in a web page is a difficult
task. In the position reporting source code I've looked at there are
special fixes for at least some versions of...
|
by: agbee1 |
last post by:
Hello:
I've finally made the effort to ween myself from overly using tables and use CSS for my positioning. However, I am having a problem with my navigational menu properly aligning in Firefox,...
|
by: DL |
last post by:
Hi,
My research on this NG hasn't produced a satisfactory answer. Here's
what I want to do:
move two div (s) (each has an image tag within) to another location on
the same page.
// no...
|
by: Frinavale |
last post by:
I think I'm trying to do something impossible.
I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
| |