473,396 Members | 1,998 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.

controlling scrolling in a form programatically?

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
3 3632
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Susan | last post by:
I have a bound form and subform and am trying to enter the data in both forms programatically. The Linkmaster and Linkchild properties are set. My intent is to be able to look at the data before it...
1
by: Trint Smith | last post by:
I know that this may belong in the asp group, but I want to programatically control the web form image control. For example, I want to let the program choose the image url at load time and the...
0
by: Scott M | last post by:
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...
3
by: Scott M | last post by:
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...
5
by: Kent Briggs | last post by:
VB 2005 Express. I have a readonly multiline textbox with a vertical scrollbar. I'm programatically adding text to it with textbox1.appendtext(mytext) and it scrolls automatically. However, I only...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
0
by: Wilfried Mestdagh | last post by:
Hi, I have a form containing a menu strip where I add programatically items on it, depending on a real time situation that can change. This is the view to explain what I'm trying to tell: ...
0
by: SteelNetNob | last post by:
I am having a problem where I have a COM application that can be run stand-alone and programatically via COM interop. If an instance of the COM application is being run when my .NET application that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
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...
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...
0
agi2029
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,...

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.