Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Floating Buttons
Sat, Sep 16 2017 6:02 PMPermanent Link

Allen Hunt

Can someone please provide some direction as how to create floating buttons that don't move when the page is scrolled?

Thank you very much!

Allen
Sun, Sep 17 2017 6:30 AMPermanent Link

Uli Becker

Allen,

> Can someone please provide some direction as how to create floating
buttons that don't move when the page is scrolled?
Are you scrolling the viewport or a form?

Haven't used that before, but this should work:

procedure TForm1.Form1Create(Sender: TObject);
begin
   InitialTop := ButtonTest.Top;
end;

procedure TForm1.Form1Scroll(Sender: TObject);
begin
   ButtonTest.Top := InitialTop + Self.ScrollTop;
   // ButtonTest.Top := InitialTop + Application.ViewPort.ScrollTop;   
end;

You will see some flickering though.

Maybe there are smoother solutions using transparent layers e.g. I'll
check that out when I'll have some time left.

Uli
Sun, Sep 17 2017 11:41 AMPermanent Link

Allen Hunt

Hi Uli,

<< Are you scrolling the viewport or a form? >>

I am still a newbie and I haven't figured out whether or not to use a viewport solution or form solution for my projects but I have tried both.

<< Haven't used that before, but this should work >>

I should have mentioned I did figure out this solution but I am trying to prevent the flicker.

https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&msg=2905&start=1&keywords=http%20www%20castrum%20co%20uk&searchbody=True&forum=EWB_Announce&forum=EWB_General&forum=EWB_Components&forum=EWB_Server&forum=EWB_Demos&forum=EWB_Binaries&forum=EWB_Discussion&forum=EWB2_Preview&forum=EWB_Beta#2905

I know this link is from an old post but I am trying to duplicate the CONTACT and SUPPORT buttons Mark Brooks did here http://www.castrum.co.uk  (if it is still a EWB app.)  I inspected the buttons and it looks like he might be using bootstrap.

<< Maybe there are smoother solutions using transparent layers. >>

Thanks for the tip.  I will work on learning this and see if I can come up with a solution.

Your help is greatly appreciated!

Allen
Sun, Sep 17 2017 1:22 PMPermanent Link

Raul

Team Elevate Team Elevate

On 9/16/2017 6:02 PM, Allen W. Hunt wrote:
> Can someone please provide some direction as how to create floating buttons that don't move when the page is scrolled?

Have not tried it but here's what i would do
- make a new form (buttonform)
- size it to size of the button
- set alwaysontop to true
- set visible false
- drop a button on it and set layout to take up entire form
- configure label, colour etc

Then in code on your main form OnCreate create this new form and
position it so it's on appropriate place relative to main main  and then
show it

It should sit on top of the main form and you can still scroll main form
without this button (form) moving

Raul
Mon, Sep 18 2017 3:52 AMPermanent Link

Matthew Jones

Allen W. Hunt wrote:

> Can someone please provide some direction as how to create floating buttons that don't move when the page is scrolled?

Can I ask what you are trying to achieve, as it may be different to what you are asking for. I mean, if you mean just a single button that doesn't scroll, that's one thing, but most of my applications are a main form with a panel at the top and bottom, and then I have the scrollable content in the middle which is created on another form that is parented there. So when you scroll the contents, the header is always visible, and so is the footer.

And given it is the content that scrolls, it is quite easy to have a TListBox on a form that will scroll, and a button, parented to the form not the list, slapped on top of the list, that does not scroll when the list scrolls.

So to an extent, I don't understand why you want what you want, as it just does it as you expect IME.

--

Matthew Jones
Mon, Sep 18 2017 5:23 PMPermanent Link

Allen Hunt

"Matthew Jones" wrote:

<< Can I ask what you are trying to achieve, as it may be different to what you are asking for. >>

Sorry, maybe I shouldn't have said floating.  I'm trying to achieve 'Contact' and 'Support' buttons on the right hand side that are always visible so when they are clicked I can popup a separate TDialog for each.

In addition (which I didn't mention and you did), I wanted the fixed header and footer.  So I took your suggestion and I made my main form with the header and footer and parented a scrollable body form.

I then took Raul suggestion and made another button form that contains the 'Contact' and 'Support' buttons (actually TImage's to make them look nicer).

It works perfectly!  and has the unique look and feel of an EWB app using TScrollPanel instead of a browsers vertical scrollbar.  I really appreciate Uli's, Raul's and your help.

Thank you!

Allen
Image