Connecting Tech Pros Worldwide Forums | Help | Site Map

controlling scrolling in a form programatically?

Scott M
Guest
 
Posts: n/a
#1: Nov 22 '05
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.

Steve McLellan
Guest
 
Posts: n/a
#2: Nov 22 '05

re: controlling scrolling in a form programatically?


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" <scottmacebay@tiscali.co.uk> wrote in message
news:ea44d7c8.0406020820.6e8b4f46@posting.google.c om...[color=blue]
> 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.[/color]


Scott M
Guest
 
Posts: n/a
#3: Nov 22 '05

re: controlling scrolling in a form programatically?


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:<OP8xzhMSEHA.2216@TK2MSFTNGP12.phx.gbl>...[color=blue]
> 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" <scottmacebay@tiscali.co.uk> wrote in message
> news:ea44d7c8.0406020820.6e8b4f46@posting.google.c om...[color=green]
> > 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.[/color][/color]
Steve McLellan
Guest
 
Posts: n/a
#4: Nov 22 '05

re: controlling scrolling in a form programatically?


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" <scottmacebay@tiscali.co.uk> wrote in message
news:ea44d7c8.0406021330.3090d119@posting.google.c om...[color=blue]
> 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[/color]
news:<OP8xzhMSEHA.2216@TK2MSFTNGP12.phx.gbl>...[color=blue][color=green]
> > 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[/color][/color]
scroll[color=blue][color=green]
> > events. You can then wait until you know the sprite is at the bottom,[/color][/color]
and[color=blue][color=green]
> > then force the scrollbar to do its stuff. Autoscrolling's great but[/color][/color]
can't[color=blue][color=green]
> > always be applied to every situation because you don't have full control[/color][/color]
of[color=blue][color=green]
> > it.
> >
> > Good luck!
> >
> > Steve
> >
> > "Scott M" <scottmacebay@tiscali.co.uk> wrote in message
> > news:ea44d7c8.0406020820.6e8b4f46@posting.google.c om...[color=darkred]
> > > 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.[/color][/color][/color]


Closed Thread