Discussion in 'Questions (Windows Mobile)' started by burd27, Feb 12, 2008.
I have an app' that has an elongated screen size that progressively fills up with Text boxes (up to a prescibed limit of course). When the usable form size on the device need to show more that what the screen itself is able to show, then a Vertical scroll bar appears and the user can scroll down/up to the section wanted.
What I want to be able to do is in response to an event is to put a text box and/or button in the middle of the PDA screen, regardless where the form is vertcally. EG. Regardless of where the form is per the vertical scroll bar, a MsgBox alway appears in the centre of the screen. How can I acheive this with a button.
Please note, the mousedown event doesn't appear to be able to be used as the screen/form is covered with text boxes, so there is no form visible to capture the mousedown event.
I have experimented with capturing the position of the textboxes, but as the text box may be at the top or bottom of the screen, I cannot use this value as a reference to position someting in the middle of the screen - or can I?
Where does the MsgBox get its coordinates from to position itself correctly in the middle. Are they accessable and usable?
Forcing the button to the front would probably be a good idea if your form is covered with other controls.
Are your text boxes placed on the form itself, or are you using a panel?
Thanks Gary. At first I thought that using the form height would not acieve the goal as technically my form is bigger than the screen (hence the scroll bar). On the Desktop using your method centres the button in the middle of the form, so I thought the same for the device.
But, when run on the device, it centres it on the screen and not on the form. So I suppose in essence that makes the form.height really a "screen.height" function.
Yet another lesson learned on this steep learning curve. You are right.."it's pretty simple...."
Er? Your form is bigger than the screen? I didn't think that was possible.
Do you mean that you've created controls that are outside the viewable area?
I've used scrollbars to adjust the vertical height of controls on a form and hide the ones that are outside the viewable area, but never really been happy with the result. On forms with large numbers of controls, it just takes too long for the program to respond when the scrollbar is moved.
A better solution is to use a large Panel.
I have a Dell Axim X51V which has a vga screen (not that I think that is necessary relevant to the question you asked.....but just in case).
With my application I have a huge number of textboxes on the screen in groups of eight. I use the application for my work as I records details of work completed, etc. The screen itself defaults to four (4) groups of these eight (8) text boxes. In this "default" condition there is no vertcal scroll bar present.
In Designer, I created the form to be approx 2.5 times the height of the screen. I laid out all of the textboxes on it to accommodate ten (10) groups of text boxes, but the last six are set and not visible (hence why the default screen shows only four (4) lots).
When the fourth of the groups is used in the app', it makes the fifth group visible, however as this fifth group is off the screen,the application automatically inserts a vertical scroll bar so that I an scroll down to use the fifth group.
I hope my description is clear enough. I have not "programmed" the verticle scroll bar to appear...it just does, all by itself!
The Axim that I have is the 624Mhz version which was the top of teh range at the time (just over 12 months ago). I found that from day 1, running it at full speed (624Mhz) was necessary otherwise it was too slow. Reading other forums, this is more a result of he "sluggish" WM5, and not the Axim itself. Unfortunately, Dell has not brought out an upgrade to WM6 which is appently quicker : ( [unless someone can tell me otherwise].
Would it improve performance (speed), if I place the text boxes on a "panel". Is there any advantage for me to go to a panel format if the current verticle scroll bar is "working"? Secondly, would a table / database speed this up for me? In my app' background colors are being changed for text box groups depending upon their content, this checking content and changing background colors, obviously put a load on the cpu.
Burd, that vertical scrollbar is showing up simply because you've placed a control outside the viewable area. The same thing will happen horizontally if you set the 'left' property of a control to a value greater than the width of the form. I suppose you could rely on that scrollbar to move up and down the form, but since it's actually Windows that's placing it there... well, let's just say that I don't trust Windows as much as I trust my own code.
Take some time to look at the example in the thread Erel posted. It's a really good place to start. I don't think your program will run any faster, and it will take some work on your part, but you'll learn a lot about panels and dynamic control placement. Give it a try.