By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.