Page 1 of 1

Keep a TPanel fixed

PostPosted: Sun Apr 05, 2020 1:08 pm
by mark_c
I created a TForm, added a TPanel and a TImage dynamically. When the image is larger than the TForm, the scroll bars appear. My problem is that the TPanel also moves with the TImage but I would like it to remain fixed.

Code: Select all
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        TForm *MyForm = new TForm(this);
        MyForm->Visible=true;
        MyForm->HorzScrollBar->Visible=true;
        MyForm->VertScrollBar->Visible=true;
        MyForm->Width=1000;
        MyForm->Height=500;

        TPanel *MyPanel = new TPanel(MyForm);
        MyPanel->Parent=MyForm;
        MyPanel->Align=alTop;
        MyPanel->Height=40;

        TImage *Image1 = new TImage(MyForm);
        Image1->Parent=MyForm;
        Image1->Left=0;
        Image1->Top=40;

        Image1->Picture->Bitmap->LoadFromFile("mypicture.bmp");
        Image1->Picture->Bitmap->Width=12000;
        Image1->Picture->Bitmap->Height=2124;
        Image1->Width=12000;
        Image1->Height=2124;



        MyForm->VertScrollBar->Position=900;       
}

Re: Keep a TPanel fixed

PostPosted: Mon Apr 06, 2020 1:09 am
by mark_c
after many settings I am convinced that it is not possible to block the TPanel which continues to scroll together with the TImage.
How is it possible that there is no way to anchor the TPanel to the title bar so that the TImage flows under the TPanel?

Re: Keep a TPanel fixed

PostPosted: Mon Apr 06, 2020 1:48 am
by mark_c
sorry but I solved it myself using the ScrollBox component that I had never used: there is always a first time.

Thanks anyway.

Re: Keep a TPanel fixed

PostPosted: Mon Apr 06, 2020 6:00 am
by mark_c
nothing has changed, I caught a crab.
I want the TPanel to scroll horizontally but remain anchored to the title bar, as if it were a ruler.

Re: Keep a TPanel fixed

PostPosted: Tue Apr 07, 2020 10:15 am
by HsiaLin
Set panels Align property to alTop.

Re: Keep a TPanel fixed

PostPosted: Tue Apr 07, 2020 11:48 am
by mark_c
thanks, but I've already tried that way

look at the Score View of this screen https://ibb.co/c88DnGr the ruler remains stationary and the staff can freely scroll to the right and down

Re: Keep a TPanel fixed

PostPosted: Wed Apr 08, 2020 6:39 pm
by HsiaLin
That an MDI application it looks like. Multiple document interface.

Re: Keep a TPanel fixed

PostPosted: Wed Apr 08, 2020 7:24 pm
by HsiaLin
I`m not really sure what you are trying to do but maybe this will help.
If not then i don't know what to tell you.

Re: Keep a TPanel fixed

PostPosted: Thu Apr 09, 2020 5:26 am
by mark_c
thanks for trying, the way is that.
However, if you look well, the image must remain fixed to the left and the "page" must scroll below the image. If you look at the image I posted, the piano keyboard remains fixed while the score scrolls below.

Re: Keep a TPanel fixed

PostPosted: Thu Apr 09, 2020 8:46 am
by HsiaLin
I was only making the scrolling part for you, you could add another panel to the bottom and put pictures onto it that will not scroll, like the piano is. That whole application in the picture is custom made, you`ll have to do the same with ingenuity.

Re: Keep a TPanel fixed

PostPosted: Thu Apr 09, 2020 9:56 am
by mark_c
you're right, I can solve the problem with a second panel on the left.

Thanks