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 1176
"Jay" <Ja*@discussion s.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*@discussion s.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*@discussion s.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(ByVa l 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.IsInputK ey(keyData)
End Select
End Function
Protected Overrides Function ProcessDialogKe y(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.ProcessD ialogKey(keyDat a)
End Select
Me.PictureBox1. Location = New Point(Me.Pictur eBox1.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*@discussion s.microsoft.com > wrote in message
news:0E******** *************** ***********@mic rosoft.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!
ProcessDialogKe y should return a True if it processed the key.
| Protected Overrides Function ProcessDialogKe y(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.ProcessD ialogKey(keyDat a)
| End Select
| Me.PictureBox1. Location = New Point(Me.Pictur eBox1.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******** ******@TK2MSFTN GP14.phx.gbl...
| Jay,
| Image.Position is a structure you need to change the entire structure.
|
| Something like:
|
| Protected Overrides Function IsInputKey(ByVa l 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.IsInputK ey(keyData)
| End Select
| End Function
|
| Protected Overrides Function ProcessDialogKe y(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.ProcessD ialogKey(keyDat a)
| End Select
| Me.PictureBox1. Location = New Point(Me.Pictur eBox1.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*@discussion s.microsoft.com > wrote in message
| news:0E******** *************** ***********@mic rosoft.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 href="somewhere.html" style="position: absolute; left: 25px;">
<IMG src="CopyButton.gif" border="0" /></A>
<A href="anywhere.html" style="position: absolute; left: 45px;">
|
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.)
The page renders correctly in TopStyle and Dreamweaver 4, and also online in
my test website, i.e., the 5 successive navigation divs are correctly
rendered one after another.
|
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 whether it was docked or not. I added the
following code to my "OnConnection" function but it fails
with an error, "Run-time exception thrown :
System.IO.IOException - Bad file name or number."
With applicationObject.CommandBars("SampleToolbar")
|
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"?>
<?xml-stylesheet type="text/xsl" href="position.xsl"?>
|
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 text</td>
</tr>
<tr>
<td bgcolor="#eeeeee" align="center">this is another line of
text</td>
| |
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 description and example can be found at:
http://www.kinderuitje.nl/problem.html
Thx
|
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 Safari and Opera. I am
doing a lot of dragdrop experimentation and in some situations need a
position reporting function. The function doesn't need to report the
positions of exotic elements like images in button elements; however, I
would like a...
|
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, despite the fact that I have gotten a green light from W3.
link to problem page:
I didn't see a feature to attach my css code so I pasted sections of the code that dealt with layout and navigation below.
Thanking you in advance,
|
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 problem with that
// prior to move, position = fixed;
// at each move, I capture the new top value
|
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.
There are a number of elements within this <div> that cause the <div> to participate in an Ajax call to the server.
In order to maintain the scroll position of the <div> during the Ajax request I store the scroll value in a hidden field so that when...
|
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...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |