Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Delphi (http://www.programmingforums.org/forum41.html)
-   -   Page Scrolling ? (http://www.programmingforums.org/showthread.php?t=1503)

misa86 Dec 11th, 2004 1:00 PM

Hello every1 !
I'm from Serbia and I'm a new user !

I've learned Pascal in school and I decided to make an aplication in Delphi. I make a form and beacuse that page is large i get a vertical scroll bar. But when i run in i can't use my scroll button on mouse ?

Please help me !

kurifu Dec 11th, 2004 2:24 PM

You need to trap your WM_MOUSE event, find out of the control you are trying to use has focus, and if it does programatically scroll you window down. If you check the Borland Development Network (BDN.BORLAND.COM) you will actually find a solution for this problem, I have seen it posted there before.

misa86 Dec 12th, 2004 10:57 AM

I don't understant ?

Carl Dec 12th, 2004 11:53 AM

I pressume when you talk about the scroll button on the mouse you're talking about the wheel?

If so, each form has a OnWheelMouseUp and OnWheelMouseDown event. Code in to these what you want to happen when the user moves the mouse wheel.

For example:

:

procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
 MousePos: TPoint; var Handled: Boolean);
begin
 //
 // Scroll the scrollbar down by 10 pixels
 Self.VertScrollBar.Position := Self.VertScrollBar.Position + 10;
end;


If you need any more help or don't understand, please let me know.

Carl

misa86 Dec 19th, 2004 4:50 PM

Thank you Carl ! You helped me !

But there is one more thing. I learned Delphi in school and we learned it only for a few classes and I don't know how to set up little thing. For exaple :

I want to fix the width of the windows. I don't want user to expand it, but he can because when cursor is changed into tho arrows he can do that ! And just to tell you that I have a verticall scroll on that page, and at the end of the page I want some blank space but deplhi always reduces it ?
Can you help me ?

Carl Dec 23rd, 2004 3:18 AM

Quote:

I want to fix the width of the windows. I don't want user to expand it, but he can because when cursor is changed into tho arrows he can do that
There are 2 ways to go about this. The first, and probably the easiest, is to change the BorderStyle of the form to bsFixedSingle. Stops anyone from resizing the window. The second way depends on your Delphi version. Since Version 5 they have added a Constraints property to the form so you can set the minimum and maximum allowed size.

Quote:

And just to tell you that I have a verticall scroll on that page, and at the end of the page I want some blank space but deplhi always reduces it ?
Here you have to be a little clever and put a panel on the form first. The put all the controls on the panel. Delphi won't make the panel smaller and will resize the scrollbar to suit the panel.

Hope this helps.

Happy Christmas

Carl

misa86 Dec 23rd, 2004 6:33 AM

Thanx again.

In Serbia we first celebrate New Year and later Christmas !

Happy Christmas and New year !

misa86 Dec 26th, 2004 2:40 PM

Hi !

Another little problem.

I'm making some program and user must enter some number from 0 to 10 in edit1.text . But, how can i ban him to enter something else but number from 0 to 10 ? Because he can enter some strgin and my programme will crash.

I can make my own procedure for this but it's large, so you might have some faster solution ?

Infinite Recursion Dec 27th, 2004 12:04 AM

you should make another thread for this question... you will get more / better responses.

the the type of the value with one of the isA functions... or type cast it to an integer value... compare that value to be >= 0 and/or <= 10.

Carl Dec 31st, 2004 8:38 AM

Quote:

Originally posted by misa86@Dec 26 2004, 07:40 PM
Hi !

Another little problem.

I'm making some program and user must enter some number from 0 to 10 in edit1.text . But, how can i ban him to enter something else but number from 0 to 10 ? Because he can enter some strgin and my programme will crash.

I can make my own procedure for this but it's large, so you might have some faster solution ?

Although it is possible using the KeyPress event to mask out invalid characters then check the result in the Exit event, personally I prefer to use a VCL control built for the purpose.

If you visit http://www.torry.net you'll find an assortment of controls for almost every purpose. I highly recommend the JVCL which is a freeware suite of components. Takes some getting used to but well worth it.

After all, why re-invent the wheel when someone has already done it?

Carl


All times are GMT -5. The time now is 3:43 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC