473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Win Form, Image and getting the presice x,y Pixel the mouse is poi

Hello All,

Here is what I would like to do

I am creating a game program that displays a map (preferably in hexes but
that is another matter) and whenever the user is over the "map" I want to
know the x,y coords (in pixels) of where he is pointing to.

Here is what I have done

Place an Picturebox on a windows form

Assign a picture to the control

Is there an event on the picturebox control that fires whenever the mouse
moves along on the picture?

If I am trying to implement the wrong approach please let me know.

Thanks

p.s. side note -- if anyone can point me in the right direction for finding
a book that helps program games using VB I would much appreciate it.

Corey
Jul 21 '05 #1
6 2067
There is a mousemove event that will tell you every time the user moves the
mouse, and you can get the x,y from that event. I think it will be relative
to the picturebox and not the form, but you'll have to look to see about
that.

Post any more questions you have... Happy to help.

Chris

"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
Hello All,

Here is what I would like to do

I am creating a game program that displays a map (preferably in hexes but
that is another matter) and whenever the user is over the "map" I want to
know the x,y coords (in pixels) of where he is pointing to.

Here is what I have done

Place an Picturebox on a windows form

Assign a picture to the control

Is there an event on the picturebox control that fires whenever the mouse
moves along on the picture?

If I am trying to implement the wrong approach please let me know.

Thanks

p.s. side note -- if anyone can point me in the right direction for
finding
a book that helps program games using VB I would much appreciate it.

Corey

Jul 21 '05 #2
Chris,

Thank you it worked, now all i have to do is figure out how to get a map of
the world that is an image and to get it to scroll left and right and up and
down automatically when you move the mouse near the top, bottom, left and
right of the map

And (LOL) i have to figure out a way to get this map image to work like a
cylinder (that means that i can continuously scroll left and right and it
will loop.

Lots to ask for i know, your help is much appreciated.

Again any pointers to websites, books etc that can show me how to do this
would be much appreciated.

Corey
"Chris, Master of All Things Insignifican" wrote:
There is a mousemove event that will tell you every time the user moves the
mouse, and you can get the x,y from that event. I think it will be relative
to the picturebox and not the form, but you'll have to look to see about
that.

Post any more questions you have... Happy to help.

Chris

"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
Hello All,

Here is what I would like to do

I am creating a game program that displays a map (preferably in hexes but
that is another matter) and whenever the user is over the "map" I want to
know the x,y coords (in pixels) of where he is pointing to.

Here is what I have done

Place an Picturebox on a windows form

Assign a picture to the control

Is there an event on the picturebox control that fires whenever the mouse
moves along on the picture?

If I am trying to implement the wrong approach please let me know.

Thanks

p.s. side note -- if anyone can point me in the right direction for
finding
a book that helps program games using VB I would much appreciate it.

Corey


Jul 21 '05 #3
Mousemove event on the picturebox control. Then use the mouseeventargs
object to locate your x or y coordinate.
"CoreyMas" wrote:
Hello All,

Here is what I would like to do

I am creating a game program that displays a map (preferably in hexes but
that is another matter) and whenever the user is over the "map" I want to
know the x,y coords (in pixels) of where he is pointing to.

Here is what I have done

Place an Picturebox on a windows form

Assign a picture to the control

Is there an event on the picturebox control that fires whenever the mouse
moves along on the picture?

If I am trying to implement the wrong approach please let me know.

Thanks

p.s. side note -- if anyone can point me in the right direction for finding
a book that helps program games using VB I would much appreciate it.

Corey

Jul 21 '05 #4
Well what you are trying to do isn't too difficult. I'll lay out the
concepts and you let me know what you need more help with.

To figure out when to scroll right and left, this is the easy one. Let's
say your are going to put them in scroll mode when they hit withing 5% of
the edge of the picturebox. That just becomes LeftSide if the X coord is
<= (.05*PictureBox1.Width), RightSide if the X coord is >=
PictureBox1.Width - (.05*PictureBox1.Width) and so on for the top and
bottom.

Now for the scrollingi image, I think you are going to have to do some
picture manuplation. I've never done anything like this so maybe someone
else can talk about it. But, as you scroll left, you need to take the left
move Column of pixels and move them to the right side and slide all the
other pixels left one. I don't know which class you use to do this type of
thing. You may have to research the data format and do it raw in memory.

Anyone smarter than me have an idea about this?

Chris

"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
Chris,

Thank you it worked, now all i have to do is figure out how to get a map
of
the world that is an image and to get it to scroll left and right and up
and
down automatically when you move the mouse near the top, bottom, left and
right of the map

And (LOL) i have to figure out a way to get this map image to work like a
cylinder (that means that i can continuously scroll left and right and it
will loop.

Lots to ask for i know, your help is much appreciated.

Again any pointers to websites, books etc that can show me how to do this
would be much appreciated.

Corey
"Chris, Master of All Things Insignifican" wrote:
There is a mousemove event that will tell you every time the user moves
the
mouse, and you can get the x,y from that event. I think it will be
relative
to the picturebox and not the form, but you'll have to look to see about
that.

Post any more questions you have... Happy to help.

Chris

"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
> Hello All,
>
> Here is what I would like to do
>
> I am creating a game program that displays a map (preferably in hexes
> but
> that is another matter) and whenever the user is over the "map" I want
> to
> know the x,y coords (in pixels) of where he is pointing to.
>
> Here is what I have done
>
> Place an Picturebox on a windows form
>
> Assign a picture to the control
>
> Is there an event on the picturebox control that fires whenever the
> mouse
> moves along on the picture?
>
> If I am trying to implement the wrong approach please let me know.
>
> Thanks
>
> p.s. side note -- if anyone can point me in the right direction for
> finding
> a book that helps program games using VB I would much appreciate it.
>
> Corey


Jul 21 '05 #5
Thanks Chris,

I had thought of that, thank you for confirming my hypothesis.

I figure that i will have to find some way of redrawing the image, or I
would have to have the image broken up into vertical 1 pixel slices and
manually draw them into my container as needed (so that each time I scrolled
left, I would get the vertical slice that was immediately to the left of the
currently displayed leftmost slice....

I must be blithering on at this point, there must be some tool or graphical
format(graphical tool) that will do this for me (like photoshop etc).

Corey

"Chris, Master of All Things Insignifican" wrote:
Well what you are trying to do isn't too difficult. I'll lay out the
concepts and you let me know what you need more help with.

To figure out when to scroll right and left, this is the easy one. Let's
say your are going to put them in scroll mode when they hit withing 5% of
the edge of the picturebox. That just becomes LeftSide if the X coord is
<= (.05*PictureBox1.Width), RightSide if the X coord is >=
PictureBox1.Width - (.05*PictureBox1.Width) and so on for the top and
bottom.

Now for the scrollingi image, I think you are going to have to do some
picture manuplation. I've never done anything like this so maybe someone
else can talk about it. But, as you scroll left, you need to take the left
move Column of pixels and move them to the right side and slide all the
other pixels left one. I don't know which class you use to do this type of
thing. You may have to research the data format and do it raw in memory.

Anyone smarter than me have an idea about this?

Chris

"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
Chris,

Thank you it worked, now all i have to do is figure out how to get a map
of
the world that is an image and to get it to scroll left and right and up
and
down automatically when you move the mouse near the top, bottom, left and
right of the map

And (LOL) i have to figure out a way to get this map image to work like a
cylinder (that means that i can continuously scroll left and right and it
will loop.

Lots to ask for i know, your help is much appreciated.

Again any pointers to websites, books etc that can show me how to do this
would be much appreciated.

Corey
"Chris, Master of All Things Insignifican" wrote:
There is a mousemove event that will tell you every time the user moves
the
mouse, and you can get the x,y from that event. I think it will be
relative
to the picturebox and not the form, but you'll have to look to see about
that.

Post any more questions you have... Happy to help.

Chris

"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
> Hello All,
>
> Here is what I would like to do
>
> I am creating a game program that displays a map (preferably in hexes
> but
> that is another matter) and whenever the user is over the "map" I want
> to
> know the x,y coords (in pixels) of where he is pointing to.
>
> Here is what I have done
>
> Place an Picturebox on a windows form
>
> Assign a picture to the control
>
> Is there an event on the picturebox control that fires whenever the
> mouse
> moves along on the picture?
>
> If I am trying to implement the wrong approach please let me know.
>
> Thanks
>
> p.s. side note -- if anyone can point me in the right direction for
> finding
> a book that helps program games using VB I would much appreciate it.
>
> Corey


Jul 21 '05 #6
I believe that the format of a bitmap is pretty readily avaible. You should
be able to read the file into memory and then move the pieces around to
create a new bitmap. It might be the hard way to go about it, but it should
work. Do a google search for bitmap format, you'll find lots of sites that
talk about it.

Chris


"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:99**********************************@microsof t.com...
Thanks Chris,

I had thought of that, thank you for confirming my hypothesis.

I figure that i will have to find some way of redrawing the image, or I
would have to have the image broken up into vertical 1 pixel slices and
manually draw them into my container as needed (so that each time I
scrolled
left, I would get the vertical slice that was immediately to the left of
the
currently displayed leftmost slice....

I must be blithering on at this point, there must be some tool or
graphical
format(graphical tool) that will do this for me (like photoshop etc).

Corey

"Chris, Master of All Things Insignifican" wrote:
Well what you are trying to do isn't too difficult. I'll lay out the
concepts and you let me know what you need more help with.

To figure out when to scroll right and left, this is the easy one. Let's
say your are going to put them in scroll mode when they hit withing 5% of
the edge of the picturebox. That just becomes LeftSide if the X coord is
<= (.05*PictureBox1.Width), RightSide if the X coord is >=
PictureBox1.Width - (.05*PictureBox1.Width) and so on for the top and
bottom.

Now for the scrollingi image, I think you are going to have to do some
picture manuplation. I've never done anything like this so maybe someone
else can talk about it. But, as you scroll left, you need to take the
left
move Column of pixels and move them to the right side and slide all the
other pixels left one. I don't know which class you use to do this type
of
thing. You may have to research the data format and do it raw in memory.

Anyone smarter than me have an idea about this?

Chris

"CoreyMas" <Co******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
> Chris,
>
> Thank you it worked, now all i have to do is figure out how to get a
> map
> of
> the world that is an image and to get it to scroll left and right and
> up
> and
> down automatically when you move the mouse near the top, bottom, left
> and
> right of the map
>
> And (LOL) i have to figure out a way to get this map image to work like
> a
> cylinder (that means that i can continuously scroll left and right and
> it
> will loop.
>
> Lots to ask for i know, your help is much appreciated.
>
> Again any pointers to websites, books etc that can show me how to do
> this
> would be much appreciated.
>
> Corey
> "Chris, Master of All Things Insignifican" wrote:
>
>> There is a mousemove event that will tell you every time the user
>> moves
>> the
>> mouse, and you can get the x,y from that event. I think it will be
>> relative
>> to the picturebox and not the form, but you'll have to look to see
>> about
>> that.
>>
>> Post any more questions you have... Happy to help.
>>
>> Chris
>>
>> "CoreyMas" <Co******@discussions.microsoft.com> wrote in message
>> news:53**********************************@microsof t.com...
>> > Hello All,
>> >
>> > Here is what I would like to do
>> >
>> > I am creating a game program that displays a map (preferably in
>> > hexes
>> > but
>> > that is another matter) and whenever the user is over the "map" I
>> > want
>> > to
>> > know the x,y coords (in pixels) of where he is pointing to.
>> >
>> > Here is what I have done
>> >
>> > Place an Picturebox on a windows form
>> >
>> > Assign a picture to the control
>> >
>> > Is there an event on the picturebox control that fires whenever the
>> > mouse
>> > moves along on the picture?
>> >
>> > If I am trying to implement the wrong approach please let me know.
>> >
>> > Thanks
>> >
>> > p.s. side note -- if anyone can point me in the right direction for
>> > finding
>> > a book that helps program games using VB I would much appreciate it.
>> >
>> > Corey
>>
>>
>>


Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Raj | last post by:
Hello Members, I wrote a program to convert a greyscale bitmap image in to monochrome bitmap image, a simple thresholding. Input:Greyscale image; Expected Output:Monochrome image Pseudocode:...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
6
by: CoreyMas | last post by:
Hello All, Here is what I would like to do I am creating a game program that displays a map (preferably in hexes but that is another matter) and whenever the user is over the "map" I want to...
4
by: Simon Tamman {Uchiha Jax} | last post by:
Scenario: Two System.Windows.Forms: Form1 and Form2. Form1 is displayed, Form2 is hidden. At this juncture, is it possible to take the graphics from Form2 and output that to Form1's display...
4
by: LT.Ang | last post by:
I am developing an application that possibly opens very large images - bmp, jpeg, tiff. I have 2 questions: Language: C#, VS .NET 2003. 1. When the program opens a BMP image, the amount of...
2
by: ajay_itbhu | last post by:
Hi everyone, I want to read the pixel values of 2 similar images in bitmap format like 2 continuous frame of a video for calculating the median. But i dont know how to read the pixel values of...
4
by: skanemupp | last post by:
mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of...
13
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.