Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollbars in a PRG-based form 1

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,516
Scotland

I need to place a vertical scrollbar on a form.

If I create the form in the Form Designer, I can simply go to the property window and set the ScrolBars property to 2 - Vertical.

However, this particular form is a PRG-based form. I tried writing THIS.ScrollBars = 2 in the Init, but this has no effect. This is consistent with the Help, which says: Read/write at design time; read-only at run time.

So, does anyone know a way of adding scrollbars to a form that is created programmatically, rather than through the designer?

Because I wish to publish this form, I want to base it on the built-in VFP form class, not one of my own form classes. I am working in VFP 9.0, but would ideally like a solution that works in 7.0 and above.

Thanks in advance.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Try something like this:

Code:
local oForm
oForm = createobject("MyForm")
oForm.show()
read events

define class MyForm as form

  docreate = .t.
  autocenter = .t.
  caption = "PRG based form with scroll bars"
  width = 300
  height = 300
  [red]scrollbars = 2[/red]

  add object edtBigEditBox as editbox with ;
    top = 10, ;
    left = 10, ;
    width = this.width - 40, ;
    height = 100, ;
    value = "See textbox at bottom of form"+chr(10)+chr(10)+;
    "It is what causes the form's scroll bars to show"

  add object txtTextBoxPastBottomOfForm as textbox with ;
    left = 10, ;
    width = 200, ;
    top = this.height - 14, ;
    value = "I'm split!"

  add object lblTextBoxLabel as label with ;
    left = 10, ;
    top = this.txtTextBoxPastBottomOfForm.top - 14, ;
    caption = "Text box is split at bottom of form", ;
    autosize = .t., ;
    backstyle = 0

  procedure destroy
    clear events
  endproc

enddefine
 

Darrell,

Worked perfectly.

My mistake was in trying to set the Scrollbars property in the calling program rather than the class definition.

Thanks very much.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

Slight problem.

This particular form has an option to be docked. Docking is not compatible with scrollbars. If the caller chooses not to dock the form, Darrell's solution works fine. But if the caller does dock, I get an error saying that there is a conflict of properties. That's why I wanted to set ScrollBars at run time.

Ah, well. I'll just have to find another way of letting them scroll the form.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
MikeLewis,

I've used the Flat Scrollbar Activex control with success. You would need to have a container within your form holding all of the form's contained objects, or a more difficult approach would be to move all the form's objects up or down in the scrollbar's change and scroll events (you'd need to utilize lockscreen to make the painting smooth). Container is mmoved within the form to simulate scrolling. Not sure if that would work in your case, and of course you'd have an activex dependency. Just a thought and perhaps a workaround for your problem.

boyd.gif

 
After reviewing the online documentation, it appears that
the Docked property was added to the form object in
Version 9. Is this true?

Darrell
 

Craig,

Thanks for that. I had wondered about using the FlatScrollbar. I have not used it before. There would be no problem in moving all the controls into a container. I deliberatly desgined the whole thing so that the level of containership is transparant to the calling program.

Darrell,

Yes, this is a docked form, a la VFP 9.0. I give the programmer the option of making it either a permanently docked form or a normal form that is fixed to the side of the screen.

(If anyone's interested, this is an Outlook-style navigation bar.)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,

>> If anyone's interested, this is an Outlook-style navigation bar

Have you considered the ctListBar in the DBI tools? Would save you a lot of work.

Volker/
 

Hi Volker,

Good to see you here. Welcome to the forum. You'll see a few familiar faces.

Re ctListBar in the DBI tools. Yes, this was one of the possibilities we considered. But the end-users wanted a slightly different design, which I have now done.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
(If anyone's interested, this is an Outlook-style navigation bar.)

I've already done something like this.

Check Outlook style listbar on UniversalThread download section
 

Badukist,

We've talked about your Outlook-style bar, and I looked at your demo. It was very impressive.

I think I mentioned at the time that my users were interested in something that looked like the "common tasks" bar in XP folder windows, and this is what I ended up doing.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi
Sems that I need some vitamins :)
I remember now.
It is on my list too, bu I didn't had time for it.
I think about using VFP9 bindings to windows events and common controls native windows scroll bar in place of a container.
 

Badukist,

Once I've got my control in better shape, we'll have to compare notes. I'm quite pleased with what I've done, but there are some rough edges, mainly becuase the whole thing is hosted in a docked form, which gives rise to several annoyances.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top