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

controlling scrolling in a form programatically?

P: n/a
Hi,

I am currently trying to write a simple game using vb.net

the form I am working on is 800*600 (this is set as the maximum size)
and autoscroll is set to true. The user moves around the screen by
moving a picturebox (sprite) with the cursor keys.

When the user hits the bottom of the screen I want the screen to
automatically scroll down to keep the picture box in view - The screen
I want to work with is 800*1200 but the window should not resize above
800*600. I would also like to keep a status bar (just a text box) on
the bottom line of the screen (displaying lives etc - this needs to
remain fixed even if the screen scrolls)

Any ideas?

I had a couple of ideas myself - create a "background" picture box
that is 800*1200 (this then displays scroll bars in the form). Then
create a couple of hidden picture boxes, one at the top of the screen
and one at the bottom of the screen. When the user moves the sprite
picture box below the bottom of the form (y>=600) then move focus to
the bottom picture box. And when they move above this (y<600) focus
on the top picture box. In this way the form appears to auto scroll.

However, this means that the status bar gets lost when the screen
scrolls (although I suppose I could move this programatically when the
screen moves). Of course I'll need to trap the user scrolling around
the form themselves as well.

Also heard about mdi forms (never used them though) would I be able to
have the scrolling form as a child with the status bar as a parent?

Finally, how do you programatically scroll a form - I couldn't find
any obvious commands like scrollwindow(x,y)?

thanks in advance

Scott M.
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If you handle the scrolling yourself it'd be easy - just build a big
picturebox, put a vertical scrollbar by the side of it and handle the scroll
events. You can then wait until you know the sprite is at the bottom, and
then force the scrollbar to do its stuff. Autoscrolling's great but can't
always be applied to every situation because you don't have full control of
it.

Good luck!

Steve

"Scott M" <sc**********@tiscali.co.uk> wrote in message
news:ea**************************@posting.google.c om...
Hi,

I am currently trying to write a simple game using vb.net

the form I am working on is 800*600 (this is set as the maximum size)
and autoscroll is set to true. The user moves around the screen by
moving a picturebox (sprite) with the cursor keys.

When the user hits the bottom of the screen I want the screen to
automatically scroll down to keep the picture box in view - The screen
I want to work with is 800*1200 but the window should not resize above
800*600. I would also like to keep a status bar (just a text box) on
the bottom line of the screen (displaying lives etc - this needs to
remain fixed even if the screen scrolls)

Any ideas?

I had a couple of ideas myself - create a "background" picture box
that is 800*1200 (this then displays scroll bars in the form). Then
create a couple of hidden picture boxes, one at the top of the screen
and one at the bottom of the screen. When the user moves the sprite
picture box below the bottom of the form (y>=600) then move focus to
the bottom picture box. And when they move above this (y<600) focus
on the top picture box. In this way the form appears to auto scroll.

However, this means that the status bar gets lost when the screen
scrolls (although I suppose I could move this programatically when the
screen moves). Of course I'll need to trap the user scrolling around
the form themselves as well.

Also heard about mdi forms (never used them though) would I be able to
have the scrolling form as a child with the status bar as a parent?

Finally, how do you programatically scroll a form - I couldn't find
any obvious commands like scrollwindow(x,y)?

thanks in advance

Scott M.

Jul 21 '05 #2

P: n/a
Hi Steve,

thanks for that, but do you have some code samples to get me started?

or explain to me how I "handle the scroll events"

regards,

Scott M.

"Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> wrote in message news:<OP**************@TK2MSFTNGP12.phx.gbl>...
If you handle the scrolling yourself it'd be easy - just build a big
picturebox, put a vertical scrollbar by the side of it and handle the scroll
events. You can then wait until you know the sprite is at the bottom, and
then force the scrollbar to do its stuff. Autoscrolling's great but can't
always be applied to every situation because you don't have full control of
it.

Good luck!

Steve

"Scott M" <sc**********@tiscali.co.uk> wrote in message
news:ea**************************@posting.google.c om...
Hi,

I am currently trying to write a simple game using vb.net

the form I am working on is 800*600 (this is set as the maximum size)
and autoscroll is set to true. The user moves around the screen by
moving a picturebox (sprite) with the cursor keys.

When the user hits the bottom of the screen I want the screen to
automatically scroll down to keep the picture box in view - The screen
I want to work with is 800*1200 but the window should not resize above
800*600. I would also like to keep a status bar (just a text box) on
the bottom line of the screen (displaying lives etc - this needs to
remain fixed even if the screen scrolls)

Any ideas?

I had a couple of ideas myself - create a "background" picture box
that is 800*1200 (this then displays scroll bars in the form). Then
create a couple of hidden picture boxes, one at the top of the screen
and one at the bottom of the screen. When the user moves the sprite
picture box below the bottom of the form (y>=600) then move focus to
the bottom picture box. And when they move above this (y<600) focus
on the top picture box. In this way the form appears to auto scroll.

However, this means that the status bar gets lost when the screen
scrolls (although I suppose I could move this programatically when the
screen moves). Of course I'll need to trap the user scrolling around
the form themselves as well.

Also heard about mdi forms (never used them though) would I be able to
have the scrolling form as a child with the status bar as a parent?

Finally, how do you programatically scroll a form - I couldn't find
any obvious commands like scrollwindow(x,y)?

thanks in advance

Scott M.

Jul 21 '05 #3

P: n/a
Check out the MSDN entry on the link below, and have a Google (especially
look out for any CodeProject links). Unfortunately I don't have time to give
you a sample myself, as it's already 1.30am and I'm under a deadline :-)

Good luck with it!

http://msdn.microsoft.com/library/de...classtopic.asp
"Scott M" <sc**********@tiscali.co.uk> wrote in message
news:ea**************************@posting.google.c om...
Hi Steve,

thanks for that, but do you have some code samples to get me started?

or explain to me how I "handle the scroll events"

regards,

Scott M.

"Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> wrote in message

news:<OP**************@TK2MSFTNGP12.phx.gbl>...
If you handle the scrolling yourself it'd be easy - just build a big
picturebox, put a vertical scrollbar by the side of it and handle the scroll events. You can then wait until you know the sprite is at the bottom, and then force the scrollbar to do its stuff. Autoscrolling's great but can't always be applied to every situation because you don't have full control of it.

Good luck!

Steve

"Scott M" <sc**********@tiscali.co.uk> wrote in message
news:ea**************************@posting.google.c om...
Hi,

I am currently trying to write a simple game using vb.net

the form I am working on is 800*600 (this is set as the maximum size)
and autoscroll is set to true. The user moves around the screen by
moving a picturebox (sprite) with the cursor keys.

When the user hits the bottom of the screen I want the screen to
automatically scroll down to keep the picture box in view - The screen
I want to work with is 800*1200 but the window should not resize above
800*600. I would also like to keep a status bar (just a text box) on
the bottom line of the screen (displaying lives etc - this needs to
remain fixed even if the screen scrolls)

Any ideas?

I had a couple of ideas myself - create a "background" picture box
that is 800*1200 (this then displays scroll bars in the form). Then
create a couple of hidden picture boxes, one at the top of the screen
and one at the bottom of the screen. When the user moves the sprite
picture box below the bottom of the form (y>=600) then move focus to
the bottom picture box. And when they move above this (y<600) focus
on the top picture box. In this way the form appears to auto scroll.

However, this means that the status bar gets lost when the screen
scrolls (although I suppose I could move this programatically when the
screen moves). Of course I'll need to trap the user scrolling around
the form themselves as well.

Also heard about mdi forms (never used them though) would I be able to
have the scrolling form as a child with the status bar as a parent?

Finally, how do you programatically scroll a form - I couldn't find
any obvious commands like scrollwindow(x,y)?

thanks in advance

Scott M.

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.